Skip to content

Commit

Permalink
Reconfigure our CodeNarc implementation to define a "Groovy (gradle)"…
Browse files Browse the repository at this point in the history
… language that only analyse gradle files. Doing this, we can work with the CodeNarc Groovy plugin installed on SonarQube without conflict.
  • Loading branch information
jhertout committed Jan 16, 2024
1 parent b84782b commit 7c805fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@

public class Groovy extends AbstractLanguage {

public static final String KEY = "grvy";
public static final String NAME = "Groovy";
public static final String KEY = "groovy_gradle";
public static final String NAME = "Groovy (Gradle)";
public static final String PROFILE_NAME = "ecoCode (Android)";
public static final String FILE_SUFFIXES_KEY = "sonar.groovy.file.suffixes";
static final String DEFAULT_FILE_SUFFIXES = ".groovy,.gradle";
public static final String FILE_SUFFIXES_KEY = "sonar.gradle.file.suffixes";
static final String DEFAULT_FILE_SUFFIXES = ".gradle";

/** Settings of the plugin. */
private final Configuration settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public class GroovyTest {
public void test() {
MapSettings settings = new MapSettings();
Groovy language = new Groovy(settings.asConfig());
assertThat(language.getKey()).isEqualTo("grvy");
assertThat(language.getName()).isEqualTo("Groovy");
assertThat(language.getFileSuffixes()).isEqualTo(new String[] {".groovy",".gradle"});
assertThat(language.getKey()).isEqualTo("groovy_gradle");
assertThat(language.getName()).isEqualTo("Groovy (Gradle)");
assertThat(language.getFileSuffixes()).isEqualTo(new String[] {".gradle"});

settings.setProperty(Groovy.FILE_SUFFIXES_KEY, "");
assertThat(language.getFileSuffixes()).containsOnly(".groovy",".gradle");
assertThat(language.getFileSuffixes()).containsOnly(".gradle");

settings.setProperty(Groovy.FILE_SUFFIXES_KEY, ".groovy, .grvy");
assertThat(language.getFileSuffixes()).containsOnly(".groovy", ".grvy");
Expand Down

0 comments on commit 7c805fc

Please sign in to comment.