Skip to content

Remove enforcement rules of rule F.17 #2162

Description

@pauljansen42

Rule F.17 (For “in-out” parameters, pass by reference to non-const) and Con.3 (By default, pass pointers and references to consts) have both two enforcement rules of which one of them is nearly identical:

  • F.17: Warn about functions regarding reference to non-const parameters that do not write to them
  • Con.3 Flag a function that does not modify an object passed by pointer or reference to non-const

This means that 2 rules will fire if a non-const reference parameter is not changed in the corresponding function body. Having 2 rules firing for the same situation is a coding standard design smell.

In order to solve this, I suggest to remove all enforcements from rule F.17 because the rule is about expresssing an intention, i.e. an in-out parameter. That is something you can't check automatically. To take this one step further, one might even consider to remove F.17 completely because we also have rule F.20 (For “out” output values, prefer return values to output parameters). Since F.20 describes some exceptions, removing F.17 might a bit too strong. So I suggest to remove the 2 enforcement rules of rule F.17.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions