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

Non-empty statements should change control flow or have at least one side-effect

    Details

    • Type: Bug Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Remove or refactor this statement; it has no side effects.
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Covered Languages:
      C, C++, JavaScript, Objective-C, PHP, Python, TypeScript
    • Irrelevant for Languages:
      C#, Java, Swift
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      10min
    • CWE:
      CWE-482
    • CPPCheck:
      suspiciousEqualityComparison, constStatement
    • ESLint:
      no-unused-expressions
    • PC-Lint:
      522, 1522
    • Pylint:
      w0104
    • TSLint:
      no-unused-expression

      Description

      Any statement (other than a null statement, which means a statement containing only a semicolon ;) which has no side effect and does not result in a change of control flow will normally indicate a programming error, and therefore should be refactored.

      Noncompliant Code Example

      a == 1; // Noncompliant; was assignment intended? 
      a < b; // Noncompliant; have we forgotten to assign the result to a variable? 
      

      See

        Attachments

          Issue Links

          1.
          JavaScript RSPEC-3000 Language-Specification Active Unassigned
          2.
          C-Family RSPEC-3328 Language-Specification Active Unassigned
          3.
          PHP RSPEC-3387 Language-Specification Active Unassigned
          4.
          Python RSPEC-5791 Language-Specification Active Unassigned

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Anonymous
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: