C4tWithShell / community-rust

SonarQube plugin to analyze Rust files
GNU Lesser General Public License v3.0
127 stars 11 forks source link

IllegalArgumentException when scanning some repos #100

Closed ptupitsyn closed 5 months ago

ptupitsyn commented 6 months ago
java.lang.IllegalArgumentException: 30 is not a valid line offset for pointer. File src/lib.rs has 23 character(s) at line 19
        at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
        at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:374)
        at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:307)
        at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:323)
        at org.elegoff.plugins.communityrust.clippy.ClippySensor.saveIssue(ClippySensor.java:93)
        at org.elegoff.plugins.communityrust.clippy.ClippySensor.lambda$importReport$1(ClippySensor.java:123)
        at org.elegoff.plugins.communityrust.clippy.ClippyJsonReportReader.onResult(ClippyJsonReportReader.java:148)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
        at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
        at org.elegoff.plugins.communityrust.clippy.ClippyJsonReportReader.read(ClippyJsonReportReader.java:111)
        at org.elegoff.plugins.communityrust.clippy.ClippyJsonReportReader.read(ClippyJsonReportReader.java:57)
        at org.elegoff.plugins.communityrust.clippy.ClippySensor.importReport(ClippySensor.java:123)
        at org.elegoff.plugins.communityrust.clippy.ClippySensor.lambda$execute$0(ClippySensor.java:114)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at org.elegoff.plugins.communityrust.clippy.ClippySensor.execute(ClippySensor.java:114)
        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:223)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:202)
        at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:197)
        at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:193)
        at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:166)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:223)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:202)
        at org.sonar.scanner.bootstrap.SpringScannerContainer.doAfterStart(SpringScannerContainer.java:351)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:223)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:202)
        at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:138)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:223)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:202)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:71)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:65)
        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(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        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)
C4tWithShell commented 6 months ago

Hi! I will check this issue. What version of SonarQube are you using?

ptupitsyn commented 5 months ago

Hi! I will check this issue. What version of SonarQube are you using?

We use 10.4.1-community via Docker

C4tWithShell commented 5 months ago

@ptupitsyn, I can't reproduce it. I have checked your projects several times, but I have not encountered this problem. I used sonar scanner as the cli and docker, but everything went fine in both cases

What is the workflow for your project? Can some steps affect the code?

elegoff commented 5 months ago

My assumption is that there is a mismatch in the file content between the moment the clippy report was generated and the moment the code was scanned on Sonar

The error is pointing to line of the clippy report that does not exist in the scanned code

ptupitsyn commented 5 months ago

@elegoff thank you for the pointer. Looks like an error somewhere in my script. The problem does not reproduce when I run the scanner manually on that repo.