SonarQube JavaScript
  1. SonarQube JavaScript
  2. SONARJS-16

Parser should comply with ECMAScript Rules of Automatic Semicolon Insertion

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.3
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows Server 2008 x64, Jenkins
    • Number of attachments :
      2

      Description

      Got some exception on Jenkins console when trying to analyze JS project.
      See attached file

      1. log.txt
        158 kB
        Andrzej Pasterczyk
      2. SONARPLUGINS-2590.js
        0.2 kB
        Evgeny Mandrikov

        Activity

        Hide
        Evgeny Mandrikov added a comment -

        SONARPLUGINS-2590.js can be used to reproduce this issue.

        Show
        Evgeny Mandrikov added a comment - SONARPLUGINS-2590.js can be used to reproduce this issue.
        Hide
        Evgeny Mandrikov added a comment -

        Should be noted that this issue is not only about parse error, but also about creation of incorrect AST. For example:

        return
        a + b
        

        parsed as a single return statement, but according to http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.2 should be parsed as return statement and expression statement.
        Another example:

        a = b
        ++c
        

        should be treated as two statements too.

        Show
        Evgeny Mandrikov added a comment - Should be noted that this issue is not only about parse error, but also about creation of incorrect AST. For example: return a + b parsed as a single return statement, but according to http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.2 should be parsed as return statement and expression statement. Another example: a = b ++c should be treated as two statements too.
        Hide
        Freddy Mallet added a comment -

        Works well Evgeny but there is just a side effect on the Javascript toolkit.

        As soon as you work on AstNode close to the statement not ended with semi-colon, the following exception is thrown :

        java.lang.NullPointerException
        	at org.sonar.sslr.internal.toolkit.LineOffsets.getEndOffset(LineOffsets.java:53)
        	at org.sonar.sslr.internal.toolkit.ToolkitViewImpl.highlightSourceCode(ToolkitViewImpl.java:382)
        	at org.sonar.sslr.internal.toolkit.ToolkitPresenter.onAstSelectionChanged(ToolkitPresenter.java:185)
        	at org.sonar.sslr.internal.toolkit.ToolkitViewImpl$1.valueChanged(ToolkitViewImpl.java:145)
        	at javax.swing.JTree.fireValueChanged(JTree.java:2820)
        	at javax.swing.JTree$TreeSelectionRedirector.valueChanged(JTree.java:3191)
        	at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:629)
        	at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1078)
        	at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(DefaultTreeSelectionModel.java:287)
        	at javax.swing.JTree.setSelectionInterval(JTree.java:2469)
        	at javax.swing.plaf.basic.BasicTreeUI$Actions.increment(BasicTreeUI.java:4266)
        

        Looks like this relates to the new EOS terminal.

        Show
        Freddy Mallet added a comment - Works well Evgeny but there is just a side effect on the Javascript toolkit. As soon as you work on AstNode close to the statement not ended with semi-colon, the following exception is thrown : java.lang.NullPointerException at org.sonar.sslr.internal.toolkit.LineOffsets.getEndOffset(LineOffsets.java:53) at org.sonar.sslr.internal.toolkit.ToolkitViewImpl.highlightSourceCode(ToolkitViewImpl.java:382) at org.sonar.sslr.internal.toolkit.ToolkitPresenter.onAstSelectionChanged(ToolkitPresenter.java:185) at org.sonar.sslr.internal.toolkit.ToolkitViewImpl$1.valueChanged(ToolkitViewImpl.java:145) at javax.swing.JTree.fireValueChanged(JTree.java:2820) at javax.swing.JTree$TreeSelectionRedirector.valueChanged(JTree.java:3191) at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:629) at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1078) at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(DefaultTreeSelectionModel.java:287) at javax.swing.JTree.setSelectionInterval(JTree.java:2469) at javax.swing.plaf.basic.BasicTreeUI$Actions.increment(BasicTreeUI.java:4266) Looks like this relates to the new EOS terminal.
        Hide
        Evgeny Mandrikov added a comment -

        Fixed.

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

        Manually tested !

        Show
        Freddy Mallet added a comment - Manually tested !

          People

          • Assignee:
            Evgeny Mandrikov
            Reporter:
            Anonymous
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: