Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ Additionally, some Error Prone plugins are included:
- [Uber's NullAway](https://github.com/uber/NullAway)
- [errorprone-slf4j](https://github.com/KengoTODA/errorprone-slf4j)
- [Autodispose2](https://uber.github.io/AutoDispose/lint-check/)
- [Picnic Error Prone Support](https://github.com/PicnicSupermarket/error-prone-support)

## Usage

Enable a quality profile including some rules, for NullAway you will need to configure the list of annotated packages

## Compatibility

The plugin is compatible with SonarQube 8.9 LTS and 9.5.
The plugin is compatible with SonarQube 8.9 LTS and 9.6.

The Sonar analyzer and Error Prone must run on JDK 11 or newer but can analyze Java 8 code.
When running on JDK 16 or newer add the following options due to [JEP 396](https://openjdk.java.net/jeps/396):
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<packaging>sonar-plugin</packaging>

<name>Error Away SonarQube plugin</name>
<description>Analyze Java Code with ErrorProne, NullAway, errorprone-slf4j and Autodispose2</description>
<description>Analyze Java Code with ErrorProne, NullAway, errorprone-slf4j, Picnic Error Prone Support and Autodispose2</description>
<url>https://github.com/erroraway/sonar-erroraway-plugin</url>

<licenses>
Expand Down Expand Up @@ -38,6 +38,7 @@
<nullaway.version>0.10.2</nullaway.version>
<errorprone.slf4j.version>0.1.16</errorprone.slf4j.version>
<autodispose2.version>2.1.1</autodispose2.version>
<picnic.errorprone.support.version>0.4.0</picnic.errorprone.support.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

Expand Down Expand Up @@ -76,6 +77,11 @@
<artifactId>autodispose-error-prone</artifactId>
<version>${autodispose2.version}</version>
</dependency>
<dependency>
<groupId>tech.picnic.error-prone-support</groupId>
<artifactId>error-prone-contrib</artifactId>
<version>${picnic.errorprone.support.version}</version>
</dependency>

<!-- SonarQube dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class ErrorAwayQualityProfile implements BuiltInQualityProfilesDefinition
public static final String NULL_AWAY_PROFILE_NAME = "Null Away";
public static final String ERROR_PRONE_SLF4J_PROFILE_NAME = "Error Prone SLF4J";
public static final String AUTODISPOSE2_PROFILE_NAME = "Autodispose2";
public static final String PICNIC_PROFILE_NAME = "Picnic Error Prone Support";
public static final String ERROR_PRONE_AND_PLUGINS_PROFILE_NAME = "Error Prone and plugins";

@Override
Expand All @@ -45,7 +46,8 @@ public void define(Context context) {
NewBuiltInQualityProfile nullAwayProfile = context.createBuiltInQualityProfile(NULL_AWAY_PROFILE_NAME, "java");
NewBuiltInQualityProfile errorProneSlf4jProfile = context.createBuiltInQualityProfile(ERROR_PRONE_SLF4J_PROFILE_NAME, "java");
NewBuiltInQualityProfile autodisposeProfile = context.createBuiltInQualityProfile(AUTODISPOSE2_PROFILE_NAME, "java");
NewBuiltInQualityProfile errorProneAndPluginsProfile = context.createBuiltInQualityProfile(ERROR_PRONE_AND_PLUGINS_PROFILE_NAME, "java");
NewBuiltInQualityProfile picnicEerrorProneProfile = context.createBuiltInQualityProfile(PICNIC_PROFILE_NAME, "java");
NewBuiltInQualityProfile errorProneAndPluginsProfile = context.createBuiltInQualityProfile(ERROR_PRONE_AND_PLUGINS_PROFILE_NAME, "java");

// Built-in checkers
processCheckers(errorProneProfile, BuiltInCheckerSuppliers.ENABLED_WARNINGS, ErrorAwayRulesDefinition.ERRORPRONE_REPOSITORY);
Expand All @@ -59,6 +61,7 @@ public void define(Context context) {
pluginRepositories.put(ErrorAwayRulesDefinition.NULLAWAY_REPOSITORY, nullAwayProfile);
pluginRepositories.put(ErrorAwayRulesDefinition.ERRORPRONE_SLF4J_REPOSITORY, errorProneSlf4jProfile);
pluginRepositories.put(ErrorAwayRulesDefinition.AUTODISPOSE2_REPOSITORY, autodisposeProfile);
pluginRepositories.put(ErrorAwayRulesDefinition.PICNIC_REPOSITORY, picnicEerrorProneProfile);

Map<String, List<Class<? extends BugChecker>>> pluginCheckers = ErrorAwayRulesDefinition.checkerClassesByRepository();

Expand All @@ -77,6 +80,7 @@ public void define(Context context) {
nullAwayProfile.done();
errorProneSlf4jProfile.done();
autodisposeProfile.done();
picnicEerrorProneProfile.done();
errorProneAndPluginsProfile.done();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,26 @@ public class ErrorAwayRulesDefinition implements RulesDefinition {
public static final String NULLAWAY_REPOSITORY = "nullaway";
public static final String ERRORPRONE_SLF4J_REPOSITORY = "errorprone-slf4j";
public static final String AUTODISPOSE2_REPOSITORY = "autodispose2";
public static final String PICNIC_REPOSITORY = "picnic-errorprone";

public static final int ERRORPRONE_REPOSITORY_RULES_COUNT = 407;
public static final int NULLAWAY_REPOSITORY_RULES_COUNT = 1;
public static final int ERRORPRONE_SLF4J_REPOSITORY_RULES_COUNT = 8;
public static final int AUTODISPOSE2_REPOSITORY_RULES_COUNT = 1;
public static final int PICNIC_REPOSITORY_RULES_COUNT = 32;

public static final int RULES_COUNT = ERRORPRONE_REPOSITORY_RULES_COUNT
+ NULLAWAY_REPOSITORY_RULES_COUNT
+ ERRORPRONE_SLF4J_REPOSITORY_RULES_COUNT
+ AUTODISPOSE2_REPOSITORY_RULES_COUNT;
+ AUTODISPOSE2_REPOSITORY_RULES_COUNT
+ PICNIC_REPOSITORY_RULES_COUNT;

protected static final String[] REPOSITORIES = new String[] {
ERRORPRONE_REPOSITORY,
NULLAWAY_REPOSITORY,
ERRORPRONE_SLF4J_REPOSITORY,
AUTODISPOSE2_REPOSITORY };
AUTODISPOSE2_REPOSITORY,
PICNIC_REPOSITORY};

private static final String[] DESCRIPTION_FOLDERS = new String[] {
null,
Expand All @@ -89,6 +93,7 @@ public void define(Context context) {
NewRepository nullAwayRepository = context.createRepository(NULLAWAY_REPOSITORY, "java").setName("Null Away");
NewRepository errorProneSlf4jRepository = context.createRepository(ERRORPRONE_SLF4J_REPOSITORY, "java").setName("Error Prone SLF4J");
NewRepository autodisposeRepository = context.createRepository(AUTODISPOSE2_REPOSITORY, "java").setName("AutoDispose");
NewRepository picnicErrorProneSupportRepository = context.createRepository(PICNIC_REPOSITORY, "java").setName("Picnic Error Prone Support");

// Built-in checkers
processCheckers(errorProneRepository, BuiltInCheckerSuppliers.ENABLED_WARNINGS, Severity.MINOR);
Expand All @@ -99,6 +104,7 @@ public void define(Context context) {
pluginRepositories.put(NULLAWAY_REPOSITORY, nullAwayRepository);
pluginRepositories.put(ERRORPRONE_SLF4J_REPOSITORY, errorProneSlf4jRepository);
pluginRepositories.put(AUTODISPOSE2_REPOSITORY, autodisposeRepository);
pluginRepositories.put(PICNIC_REPOSITORY, picnicErrorProneSupportRepository);

Map<String, List<Class<? extends BugChecker>>> pluginCheckers = checkerClassesByRepository();

Expand All @@ -115,6 +121,7 @@ public void define(Context context) {
nullAwayRepository.done();
errorProneSlf4jRepository.done();
autodisposeRepository.done();
picnicErrorProneSupportRepository.done();
}

public static Map<String, List<Class<? extends BugChecker>>> checkerClassesByRepository() {
Expand Down Expand Up @@ -247,7 +254,9 @@ public static String repository(Class<? extends BugChecker> type) {
return ERRORPRONE_SLF4J_REPOSITORY;
} else if (className.startsWith("autodispose2.")) {
return AUTODISPOSE2_REPOSITORY;
} else {
} else if (className.startsWith("tech.picnic.errorprone.")) {
return PICNIC_REPOSITORY;
} else {
throw new ErrorAwayException("Could not find rules repository for class " + className);
}
}
Expand Down