Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-2772

"pass" should not be used needlessly

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Remove this unneeded "pass".
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way
    • Covered Languages:
      Python
    • Irrelevant for Languages:
      C++, Cobol, Flex, HTML, Java, JavaScript, Objective-C, PHP, PL/I, PL/SQL, RPG, Swift, VB.Net, VB6, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2min
    • Pylint:
      W0107

      Description

      The use of a pass statement where it's not required by the syntax is pure cruft and should be removed.

      Noncompliant Code Example

          def __init__(self, log="", who="", date=0, files=[]):
              self.log = log
              self.files = files
              self.who = who
              self.date = date
              pass    # Noncompliant
      
          def lookup():
              pass    # Compliant; method can't be empty
      

      Compliant Solution

          def __init__(self, log="", who="", date=0, files=[]):
              self.log = log
              self.files = files
              self.who = who
              self.date = date
      
          def lookup():
              pass
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            ann.campbell.2 Ann Campbell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: