Error while importing rubocop report in 9.9 LTS

  • What version are you upgrading from? → 8.9.9 to 9.9.1
  • System information (Operating system, Java version, Database provider/version) → OS Debian Slim Buster, Java 17.01 , Postgres 10
  • What’s the issue you’re facing?

while running an analysis on our staging license before upgrading to the latest LTS, we faced the following issue in one of our ruby projects.

INFO: Importing XXX/report.json
ERROR: No issues information will be saved as the report file '/XXX/report.json' can't be read. 1 is not a valid line offset for pointer. File XXX.rb has 0 character(s) at line 32
java.lang.IllegalArgumentException: 1 is not a valid line offset for pointer. File XXX.rb has 0 character(s) at line 32
	at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
	at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:356)
	at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:289)
	at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:305)
	at org.sonarsource.ruby.externalreport.rubocop.RuboCopSensor.saveIssue(RuboCopSensor.java:120)
	at org.sonarsource.ruby.externalreport.rubocop.RuboCopSensor.lambda$importReport$1(RuboCopSensor.java:86)
	at org.sonarsource.ruby.externalreport.rubocop.RuboCopJsonReportReader.onOffense(RuboCopJsonReportReader.java:96)
	at org.sonarsource.ruby.externalreport.rubocop.RuboCopJsonReportReader.lambda$onFile$0(RuboCopJsonReportReader.java:77)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
	at org.sonarsource.ruby.externalreport.rubocop.RuboCopJsonReportReader.onFile(RuboCopJsonReportReader.java:77)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
	at org.sonarsource.ruby.externalreport.rubocop.RuboCopJsonReportReader.read(RuboCopJsonReportReader.java:69)
	at org.sonarsource.ruby.externalreport.rubocop.RuboCopJsonReportReader.read(RuboCopJsonReportReader.java:62)
	at org.sonarsource.ruby.externalreport.rubocop.RuboCopSensor.importReport(RuboCopSensor.java:86)
	at org.sonarsource.ruby.externalreport.rubocop.RuboCopSensor.lambda$reportConsumer$0(RuboCopSensor.java:70)
	at org.sonarsource.slang.plugin.AbstractPropertyHandlerSensor.lambda$executeOnFiles$1(AbstractPropertyHandlerSensor.java:84)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
	at org.sonarsource.slang.plugin.AbstractPropertyHandlerSensor.executeOnFiles(AbstractPropertyHandlerSensor.java:82)
	at org.sonarsource.slang.plugin.AbstractPropertyHandlerSensor.execute(AbstractPropertyHandlerSensor.java:74)
	at org.sonarsource.ruby.externalreport.rubocop.RuboCopSensor.execute(RuboCopSensor.java:64)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
	at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:403)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:399)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:368)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at jdk.proxy1/jdk.proxy1.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
	at org.sonarsource.scanner.cli.Main.main(Main.java:62)
INFO: Sensor Import of RuboCop issues [ruby] (done) | time=937ms

We depend on using rubocop as a third-party issue report and need this for our reporting to the customers.

We figured out this is mostly raised by rules refering to an empty line or a block comment, so mainly Layout and Style catagory cops.

Up to now we could identifiy the following cops to fail for sure:
Style/BlockComments,Layout/EmptyLines,Layout/EmptyLinesAroundBeginBody,Layout/EmptyLinesAroundAccessModifier,Layout/EmptyLinesAroundArguments,Layout/EmptyLinesAroundAttributeAccessor,Layout/EmptyLinesAroundBlockBody,Layout/EmptyLinesAroundClassBody,Layout/EmptyLinesAroundExceptionHandlingKeywords,Layout/EmptyLinesAroundMethodBody,Layout/EmptyLinesAroundModuleBody,Style/FrozenStringLiteralComment

Hey there.

Thanks for the report.

I suggest putting together a small sample project that can reproduce the issue (with a real rubocop issue and json report file) so that we can investigate further.

And please no screenshots of logs. :slight_smile:

Here is an example GitLab project with a dummy ruby file and a gitlab-ci.yml configuration with an integrated rubocop analysis.

rubocop-sonar9.zip (1.0 KB)

Hope this is helping to get further investigation done!

Hello @a.stalitza,

Thanks for your message. Could you, please, share with me a rubocop repport? Sonar doesn’t execute rubocop, it just reads the report file. So I need the report to understand, what’s not working.

From what I see in the code, we shouldn’t see issues like this. However, maybe something in the report changed and our assumptions aren’t valid anymore.

Best,
Margarita

Hope this is helping out!
report.json (2.0 KB)

Is there any update from your side? We still wait desperately for a solution on this topic as it prevents our upgrade to the latest LTS. Thank you very much in advance.

Hey @a.stalitza,

Yep, I’m working on it. Will get back to you soon.

Please, note, that answering community threads is not our main priority at the moment. We try to provide the best experience we can, however, we can’t give you any guarantee regarding fast answers.

Best,
Margarita

I was able to reproduce the issue, and after some investigation, found out the root cause.

Here you will find the ticket to fix the issue:

https://sonarsource.atlassian.net/browse/SONARSLANG-624

Thanks for your valuable feedback.

Best,
Margarita

Thanks for your effort!

I saw that the solution has been implemented and was also linked to a solution version of the SonarSlang repository.

Can you tell us in which version of SonarQube we can expect this bug fix to be released? We are looking forward to be able to upgrade our instance which is still stuck on 8.9.

Thanks a lot in advance