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

FN on Rule S2638 when varargs or keywords arguments are used

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.8
    • Fix Version/s: None
    • Component/s: Rules
    • Labels:
      None

      Description

      The current implementation of RSPEC-2638 has the following False Negatives:

      #
      # Vararg and Keywords parameters
      #
      class ParentClass(object):
          def mymethod(self, param1):
              pass
      
      class ChildClassAddVararg(ParentClass):
          def mymethod(self, param1, *args):  # ok. Accepting more optional parameters.
              pass
      
      class ChildClassReplaceVararg(ParentClass):
          def mymethod(self, *args):  # ok. Making param1 optional but still accepting it.
              pass
      
      class ChildClassAddKWarg(ParentClass):
          def mymethod(self, param1, *kwargs):  # ok. Accepting more optional parameters.
              pass
      
      class ChildClassAddKWarg(ParentClass):
          def mymethod(self, *kwargs):  # ok. Making param1 optional but still accepting it.
              pass
      
      
      class ParentClassVararg(object):
          def mymethod(self, *args):
              pass
      
      class ChildClassNoVararg1(ParentClassVararg):
          def mymethod(self):  # Noncompliant. Add missing vararg parameter (*args)
              pass
      
      class ChildClassNoVararg2(ParentClassVararg):
          def mymethod(self, param1, *args):  # Noncompliant. Remove parameter "param1"
              pass
      
      class ParentClassKWararg(object):
          def mymethod(self, *kwargs):
              pass
      
      class ChildClassNoKWararg1(ParentClassKWararg):
          def mymethod(self):  # Noncompliant. Add missing keywords parameter (*kwargs)
              pass
      
      class ChildClassNoKWararg2(ParentClassKWararg):
          def mymethod(self, param1=None, *kwargs):  # Ok
              pass
      
      class ChildClassNoKWararg3(ParentClassKWararg):
          def mymethod(self, param1, *kwargs):  # Noncompliant. Remove parameter "param1" or provide a default value.
              pass
      
      

        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: