CheckList { public static List<Class> getChecks() { return ImmutableList.<Class> of( CommentRegularExpressionCheck.class, ElseIfWithoutElseCheck.class, FileNameCheck.class, FunctionNameCheck.class, IterateStatementCheck.class, LineLengthCheck.class, ModuleNameCheck.class, NestedIfDepthCheck.class, NonReservedKeywordCheck.class, OneStatementPerLineCheck.class, ParsingErrorCheck.class, ProcedureNameCheck.class, TooManyIterateOrLeaveInLoopCheck.class, TooManyLinesInFileCheck.class, UseBrokerSchemaCheck.class, VariableNameCheck.class, PropagateToLabelCheck.class, ConstantNameCheck.class, MissingNewlineAtEndOfFileCheck.class, UnusedRoutineCheck.class, EmptyBlockCheck.class, EmptyFileCheck.class, UselessParenthesesCheck.class, CaseAtLeastThreeWhenCheck.class, FileHeaderCheck.class, IdenticalExpressionOnBinaryOperatorCheck.class, IfConditionalAlwaysTrueOrFalseCheck.class, DuplicateConditionIfElseAndCaseWhensCheck.class, BooleanInversionCheck.class, BooleanEqualityComparisonCheck.class, HardCodedCredentialsCheck.class, HardcodedIpCheck.class, HardcodedURICheck.class, BooleanLiteralCheck.class, CaseWithoutElseCheck.class, CardinalityInLoopCheck.class, LoopWithoutLeaveCheck.class, EmptyMainFunctionCheck.class, UnknownMessageDomainCheck.class, ParameterWithDirectionCheck.class, DeleteFromWithoutWhereCheck.class, SelectAllCheck.class, SleepCheck.class, EvalCheck.class, CaseWithTooManyWhensCheck.class, InitializeVariablesCheck.class, UndocumentedModuleCheck.class, UndocumentedRoutineCheck.class, TooManyParametersCheck.class, VariablesSubtreeCheck.class, XmlnscDomainCheck.class, RoutineWithExcessiveReturnsCheck.class, KeyWordCaseCheck.class, CyclomaticComplexityCheck.class, PassThruStatementCheck.class, SubElementNameCheck.class, FunctionProcedureLengthCheck.class, FilterNodeModifyMessageCheck.class, FilterNodeHaveOnlyOneReturnCheck.class, NavigatingTreeCouldBeReferenceCheck.class, UnusedVariableCheck.class, DeprecatedMethodCheck.class, ProcessInvokingItselfCheck.class, InsertBlankLineBetweenFuncProcCheck.class, BlankLineBeforeCommentsCheck.class, RoutineCommentsCheck.class, PropagateConsistencyCheck.class, UnreachableCodeCheck.class, CommentedCodeCheck.class, SelfAssignmentCheck.class, ConditionBracesCheck.class, TrailingCommentsCheck.class, CommentsCheck.class, DeclareCombineCheck.class, BinaryOperatorSeparatedBySpaceCheck.class, TrailingWhitespaceCheck.class, ImmediatelyReturnedVariableCheck.class, StringLiteralDuplicatedCheck.class ); } private  CheckList(); static List<Class> getChecks(); static final String REPOSITORY_KEY; static final String REPOSITORY_NAME; static final String SONAR_WAY_PROFILE; }
@Test public void count() { int count = 0; List<File> files = (List<File>) FileUtils.listFiles(new File("src/main/java/com/exxeta/iss/sonar/esql/check/"), new String[] { "java" }, true); for (File file : files) { String name = file.getName(); if (name.endsWith("Check.java") && !name.startsWith("Abstract")) { count++; } } assertThat(CheckList.getChecks().size()).isEqualTo(count); }
@Test public void test() { List<Class> checks = CheckList.getChecks(); for (Class cls : checks) { if (!cls.getSimpleName().equals("ParsingErrorCheck")) { String testName = '/' + cls.getName().replace('.', '/') + "Test.class"; assertThat(getClass().getResource(testName)) .overridingErrorMessage("No test for " + cls.getSimpleName()) .isNotNull(); } } List<String> keys = Lists.newArrayList(); List<Rule> rules = new AnnotationRuleParser().parse("repositoryKey", checks); for (Rule rule : rules) { keys.add(rule.getKey()); assertThat(getClass().getResource("/org/sonar/l10n/esql/rules/esql/" + rule.getKey() + ".html")) .overridingErrorMessage("No description for " + rule.getKey()) .isNotNull(); assertThat(rule.getDescription()) .overridingErrorMessage("Description of " + rule.getKey() + " should be in separate file") .isNull(); } assertThat(keys).doesNotHaveDuplicates(); }