SonarSource / sonar-scanner-msbuild

SonarScanner for .NET
http://redirect.sonarsource.com/doc/msbuild-sq-runner.html
GNU Lesser General Public License v3.0
365 stars 143 forks source link

IllegalStateException during analyze #1038

Closed jincod closed 3 years ago

jincod commented 3 years ago

Description

I've done upgrade SonarQube 8.4 -> 8.9 LTS.

Repro steps

dotnet sonar-scanner-msbuild-5.2.2.33595-net5.0\SonarScanner.MSBuild.dll begin /k:demo-app /n:DemoApp /v:1.0.0 /d:sonar.host.url=https://sonarqube.local /d:sonar.login=xxx /d:sonar.sources=src
dotnet build
dotnet sonar-scanner-msbuild-5.2.2.33595-net5.0\SonarScanner.MSBuild.dll end /d:sonar.login=xxx

If possible then please create a git repository with a repro sample or attach a zip to the issue.

Expected behavior

Works without errors

Actual behavior

Getting error. java.lang.IllegalStateException: The field 'threshold' does not exist or is not annotated with @RuleProperty in the class org.sonar.flex.checks.ClassNameCheck

java.lang.IllegalStateException: The field 'threshold' does not exist or is not annotated with @RuleProperty in the class org.sonar.flex.checks.ClassNameCheck
        at org.sonar.api.batch.rule.Checks.configureFields(Checks.java:178)
        at org.sonar.api.batch.rule.Checks.instantiate(Checks.java:162)
        at org.sonar.api.batch.rule.Checks.addAnnotatedChecks(Checks.java:136)
        at org.sonar.plugins.flex.FlexSquidSensor.<init>(FlexSquidSensor.java:71)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:145)
        at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:342)
        at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
        at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
        at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
        at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
        at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
        at org.picocontainer.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:606)
        at org.picocontainer.DefaultPicoContainer.getComponents(DefaultPicoContainer.java:587)
        at org.sonar.core.platform.ComponentContainer.getComponentsByType(ComponentContainer.java:291)
        at org.sonar.scanner.bootstrap.AbstractExtensionDictionnary.completeScannerExtensions(AbstractExtensionDictionnary.java:82)
        at org.sonar.scanner.bootstrap.AbstractExtensionDictionnary.getExtensions(AbstractExtensionDictionnary.java:77)
        at org.sonar.scanner.bootstrap.AbstractExtensionDictionnary.getFilteredExtensions(AbstractExtensionDictionnary.java:67)
        at org.sonar.scanner.sensor.ModuleSensorExtensionDictionnary.selectSensors(ModuleSensorExtensionDictionnary.java:40)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$0(ModuleSensorsExecutor.java:52)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:52)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:392)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:385)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:150)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
        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(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        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:189)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Known workarounds

No

Related information

Did some research and found out https://github.com/SonarSource/sonar-flex/blob/52600cc15ea25bcf82ef57083c40f29a1b4ab0a8/flex-checks/src/main/java/org/sonar/flex/checks/ClassNameCheck.java. For some reason scanner use Flex plugin. At SonarQube Flex Language settings page we had suffix 'as' instead of '.as'. Changed to '.as' - didn't help.

jincod commented 3 years ago

Update:

I've dropped Flex plugin manually and restarted server. Now I'm getting error from PHP plugin

java.lang.IllegalStateException: The field 'maximumFunctionComplexityThreshold' does not exist or is not annotated with @RuleProperty in the class org.sonar.php.checks.HardCodedCredentialsCheck
        at org.sonar.api.batch.rule.Checks.configureFields(Checks.java:178)
        at org.sonar.api.batch.rule.Checks.instantiate(Checks.java:162)
        at org.sonar.api.batch.rule.Checks.addAnnotatedChecks(Checks.java:136)
        at org.sonar.plugins.php.PHPChecks.addChecks(PHPChecks.java:53)
        at org.sonar.plugins.php.PHPSensor.<init>(PHPSensor.java:90)
        at org.sonar.plugins.php.PHPSensor.<init>(PHPSensor.java:82)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:145)
        at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:342)
        at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
        at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
        at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
        at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
        at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
        at org.picocontainer.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:606)
        at org.picocontainer.DefaultPicoContainer.getComponents(DefaultPicoContainer.java:587)
        at org.sonar.core.platform.ComponentContainer.getComponentsByType(ComponentContainer.java:291)
        at org.sonar.scanner.bootstrap.AbstractExtensionDictionnary.completeScannerExtensions(AbstractExtensionDictionnary.java:82)
        at org.sonar.scanner.bootstrap.AbstractExtensionDictionnary.getExtensions(AbstractExtensionDictionnary.java:77)
        at org.sonar.scanner.bootstrap.AbstractExtensionDictionnary.getFilteredExtensions(AbstractExtensionDictionnary.java:67)
        at org.sonar.scanner.sensor.ModuleSensorExtensionDictionnary.selectSensors(ModuleSensorExtensionDictionnary.java:40)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$0(ModuleSensorsExecutor.java:52)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:52)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:392)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:385)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:150)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
        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(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        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:189)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)
vilchik-elena commented 3 years ago

Similar problem when upgrading to previous LTS https://community.sonarsource.com/t/the-field-format-does-not-exist-or-is-not-annotated-with-ruleproperty/29633

andrei-epure-sonarsource commented 3 years ago

Hello @jincod

Could you please provide the verbose logs (all of them - you can attach them in a file on the community forum https://community.sonarsource.com/c/help/8)?

To do so please run

SonarScanner.MSBuild.exe begin /k:“MyProject” /d:sonar.verbose=true ...

as the begin step, and please attach the output of the BEGIN and END steps.

Do you have files with the .as extension in your solution?

Thanks, Andrei

jincod commented 3 years ago

Hello @andrei-epure-sonarsource,

log.txt

Do you have files with the .as extension in your solution?

No, we don't.

andrei-epure-sonarsource commented 3 years ago

I am a bit puzzled by the logs you gave. The IllegalStateException isn't present in the logs. And they seem to be missing information.

Even more, I see at the end EXECUTION FAILURE but without any WARN or ERROR logs...

Could you help me understand what's happening here?

jincod commented 3 years ago

Hi @andrei-epure-sonarsource ,

log.txt

Exception was lost. Here the full log.

andrei-epure-sonarsource commented 3 years ago

Acknowledged.

So the sensor fails when getting initialized.

The scanner doesn't really use the Flex or PHP plugin - the failure happens during initialization. Normally, the plugins should be initialized and then queried for the language extensions they support. But this failure happens before this step - when the class is actually initialized...

It seems such issues ocurred in the past:

Pending investigation.

jincod commented 3 years ago

@andrei-epure-sonarsource

image

image

Is ok that different languages have the same rule id?

andrei-epure-sonarsource commented 3 years ago

Yes, the same rules are implemented in multiple languages. The rule repository differs (the fully qualified name for the rule is given by rule repository name + rule id).

Can you verify that all language plugins are only in SQ_FOLDER\lib\extensions and the SQ_FOLDER\extensions\plugins is empty (has only the README file)? This may be caused by old language plugins being around and confusing the scanner.

jincod commented 3 years ago

@andrei-epure-sonarsource correct

andrei-epure-sonarsource commented 3 years ago

great, I am glad everything works now

jincod commented 3 years ago

No, I'm mean folder is empty. Plugins aren't duplicated.

The error is still presenting

andrei-epure-sonarsource commented 3 years ago

could you please share the system info file with us? (https://support.microsoft.com/en-us/topic/description-of-microsoft-system-information-msinfo32-exe-tool-10d335d8-5834-90b4-8452-42c58e61f9fc )

jincod commented 3 years ago

@andrei-epure-sonarsource

At production environment we have Docker based installation.

My local information:

deleted
andrei-epure-sonarsource commented 3 years ago

Oops sorry I gave the wrong link - we'd need the SQ System Info https://docs.sonarqube.org/latest/instance-administration/system-info/#header-1

jincod commented 3 years ago

@andrei-epure-sonarsource

sonarqube-support-info.zip

andrei-epure-sonarsource commented 3 years ago

Thanks. To check if something went wrong with the update, could you do the analysis with a local fresh SQ 8.9 install (with the out-of-the-box in-memory database for testing purposes)?

jincod commented 3 years ago

Hi @andrei-epure-sonarsource

I've updated Server to 9.0.1 version, dropped flex plugin manually and restarted server. Now it works

Shall I close the issue?

Thank you for your support

pavel-mikula-sonarsource commented 3 years ago

Thanks for letting us know.

This looks like an issue with SQ or its plugins that cannot be fixed in this repo so I'll close this.