From e18e31f0f7c2dfce059e1ee1b8672b4e0fb359fa Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Tue, 4 Jun 2019 13:46:24 +0530 Subject: [PATCH] Lombok Adding lombok for cleaner code updated documentation --- README.md | 20 +-- build.gradle | 2 + .../zachary_moore/filters/FilterMapper.java | 9 +- .../lint/LintImplementation.java | 10 +- .../com/zachary_moore/lint/LintRegister.java | 17 ++- .../java/com/zachary_moore/lint/LintRule.java | 116 ++++-------------- .../com/zachary_moore/objects/JSONArray.java | 14 +-- .../com/zachary_moore/objects/JSONFile.java | 15 +-- .../com/zachary_moore/objects/JSONObject.java | 17 +-- .../objects/WrappedObjectHelper.java | 8 +- .../objects/WrappedPrimitive.java | 17 ++- .../zachary_moore/report/LintRuleSection.java | 9 +- .../java/com/zachary_moore/report/Report.java | 13 +- .../zachary_moore/runner/ReportRunner.java | 10 +- .../lint/LintRegisterShould.java | 24 ++-- .../zachary_moore/lint/LintRuleShould.java | 40 +++--- .../runner/LintRunnerShould.java | 17 +-- 17 files changed, 131 insertions(+), 227 deletions(-) diff --git a/README.md b/README.md index 9051acc..680a656 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,10 @@ class Example { }; // Use builder to create rule - LintRule rule = new LintRule.Builder() - .setLevel(LintLevel.ERROR) - .setImplementation(lintImplementation) - .setIssueId("STRING_VALUE_NAMED_TEST") + LintRule rule = LintRule.builder() + .level(LintLevel.ERROR) + .implementation(lintImplementation) + .issueId("STRING_VALUE_NAMED_TEST") .build(); // Create register and register rule @@ -113,7 +113,7 @@ The classes are: `LintImplementation` - Target `WrappedObject` implementing class type, determine rules for failure, configure output ↓ -`LintRule.Builder` → `LintRule` - Configure severity, set issue ID, explanation, description, and implementation. +`LintRule.builder()` → `LintRule` - Configure severity, set issue ID, explanation, description, and implementation. ↓ `LintRegister` - Register all `LintRule`s ↓ @@ -228,7 +228,7 @@ A `LintRule` can have the following properties set through the builder: * `String issueDescription` - Short description of this lint rule. * `String issueExplanation` - More in-depth description of lint rule. -*Note:* If the required fields are not set when `LintRule.Builder.build()` is called a `LintRuleBuilderException` will be thrown. +*Note:* If the required fields are not set when `LintRule.builder().build()` is called a `NullPointerException` will be thrown. ## LintRegister `LintRegister` is a simple class to register as many or as few `LintRule`s as wanted. @@ -331,10 +331,10 @@ class Example { } }; - LintRule rule = new LintRule.Builder() - .setLevel(LintLevel.ERROR) - .setImplementation(lintImplementation) - .setIssueId("BOOLEAN_NAME_STARTS_WITH_HAS") + LintRule rule = LintRule.builder() + .level(LintLevel.ERROR) + .implementation(lintImplementation) + .issueId("BOOLEAN_NAME_STARTS_WITH_HAS") .build(); LintRegister register = new LintRegister(); diff --git a/build.gradle b/build.gradle index 6ed2bc3..eaf1b2c 100644 --- a/build.gradle +++ b/build.gradle @@ -100,6 +100,8 @@ dependencies { implementation group: 'commons-io', name: 'commons-io', version: '2.6' implementation group: 'org.json', name: 'json', version: '20180813' implementation group: 'com.j2html', name: 'j2html', version: '1.4.0' + compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.8' + annotationProcessor 'org.projectlombok:lombok:1.18.8' testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.4.2' testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.27.0' diff --git a/src/main/java/com/zachary_moore/filters/FilterMapper.java b/src/main/java/com/zachary_moore/filters/FilterMapper.java index 1f12c44..3206ac3 100644 --- a/src/main/java/com/zachary_moore/filters/FilterMapper.java +++ b/src/main/java/com/zachary_moore/filters/FilterMapper.java @@ -8,12 +8,13 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.List; +import lombok.experimental.UtilityClass; -public class FilterMapper { - private FilterMapper() {} +@UtilityClass +public class FilterMapper { - private static Filters filters = new Filters(); + private Filters filters = new Filters(); /** * Filter JSONFile down to a list of types determined by given {@link LintImplementation} @@ -21,7 +22,7 @@ private FilterMapper() {} * @param lintImplementation {@link LintImplementation} that will be used to determine what types we should filter JSONFile down to * @return {@link java.util.ArrayList} of type {@link LintImplementation#getClazz()} */ - public static List filter(JSONFile jsonFile, LintImplementation lintImplementation) { + public List filter(JSONFile jsonFile, LintImplementation lintImplementation) { if (lintImplementation.getClazz() == String.class) { return filters.filterToStrings(jsonFile); } else if (lintImplementation.getClazz() == Byte.class) { diff --git a/src/main/java/com/zachary_moore/lint/LintImplementation.java b/src/main/java/com/zachary_moore/lint/LintImplementation.java index 7c25446..7bf5b18 100644 --- a/src/main/java/com/zachary_moore/lint/LintImplementation.java +++ b/src/main/java/com/zachary_moore/lint/LintImplementation.java @@ -1,5 +1,10 @@ package com.zachary_moore.lint; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; + + /** * Abstract class to represent a Lint implementation * @param Type of Class to build a LintRule for @@ -9,6 +14,7 @@ public abstract class LintImplementation extends BaseJSONAnalyzer { /** * Message reported when a lint issue is found, can be set at runtime or statically */ + @Setter(AccessLevel.PROTECTED) private String reportMessage; /** @@ -37,10 +43,6 @@ public String report(T t) throws NoReportSetException { return reportMessage; } - protected void setReportMessage(String reportMessage) { - this.reportMessage = reportMessage; - } - public static class NoReportSetException extends Exception { private NoReportSetException(String errorMessage) { super(errorMessage); diff --git a/src/main/java/com/zachary_moore/lint/LintRegister.java b/src/main/java/com/zachary_moore/lint/LintRegister.java index d3669c5..8850f6c 100644 --- a/src/main/java/com/zachary_moore/lint/LintRegister.java +++ b/src/main/java/com/zachary_moore/lint/LintRegister.java @@ -3,20 +3,23 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.RequiredArgsConstructor; + /** * Class to be passed around to represent all {@link LintRule} to be checked */ + +@Getter +@NoArgsConstructor public class LintRegister { /** * List to hold all of our {@link LintRule} */ - private final List lintRules; - - public LintRegister() { - lintRules = new ArrayList<>(); - } + private final List lintRules = new ArrayList<>(); /** * Register new LintRule into {@link LintRegister} @@ -25,8 +28,4 @@ public LintRegister() { public void register(LintRule ...toRegister) { lintRules.addAll(Arrays.asList(toRegister)); } - - public List getLintRules() { - return lintRules; - } } diff --git a/src/main/java/com/zachary_moore/lint/LintRule.java b/src/main/java/com/zachary_moore/lint/LintRule.java index b8ad0d9..569e70c 100644 --- a/src/main/java/com/zachary_moore/lint/LintRule.java +++ b/src/main/java/com/zachary_moore/lint/LintRule.java @@ -7,29 +7,38 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + /** * Class to represent a lint rule configuration */ +@Builder +@RequiredArgsConstructor +@EqualsAndHashCode(onlyExplicitlyIncluded = true) public class LintRule { + @Getter + @NonNull private final LintLevel level; + + @NonNull private final LintImplementation implementation; + + @Getter + @NonNull + @EqualsAndHashCode.Include private final String issueId; + + @Getter private final String issueDescription; - private final String issueExplanation; - private LintRule(LintLevel level, - LintImplementation implementation, - String issueId, - String issueDescription, - String issueExplanation) { - this.level = level; - this.implementation = implementation; - this.issueId = issueId; - this.issueDescription = issueDescription; - this.issueExplanation = issueExplanation; - } + @Getter + private final String issueExplanation; /** * Given a list of files lint each file based on setup config @@ -59,87 +68,4 @@ public Map> lint(JSONFile ...jsonFiles) throws LintImplem return reportMessages; } - - public LintLevel getLevel() { - return level; - } - - public String getIssueId() { - return issueId; - } - - public String getIssueDescription() { - return issueDescription; - } - - public String getIssueExplanation() { - return issueExplanation; - } - - @Override - public int hashCode() { - return this.issueId.hashCode(); - } - - /** - * Builder pattern class for building our {@link LintRule} - */ - public static class Builder { - - private LintLevel level; - private LintImplementation implementation; - private String issueId; - private String issueDescription; - private String issueExplanation; - - public Builder setLevel(LintLevel level) { - this.level = level; - return this; - } - - public Builder setImplementation(LintImplementation implementation) { - this.implementation = implementation; - return this; - } - - public Builder setIssueId(String issueId) { - this.issueId = issueId; - return this; - } - - public Builder setIssueDescription(String issueDescription) { - this.issueDescription = issueDescription; - return this; - } - - public Builder setIssueExplanation(String issueExplanation) { - this.issueExplanation = issueExplanation; - return this; - } - - /** - * Builds a {@link LintRule} - * @return new {@link LintRule} - * @throws LintRuleBuilderException if either {@link LintLevel}, IssueID, or {@link LintImplementation} is not set - */ - public LintRule build() throws LintRuleBuilderException { - if (level == null - || implementation == null - || issueId == null) { - throw new LintRuleBuilderException("Must set LintLevel, LintImplementation and IssueId in a lint rule"); - } - - return new LintRule(level, - implementation, - issueId, - issueDescription, - issueExplanation); - } - - public static class LintRuleBuilderException extends Exception { - private LintRuleBuilderException(String errorMessage) { - super(errorMessage); - } - } - } } \ No newline at end of file diff --git a/src/main/java/com/zachary_moore/objects/JSONArray.java b/src/main/java/com/zachary_moore/objects/JSONArray.java index ebe5d1c..3fbe725 100644 --- a/src/main/java/com/zachary_moore/objects/JSONArray.java +++ b/src/main/java/com/zachary_moore/objects/JSONArray.java @@ -1,5 +1,6 @@ package com.zachary_moore.objects; +import lombok.Getter; import org.json.JSONException; import org.json.JSONObject; @@ -9,7 +10,10 @@ public class JSONArray extends org.json.JSONArray implements WrappedObject { + @Getter private final String originatingKey; + + @Getter private final WrappedObject parentObject; private List contents; @@ -26,16 +30,6 @@ public class JSONArray extends org.json.JSONArray implements WrappedObject { this.parentObject = parentObject; } - @Override - public String getOriginatingKey() { - return originatingKey; - } - - @Override - public WrappedObject getParentObject() { - return parentObject; - } - @Override public boolean isPrimitive() { return false; diff --git a/src/main/java/com/zachary_moore/objects/JSONFile.java b/src/main/java/com/zachary_moore/objects/JSONFile.java index 9ca21aa..807ac19 100644 --- a/src/main/java/com/zachary_moore/objects/JSONFile.java +++ b/src/main/java/com/zachary_moore/objects/JSONFile.java @@ -1,5 +1,7 @@ package com.zachary_moore.objects; +import lombok.EqualsAndHashCode; +import lombok.Getter; import org.json.JSONException; import org.json.JSONTokener; @@ -8,10 +10,14 @@ import java.io.FileReader; import java.io.IOException; +@EqualsAndHashCode(onlyExplicitlyIncluded = true) public class JSONFile { private org.json.JSONObject jsonObject; private org.json.JSONArray jsonArray; + + @Getter + @EqualsAndHashCode.Include private String filePath; public JSONFile(File file) throws IOException { @@ -39,13 +45,4 @@ public Object getObject() { throw new RuntimeException("Could not parse either a JSONArray or JSONObject from file"); } } - - public String getFilePath() { - return filePath; - } - - @Override - public int hashCode() { - return this.filePath.hashCode(); - } } diff --git a/src/main/java/com/zachary_moore/objects/JSONObject.java b/src/main/java/com/zachary_moore/objects/JSONObject.java index b6e9e6d..7b9a3bf 100644 --- a/src/main/java/com/zachary_moore/objects/JSONObject.java +++ b/src/main/java/com/zachary_moore/objects/JSONObject.java @@ -1,13 +1,16 @@ package com.zachary_moore.objects; -import org.json.JSONException; - import java.util.HashMap; import java.util.Map; +import lombok.Getter; +import org.json.JSONException; public class JSONObject extends org.json.JSONObject implements WrappedObject { + @Getter private final String originatingKey; + + @Getter private final WrappedObject parentObject; private final org.json.JSONObject clonedObject; @@ -25,16 +28,6 @@ public class JSONObject extends org.json.JSONObject implements WrappedObject { this.clonedObject = clone; } - @Override - public String getOriginatingKey() { - return originatingKey; - } - - @Override - public WrappedObject getParentObject() { - return parentObject; - } - @Override public boolean isPrimitive() { return false; diff --git a/src/main/java/com/zachary_moore/objects/WrappedObjectHelper.java b/src/main/java/com/zachary_moore/objects/WrappedObjectHelper.java index c588951..5ee8e7f 100644 --- a/src/main/java/com/zachary_moore/objects/WrappedObjectHelper.java +++ b/src/main/java/com/zachary_moore/objects/WrappedObjectHelper.java @@ -1,14 +1,16 @@ package com.zachary_moore.objects; -class WrappedObjectHelper { +import lombok.experimental.UtilityClass; + - private WrappedObjectHelper(){} +@UtilityClass +class WrappedObjectHelper { /** * Take in JSONRepresentation and wrap in proper {@link WrappedObject} * @return proper {@link WrappedObject} based on originalObject */ - static WrappedObject getWrappedObject(String originatingKey, + WrappedObject getWrappedObject(String originatingKey, WrappedObject parentObject, Object originalObject) { WrappedObject wrappedObject; diff --git a/src/main/java/com/zachary_moore/objects/WrappedPrimitive.java b/src/main/java/com/zachary_moore/objects/WrappedPrimitive.java index d53bf13..68c3ce8 100644 --- a/src/main/java/com/zachary_moore/objects/WrappedPrimitive.java +++ b/src/main/java/com/zachary_moore/objects/WrappedPrimitive.java @@ -1,13 +1,20 @@ package com.zachary_moore.objects; +import lombok.Getter; + + /** * Object to implement {@link WrappedObject} and encapsulate any non {@link org.json.JSONArray} or {@link org.json.JSONObject} * @param Type of original Object this class was created from */ public class WrappedPrimitive implements WrappedObject { + @Getter private final String originatingKey; + + @Getter private final WrappedObject parentObject; + private final T value; WrappedPrimitive(String originatingKey, @@ -35,16 +42,6 @@ public boolean equals(Object other) { } } - @Override - public String getOriginatingKey() { - return originatingKey; - } - - @Override - public WrappedObject getParentObject() { - return parentObject; - } - @Override public boolean isPrimitive(){ return true; diff --git a/src/main/java/com/zachary_moore/report/LintRuleSection.java b/src/main/java/com/zachary_moore/report/LintRuleSection.java index a73b7ba..0bde057 100644 --- a/src/main/java/com/zachary_moore/report/LintRuleSection.java +++ b/src/main/java/com/zachary_moore/report/LintRuleSection.java @@ -7,18 +7,16 @@ import java.util.List; import java.util.Map; +import lombok.RequiredArgsConstructor; import static j2html.TagCreator.*; class LintRuleSection { - private final FileSection fileSection; - - LintRuleSection() { - this.fileSection = new FileSection(); - } + private final FileSection fileSection = new FileSection(); Tag getLintRuleSection(Map.Entry>> lintRuleMapEntry) { + int numTotalIssues = 0; for (Map.Entry> entry : lintRuleMapEntry.getValue().entrySet()) { numTotalIssues += entry.getValue().size(); @@ -39,5 +37,4 @@ Tag getLintRuleSection(Map.Entry>> lintRule ).withClasses("container-fluid") ).withClasses("container-fluid", lintRuleMapEntry.getKey().getLevel() == LintLevel.ERROR ? "bg-danger" : "bg-warning"); } - } diff --git a/src/main/java/com/zachary_moore/report/Report.java b/src/main/java/com/zachary_moore/report/Report.java index 7551df7..6785bce 100644 --- a/src/main/java/com/zachary_moore/report/Report.java +++ b/src/main/java/com/zachary_moore/report/Report.java @@ -6,20 +6,15 @@ import java.util.List; import java.util.Map; +import lombok.RequiredArgsConstructor; import static j2html.TagCreator.*; public class Report { - private final ReportSummary reportSummary; - private final LintRuleSection lintRuleSection; - private final FooterSection footerSection; - - public Report() { - this.reportSummary = new ReportSummary(); - this.lintRuleSection = new LintRuleSection(); - this.footerSection = new FooterSection(); - } + private final ReportSummary reportSummary = new ReportSummary(); + private final LintRuleSection lintRuleSection = new LintRuleSection(); + private final FooterSection footerSection = new FooterSection(); /** * Generate html report of input lint results diff --git a/src/main/java/com/zachary_moore/runner/ReportRunner.java b/src/main/java/com/zachary_moore/runner/ReportRunner.java index 6754f28..a641c54 100644 --- a/src/main/java/com/zachary_moore/runner/ReportRunner.java +++ b/src/main/java/com/zachary_moore/runner/ReportRunner.java @@ -1,21 +1,19 @@ package com.zachary_moore.runner; -import j2html.tags.Tag; import com.zachary_moore.report.Report; - +import j2html.tags.Tag; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.logging.Logger; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor public class ReportRunner { private final LintRunner lintRunner; - public ReportRunner(LintRunner lintRunner) { - this.lintRunner = lintRunner; - } - /** * Generate an HTML report for any Lint issues and exit program based off of lint results * @param outputPath output path for html report diff --git a/src/test/java/com/zachary_moore/lint/LintRegisterShould.java b/src/test/java/com/zachary_moore/lint/LintRegisterShould.java index b642475..0cc916c 100644 --- a/src/test/java/com/zachary_moore/lint/LintRegisterShould.java +++ b/src/test/java/com/zachary_moore/lint/LintRegisterShould.java @@ -18,10 +18,10 @@ public void setUp() { @Test public void addOneLintRule() throws Exception { - this.lintRegister.register(new LintRule.Builder() - .setImplementation(mock(LintImplementation.class)) - .setIssueId("") - .setLevel(LintLevel.IGNORE) + this.lintRegister.register(LintRule.builder() + .implementation(mock(LintImplementation.class)) + .issueId("") + .level(LintLevel.IGNORE) .build()); assert(lintRegister.getLintRules().size() == 1); assert(lintRegister.getLintRules().get(0).getIssueId().equals("")); @@ -29,15 +29,15 @@ public void addOneLintRule() throws Exception { @Test public void addMultipleLintRules() throws Exception { - this.lintRegister.register(new LintRule.Builder() - .setImplementation(mock(LintImplementation.class)) - .setIssueId("") - .setLevel(LintLevel.IGNORE) + this.lintRegister.register(LintRule.builder() + .implementation(mock(LintImplementation.class)) + .issueId("") + .level(LintLevel.IGNORE) .build(), - new LintRule.Builder() - .setImplementation(mock(LintImplementation.class)) - .setIssueId("") - .setLevel(LintLevel.IGNORE) + LintRule.builder() + .implementation(mock(LintImplementation.class)) + .issueId("") + .level(LintLevel.IGNORE) .build()); assert(lintRegister.getLintRules().size() == 2); assert(lintRegister.getLintRules().get(0).getIssueId().equals("")); diff --git a/src/test/java/com/zachary_moore/lint/LintRuleShould.java b/src/test/java/com/zachary_moore/lint/LintRuleShould.java index a24ec2a..0ed34cc 100644 --- a/src/test/java/com/zachary_moore/lint/LintRuleShould.java +++ b/src/test/java/com/zachary_moore/lint/LintRuleShould.java @@ -10,50 +10,50 @@ public class LintRuleShould { @Test public void expectLintRuleBuilderExceptionBaseBuild() { - Assertions.assertThrows(LintRule.Builder.LintRuleBuilderException.class, () -> { - new LintRule.Builder().build(); + Assertions.assertThrows(NullPointerException.class, () -> { + LintRule.builder().build(); }); } @Test public void expectLintRuleBuilderExceptionNullImplementation() { - Assertions.assertThrows(LintRule.Builder.LintRuleBuilderException.class, () -> { - new LintRule.Builder().setImplementation(null).build(); + Assertions.assertThrows(NullPointerException.class, () -> { + LintRule.builder().implementation(null).build(); }); } @Test public void expectLintRuleBuilderExceptionNullIssueId() { - Assertions.assertThrows(LintRule.Builder.LintRuleBuilderException.class, () -> { - new LintRule.Builder().setIssueId(null).build(); + Assertions.assertThrows(NullPointerException.class, () -> { + LintRule.builder().issueId(null).build(); }); } @Test public void expectLintRuleBuilderExceptionNullLevel() { - Assertions.assertThrows(LintRule.Builder.LintRuleBuilderException.class, () -> { - new LintRule.Builder().setLevel(null).build(); + Assertions.assertThrows(NullPointerException.class, () -> { + LintRule.builder().level(null).build(); }); } @Test - public void minimalLintRule() throws LintRule.Builder.LintRuleBuilderException { - LintRule lintRule = new LintRule.Builder() - .setImplementation(mock(LintImplementation.class)) - .setLevel(LintLevel.IGNORE) - .setIssueId("") + public void minimalLintRule() { + LintRule lintRule = LintRule.builder() + .implementation(mock(LintImplementation.class)) + .level(LintLevel.IGNORE) + .issueId("") .build(); assert(lintRule != null); } @Test - public void fullLintRule() throws LintRule.Builder.LintRuleBuilderException { - LintRule lintRule = new LintRule.Builder() - .setImplementation(mock(LintImplementation.class)) - .setLevel(LintLevel.IGNORE) - .setIssueId("") - .setIssueDescription("") - .setIssueExplanation("") + public void fullLintRule() { + LintRule lintRule = LintRule.builder() + .implementation(mock(LintImplementation.class)) + .level(LintLevel.IGNORE) + .issueId("") + .issueDescription("") + .issueExplanation("") .build(); assert(lintRule != null); } diff --git a/src/test/java/com/zachary_moore/runner/LintRunnerShould.java b/src/test/java/com/zachary_moore/runner/LintRunnerShould.java index c475962..cee950b 100644 --- a/src/test/java/com/zachary_moore/runner/LintRunnerShould.java +++ b/src/test/java/com/zachary_moore/runner/LintRunnerShould.java @@ -15,15 +15,15 @@ public class LintRunnerShould { private LintRunner lintRunner; - private LintRule.Builder builder; + private LintRule.LintRuleBuilder builder; private LintRegister lintRegister; @BeforeEach public void setUp() { this.lintRunner = new LintRunner(new LintRegister(), "./src/test/resources"); - this.builder = new LintRule.Builder() - .setImplementation(new LintImplementation>() { + this.builder = LintRule.builder() + .implementation(new LintImplementation>() { @Override public Class getClazz() { return String.class; @@ -35,7 +35,8 @@ public boolean shouldReport(WrappedPrimitive stringWrappedPrimitive) { return true; } }) - .setIssueId(""); + .issueId("") + ; this.lintRegister = new LintRegister(); } @@ -53,7 +54,7 @@ public void lintRunnerShouldGiveExitStatus0() { @Test public void lintRunnerShouldGiveExitStatus1() throws Exception { - this.lintRegister.register(builder.setLevel(LintLevel.ERROR).build()); + this.lintRegister.register(builder.level(LintLevel.ERROR).build()); LintRunner lintRunner = new LintRunner(this.lintRegister, "./src/test/resources"); lintRunner.lint(); assert(lintRunner.analyzeLintAndGiveExitCode() == 1); @@ -61,7 +62,7 @@ public void lintRunnerShouldGiveExitStatus1() throws Exception { @Test public void lintRunnerShouldGiveExitStatus0WithWarning() throws Exception { - lintRegister.register(builder.setLevel(LintLevel.WARNING).build()); + lintRegister.register(builder.level(LintLevel.WARNING).build()); LintRunner lintRunner = new LintRunner(lintRegister, "./src/test/resources"); lintRunner.lint(); assert(lintRunner.analyzeLintAndGiveExitCode() == 0); @@ -69,7 +70,7 @@ public void lintRunnerShouldGiveExitStatus0WithWarning() throws Exception { @Test public void lintRunnerShouldGiveExitStatus0WithIgnore() throws Exception { - this.lintRegister.register(builder.setLevel(LintLevel.IGNORE).build()); + this.lintRegister.register(builder.level(LintLevel.IGNORE).build()); LintRunner lintRunner = new LintRunner(this.lintRegister, "./src/test/resources"); lintRunner.lint(); assert(lintRunner.analyzeLintAndGiveExitCode() == 0); @@ -77,7 +78,7 @@ public void lintRunnerShouldGiveExitStatus0WithIgnore() throws Exception { @Test public void lintRunnerShouldTakeMultipleFiles() throws Exception { - LintRule lintRule = builder.setLevel(LintLevel.ERROR).build(); + LintRule lintRule = builder.level(LintLevel.ERROR).build(); this.lintRegister.register(lintRule); LintRunner lintRunner = new LintRunner(