Skip to content

Commit

Permalink
add scala language (#352)
Browse files Browse the repository at this point in the history
* add scala language
* add small testcase
* Fix switch statement

---------

Co-authored-by: Christian Köberl <[email protected]>
  • Loading branch information
Janpopan and derkoe authored Oct 12, 2023
1 parent c7422be commit c1e88b4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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()
Expand Down

0 comments on commit c1e88b4

Please sign in to comment.