Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.3
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      1

      Description

      The LCOVParser class incorrectly parses the lcov file format (as described here: http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php
      It crashes when it encounters a line like this: "FNDA:0,(anonymous_2)".
      This is due to the way it matches the line type identifier. It simply makes a "contains" (using a indexOf) instead of a "startsWith" comparison.
      A pull request has been submitted here: https://github.com/SonarCommunity/sonar-javascript/pull/4

        Activity

        Hide
        Gleb Godonoga added a comment - - edited

        Here is a completely valid LCOV file.
        Notice the FNDA and BRDA inside.

        Code fails with

        Exception in thread "main" org.sonar.runner.RunnerException: java.lang.NumberFormatException: For input string: "(anonymous_1)"
                at org.sonar.runner.Runner.delegateExecution(Runner.java:288)
                at org.sonar.runner.Runner.execute(Runner.java:151)
                at org.sonar.runner.Main.execute(Main.java:84)
                at org.sonar.runner.Main.main(Main.java:56)
        Caused by: java.lang.NumberFormatException: For input string: "(anonymous_1)"
                at java.lang.NumberFormatException.forInputString(NumberFormatException.
        java:48)
                at java.lang.Integer.parseInt(Integer.java:449)
                at java.lang.Integer.valueOf(Integer.java:554)
                at org.sonar.plugins.javascript.coverage.LCOVParser.parseFile(LCOVParser
        .java:66)
        
        Show
        Gleb Godonoga added a comment - - edited Here is a completely valid LCOV file. Notice the FNDA and BRDA inside. Code fails with Exception in thread "main" org.sonar.runner.RunnerException: java.lang.NumberFormatException: For input string: "(anonymous_1)" at org.sonar.runner.Runner.delegateExecution(Runner.java:288) at org.sonar.runner.Runner.execute(Runner.java:151) at org.sonar.runner.Main.execute(Main.java:84) at org.sonar.runner.Main.main(Main.java:56) Caused by: java.lang.NumberFormatException: For input string: "(anonymous_1)" at java.lang.NumberFormatException.forInputString(NumberFormatException. java:48) at java.lang.Integer.parseInt(Integer.java:449) at java.lang.Integer.valueOf(Integer.java:554) at org.sonar.plugins.javascript.coverage.LCOVParser.parseFile(LCOVParser .java:66)
        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:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: