Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Remove this empty statement.
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way
    • Legacy Key:
      EmptyStatementUsageCheck
    • Covered Languages:
      C#, C, C++, CSS, Flex, Go, Java, JavaScript, Objective-C, PHP, T-SQL, TypeScript, VB6
    • Irrelevant for Languages:
      ABAP, Cobol, HTML, PL/I, PL/SQL, Python, RPG, Swift, VB.Net, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2min
    • Analysis Level:
      Syntactic Analysis
    • Analysis Scope:
      Main Sources, Test Sources
    • Common Rule:
      Yes
    • CERT:
      MSC12-C., MSC51-J., EXP15-C.
    • Checkstyle:
      EmptyStatement
    • CPPCheck:
      suspiciousSemicolon
    • ESLint:
      no-extra-semi
    • FindBugs:
      UCF_USELESS_CONTROL_FLOW_NEXT_LINE
    • PC-Lint:
      9138
    • PMD:
      EmptyStatementNotInLoop
    • ReSharper:
      EmptyEmbeddedStatement, EmptyStatement
    • Stylelint:
      no-extra-semicolons
    • TSLint-SonarTS:
      no-extra-semicolon
    • VisualStudio:
      CS0642
    • Quick-fixes:
      Hide

      Remove empty statement: removes the empty statement where the statement is a direct child of a block expression.

      { ; }

      //handled
      while (true) ; //not handled

      Show
      Remove empty statement: removes the empty statement where the statement is a direct child of a block expression. { ; } //handled while (true) ; //not handled

      Description

      Empty statements, i.e. ;, are usually introduced by mistake, for example because:

      • It was meant to be replaced by an actual statement, but this was forgotten.
      • There was a typo which lead the semicolon to be doubled, i.e. ;;.

      See

      • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
      • CERT, MSC51-J. - Do not place a semicolon immediately following an if, for, or while condition
      • CERT, EXP15-C. - Do not place a semicolon on the same line as an if, for, or while statement

        Attachments

          Issue Links

          1.
          C-Family RSPEC-2892 Language-Specification Active Unassigned
          2.
          VB6 RSPEC-3202 Language-Specification Active Unassigned
          3.
          Java RSPEC-3203 Language-Specification Active Unassigned
          4.
          Flex RSPEC-3204 Language-Specification Active Unassigned
          5.
          PHP RSPEC-3205 Language-Specification Active Unassigned
          6.
          C# RSPEC-3206 Language-Specification Active Unassigned
          7.
          Javascript: Extra semicolons should be removed RSPEC-3762 Language-Specification Active Unassigned
          8.
          Go RSPEC-4591 Language-Specification Active Unassigned
          9.
          CSS: Extra semicolons should be removed RSPEC-4699 Language-Specification Active Unassigned

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                fabrice.bellingard Fabrice Bellingard
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: