CheckList { public static Iterable<Class> getChecks() { return Collections.unmodifiableSet(new HashSet<>(Arrays.asList( AfterJumpStatementCheck.class, AllBranchesAreIdenticalCheck.class, ArgumentNumberCheck.class, ArgumentTypeCheck.class, BackslashInStringCheck.class, BackticksUsageCheck.class, BareRaiseInFinallyCheck.class, BooleanExpressionInExceptCheck.class, BreakContinueOutsideLoopCheck.class, BuiltinShadowingAssignmentCheck.class, CaughtExceptionsCheck.class, ChangeMethodContractCheck.class, ChildAndParentExceptionCaughtCheck.class, ClassComplexityCheck.class, ClassMethodFirstArgumentNameCheck.class, ClassNameCheck.class, ClearTextProtocolsCheck.class, CognitiveComplexityFunctionCheck.class, CollapsibleIfStatementsCheck.class, CollectionLengthComparisonCheck.class, CommandLineArgsCheck.class, CommentedCodeCheck.class, CommentRegularExpressionCheck.class, ComparisonToNoneCheck.class, ConfusingTypeCheckingCheck.class, ConfusingWalrusCheck.class, ConstantConditionCheck.class, CorsCheck.class, CsrfDisabledCheck.class, DataEncryptionCheck.class, DbNoPasswordCheck.class, DeadStoreCheck.class, DebugModeCheck.class, DictionaryDuplicateKeyCheck.class, DisabledHtmlAutoEscapeCheck.class, DisabledHtmlAutoEscapeLegacyCheck.class, DuplicateArgumentCheck.class, DuplicatedMethodFieldNamesCheck.class, DuplicatedMethodImplementationCheck.class, DynamicCodeExecutionCheck.class, ElseAfterLoopsWithoutBreakCheck.class, EmailSendingCheck.class, EmptyFunctionCheck.class, EmptyNestedBlockCheck.class, ExceptionCauseTypeCheck.class, ExceptionNotThrownCheck.class, ExceptionSuperClassDeclarationCheck.class, ExceptRethrowingCheck.class, ExecStatementUsageCheck.class, ExitHasBadArgumentsCheck.class, ExpandingArchiveCheck.class, FieldDuplicatesClassNameCheck.class, FieldNameCheck.class, FileComplexityCheck.class, FixmeCommentCheck.class, FunctionComplexityCheck.class, FunctionNameCheck.class, FunctionReturnTypeCheck.class, FunctionUsingLoopVariableCheck.class, GenericExceptionRaisedCheck.class, HardCodedCredentialsCheck.class, HardcodedIPCheck.class, HashingDataCheck.class, HttpOnlyCookieCheck.class, IgnoredParameterCheck.class, IgnoredSystemExitCheck.class, IdenticalExpressionOnBinaryOperatorCheck.class, IdentityComparisonWithCachedTypesCheck.class, IdentityComparisonWithNewObjectCheck.class, IgnoredPureOperationsCheck.class, ImplicitStringConcatenationCheck.class, IncompatibleOperandsCheck.class, InconsistentTypeHintCheck.class, IncorrectExceptionTypeCheck.class, InequalityUsageCheck.class, InfiniteRecursionCheck.class, InitReturnsValueCheck.class, InstanceAndClassMethodsAtLeastOnePositionalCheck.class, InstanceMethodSelfAsFirstCheck.class, InvalidOpenModeCheck.class, InvariantReturnCheck.class, ItemOperationsTypeCheck.class, IterationOnNonIterableCheck.class, JumpInFinallyCheck.class, LdapAuthenticationCheck.class, LineLengthCheck.class, LocalVariableAndParameterNameConventionCheck.class, LoggersConfigurationCheck.class, LongIntegerWithLowercaseSuffixUsageCheck.class, LoopExecutingAtMostOnceCheck.class, MethodNameCheck.class, MethodShouldBeStaticCheck.class, MissingDocstringCheck.class, MissingNewlineAtEndOfFileCheck.class, ModifiedParameterValueCheck.class, ModuleNameCheck.class, NeedlessPassCheck.class, NestedConditionalExpressionCheck.class, NestedControlFlowDepthCheck.class, NewStyleClassCheck.class, NonCallableCalledCheck.class, NonStringInAllPropertyCheck.class, NoPersonReferenceInTodoCheck.class, NoReRaiseInExitCheck.class, NotImplementedErrorInOperatorMethodsCheck.class, OneStatementPerLineCheck.class, OsExecCheck.class, OverwrittenCollectionEntryCheck.class, ParsingErrorCheck.class, PredictableSaltCheck.class, PreIncrementDecrementCheck.class, PrintStatementUsageCheck.class, ProcessSignallingCheck.class, PropertyAccessorParameterCountCheck.class, PseudoRandomCheck.class, PubliclyWritableDirectoriesCheck.class, RaiseOutsideExceptCheck.class, RedundantJumpCheck.class, RegexCheck.class, ReturnAndYieldInOneFunctionCheck.class, ReturnYieldOutsideFunctionCheck.class, RobustCipherAlgorithmCheck.class, SameBranchCheck.class, SameConditionCheck.class, SecureCookieCheck.class, SecureModeEncryptionAlgorithmsCheck.class, SelfAssignmentCheck.class, SetDuplicateKeyCheck.class, SillyEqualityCheck.class, SillyIdentityCheck.class, SpecialMethodParamListCheck.class, SQLQueriesCheck.class, StandardInputCheck.class, StringFormatCorrectnessCheck.class, StringFormatMisuseCheck.class, StringLiteralDuplicationCheck.class, StrongCryptographicKeysCheck.class, TempFileCreationCheck.class, TooManyLinesInFileCheck.class, TooManyParametersCheck.class, TooManyReturnsCheck.class, TrailingCommentCheck.class, TrailingWhitespaceCheck.class, ReferencedBeforeAssignmentCheck.class, UndefinedNameAllPropertyCheck.class, UnreachableExceptCheck.class, UnreadPrivateAttributesCheck.class, UnreadPrivateInnerClassesCheck.class, UnreadPrivateMethodsCheck.class, UndefinedSymbolsCheck.class, UnusedLocalVariableCheck.class, UnusedNestedDefinitionCheck.class, UnverifiedHostnameCheck.class, UselessParenthesisAfterKeywordCheck.class, UselessParenthesisCheck.class, UselessStatementCheck.class, VerifiedSslTlsCertificateCheck.class, WeakSSLProtocolCheck.class, WildcardImportCheck.class, WrongAssignmentOperatorCheck.class, XMLParserXXEVulnerableCheck.class ))); } private  CheckList(); static Iterable<Class> getChecks(); static final String REPOSITORY_KEY; }
@Test public void test() { Iterable<Class> checks = CheckList.getChecks(); for (Class cls : checks) { String testName = '/' + cls.getName().replace('.', '/') + "Test.class"; assertThat(getClass().getResource(testName)) .overridingErrorMessage("No test for " + cls.getSimpleName()) .isNotNull(); } }
@Test public void count() { int count = 0; List<File> files = (List<File>) FileUtils.listFiles(new File("src/main/java/org/sonar/python/checks/"), new String[] {"java"}, true); for (File file : files) { if (file.getName().endsWith("Check.java") && !file.getName().startsWith("Abstract")) { count++; } } assertThat(Iterables.size(CheckList.getChecks())).isEqualTo(count); }