uartois / sonar-golang

Sonarqube plugin for the golang language.
GNU Lesser General Public License v3.0
245 stars 32 forks source link

Plugin crash on file colorization #1

Closed achedeuzot closed 7 years ago

achedeuzot commented 7 years ago

Description

SonarScanner crashes while coloring a file. My program has some simple ASCII art and one of the lines makes it crash. app.Log.Info(" .J ( '-' \"'--'")

Example error log 12:54:56.583 DEBUG: string 12:54:56.583 DEBUG: position -1 line app.Log.Info(" / .--, _ a L") 12:54:56.586 INFO: ------------------------------------------------------------------------ 12:54:56.586 INFO: EXECUTION FAILURE 12:54:56.586 INFO: ------------------------------------------------------------------------ 12:54:56.587 INFO: Total time: 8.380s 12:54:56.854 INFO: Final Memory: 51M/726M 12:54:56.854 INFO: ------------------------------------------------------------------------ 12:54:56.854 ERROR: Error during SonarQube Scanner execution java.lang.IllegalArgumentException: Unable to highlight file [moduleKey=project:master, relative=src/project/cmd/project/main.go, basedir=/data/ci-volumes/workspace/sas_westeros-project_master-AL2EFEG7W5KT7FA2MJGFYZMPMDL42B2OOBUJBNM672DMZCKKJULQ] at org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting.highlight(DefaultHighlighting.java:95) at org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting.highlight(DefaultHighlighting.java:35) at fr.univartois.sonargo.highlighter.Colorizer.highlightingStringInLine(Colorizer.java:71) at fr.univartois.sonargo.highlighter.Colorizer.searchAndColor(Colorizer.java:132) at fr.univartois.sonargo.highlighter.Colorizer.colorize(Colorizer.java:38) at fr.univartois.sonargo.highlighter.HighlighterSensor.lambda$execute$1(HighlighterSensor.java:36) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) at fr.univartois.sonargo.highlighter.HighlighterSensor.execute(HighlighterSensor.java:34) at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53) at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57) at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49) at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78) at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:175) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:143) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:128) at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:262) at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:257) at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:247) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:143) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:128) at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47) at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:143) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:128) at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:118) at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:117) at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) at com.sun.proxy.$Proxy0.execute(Unknown Source) at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233) at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151) at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110) at org.sonarsource.scanner.cli.Main.execute(Main.java:74) at org.sonarsource.scanner.cli.Main.main(Main.java:61) Caused by: java.lang.IllegalArgumentException: Start pointer [line=49, lineOffset=35] should be before end pointer [line=49, lineOffset=0] at org.sonar.api.internal.google.common.base.Preconditions.checkArgument(Preconditions.java:145) at org.sonar.api.batch.fs.internal.DefaultInputFile.newRangeValidPointers(DefaultInputFile.java:265) at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:203) at org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting.highlight(DefaultHighlighting.java:93) ... 45 more script returned exit code 1

Steps to Reproduce

  1. Add a string with a "stuff\"other" & launch sonar-scanner with coverage & coloring
  2. ...
  3. Profit

Versions

SonarQube version 6.3.1.21392 Gometalinter v1 Sonar-Golang plugin v1.2 Golang 1.8.1

Additional Information

Nothing much to add

thibaultfalque commented 7 years ago

Hi, Thanks you for your feedback.

Sorry for the late answer.

I am fixing the problem.

The correction will be in release 1.2.1.

Regards. Thibault.

achedeuzot commented 7 years ago

Hi Thibault,

Thanks for your help ! In the meantime I've removed the incriminating problem in the string and it works.

Best regards,

Klemen

thibaultfalque commented 7 years ago

Hi, I just published the bug fix release. Please the close the issue if the problem is solved on your side.

Regards, Thibault.

achedeuzot commented 7 years ago

I just re-ran the tests and it passed. Fixed :) Thank you ! :D