diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-07-30 17:14:05 +0200 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-07-31 12:04:26 +0200 |
commit | 6cd87655c83490cc9f80f10c71a12a09e05378f2 (patch) | |
tree | ff726994d55fc667d8f2f19833f8a28667b44e75 /sonar-batch | |
parent | 46774df18dad3bb7deeb0e9964233d8617ce9490 (diff) | |
download | sonarqube-6cd87655c83490cc9f80f10c71a12a09e05378f2.tar.gz sonarqube-6cd87655c83490cc9f80f10c71a12a09e05378f2.zip |
use new rule WS
Diffstat (limited to 'sonar-batch')
11 files changed, 725 insertions, 87 deletions
diff --git a/sonar-batch/pom.xml b/sonar-batch/pom.xml index 9c5ab4e2156..94c0a17be0c 100644 --- a/sonar-batch/pom.xml +++ b/sonar-batch/pom.xml @@ -52,6 +52,10 @@ </dependency> <dependency> <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-ws</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.sonar</groupId> <artifactId>sonar-home</artifactId> </dependency> <dependency> diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java index 1be6d3194aa..2d1a6128cf6 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java +++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java @@ -19,13 +19,12 @@ */ package org.sonar.batch.mediumtest; -import org.sonar.batch.bootstrapper.IssueListener; +import org.sonarqube.ws.Rules.ListResponse.Rule; +import org.sonar.batch.bootstrapper.IssueListener; import org.sonar.api.server.rule.RulesDefinition.Repository; import org.sonar.api.server.rule.RulesDefinition; -import org.sonar.batch.protocol.input.RulesSearchResult; import org.sonar.batch.rule.RulesLoader; -import org.sonar.batch.protocol.input.Rule; import com.google.common.base.Function; import com.google.common.io.Files; @@ -132,10 +131,16 @@ public class BatchMediumTester { return this; } - public BatchMediumTesterBuilder addRules(List<Rule> rules) { - for (Rule r : rules) { - rulesLoader.addRule(r); + public BatchMediumTesterBuilder addRule(String key, String repoKey, String internalKey, String name) { + Rule.Builder builder = Rule.newBuilder(); + builder.setKey(key); + builder.setRepository(repoKey); + if (internalKey != null) { + builder.setInternalKey(internalKey); } + builder.setName(name); + + rulesLoader.addRule(builder.build()); return this; } @@ -145,7 +150,7 @@ public class BatchMediumTester { List<Repository> repositories = context.repositories(); for (Repository repo : repositories) { for (RulesDefinition.Rule rule : repo.rules()) { - this.addRule(new Rule(rule.repository().key() + ":" + rule.key(), rule.repository().key(), rule.internalKey(), rule.name())); + this.addRule(rule.repository().key() + ":" + rule.key(), rule.repository().key(), rule.internalKey(), rule.name()); } } return this; @@ -270,7 +275,7 @@ public class BatchMediumTester { } private static class FakeRulesLoader implements RulesLoader { - private List<Rule> rules = new LinkedList<>(); + private List<org.sonarqube.ws.Rules.ListResponse.Rule> rules = new LinkedList<>(); public FakeRulesLoader addRule(Rule rule) { rules.add(rule); @@ -278,10 +283,8 @@ public class BatchMediumTester { } @Override - public RulesSearchResult load() { - RulesSearchResult r = new RulesSearchResult(); - r.setRules(rules); - return r; + public List<Rule> load() { + return rules; } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/DefaultRulesLoader.java b/sonar-batch/src/main/java/org/sonar/batch/rule/DefaultRulesLoader.java index fcb2fa3d67d..b456847765c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/DefaultRulesLoader.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/DefaultRulesLoader.java @@ -19,7 +19,14 @@ */ package org.sonar.batch.rule; -import org.sonar.batch.protocol.input.RulesSearchResult; +import org.sonarqube.ws.Rules.ListResponse.Rule; +import com.google.common.io.ByteSource; +import org.sonarqube.ws.Rules.ListResponse; + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + import org.sonar.batch.bootstrap.WSLoader; public class DefaultRulesLoader implements RulesLoader { @@ -32,21 +39,17 @@ public class DefaultRulesLoader implements RulesLoader { } @Override - public RulesSearchResult load() { - - RulesSearchResult rules = RulesSearchResult.fromJson(wsLoader.loadString(getUrl(1))); + public List<Rule> load() { + ListResponse list = loadFromSource(wsLoader.loadSource(RULES_SEARCH_URL)); + return list.getRulesList(); + } - for (int i = 2; i < 100; i++) { - RulesSearchResult moreRules = RulesSearchResult.fromJson(wsLoader.loadString(getUrl(i))); - if (moreRules.getRules().isEmpty()) { - break; - } - rules.getRules().addAll(moreRules.getRules()); + private ListResponse loadFromSource(ByteSource input) { + try (InputStream is = input.openStream()) { + return ListResponse.parseFrom(is); + } catch (IOException e) { + throw new IllegalStateException("Unable to get previous issues", e); } - return rules; } - private static String getUrl(int page) { - return RULES_SEARCH_URL + "&p=" + page; - } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesLoader.java b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesLoader.java index 84a937b05e5..a177cd72cb5 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesLoader.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesLoader.java @@ -19,8 +19,10 @@ */ package org.sonar.batch.rule; -import org.sonar.batch.protocol.input.RulesSearchResult; +import java.util.List; + +import org.sonarqube.ws.Rules.ListResponse.Rule; public interface RulesLoader { - RulesSearchResult load(); + List<Rule> load(); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java index 8e3c1ce75c0..98c4d9f60f7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java @@ -19,12 +19,13 @@ */ package org.sonar.batch.rule; -import org.picocontainer.injectors.ProviderAdapter; +import java.util.List; +import org.sonarqube.ws.Rules.ListResponse.Rule; +import org.picocontainer.injectors.ProviderAdapter; import org.sonar.api.rule.RuleKey; import org.sonar.api.batch.rule.internal.RulesBuilder; import org.sonar.api.batch.rule.internal.NewRule; -import org.sonar.batch.protocol.input.Rule; import org.sonar.api.batch.rule.Rules; public class RulesProvider extends ProviderAdapter { @@ -38,15 +39,15 @@ public class RulesProvider extends ProviderAdapter { } private static Rules load(RulesLoader ref) { + List<Rule> loadedRules = ref.load(); RulesBuilder builder = new RulesBuilder(); - for (Rule inputRule : ref.load().getRules()) { - NewRule newRule = builder.add(RuleKey.parse(inputRule.ruleKey())); - newRule.setName(inputRule.name()); - newRule.setInternalKey(inputRule.internalKey()); + for (Rule r : loadedRules) { + NewRule newRule = builder.add(RuleKey.parse(r.getKey())); + newRule.setName(r.getName()); + newRule.setInternalKey(r.getInternalKey()); } return builder.build(); } - } diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/ChecksMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/ChecksMediumTest.java index fe31dbe7d25..03b1ac8e8e8 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/ChecksMediumTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/ChecksMediumTest.java @@ -47,8 +47,8 @@ public class ChecksMediumTest { .registerPlugin("xoo", new XooPlugin()) .addRules(new XooRulesDefinition()) .addDefaultQProfile("xoo", "Sonar Way") - .addRule(new Rule("xoo:TemplateRule_1234", "xoo", "TemplateRule_1234", "A template rule")) - .addRule(new Rule("xoo:TemplateRule_1235", "xoo", "TemplateRule_1235", "Another template rule")) + .addRule("xoo:TemplateRule_1234", "xoo", "TemplateRule_1234", "A template rule") + .addRule("xoo:TemplateRule_1235", "xoo", "TemplateRule_1235", "Another template rule") .activateRule(new ActiveRule("xoo", "TemplateRule_1234", "TemplateRule", "A template rule", "MAJOR", null, "xoo").addParam("line", "1")) .activateRule(new ActiveRule("xoo", "TemplateRule_1235", "TemplateRule", "Another template rule", "MAJOR", null, "xoo").addParam("line", "2")) .build(); diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/MultilineIssuesMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/MultilineIssuesMediumTest.java index 3411fd118e4..39bfc8b8206 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/MultilineIssuesMediumTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/MultilineIssuesMediumTest.java @@ -45,7 +45,7 @@ public class MultilineIssuesMediumTest { public BatchMediumTester tester = BatchMediumTester.builder() .registerPlugin("xoo", new XooPlugin()) .addRules(new XooRulesDefinition()) - .addRule(new Rule("xoo:MultilineIssue", "xoo", null, "Multinile Issue")) + .addRule("xoo:MultilineIssue", "xoo", null, "Multinile Issue") .addDefaultQProfile("xoo", "Sonar Way") .activateRule(new ActiveRule("xoo", "MultilineIssue", null, "Multinile Issue", "MAJOR", null, "xoo")) .build(); diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java index 11610fa10c1..5dc998463ae 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java @@ -72,8 +72,8 @@ public class PreviewAndReportsMediumTest { .registerPlugin("xoo", new XooPlugin()) .addDefaultQProfile("xoo", "Sonar Way") .addRules(new XooRulesDefinition()) - .addRule(new Rule("manual:MyManualIssue", "manual", "MyManualIssue", "My manual issue")) - .addRule(new Rule("manual:MyManualIssueDup", "manual", "MyManualIssue", "My manual issue")) + .addRule("manual:MyManualIssue", "manual", "MyManualIssue", "My manual issue") + .addRule("manual:MyManualIssueDup", "manual", "MyManualIssue", "My manual issue") .activateRule(new ActiveRule("xoo", "OneIssuePerLine", null, "One issue per line", "MAJOR", null, "xoo")) .activateRule(new ActiveRule("manual", "MyManualIssue", null, "My manual issue", "MAJOR", null, null)) .setPreviousAnalysisDate(new Date()) diff --git a/sonar-batch/src/test/java/org/sonar/batch/rule/DefaultRulesLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/rule/DefaultRulesLoaderTest.java index a9d5bfd4571..4f2f85e8567 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/rule/DefaultRulesLoaderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/rule/DefaultRulesLoaderTest.java @@ -21,42 +21,26 @@ package org.sonar.batch.rule; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import org.sonarqube.ws.Rules.ListResponse.Rule; +import com.google.common.io.ByteSource; +import com.google.common.io.Resources; import java.io.IOException; -import java.util.Arrays; -import java.util.LinkedList; +import java.util.List; -import static org.mockito.Matchers.contains; +import static org.mockito.Matchers.anyString; import static org.assertj.core.api.Assertions.assertThat; import org.sonar.batch.bootstrap.WSLoader; import org.junit.Test; -import org.sonar.batch.protocol.input.Rule; -import org.sonar.batch.protocol.input.RulesSearchResult; public class DefaultRulesLoaderTest { @Test - public void testLoadingJson() throws IOException { - Rule rule1 = new Rule("squid:S1194", "squid", "S1194", "\"java.lang.Error\" should not be extended"); - Rule rule2 = new Rule("squid:ObjectFinalizeOverridenCallsSuperFinalizeCheck", "squid", "ObjectFinalizeOverridenCallsSuperFinalizeCheck", - "super.finalize() should be called at the end of Object.finalize() implementations"); - - // generate json - RulesSearchResult rulesSearch = new RulesSearchResult(); - rulesSearch.setRules(Arrays.asList(rule1, rule2)); - String json = rulesSearch.toJson(); - - RulesSearchResult empty = new RulesSearchResult(); - empty.setRules(new LinkedList<Rule>()); - String emptyJson = empty.toJson(); - + public void testParseServerResponse() throws IOException { WSLoader wsLoader = mock(WSLoader.class); - when(wsLoader.loadString(contains("p=1"))).thenReturn(json); - when(wsLoader.loadString(contains("p=2"))).thenReturn(emptyJson); - - // load - RulesLoader loader = new DefaultRulesLoader(wsLoader); - RulesSearchResult rules = loader.load(); - - assertThat(rules.toJson()).isEqualTo(json); + ByteSource source = Resources.asByteSource(this.getClass().getResource("DefaultRulesLoader/response.protobuf")); + when(wsLoader.loadSource(anyString())).thenReturn(source); + DefaultRulesLoader loader = new DefaultRulesLoader(wsLoader); + List<Rule> ruleList = loader.load(); + assertThat(ruleList).hasSize(318); } } diff --git a/sonar-batch/src/test/java/org/sonar/batch/rule/RulesProviderTest.java b/sonar-batch/src/test/java/org/sonar/batch/rule/RulesProviderTest.java index cfa69b5da8f..dbd44a3a816 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/rule/RulesProviderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/rule/RulesProviderTest.java @@ -19,42 +19,46 @@ */ package org.sonar.batch.rule; -import org.assertj.core.api.Condition; +import com.google.common.collect.Lists; import org.sonar.api.batch.rule.Rules; -import java.util.Arrays; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; import static org.mockito.Mockito.mock; -import org.sonar.batch.protocol.input.Rule; -import org.sonar.batch.protocol.input.RulesSearchResult; +import org.sonarqube.ws.Rules.ListResponse.Rule; import org.junit.Test; public class RulesProviderTest { @Test public void testRuleTranslation() { - final Rule testRule = new Rule("repo1:key1", "repo1", "key1", "name"); - - RulesSearchResult loadResult = new RulesSearchResult(); - loadResult.setRules(Arrays.asList(testRule)); RulesLoader loader = mock(RulesLoader.class); - when(loader.load()).thenReturn(loadResult); + when(loader.load()).thenReturn(Lists.newArrayList(getTestRule())); RulesProvider provider = new RulesProvider(); + Rules rules = provider.provide(loader); assertThat(rules.findAll()).hasSize(1); - assertThat(rules.findAll()).are(new Condition<org.sonar.api.batch.rule.Rule>() { - - @Override - public boolean matches(org.sonar.api.batch.rule.Rule value) { - return value.key().rule().equals(testRule.internalKey()) && - value.internalKey().equals(testRule.internalKey()) && - value.name().equals(testRule.name()) && - value.key().repository().equals(testRule.repositoryKey()); - } - }); + assertRule(rules.findAll().iterator().next()); + } + + private static void assertRule(org.sonar.api.batch.rule.Rule r) { + Rule testRule = getTestRule(); + + assertThat(r.name()).isEqualTo(testRule.getName()); + assertThat(r.internalKey()).isEqualTo(testRule.getInternalKey()); + assertThat(r.key().toString()).isEqualTo(testRule.getKey()); + assertThat(r.key().repository()).isEqualTo(testRule.getRepository()); + } + + private static Rule getTestRule() { + Rule.Builder ruleBuilder = Rule.newBuilder(); + ruleBuilder.setKey("repo1:key1"); + ruleBuilder.setRepository("repo1"); + ruleBuilder.setName("name"); + ruleBuilder.setInternalKey("key1"); + return ruleBuilder.build(); + } } diff --git a/sonar-batch/src/test/resources/org/sonar/batch/rule/DefaultRulesLoader/response.protobuf b/sonar-batch/src/test/resources/org/sonar/batch/rule/DefaultRulesLoader/response.protobuf new file mode 100644 index 00000000000..3c24dd83d29 --- /dev/null +++ b/sonar-batch/src/test/resources/org/sonar/batch/rule/DefaultRulesLoader/response.protobuf @@ -0,0 +1,637 @@ + +i +common-javaInsufficientCommentDensity">Source files should have a sufficient density of comment lines +S +common-javaDuplicatedBlocks"2Source files should not have any duplicated blocks +U +common-javaSkippedUnitTests"4Skipped unit tests should be either removed or fixed +\ +common-javaInsufficientLineCoverage"3Lines should have sufficient coverage by unit tests +A +common-javaFailedUnitTests"!Failed unit tests should be fixed +a +common-javaInsufficientBranchCoverage"6Branches should have sufficient coverage by unit tests + +squidUselessParenthesesCheckUselessParenthesesCheck"XUseless parentheses around expressions should be removed to prevent any misunderstanding +Z +squidS2134S2134"CClasses extending java.lang.Thread should override the "run" method +; +squidS138S138"&Methods should not have too many lines +G +squidS2133S2133"0Objects should not be created only to "getClass" +M +squidS1294S1294"6The Array.equals(Object obj) method should not be used +R +squidS2131S2131";Primitives should not be boxed just for "String" conversion +` +squidS135S135"KLoops should not contain more than a single "break" or "continue" statement +< +squidS1150S1150"%Enumeration should not be implemented +K +squidS1151S1151"4"switch case" clauses should not have too many lines +M +squidS1939S1939"6Extensions and implementations should not be redundant +E +squidS2039S2039".Member variable visibility should be specified +L +squidNoSonarNoSonar"1"NOSONAR" should not be used to switch off issues +> +squidS2232S2232"'"ResultSet.isLast()" should not be used +f +squidS1943S1943"OClasses and methods that rely on the default system encoding should not be used +m +squidS1158S1158"VPrimitive wrappers should not be instantiated only for "toString" or "compareTo" calls +H +squidS2230S2230"1Non-public methods should not be "@Transactional" +t +squidS1157S1157"]Case insensitive string comparisons should be made without intermediate upper or lower casing +P +squidS1155S1155"9Collection.isEmpty() should be used to test for emptiness +s +squidS2236S2236"\Methods "wait(...)", "notify()" and "notifyAll()" should never be called on Thread instances +b +squidS1948S1948"KFields in a "Serializable" class should either be transient or serializable +J +squidS1153S1153"3String.valueOf() should not be appended to a String +H +squidS2235S2235"1IllegalMonitorStateException should not be caught +b +squidS1764S1764"KIdentical expressions should not be used on both sides of a binary operator +P +squidS2130S2130"9Parsing should be used to convert "Strings" to primitives +s +squidUndocumentedApiUndocumentedApi"HPublic types, methods and fields (API) should be documented with Javadoc += +squidS2333S2333"&Redundant modifiers should not be used +o +squidTrailingCommentCheckTrailingCommentCheck":Comments should not be located at the end of lines of code +m +squidMaximumInheritanceDepthMaximumInheritanceDepth"2Inheritance tree of classes should not be too deep +< +squidS1940S1940"%Boolean checks should not be inverted +L +squidS1699S1699"5Constructors should only call non-overridable methods +T +squidS128S128"?Switch cases should end with an unconditional "break" statement +M +squidS2127S2127"6"Double.longBitsToDouble" should not be used for "int" +X +squidCallToDeprecatedMethodCallToDeprecatedMethod"Avoid use of deprecated methods +] +squidS888S888"HRelational operators should be used in "for" loop termination conditions +A +squidS2123S2123"*Values should not be uselessly incremented +S +squidS2122S2122"<"ScheduledThreadPoolExecutor" should not have 0 core threads +P +squidS1160S1160"9Public methods should throw at most one checked exception + +squidS1161S1161"x"@Override" annotation should be used on any method overriding (since Java 5) or implementing (since Java 6) another one +W +squidS1694S1694"@An abstract class should have both abstract and concrete methods += +squidS1162S1162"&Checked Exception should not be thrown +K +squidS00101S00101"2Class names should comply with a naming convention +M +squidS1695S1695"6"NullPointerException" should not be explicitly thrown +L +squidS00100S00100"3Method names should comply with a naming convention +B +squidS1696S1696"+"NullPointerException" should not be caught +n +squidS1697S1697"WShort-circuit logic should be used to prevent null pointer dereferences in conditionals +A +squidS1698S1698"*Objects should be compared with "equals()" +V +squidS1168S1168"?Empty arrays and collections should be returned instead of null +r +squidStringEqualityComparisonCheckStringEqualityComparisonCheck"+Strings should be compared using "equals()" +/ +squidS2222S2222"Locks should be released +[ +squidHiddenFieldCheckHiddenFieldCheck".Local variables should not shadow class fields +? +squidS2326S2326"(Unused type parameters should be removed +H +squidS1163S1163"1Exceptions should not be thrown in finally blocks +P +squidS2225S2225"9"toString()" and "clone()" methods should not return null +P +squidS1166S1166"9Exception handlers should preserve the original exception +< +squidS1165S1165"%Exception classes should be immutable +I +squidS2226S2226"2Servlets should never have mutable instance fields +S +squidArchitecturalConstraintArchitecturalConstraint"Architectural constraint +u +squidS134S134"`Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply +[ +squidS2325S2325"D"private" methods that don't access instance data should be "static" +J +squidS2156S2156"3"final" classes should not have "protected" members +z +squidS2154S2154"cDissimilar primitive wrappers should not be used with the ternary operator without explicit casting +M +squidS2153S2153"6Boxing and unboxing should not be immediately reversed +? +squidS2159S2159"(Silly equality checks should not be made +< +squidS2157S2157"%"Cloneables" should implement "clone" +A +squidS1172S1172"*Unused method parameters should be removed +R +squidS1479S1479";"switch" statements should not have too many "case" clauses + +squidS1170S1170"jPublic constants and fields initialized at declaration should be "static final" rather than merely "final" +D +squidS1171S1171"-Only static class initializers should be used +] +squidS1175S1175"FThe signature of "finalize()" should match that of "Object.finalize()" +b +squidS1174S1174"K"Object.finalize()" should remain protected (versus public) when overriding +A +squidS2151S2151"*"runFinalizersOnExit" should not be called +f +squidCallToFileDeleteOnExitMethodCallToFileDeleteOnExitMethod"!"deleteOnExit" should not be used +Z +squidLabelsShouldNotBeUsedCheckLabelsShouldNotBeUsedCheck"Labels should not be used +e +squidS1488S1488"NLocal Variables should not be declared and then immediately returned or thrown +Z +squidS3008S3008"CStatic non-final field names should comply with a naming convention +{ +squidSwitchLastCaseIsDefaultCheckSwitchLastCaseIsDefaultCheck"6"switch" statements should end with a "default" clause + +squid,RightCurlyBraceDifferentLineAsNextBlockCheck,RightCurlyBraceDifferentLineAsNextBlockCheck"fClose curly brace and the next "else", "catch" and "finally" keywords should be on two different lines +d +squidModifiersOrderCheckModifiersOrderCheck"1Modifiers should be declared in the correct order +? +squidS1181S1181"(Throwable and Error should not be caught +9 +squidS1905S1905""Redundant casts should not be used +c +squidS1182S1182"LClasses that override "clone" should be "Cloneable" and call "super.clone()" +j +squidS2201S2201"SReturn values should not be ignored when function calls don't have any side effects +2 +squidS1186S1186"Methods should not be empty += +squidS1872S1872"&Classes should not be compared by name +R +squidS2438S2438";"Threads" should not be used where "Runnables" are expected +u +squidS1871S1871"^Two branches in the same conditional structure should not have exactly the same implementation +l +squidS1185S1185"UOverriding methods should do more than simply call the same method in the super class +S +squidS1188S1188"<Lambdas and anonymous classes should not have too many lines +@ +squidS1873S1873")"static final" arrays should be "private" +\ +squidS2204S2204"E".equals()" should not be used to test the values of "Atomic" classes +C +squidS2437S2437",Silly bit operations should not be performed +T +squidS2200S2200"="compareTo" results should not be checked for specific values +R +squidUselessImportCheckUselessImportCheck"!Useless imports should be removed +E +squidS2209S2209"."static" members should be accessed statically +? +squidS1481S1481"(Unused local variables should be removed + +squidMissingDeprecatedCheckMissingDeprecatedCheck"GDeprecated elements should have both the annotation and the Javadoc tag +: +squidS2208S2208"#Wildcard imports should not be used +> +squidS1774S1774"'The ternary operator should not be used +V +squidS2272S2272"?"Iterator.next()" methods should throw "NoSuchElementException" + +squidS2273S2273"r"wait(...)", "notify()" and "notifyAll()" methods should only be called when a lock is obviously held on an object +a +squidLowerCaseLongSuffixCheckLowerCaseLongSuffixCheck"$Long suffix "L" should be upper case +C +squidS2786S2786",Nested "enum"s should not be declared static +J +squidS1118S1118"3Utility classes should not have public constructors +z +squidS2277S2277"cCryptographic RSA algorithms should always incorporate OAEP (Optimal Asymmetric Encryption Padding) +a +squidUnusedProtectedMethodUnusedProtectedMethod"*Unused protected methods should be removed +d +squidS2276S2276"M"wait(...)" should be used instead of "Thread.sleep(...)" when a lock is held +d +squidS2275S2275"MPrintf-style format strings should not lead to unexpected behavior at runtime +k +squidS2274S2274"T"Object.wait(...)" and "Condition.await(...)" should be called inside a "while" loop +c +squidCommentedOutCodeLineCommentedOutCodeLine".Sections of code should not be "commented out" +^ +squidS2278S2278"GNeither DES (Data Encryption Standard) nor DESede (3DES) should be used +C +squidS2912S2912","indexOf" checks should use a start position +< +squidS1656S1656"%Variables should not be self-assigned +Q +squidS1659S1659":Multiple variables should not be declared on the same line +L +squidS1264S1264"5A "while" loop should be used instead of a "for" loop +Y +squidS1125S1125"BLiteral boolean values should not be used in condition expressions +k +squidS1126S1126"TReturn of boolean expressions should not be wrapped into an "if-then-else" statement + +squidClassVariableVisibilityCheckClassVariableVisibilityCheck":Class variable fields should not have public accessibility +H +squidS2250S2250"1"ConcurrentLinkedQueue.size()" should not be used +M +squidS1643S1643"6Strings should not be concatenated using '+' in a loop +` +squidS2251S2251"IA "for" loop update clause should move the counter in the right direction +Z +squidS1640S1640"CMaps with keys that are enum values should be replaced with EnumMap +E +squidS2118S2118".Non-serializable classes should not be written +B +squidS00112S00112")Generic exceptions should never be thrown +> +squidS2111S2111"'"BigDecimal(double)" should not be used +H +squidS2112S2112"1"URL.hashCode" and "URL.equals" should be avoided +? +squidS2110S2110"(Invalid "Date" values should not be used +X +squidS2116S2116"A"hashCode" and "toString" should not be called on array instances +J +squidS2391S2391"3JUnit framework methods should be declared properly +Y +squidS2114S2114"BCollections should not be passed as arguments to their own methods +? +squidS2259S2259"(Null pointers should not be dereferenced +d +squidS1132S1132"MStrings literals should be placed on the left side when checking for equality +D +squidS00107S00107"+Methods should not have too many parameters +c +squidS2258S2258"L"javax.crypto.NullCipher" should not be used for anything other than testing +C +squidS1133S1133",Deprecated code should be removed eventually +L +squidS2257S2257"5Only standard cryptographic algorithms should be used +G +squidS00108S00108".Nested blocks of code should not be left empty +5 +squidS00103S00103"Lines should not be too long +V +squidS2254S2254"?"HttpServletRequest.getRequestedSessionId()" should not be used +< +squidS2253S2253"%Disallowed methods should not be used +5 +squidS1134S1134""FIXME" tags should be handled +A +squidS00105S00105"(Tabulation characters should not be used +C +squidS2252S2252",Loop conditions should be true at least once +4 +squidS1135S1135""TODO" tags should be handled += +squidS00104S00104"$Files should not have too many lines +? +squidS00122S00122"&Statements should be on separate lines +M +squidS00120S00120"4Package names should comply with a naming convention +U +squidS2109S2109">Reflection should not be used to check non-runtime annotations +J +squidS00121S00121"1Control structures should always use curly braces +j +squidS2676S2676"SNeither "Math.abs" nor negation should be used on numbers that could be "MIN_VALUE" +I +squidS2677S2677"2"read" and "readLine" return values should be used +N +squidS2674S2674"7The value returned from a stream read should be checked +@ +squidS2675S2675")"readObject" should not be "synchronized" +V +squidCycleBetweenPackagesCycleBetweenPackages"!Avoid cycle between java packages +h +squidS1149S1149"QSynchronized classes Vector, Hashtable, Stack and StringBuffer should not be used +O +squidS1244S1244"8Floating point numbers should not be tested for equality +P +squidS2384S2384"9Mutable members should not be stored or returned directly +{ +squidLeftCurlyBraceEndLineCheckLeftCurlyBraceEndLineCheck":An open curly brace should be located at the end of a line +Q +squidS2387S2387":Child class members should not shadow parent class members +P +squidS2386S2386"9Interfaces should not have "public static" mutable fields +U +squidS2388S2388">Inner class calls to super class methods should be unambiguous +< +squidS1141S1141"%Try-catch blocks should not be nested +L +squidS1142S1142"5Methods should not contain too many return statements +T +squidS00119S00119";Type parameter names should comply with a naming convention +c +squidS2245S2245"LPseudorandom number generators (PRNGs) should not be used in secure contexts +O +squidS1143S1143"8"return" statements should not occur in "finally" blocks +T +squidS00118S00118";Abstract class names should comply with a naming convention +i +squidS00117S00117"PLocal variable and method parameter names should comply with a naming convention +] +squidS1145S1145"FUseless "if(true) {...}" and "if(false){...}" blocks should be removed +K +squidS00116S00116"2Field names should comply with a naming convention +N +squidS00115S00115"5Constant names should comply with a naming convention + +squidLeftCurlyBraceStartLineCheckLeftCurlyBraceStartLineCheck"@An open curly brace should be located at the beginning of a line +8 +squidS1147S1147"!Exit methods should not be called +O +squidS00114S00114"6Interface names should comply with a naming convention +J +squidS1148S1148"3Throwable.printStackTrace(...) should not be called +J +squidS00113S00113"1Files should contain an empty new line at the end +] +squidS1215S1215"FExecution of the Garbage Collector should be triggered only by the JVM +T +squidS1217S1217"=Thread.run() and Runnable.run() should not be called directly +A +squidS2188S2188"*JUnit test cases should call super methods +M +squidS1219S1219"6"switch" statements should not contain non-case labels +K +squidS2186S2186"4JUnit assertions should not be used in "run" methods +5 +squidS2187S2187"TestCases should contain tests +i +squidS1210S1210"R"equals(Object obj)" should be overridden along with the "compareTo(T obj)" method +D +squidS1214S1214"-Constants should not be defined in interfaces +o +squidS1609S1609"X@FunctionalInterface annotation should be used to flag Single Abstract Method interfaces +l +squidS1213S1213"UThe members of an interface declaration or class should appear in a pre-defined order +d +squidObjectFinalizeCheckObjectFinalizeCheck"1The Object.finalize() method should not be called +< +squidS2089S2089"%HTTP referers should not be relied on +s +squidS1611S1611"\Parentheses should be removed from a single lambda input parameter when its type is inferred +J +squidS2681S2681"3Multiline blocks should be enclosed in curly braces +K +squidS1612S1612"4Replace lambdas with method references when possible +9 +squidS2185S2185""Silly math should not be performed +E +squidS2184S2184".Math operands should be cast before assignment +X +squidS1610S1610"AAbstract classes without fields should be converted to interfaces +_ +squidS2183S2183"HInts and longs should not be shifted by more than their number of bits-1 +8 +squid EmptyFile EmptyFile"Files should not be empty +N +squidS1228S1228"7Packages should have a javadoc file 'package-info.java' +Z +squidUnusedPrivateMethodUnusedPrivateMethod"'Unused private method should be removed +j +squidS1226S1226"SMethod parameters, caught exceptions and foreach variables should not be reassigned +P +squidS2197S2197"9Modulus results should not be checked for direct equality + +squidAssignmentInSubExpressionCheckAssignmentInSubExpressionCheck":Assignments should not be made from within sub-expressions +H +squidS1221S1221"1Methods should not be named "hashcode" or "equal" +E +squidS1220S1220".The default unnamed package should not be used +1 +squidS2092S2092"Cookies should be "secure" +2 +squidS2094S2094"Classes should not be empty +1 +squidS2095S2095"Resources should be closed +9 +squidS2096S2096"""main" should not "throw" anything +c +squidS1223S1223"LNon-constructor methods should not have the same name as the enclosing class +E +squidS2097S2097"."equals(Object obj)" should test argument type +K +squidS2696S2696"4Instance methods should not write to "static" fields +6 +squidS2699S2699"Tests should include assertions +? +squidS2698S2698"(JUnit assertions should include messages +D +squidS2693S2693"-Threads should not be started in constructors +J +squidS2692S2692"3"indexOf" checks should not be for positive numbers +f +squidS2695S2695"O"PreparedStatement" and "ResultSet" methods should be called with valid indices +c +squidS2694S2694"LInner classes which do not reference their owning classes should be "static" +I +squidS2885S2885"2"Calendars" and "DateFormats" should not be static +] +squidS2166S2166"FClasses named like "Exception" should extend "Exception" or a subclass +H +squidS2167S2167"1"compareTo" should not return "Integer.MIN_VALUE" += +squidS2164S2164"&Math should not be performed on floats +A +squidS2165S2165"*"finalize" should not set fields to "null" +s +squidS1994S1994"\"for" loop incrementers should modify the variable being tested in the loop's stop condition +x +squidRedundantThrowsDeclarationCheckRedundantThrowsDeclarationCheck"-Throws declarations should not be superfluous +S +squidS2162S2162"<"equals" methods should be symmetric and work for subclasses +J +squidS2160S2160"3Subclasses that add fields should override "equals" +J +squidS2175S2175"3Inappropriate "Collection" calls should not be made +o +squidForLoopCounterChangedCheckForLoopCounterChangedCheck"."for" loop stop conditions should be invariant +O +squidS2176S2176"8Class names should not shadow interfaces or superclasses +M +squidS2178S2178"6Short-circuit logic should be used in boolean contexts +T +squidS1700S1700"=A field should not duplicate the name of its containing class +Z +squidS1206S1206"C"equals(Object obj)" and "hashCode()" should be overridden in pairs +K +squidS1701S1701"4Fields and methods should not have conflicting names +S +squidS1201S1201"<Methods named "equals" should override Object.equals(Object) +p +squidS1200S1200"YClasses should not be coupled to too many other classes (Single Responsibility Principle) +` +squidClassCyclomaticComplexityClassCyclomaticComplexity"!Classes should not be too complex +f +squidS1602S1602"OLamdbas containing only one statement should not nest this statement in a block +_ +squidS1604S1604"HAnonymous inner classes containing only one method should become lambdas +J +squidS1309S1309"3The @SuppressWarnings annotation should not be used +K +squidS1607S1607"4Skipped unit tests should be either removed or fixed +P +squidS1301S1301"9"switch" statements should have at least 3 "case" clauses +1 +squidS2446S2446""notifyAll" should be used +r +squidS2445S2445"[Blocks synchronized on fields should not contain assignments of new objects to those fields +V +squidS2444S2444"?Lazy initialization of "static" fields should be "synchronized" +M +squidS1858S1858"6"toString()" should never be called on a String object +y +squidObjectFinalizeOverridenCheckObjectFinalizeOverridenCheck"4The Object.finalize() method should not be overriden +B +squidS2442S2442"+"Lock" objects should not be "synchronized" +V +squidS2441S2441"?Non-serializable objects should not be stored in "HttpSessions" +T +squidS2440S2440"=Classes with only "static" methods should not be instantiated +C +squidS1710S1710",Annotation repetitions should not be wrapped +] +squidS2583S2583"FConditions should not unconditionally evaluate to "TRUE" or to "FALSE" +d +squidS1850S1850"M"instanceof" operators that always return "true" or "false" should be removed +J +squidS2447S2447"3Null should not be returned from a "Boolean" method +F +squidS1310S1310"/"NOPMD" suppression comments should not be used +d +squidS864S864"OLimited dependence should be placed on operator precedence rules in expressions +; +squidS1313S1313"$IP addresses should not be hardcoded +d +squidS1312S1312"MLoggers should be "private static final" and should share a naming convention + +squidS1319S1319"Declarations should use Java collection interfaces such as "List" rather than specific implementation classes such as "LinkedList" +W +squidS1318S1318"@"object == null" should be used instead of "object.equals(null)" +U +squidS1452S1452">Generic wildcard types should not be used in return parameters +F +squidS1451S1451"/Copyright and license headers should be defined +X +squidIndentationCheckIndentationCheck"+Source code should be indented consistently +_ +squidS2718S2718"H"DateUtils.truncate" from Apache Commons Lang library should not be used +O +squidS1315S1315"8"CHECKSTYLE:OFF" suppression comments should not be used +6 +squidS1314S1314"Octal values should not be used +e +squidS1317S1317"N"StringBuilder" and "StringBuffer" should not be instantiated with a character +Y +squidS1860S1860"BSynchronization should not be based on Strings or boxed primitives +Y +squidS1862S1862"BRelated "if/else if" statements should not have the same condition +[ +squidS1724S1724"DDeprecated classes and interfaces should not be extended/implemented +z +squidS881S881"eIncrement (++) and decrement (--) operators should not be mixed with other operators in an expression +8 +squidParsingErrorParsingError"Java parser failure +M +squidS1598S1598"6Package declaration should match source file directory +u +squidS2055S2055"^The non-serializable super class of a "Serializable" class must have a no-argument constructor + +squidS1596S1596"|Collections.emptyList(), emptyMap() and emptySet() should be used instead of Collections.EMPTY_LIST, EMPTY_MAP and EMPTY_SET +F +squidS2057S2057"/"Serializable" classes should have a version id +^ +squidS2059S2059"G"Serializable" inner classes of "Serializable" classes should be static +N +squidS2701S2701"7Literal boolean values should not be used in assertions +; +squidS2063S2063"$Comparators should be "Serializable" + +squid'RightCurlyBraceSameLineAsNextBlockCheck'RightCurlyBraceSameLineAsNextBlockCheck"hClose curly brace and the next "else", "catch" and "finally" keywords should be located on the same line +V +squidS2061S2061"?Custom serialization method signatures should meet requirements +C +squidS1066S1066",Collapsible "if" statements should be merged +< +squidS1067S1067"%Expressions should not be too complex +_ +squidEmptyStatementUsageCheckEmptyStatementUsageCheck""Empty statements should be removed +b +squidMethodCyclomaticComplexityMethodCyclomaticComplexity"!Methods should not be too complex +6 +squidS1065S1065"Unused labels should be removed +> +squidS1068S1068"'Unused private fields should be removed +U +squidS2976S2976">"File.createTempFile" should not be used to create a directory +N +squidS2974S2974"7Classes without "public" constructors should be "final" +; +squidS2068S2068"$Credentials should not be hard-coded +4 +squidS2970S2970"Assertions should be complete +S +squidS2065S2065"<Fields in non-serializable classes should not be "transient" +b +squidS2066S2066"K"Serializable" inner classes of non-serializable classes should be "static" +U +squidS1197S1197">Array designators "[]" should be on the type, not the variable + +squidS1844S1844"j"Object.wait(...)" should never be called on objects that implement "java.util.concurrent.locks.Condition" +< +squidS1199S1199"%Nested code blocks should not be used +a +squidS1848S1848"JObjects should not be created to be dropped immediately without being used +K +squidS2301S2301"4Public methods should not contain selector arguments +M +squidS1849S1849"6"Iterator.hasNext()" should not call "Iterator.next()" +R +squidS2070S2070";SHA-1 and Message-Digest hash algorithms should not be used + +squidRightCurlyBraceStartLineCheckRightCurlyBraceStartLineCheck"@A close curly brace should be located at the beginning of a line +] +squidS2864S2864"F"entrySet()" should be iterated when both the key and value are needed + +squidS1444S1444": +G +squidS1191S1191"0Classes from "sun.*" packages should not be used +B +squidS1190S1190"+Future keywords should not be used as names +^ +squidS1193S1193"GException types should not be tested using "instanceof" in catch blocks +G +squidS2076S2076"0Values passed to OS commands should be sanitized +H +squidS2077S2077"1Values passed to SQL commands should be sanitized +5 +squidS109S109" Magic numbers should not be used +? +squidS1192S1192"(String literals should not be duplicated +P +squidS106S106";Standard ouputs should not be used directly to log anything +c +squidS1195S1195"LArray designators "[]" should be located after the type in method signatures +H +squidS2078S2078"1Values passed to LDAP queries should be sanitized + +squid.ObjectFinalizeOverridenCallsSuperFinalizeCheck.ObjectFinalizeOverridenCallsSuperFinalizeCheck"Qsuper.finalize() should be called at the end of Object.finalize() implementations +? +squidS1194S1194"("java.lang.Error" should not be extended
\ No newline at end of file |