Skip to content

Commit

Permalink
Issue checkstyle#49: resolve/suppress few inspection violations
Browse files Browse the repository at this point in the history
  • Loading branch information
romani authored and tsjensen committed Mar 21, 2019
1 parent cca19c5 commit 7cb0acc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public final class CheckstylePlugin extends SonarPlugin {

private static final String CHECKSTYLE_SUB_CATEGORY_NAME = "Checkstyle";

@SuppressWarnings("rawtypes")
@Override
public List getExtensions() {
return Arrays
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public void before() {
fileSystem.add(inputFile);
}

/**
* We do suppression to keep code the same in view
* @noinspection TooBroadScope
*/
@Test
public void testUtilityMethods() {
AuditEvent eventTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ public void getSourceFiles() {

@Test
public void getTargetXmlReport() {
final Settings conf = new Settings();
CheckstyleConfiguration configuration = new CheckstyleConfiguration(conf, null, null,
fileSystem);
final Settings settings = new Settings();
final CheckstyleConfiguration configuration = new CheckstyleConfiguration(settings,
null, null, fileSystem);
assertThat(configuration.getTargetXmlReport()).isNull();

conf.setProperty(CheckstyleConfiguration.PROPERTY_GENERATE_XML, "true");
configuration = new CheckstyleConfiguration(conf, null, null, fileSystem);
assertThat(configuration.getTargetXmlReport()).isEqualTo(
final Settings settings2 = new Settings();
settings2.setProperty(CheckstyleConfiguration.PROPERTY_GENERATE_XML, "true");
final CheckstyleConfiguration configuration2 = new CheckstyleConfiguration(settings2,
null, null, fileSystem);
assertThat(configuration2.getTargetXmlReport()).isEqualTo(
new File(fileSystem.workDir(), "checkstyle-result.xml"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ private static JavaResourceLocator createJavaResourceLocator() {
return new DefaultJavaResourceLocator(null, javaClasspath, null);
}

/**
* We do suppression as we need to cache value initialLocale
* @noinspection TooBroadScope
*/
@Test
public void generateXmlReportInEnglish() throws Exception {
final Locale initialLocale = Locale.getDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private static void validateSonarProperties(Map<Object, Object> properties,
Assert.assertFalse("sonar properties value must not have single quote: "
+ keyName, keyValue.matches(".*[^'{}]'[^'{}].*"));
Assert.assertFalse("sonar properties value must not have unescaped braces: "
+ keyName, keyValue.matches(".*[^'](\\{|})[^'].*"));
+ keyName, keyValue.matches(".*[^']([{}])[^'].*"));

final String moduleName;

Expand Down

0 comments on commit 7cb0acc

Please sign in to comment.