3

After upgrading to SonarQube 5.2 and all plugins to current version I am getting the following exception when running an analysis. IS this problem with the CSS plugin or core sonarqube?

Final Memory: 9M/181M INFO: ------------------------------------------------------------------------

org.sonar.runner.impl.RunnerException: Unable to execute Sonar
○at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
○at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
○at java.security.AccessController.doPrivileged(Native Method)
○at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
○at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
○at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
○at org.sonar.runner.api.Runner.execute(Runner.java:100)
○at org.sonar.runner.Main.executeTask(Main.java:70)
○at org.sonar.runner.Main.execute(Main.java:59)
○at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.sonar.squidbridge.api.AnalysisException: Unable to analyze file: Site.css
○at org.sonar.squidbridge.AstScanner.scanFiles(AstScanner.java:127)
○at org.sonar.plugins.css.CssSquidSensor.analyse(CssSquidSensor.java:91)
○at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
○at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
○at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:98)
○at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
○at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
○at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
○at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:258)
○at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:253)
○at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:251)
○at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243)
○at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
○at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
○at org.sonar.batch.bootstrap.GlobalContainer.executeAnalysis(GlobalContainer.java:153)
○at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:110)
○at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:76)
○at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
○at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
○at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
○at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
○at java.lang.reflect.Method.invoke(Unknown Source)
○at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
○... 9 more
Caused by: java.lang.IllegalArgumentException: Unable to highlight file [moduleKey=A:A:843EAAC4-CD77-4A90-8261-34C358025BE8, relative=Content/Site.css, basedir=BLAH] from offset 10100 to offset 10136
○at org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting.highlight(DefaultHighlighting.java:84)
○at org.sonar.batch.source.DefaultHighlightable$DefaultHighlightingBuilder.highlight(DefaultHighlightable.java:79)
○at org.sonar.css.ast.visitors.SyntaxHighlighterVisitor.visitToken(SyntaxHighlighterVisitor.java:109)
○at com.sonar.sslr.impl.ast.AstWalker.visitToken(AstWalker.java:107)
○at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:86)
○at com.sonar.sslr.impl.ast.AstWalker.visitChildren(AstWalker.java:99)
○at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:87)
○at com.sonar.sslr.impl.ast.AstWalker.walkAndVisit(AstWalker.java:69)
○at org.sonar.squidbridge.AstScanner.scanFiles(AstScanner.java:106)
○... 31 more
Caused by: java.lang.IllegalArgumentException: 10136 is not a valid offset for file [moduleKey=A:A:843EAAC4-CD77-4A90-8261-34C358025BE8, relative=Content/Site.css, basedir=BLAH]. Max offset is 10135
○at org.sonar.api.internal.google.common.base.Preconditions.checkArgument(Preconditions.java:148)
○at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:267)
○at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:262)
○at org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting.highlight(DefaultHighlighting.java:82)
○... 39 more
Pierre-Yves
  • 1,476
  • 10
  • 15
Mike Barry
  • 953
  • 5
  • 15
  • Can you try removing the CSS plugin (requires server restart) and reanalyzing? – G. Ann - SonarSource Team Nov 05 '15 at 18:59
  • The MSBuild runner succeeds after removing the CSS plugin, but now I get: 2015.11.05 15:07:56 ERROR [o.s.s.c.t.CeWorkerRunnableImpl] Failed to execute task AVDZQzxWJsT4fd35NNO2 java.lang.IllegalArgumentException: There's no changeset on line 222 at com.google.common.base.Preconditions.checkArgument(Preconditions.java:125) ~[guava-17.0.jar:na] at org.sonar.server.computation.scm.ScmInfoImpl.getChangesetForLine(ScmInfoImpl.java:64) ~[sonar-server-5.2.jar:na] at org.sonar.server.computation.scm.DbScmInfo.getChangesetForLine(DbScmInfo.java:69) ~[sonar-server-5.2.jar:na] – Mike Barry Nov 05 '15 at 20:12
  • Comment limit:-( I get a much longer stack trace but on the server side background task. – Mike Barry Nov 05 '15 at 20:21
  • that is another issue, please create another question for it - let's try to keep this one focused on the highlighting issue. – Dinesh Bolkensteyn Nov 06 '15 at 14:55
  • as my "draft answer" got deleted :), I'm adding back the link to the reproducer Javascript file sent by @Mike: https://groups.google.com/forum/#!topic/sonarqube/MWbG4gbB5c0 – Dinesh Bolkensteyn Nov 10 '15 at 07:25
  • Got a similar invalid offset on a JavaScript file after updating to SonarQube 5.2 and all the plugins. Removing `sonar.sourceEncoding=UTF-8` in the project properties file fixed the issue. – Anttu Nov 10 '15 at 13:35

3 Answers3

2

This in fact is a bug in the SonarQube CSS plugin, which is trying to highlight invalid offsets in the file, whereas SonarQube 5.2 enforces the offsets to be valid.

I've reproduced the issue on the Site.css file you sent Mike, and could minimalize it: It seems that this issue occurs whenever a comment ends the file.

I've raised a GitHub issue on the SonarQube CSS Plugin: https://github.com/SonarCommunity/sonar-css/issues/147

In the meantime, you could exclude that file from your analysis, or uninstall the CSS plugin until a fix is released.

Dinesh Bolkensteyn
  • 2,971
  • 1
  • 17
  • 20
1

New version of the SonarQube CSS plugin fixing this issue can be found at https://github.com/SonarQubeCommunity/sonar-css/releases/tag/1.7-RC1

0

I had the same problem.

If I saved the problematic file in UTF-8 encoding without BOM - this solved the issue.