SonarQube JavaScript
  1. SonarQube JavaScript
  2. SONARJS-120

Rule: "UnreachableCore" - return, break, continue, or throw statements should be followed by a } or case or default.

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      <p>
      return, break, continue, or throw statements should be followed by a } or case or default.</p>
      <pre>
      function sayHello() {
      if (true)

      { return; var b; // NOK - this will never be executed }

      else

      { var c; }

      while (true)

      { break; var d; // NOK - this will never be executed }

      }
      </pre>

        Activity

        Hide
        Eriks Nukis added a comment -

        Implemented and pull request https://github.com/SonarCommunity/javascript/pull/1 created

        Show
        Eriks Nukis added a comment - Implemented and pull request https://github.com/SonarCommunity/javascript/pull/1 created
        Hide
        Evgeny Mandrikov added a comment -

        Has been merged.

        Show
        Evgeny Mandrikov added a comment - Has been merged.
        Hide
        Freddy Mallet added a comment -

        Works well, could you just change the violation message :

        "This statement can't be reached and so start a dead code block"

        Show
        Freddy Mallet added a comment - Works well, could you just change the violation message : "This statement can't be reached and so start a dead code block"
        Hide
        Evgeny Mandrikov added a comment -

        Done.

        Show
        Evgeny Mandrikov added a comment - Done.
        Hide
        Freddy Mallet added a comment -

        Manually tested !

        Show
        Freddy Mallet added a comment - Manually tested !

          People

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

            Dates

            • Created:
              Updated:
              Resolved: