-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#92 improves code quality (reduce code duplication)
- Loading branch information
Showing
11 changed files
with
85 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
ecocode-rules-specifications/src/main/java/io/ecocode/rules/Common.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.ecocode.rules; | ||
|
||
import org.sonar.api.SonarEdition; | ||
import org.sonar.api.SonarProduct; | ||
import org.sonar.api.SonarQubeSide; | ||
import org.sonar.api.SonarRuntime; | ||
import org.sonar.api.utils.Version; | ||
|
||
/** | ||
* This class is used to reduce duplication code and to pass SonarCloud Quality Gate | ||
* //TODO: Remove this class when repository will be split | ||
*/ | ||
public final class Common { | ||
private static final Version SONARQUBE_RUNTIME_VERSION = Version.create(9, 8); | ||
|
||
/** | ||
* Base compatibility version of plugins | ||
*/ | ||
public static final SonarRuntime SONARQUBE_RUNTIME = new SonarRuntime() { | ||
@Override | ||
public Version getApiVersion() { | ||
return SONARQUBE_RUNTIME_VERSION; | ||
} | ||
|
||
@Override | ||
public SonarProduct getProduct() { | ||
return SonarProduct.SONARQUBE; | ||
} | ||
|
||
@Override | ||
public SonarQubeSide getSonarQubeSide() { | ||
return SonarQubeSide.SCANNER; | ||
} | ||
|
||
@Override | ||
public SonarEdition getEdition() { | ||
return SonarEdition.COMMUNITY; | ||
} | ||
}; | ||
|
||
private Common() { | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
ecocode-rules-specifications/src/test/java/io/ecocode/rules/CommonTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.ecocode.rules; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.sonar.api.SonarEdition; | ||
import org.sonar.api.SonarProduct; | ||
import org.sonar.api.SonarQubeSide; | ||
import org.sonar.api.SonarRuntime; | ||
import org.sonar.api.utils.Version; | ||
|
||
import static io.ecocode.rules.Common.SONARQUBE_RUNTIME; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class CommonTest { | ||
private static final Version MINIMAL_SONARQUBE_VERSION_COMPATIBILITY = Version.create(9, 8); | ||
|
||
@Test | ||
void testPluginCompatibility() { | ||
final SonarRuntime sonarRuntime = SONARQUBE_RUNTIME; | ||
|
||
assertThat(MINIMAL_SONARQUBE_VERSION_COMPATIBILITY.isGreaterThanOrEqual(sonarRuntime.getApiVersion())) | ||
.describedAs("Plugin must be compatible with SonarQube 9.8") | ||
.isTrue(); | ||
assertThat(sonarRuntime.getProduct()) | ||
.describedAs("Plugin should applied to SonarQube") | ||
.isEqualTo(SonarProduct.SONARQUBE); | ||
assertThat(sonarRuntime.getEdition()) | ||
.describedAs("Plugin should be compatible with Community Edition") | ||
.isEqualTo(SonarEdition.COMMUNITY); | ||
assertThat(sonarRuntime.getSonarQubeSide()) | ||
.describedAs("Plugin should be executed by scanner") | ||
.isEqualTo(SonarQubeSide.SCANNER); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters