From c88b820c5f3a0dbae172db5eb48c4b302bde2eed Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 15:59:44 +0000 Subject: [PATCH] builder: meet level 2 naming * remove duplicate string literal --- builder/pom.xml | 2 +- .../checkstyle/ruleset/builder/CheckstyleWriter.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/builder/pom.xml b/builder/pom.xml index 6d40d2f..b65ab86 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -25,7 +25,7 @@ 7.3 1.22.0 2.0.0-SNAPSHOT - 1-layout + 2-naming diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java index 014c044..4aab95f 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java @@ -49,6 +49,8 @@ import java.util.stream.Stream; @RequiredArgsConstructor class CheckstyleWriter implements CommandLineRunner { + private static final String NEWLINE = "\n"; + private final OutputProperties outputProperties; private final TemplateProperties templateProperties; @@ -72,14 +74,14 @@ class CheckstyleWriter implements CommandLineRunner { .filter(rule -> RuleParent.CHECKER.equals(rule.getParent())) .filter(rule -> ruleLevel.compareTo(rule.getLevel()) >= 0) .map(this::formatRuleAsModule) - .collect(Collectors.joining("\n")); + .collect(Collectors.joining(NEWLINE)); val treeWalkerRules = rulesProperties.getRules() .stream() .filter(Rule::isEnabled) .filter(rule -> RuleParent.TREEWALKER.equals(rule.getParent())) .filter(rule -> ruleLevel.compareTo(rule.getLevel()) >= 0) .map(this::formatRuleAsModule) - .collect(Collectors.joining("\n")); + .collect(Collectors.joining(NEWLINE)); try { @@ -91,7 +93,7 @@ class CheckstyleWriter implements CommandLineRunner { val bytes = Files.readAllBytes(checkstyleXmlTemplate); val template = new String(bytes); val output = Arrays.asList(String.format(template, checkerRules, treeWalkerRules) - .split("\n")); + .split(NEWLINE)); Files.write(xmlFile, output, StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING); } catch (IOException e) { throw new RuntimeException(e); @@ -111,6 +113,6 @@ class CheckstyleWriter implements CommandLineRunner { private String formatProperties(final Map properties) { return MapStream.of(properties) .map((k, v) -> String.format("", k, v)) - .collect(Collectors.joining("\n")); + .collect(Collectors.joining(NEWLINE)); } }