diff --git a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckRulesDefinition.java b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckRulesDefinition.java index 7da7ede0..5c9ced18 100644 --- a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckRulesDefinition.java +++ b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckRulesDefinition.java @@ -13,12 +13,14 @@ public final class LicenseCheckRulesDefinition implements RulesDefinition public static final String LANG_TS = "ts"; public static final String LANG_GROOVY = "grvy"; public static final String LANG_KOTLIN = "kotlin"; + public static final String LANG_SCALA = "scala"; public static final String RULE_REPO_KEY = "licensecheck"; public static final String RULE_REPO_KEY_JS = "licensecheck-js"; public static final String RULE_REPO_KEY_TS = "licensecheck-ts"; public static final String RULE_REPO_KEY_GROOVY = "licensecheck-groovy"; public static final String RULE_REPO_KEY_KOTLIN = "licensecheck-kotlin"; + public static final String RULE_REPO_KEY_SCALA = "licensecheck-scala"; public static final String RULE_UNLISTED_KEY = "licensecheck.unlisted"; public static final String RULE_NOT_ALLOWED_LICENSE_KEY = "licensecheck.notallowedlicense"; @@ -32,6 +34,7 @@ public void define(Context context) context.createRepository(RULE_REPO_KEY_TS, LANG_TS), context.createRepository(RULE_REPO_KEY_GROOVY, LANG_GROOVY), context.createRepository(RULE_REPO_KEY_KOTLIN, LANG_KOTLIN), + context.createRepository(RULE_REPO_KEY_SCALA, LANG_SCALA), }; for (NewRepository repo : repos) diff --git a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/ValidateLicenses.java b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/ValidateLicenses.java index 529f2ae3..c61e148e 100644 --- a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/ValidateLicenses.java +++ b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/ValidateLicenses.java @@ -241,6 +241,8 @@ private static String getRepoKey(Dependency dependency) return LicenseCheckRulesDefinition.RULE_REPO_KEY_TS; case LicenseCheckRulesDefinition.LANG_GROOVY: return LicenseCheckRulesDefinition.RULE_REPO_KEY_GROOVY; + case LicenseCheckRulesDefinition.LANG_SCALA: + return LicenseCheckRulesDefinition.RULE_REPO_KEY_SCALA; case LicenseCheckRulesDefinition.LANG_KOTLIN: return LicenseCheckRulesDefinition.RULE_REPO_KEY_KOTLIN; case LicenseCheckRulesDefinition.LANG_JAVA: diff --git a/src/test/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckRulesDefinitionTest.java b/src/test/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckRulesDefinitionTest.java index 8d02777e..52704a2c 100644 --- a/src/test/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckRulesDefinitionTest.java +++ b/src/test/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckRulesDefinitionTest.java @@ -1,11 +1,11 @@ package at.porscheinformatik.sonarqube.licensecheck; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - import org.junit.Test; import org.sonar.api.server.rule.RulesDefinition; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + public class LicenseCheckRulesDefinitionTest { @Test @@ -15,7 +15,7 @@ public void define() new LicenseCheckRulesDefinition().define(context); - assertThat(context.repositories().size(), is(5)); + assertThat(context.repositories().size(), is(6)); for (RulesDefinition.Repository repository : context.repositories()) { assertThat(repository.rules().size(), is(2)); diff --git a/src/test/java/at/porscheinformatik/sonarqube/licensecheck/ValidateLicensesTest.java b/src/test/java/at/porscheinformatik/sonarqube/licensecheck/ValidateLicensesTest.java index 47271f86..7e9401e4 100644 --- a/src/test/java/at/porscheinformatik/sonarqube/licensecheck/ValidateLicensesTest.java +++ b/src/test/java/at/porscheinformatik/sonarqube/licensecheck/ValidateLicensesTest.java @@ -82,6 +82,19 @@ public void licenseAllowed() verify(context, never()).newIssue(); } + @Test + public void licenseAllowed_scala() + { + SensorContext context = createContext(); + + validateLicenses.validateLicenses( + deps(new Dependency("thing", "1.0", "Apache-2.0", LicenseCheckRulesDefinition.LANG_SCALA), + new Dependency("another", "2.0", "Apache-2.0", LicenseCheckRulesDefinition.LANG_SCALA)), + context); + + verify(context, never()).newIssue(); + } + @Test public void licenseAllowed_kotlin() { @@ -95,7 +108,6 @@ public void licenseAllowed_kotlin() verify(context, never()).newIssue(); } - // (LGPL OR Apache-2.0) AND (LGPL OR Apache-2.0) @Test public void checkSpdxOrCombination()