Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java:s4143 not found in sonarqube 7.9.4 #111

Open
maybeec opened this issue Oct 29, 2020 · 5 comments
Open

java:s4143 not found in sonarqube 7.9.4 #111

maybeec opened this issue Oct 29, 2020 · 5 comments

Comments

@maybeec
Copy link
Member

maybeec commented Oct 29, 2020

Expected behavior

As an architect, I want to install devon4j sonar plugin so that I can verify my architecture.

Actual behavior

After installing the latest sonar-devon4j-plugin from marketplace in sonarqube 7.9.4, I get the following blocking error on startup:

java.lang.IllegalStateException: Rule with key 'java:S4143' not found
	at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.lambda$updateOrCreateBuilder$6(BuiltInQProfileRepositoryImpl.java:200)
	at java.base/java.util.ArrayList.forEach(Unknown Source)
	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Unknown Source)
	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.updateOrCreateBuilder(BuiltInQProfileRepositoryImpl.java:197)
	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.lambda$toQualityProfileBuilders$5(BuiltInQProfileRepositoryImpl.java:176)
	at java.base/java.util.HashMap.compute(Unknown Source)
	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.toQualityProfileBuilders(BuiltInQProfileRepositoryImpl.java:174)
	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.lambda$toFlatList$2(BuiltInQProfileRepositoryImpl.java:132)
	at org.sonar.core.util.stream.MoreCollectors.lambda$uniqueIndex$9(MoreCollectors.java:258)
	at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(Unknown Source)
	at java.base/java.util.HashMap$EntrySpliterator.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.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.toFlatList(BuiltInQProfileRepositoryImpl.java:130)
	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.initialize(BuiltInQProfileRepositoryImpl.java:84)
	at org.sonar.server.qualityprofile.BuiltInQProfileLoader.start(BuiltInQProfileLoader.java:37)
	at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.start(StartableCloseableSafeLifecyleStrategy.java:40)
	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
	at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
	at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
	at org.picocontainer.behaviors.Stored.start(Stored.java:110)
	at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
	at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
	at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
	at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:90)
	at org.sonar.server.platform.platformlevel.PlatformLevelStartup.access$001(PlatformLevelStartup.java:48)
	at org.sonar.server.platform.platformlevel.PlatformLevelStartup$1.doPrivileged(PlatformLevelStartup.java:85)
	at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:46)
	at org.sonar.server.platform.platformlevel.PlatformLevelStartup.start(PlatformLevelStartup.java:82)
	at org.sonar.server.platform.Platform.executeStartupTasks(Platform.java:196)
	at org.sonar.server.platform.Platform.access$400(Platform.java:46)
	at org.sonar.server.platform.Platform$1.lambda$doRun$1(Platform.java:121)
	at org.sonar.server.platform.Platform$AutoStarterRunnable.runIfNotAborted(Platform.java:371)
	at org.sonar.server.platform.Platform$1.doRun(Platform.java:121)
	at org.sonar.server.platform.Platform$AutoStarterRunnable.run(Platform.java:355)
	at java.base/java.lang.Thread.run(Unknown Source)

Steps to reproduce (bug) / Use Case of feature request (enhancement)

  1. Install the plugin
  2. Restart sonarqube

Related/Dependent Issues

Comments/Hints:

Further installed plugins:
image

Affected version:

@maybeec maybeec added the bug label Oct 29, 2020
@lmarniazman lmarniazman added this to the release:2020.12.001 milestone Nov 10, 2020
@lmarniazman
Copy link
Member

Thanks for finding this bug.
It seems that this rule can not be found in versions 7.9.4, 8.0 and 8.1, which is weird since this rule S4143 exists since July 2017, so long before any of these versions were released.

@lmarniazman
Copy link
Member

This is an issue related to the version of SonarJava that is installed on the server. Not all rules that we are using are available in all versions of SonarJava.

I am working on a fix for this right now, so that we can include / exclude certain rules by detecting which version of SonarJava is running on SonarQube.

@maybeec
Copy link
Member Author

maybeec commented Nov 11, 2020

I am totally new to sonarqube plugin creations, but if you need a logic which will work in any environment, possibly you can enable any of the dependent rules just in case they are available at all?
This would make the plugin much more stable although it will not be stable with respect to the rules executed.

@hohwille
Copy link
Member

As we are adding the rules to our quality profile sequentially, we should simply check if that rule is actually available and otherwise only log a warning and continue. If no other way, we can simply catch the exception and proceed. Even better would be to check the existance of the rule without exception if possible.

@hohwille
Copy link
Member

As discussed with @lmarniazman the exception is not raised, when we are looking up or adding the rule but deferred after our plugin bootstrapping is completed. Therefore we can not catch the error and handle the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants