SonarJS
SonarJS copied to clipboard
Analysis should not fail when highlighting has wrong location for symbol
Parser can sometimes provide invalid text range for some symbols. We should not fail hard the analysis in such cases when saving highlighting. We should catch the exception and issue a warning. Warning should contain the information for the user that likely reason of the failure is incorrect source encoding and that it should be fixed by setting the correct encoding (ps TypeScript actually requires utf-8, however JS does not). We should only issue the encoding hint when we detect that encoding is different.
We should not catch the exception in case when we are raising the issue, since this would compromise the user experience (issue not being raised).
https://community.sonarsource.com/t/the-last-analysis-failed-ay1bfgmeze98x1oe3-da/108210/4
Caused by: java.lang.IllegalArgumentException: 6 is not a valid line offset for pointer. File src/common/video_conference/audio_video_settings/notary_alert.tsx has 0 character(s) at line 41
Process terminated with code: 1, time elapsed PT2M16.825569489S
5
Analysis failed:
6
7
at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:271)
8
at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:287)
9
at org.sonar.plugins.javascript.bridge.BridgeServer$Location.toTextRange(BridgeServer.java:233)
10
at org.sonar.plugins.javascript.bridge.AnalysisProcessor.saveHighlights(AnalysisProcessor.java:200)
11
at org.sonar.plugins.javascript.bridge.AnalysisProcessor.processResponse(AnalysisProcessor.java:117)
12
at org.sonar.plugins.javascript.bridge.AnalysisWithProgram.analyze(AnalysisWithProgram.java:179)
13
at org.sonar.plugins.javascript.bridge.AnalysisWithProgram.analyzeProgram(AnalysisWithProgram.java:147)
14
at org.sonar.plugins.javascript.bridge.AnalysisWithProgram.analyzeFiles(AnalysisWithProgram.java:100)
15
at org.sonar.plugins.javascript.bridge.JsTsSensor.analyzeFiles(JsTsSensor.java:132)
16
at org.sonar.plugins.javascript.bridge.AbstractBridgeSensor.execute(AbstractBridgeSensor.java:79)
17
... 33 more
18
ERROR:
19
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
20
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
21
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
22
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:125)
23
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
24
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
25
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:57)
26
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:51)
27
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
28
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
29
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
30
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
31
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
32
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
33
at jdk.proxy1/jdk.proxy1.$Proxy0.execute(Unknown Source)
34
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
35
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
36
at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
37
at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
38
at org.sonarsource.scanner.cli.Main.main(Main.java:62)
39
Caused by: java.lang.IllegalArgumentException: 6 is not a valid line offset for pointer. File src/common/video_conference/audio_video_settings/notary_alert.tsx has 0 character(s) at line 41
40
at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
41
at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:338)
42
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:48)
43
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:66)
44
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:48)
45
at org.son
See also https://github.com/SonarSource/SonarJS/issues/3667