Uploaded image for project: 'SonarPython'
  1. SonarPython
  2. SONARPY-689

Update the default regular expression of rule S100 to not raise on short names

    Details

    • Type: False-Positive
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Rules
    • Labels:
      None

      Description

      Python default styling convention is de facto PEP-8. Anything accepted by PEP-8 should be accepted by the few styling rules we have.

      The current regular expression used in RSPEC-100 raises issues on method names shorter than 3 characters. PEP-8 does not recommend any minimal length for method names.

      Because of this we raise False Positives on the following code:

      class DatabaseModel:
          @property
          def db(self):  # False Positive
              raiseNotImplementedError()
      
      class Coordinate:
          @property
          def x(self):  # False Positive
              return 42
       
          @property
          def y(self):  # False Positive
              return 42
      

      It also creates inconsistencies as "db" is not allowed but "_db" is.
       
      The new default regular expression should be ^[a-z_][a-z0-9_]*$
      Once done the RSPEC should be updated.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                nicolas.harraudeau Nicolas Harraudeau
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: