All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.javascript.checks.CheckList Maven / Gradle / Ivy

There is a newer version: 10.20.0.29356
Show newest version
/*
 * SonarQube JavaScript Plugin
 * Copyright (C) 2011-2024 SonarSource SA
 * mailto:info AT sonarsource DOT com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package org.sonar.javascript.checks;

import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.List;
import org.sonar.plugins.javascript.api.JavaScriptCheck;
import org.sonar.plugins.javascript.api.JavaScriptRule;
import org.sonar.plugins.javascript.api.TypeScriptRule;

public final class CheckList {

  public static final String JS_REPOSITORY_KEY = "javascript";
  public static final String TS_REPOSITORY_KEY = "typescript";

  public static final String REPOSITORY_NAME = "SonarAnalyzer";

  private CheckList() {}

  public static List> getTypeScriptChecks() {
    return filterChecksByAnnotation(TypeScriptRule.class);
  }

  public static List> getJavaScriptChecks() {
    return filterChecksByAnnotation(JavaScriptRule.class);
  }

  private static List> filterChecksByAnnotation(
    Class annotation
  ) {
    List> allChecks = getAllChecks();
    return allChecks.stream().filter(c -> c.isAnnotationPresent(annotation)).toList();
  }

  public static List> getAllChecks() {
    return Arrays.asList(
      AdjacentOverloadSignaturesCheck.class,
      AlertUseCheck.class,
      AlphabeticalSortCheck.class,
      AltTextCheck.class,
      AlwaysUseCurlyBracesCheck.class,
      AnchorHasContentCheck.class,
      AnchorIsValidCheck.class,
      AnchorPrecedenceCheck.class,
      AngleBracketTypeAssertionCheck.class,
      ArgumentTypesCheck.class,
      ArgumentsCallerCalleeUsageCheck.class,
      ArgumentsUsageCheck.class,
      AriaActivedescendantHasTabindexCheck.class,
      AriaProptypesCheck.class,
      AriaRoleCheck.class,
      AriaUnsupportedElementsCheck.class,
      ArithmeticOperationReturningNanCheck.class,
      ArrayCallbackWithoutReturnCheck.class,
      ArrayConstructorsCheck.class,
      ArrowFunctionConventionCheck.class,
      AssertionsInTestsCheck.class,
      AssociativeArraysCheck.class,
      AutocompleteValidCheck.class,
      AwsApigatewayPublicApiCheck.class,
      AwsEc2RdsDmsPublicCheck.class,
      AwsEc2UnencryptedEbsVolumeCheck.class,
      AwsEfsUnencryptedCheck.class,
      AwsIamAllPrivilegesCheck.class,
      AwsIamAllResourcesAccessibleCheck.class,
      AwsIamPrivilegeEscalationCheck.class,
      AwsIamPublicAccessCheck.class,
      AwsOpenSearchServiceDomainCheck.class,
      AwsRdsUnencryptedDatabasesCheck.class,
      AwsRestrictedIpAdminAccessCheck.class,
      AwsS3BucketGrantedAccessCheck.class,
      AwsS3BucketInsecureHttpCheck.class,
      AwsS3BucketPublicAccessCheck.class,
      AwsS3BucketServerEncryptionCheck.class,
      AwsS3BucketVersioningCheck.class,
      AwsSagemakerUnencryptedNotebookCheck.class,
      AwsSnsUnencryptedTopicsCheck.class,
      AwsSqsUnencryptedQueueCheck.class,
      BitwiseOperatorsCheck.class,
      BoolParamDefaultCheck.class,
      BooleanEqualityComparisonCheck.class,
      BuiltInObjectOverriddenCheck.class,
      CertificateTransparencyCheck.class,
      ChaiDeterminateAssertionCheck.class,
      ClassNameCheck.class,
      ClassPrototypeCheck.class,
      CognitiveComplexityFunctionCheck.class,
      CollapsibleIfStatementsCheck.class,
      CollectionSizeComparisonCheck.class,
      CommaOperatorInSwitchCaseCheck.class,
      CommaOperatorUseCheck.class,
      CommentRegularExpressionCheck.class,
      CommentedCodeCheck.class,
      ComparisonWithNaNCheck.class,
      ConciseRegexCheck.class,
      ConditionalIndentationCheck.class,
      ConditionalOperatorCheck.class,
      ConfidentialInformationLoggingCheck.class,
      ConsistentReturnsCheck.class,
      ConsoleLoggingCheck.class,
      ConstructorFunctionsForSideEffectsCheck.class,
      ContentLengthCheck.class,
      ContentSecurityPolicyCheck.class,
      ContinueStatementCheck.class,
      CookieNoHttpOnlyCheck.class,
      CookiesCheck.class,
      CorsCheck.class,
      CounterUpdatedInLoopCheck.class,
      CsrfCheck.class,
      CyclomaticComplexityJavaScriptCheck.class,
      CyclomaticComplexityTypeScriptCheck.class,
      DeadStoreCheck.class,
      DebuggerStatementCheck.class,
      DeclarationInGlobalScopeCheck.class,
      DefaultParametersNotLastCheck.class,
      DefaultPropsMatchPropTypesCheck.class,
      DeleteNonPropertyCheck.class,
      DeprecationCheck.class,
      DestructuringAssignmentSyntaxCheck.class,
      DifferentTypesComparisonCheck.class,
      DisabledAutoEscapingCheck.class,
      DisabledResourceIntegrityCheck.class,
      DisabledTimeoutCheck.class,
      DnsPrefetchingCheck.class,
      DuplicateAllBranchImplementationCheck.class,
      DuplicateBranchImplementationCheck.class,
      DuplicateConditionIfCheck.class,
      DuplicateFunctionArgumentCheck.class,
      DuplicatePropertyNameCheck.class,
      DuplicatesInCharacterClassCheck.class,
      ElseIfWithoutElseCheck.class,
      EmptyBlockCheck.class,
      EmptyCharacterClassesCheck.class,
      EmptyDestructuringPatternCheck.class,
      EmptyFunctionCheck.class,
      EmptyStatementCheck.class,
      EmptyStringRepetitionCheck.class,
      EncryptionCheck.class,
      EncryptionSecureModeCheck.class,
      EqEqEqCheck.class,
      EqualInForLoopTerminationCheck.class,
      ErrorWithoutThrowCheck.class,
      EvalCheck.class,
      ExistingGroupsCheck.class,
      ExpressionComplexityCheck.class,
      FileHeaderCheck.class,
      FileNameDiffersFromClassCheck.class,
      FilePermissionsCheck.class,
      FileUploadsCheck.class,
      FixmeTagPresenceCheck.class,
      ForHidingWhileCheck.class,
      ForInCheck.class,
      ForLoopConditionAndUpdateCheck.class,
      ForLoopIncrementSignCheck.class,
      FrameAncestorsCheck.class,
      FunctionCallArgumentsOnNewLineCheck.class,
      FunctionConstructorCheck.class,
      FunctionDeclarationsWithinBlocksCheck.class,
      FunctionDefinitionInsideLoopCheck.class,
      FunctionNameCheck.class,
      FunctionReturnTypeCheck.class,
      FutureReservedWordsCheck.class,
      GeneratorWithoutYieldCheck.class,
      GetterSetterCheck.class,
      GlobalThisCheck.class,
      GlobalsShadowingCheck.class,
      GratuitousConditionCheck.class,
      HardcodedCredentialsCheck.class,
      HashingCheck.class,
      HeadingHasContentCheck.class,
      HiddenFilesCheck.class,
      HookUseStateCheck.class,
      HtmlHasLangCheck.class,
      IdenticalExpressionOnBinaryOperatorCheck.class,
      IdenticalFunctionsCheck.class,
      IframeHasTitleCheck.class,
      IgnoredReturnCheck.class,
      ImgRedundantAltCheck.class,
      ImmediatelyReturnedVariableCheck.class,
      ImplicitDependenciesCheck.class,
      InOperatorTypeErrorCheck.class,
      InconsistentFunctionCallCheck.class,
      IncrementDecrementInSubExpressionCheck.class,
      IndexOfCompareToPositiveNumberCheck.class,
      InsecureCookieCheck.class,
      InsecureJwtTokenCheck.class,
      InstanceofInMisuseCheck.class,
      InteractiveElementsShouldBeFocusableCheck.class,
      IntrusivePermissionsCheck.class,
      InvariantReturnCheck.class,
      InvertedAssertionArgumentsCheck.class,
      IpForwardCheck.class,
      JsxChildElementSpacingCheck.class,
      JsxKeyCheck.class,
      JsxNoBindCheck.class,
      JsxNoCommentTextnodesCheck.class,
      JsxNoConstructedContextValuesCheck.class,
      JsxNoLeakedRenderCheck.class,
      JsxNoUselessFragmentCheck.class,
      JsxPascalCaseCheck.class,
      JumpStatementInFinallyCheck.class,
      LabelHasAssociatedControlCheck.class,
      LabelPlacementCheck.class,
      LabelledStatementCheck.class,
      LineLengthCheck.class,
      LinkWithTargetBlankCheck.class,
      LoopsShouldNotBeInfiniteCheck.class,
      MaxParameterCheck.class,
      MaxSwitchCasesCheck.class,
      MaxUnionSizeCheck.class,
      MediaHasCaptionCheck.class,
      MisorderedParameterListCheck.class,
      MissingNewlineAtEndOfFileCheck.class,
      MissingTrailingCommaCheck.class,
      MouseEventsA11YCheck.class,
      MultilineBlockCurlyBraceCheck.class,
      MultilineStringLiteralsCheck.class,
      NestedAssignmentCheck.class,
      NestedConditionalOperatorsCheck.class,
      NestedControlFlowDepthCheck.class,
      NewCapCheck.class,
      NewOperatorMisuseCheck.class,
      NoAbsolutePathCheck.class,
      NoAccessKeyCheck.class,
      NoAccessStateInSetstateCheck.class,
      NoAccessorFieldMismatchCheck.class,
      NoAngularBypassSanitizationCheck.class,
      NoAnyCheck.class,
      NoAriaHiddenOnFocusableCheck.class,
      NoArrayDeleteCheck.class,
      NoArrayIndexKeyCheck.class,
      NoBaseToStringCheck.class,
      NoCaseDeclarationsCheck.class,
      NoChildrenPropCheck.class,
      NoClearTextProtocolsCheck.class,
      NoCodeAfterDoneCheck.class,
      NoConfusingNonNullAssertionCheck.class,
      NoConstantBinaryExpressionCheck.class,
      NoConstructorReturnCheck.class,
      NoControlRegexCheck.class,
      NoDangerWithChildrenCheck.class,
      NoDeprecatedReactCheck.class,
      NoDirectMutationStateCheck.class,
      NoDuplicateEnumValuesCheck.class,
      NoDuplicateImportsCheck.class,
      NoDuplicateInCompositeCheck.class,
      NoDuplicateStringCheck.class,
      NoElementOverwriteCheck.class,
      NoEmptyAfterReluctantCheck.class,
      NoEmptyAlternativesCheck.class,
      NoEmptyClassCheck.class,
      NoEmptyCollectionCheck.class,
      NoEmptyGroupCheck.class,
      NoEmptyInterfaceCheck.class,
      NoEmptyTestFileCheck.class,
      NoExclusiveTestsCheck.class,
      NoExtendNativeCheck.class,
      NoExtraBindCheck.class,
      NoExtraBooleanCastCheck.class,
      NoFindDomNodeCheck.class,
      NoForInArrayCheck.class,
      NoHardcodedIpCheck.class,
      NoHookSetterInBodyCheck.class,
      NoIgnoredExceptionsCheck.class,
      NoImportAssignCheck.class,
      NoInMisuseCheck.class,
      NoIncompleteAssertionsCheck.class,
      NoInferrableTypesCheck.class,
      NoInteractiveElementToNoninteractiveRoleCheck.class,
      NoInvalidAwaitCheck.class,
      NoInvertedBooleanCheckCheck.class,
      NoIsMountedCheck.class,
      NoLiteralCallCheck.class,
      NoLoneBlocksCheck.class,
      NoLonelyIfCheck.class,
      NoLossOfPrecisionCheck.class,
      NoMagicNumbersCheck.class,
      NoMimeSniffCheck.class,
      NoMisleadingArrayReverseCheck.class,
      NoMisusedNewCheck.class,
      NoMisusedPromisesCheck.class,
      NoMixedContentCheck.class,
      NoMixedEnumsCheck.class,
      NoMutableExportsCheck.class,
      NoNestedFunctionsCheck.class,
      NoNestedSwitchCheck.class,
      NoNestedTemplateLiteralsCheck.class,
      NoNewNativeNonconstructorCheck.class,
      NoNonInteractiveElementsWithHandlersCheck.class,
      NoNonNullAssertionCheck.class,
      NoNoninteractiveElementToInteractiveRoleCheck.class,
      NoNoninteractiveTabindexCheck.class,
      NoOctalEscapeCheck.class,
      NoOneIterationLoopCheck.class,
      NoOsCommandsFromPathCheck.class,
      NoProtoCheck.class,
      NoRedundantJumpCheck.class,
      NoRedundantOptionalCheck.class,
      NoRedundantRolesCheck.class,
      NoRedundantShouldComponentUpdateCheck.class,
      NoRedundantTypeConstituentsCheck.class,
      NoReferrerPolicyCheck.class,
      NoRegexSpacesCheck.class,
      NoRenderReturnValueCheck.class,
      NoReturnAwaitCheck.class,
      NoReturnTypeAnyCheck.class,
      NoSameArgumentAssertCheck.class,
      NoSelfCompareCheck.class,
      NoSparseArraysCheck.class,
      NoStaticElementInteractionsCheck.class,
      NoStringRefsCheck.class,
      NoThisAliasCheck.class,
      NoThisInSfcCheck.class,
      NoUndefInitCheck.class,
      NoUnescapedEntitiesCheck.class,
      NoUniqKeyCheck.class,
      NoUnknownPropertyCheck.class,
      NoUnnecessaryTypeAssertionCheck.class,
      NoUnnecessaryTypeConstraintCheck.class,
      NoUnneededTernaryCheck.class,
      NoUnsafeCheck.class,
      NoUnsafeOptionalChainingCheck.class,
      NoUnstableNestedComponentsCheck.class,
      NoUnusedClassComponentMethodsCheck.class,
      NoUnusedPrivateClassMembersCheck.class,
      NoUnusedPropTypesCheck.class,
      NoUselessCallCheck.class,
      NoUselessCatchCheck.class,
      NoUselessConstructorCheck.class,
      NoUselessReactSetstateCheck.class,
      NoUselessRenameCheck.class,
      NoVueBypassSanitizationCheck.class,
      NoWeakCipherCheck.class,
      NoWeakKeysCheck.class,
      NonCaseLabelInSwitchCheck.class,
      NonEmptyCaseWithoutBreakCheck.class,
      NonExistentAssignmentOperatorCheck.class,
      NonNumberInArithmeticExpressionCheck.class,
      NonStandardImportCheck.class,
      NullDereferenceCheck.class,
      OSCommandCheck.class,
      ObjectLiteralShorthandCheck.class,
      OctalNumberCheck.class,
      OneStatementPerLineCheck.class,
      OpenCurlyBracesAtEOLCheck.class,
      ParenthesesCheck.class,
      ParseIntCallWithoutBaseCheck.class,
      ParsingErrorCheck.class,
      PostMessageCheck.class,
      PreferAsConstCheck.class,
      PreferDefaultLastCheck.class,
      PreferEnumInitializersCheck.class,
      PreferForOfCheck.class,
      PreferFunctionTypeCheck.class,
      PreferLiteralEnumMemberCheck.class,
      PreferNamespaceCheck.class,
      PreferNullishCoalescingCheck.class,
      PreferObjectHasOwnCheck.class,
      PreferObjectLiteralCheck.class,
      PreferObjectSpreadCheck.class,
      PreferPromiseRejectErrorsCheck.class,
      PreferPromiseShorthandCheck.class,
      PreferReadOnlyPropsCheck.class,
      PreferReadonlyCheck.class,
      PreferRegexLiteralsCheck.class,
      PreferRegexpExecCheck.class,
      PreferReturnThisTypeCheck.class,
      PreferSpreadCheck.class,
      PreferStringStartsEndsWithCheck.class,
      PreferTagOverRoleCheck.class,
      PreferTypeGuardCheck.class,
      PrimitiveWrappersCheck.class,
      ProcessArgvCheck.class,
      ProductionDebugCheck.class,
      PropTypesCheck.class,
      PseudoRandomCheck.class,
      PublicStaticReadonlyCheck.class,
      PubliclyWritableDirectoriesCheck.class,
      ReassignedParameterCheck.class,
      RedeclaredSymbolCheck.class,
      ReduceInitialValueCheck.class,
      RedundantAssignmentCheck.class,
      RedundantTypeAliasesCheck.class,
      ReferenceErrorCheck.class,
      RegexComplexityCheck.class,
      RegularExprCheck.class,
      RequireRenderReturnCheck.class,
      ReturnInSetterCheck.class,
      ReturnOfBooleanExpressionCheck.class,
      RoleHasRequiredAriaPropsCheck.class,
      RoleSupportsAriaPropsCheck.class,
      RulesOfHooksCheck.class,
      SameLineConditionalCheck.class,
      SelfAssignmentCheck.class,
      SemicolonCheck.class,
      SessionRegenerationCheck.class,
      ShorthandPropertiesNotGroupedCheck.class,
      SingleCharInCharacterClassesCheck.class,
      SingleCharacterAlternativeCheck.class,
      SlowRegexCheck.class,
      SocketsCheck.class,
      SonarNoInvalidRegexCheck.class,
      SonarNoMisleadingCharacterClassCheck.class,
      SonarPreferOptionalChainCheck.class,
      SqlQueriesCheck.class,
      StableTestsCheck.class,
      StandardInputCheck.class,
      StatefulRegexCheck.class,
      StrictModeCheck.class,
      StrictTransportSecurityCheck.class,
      StringConcatenatedWithNonStringCheck.class,
      StringConcatenationCheck.class,
      StringLiteralsQuotesCheck.class,
      StringsComparisonCheck.class,
      SuperInvocationCheck.class,
      SwitchWithNotEnoughCaseCheck.class,
      SwitchWithoutDefaultCheck.class,
      TabCharacterCheck.class,
      TabindexNoPositiveCheck.class,
      TemplateStringMisuseCheck.class,
      TestCheckExceptionCheck.class,
      ThrowLiteralCheck.class,
      TodoTagPresenceCheck.class,
      TooManyArgumentsCheck.class,
      TooManyBreakOrContinueInLoopCheck.class,
      TooManyLinesInFileCheck.class,
      TooManyLinesInFunctionCheck.class,
      TrailingCommaCheck.class,
      TrailingCommentCheck.class,
      TrailingWhitespaceCheck.class,
      TryPromiseCheck.class,
      UnchangedLetVariableCheck.class,
      UndefinedArgumentCheck.class,
      UndefinedAssignmentCheck.class,
      UnicodeAwareRegexCheck.class,
      UnnecessaryCharacterEscapesCheck.class,
      UnnecessaryTypeArgumentsCheck.class,
      UnreachableCodeCheck.class,
      UnsafeUnzipCheck.class,
      UnusedCollectionCheck.class,
      UnusedFunctionArgumentCheck.class,
      UnusedImportCheck.class,
      UnusedNamedGroupsCheck.class,
      UnusedVariableCheck.class,
      UnverifiedCertificateCheck.class,
      UnverifiedHostnameCheck.class,
      UpdatedConstVariableCheck.class,
      UseOfEmptyReturnValueCheck.class,
      UseTypeAliasCheck.class,
      UselessExpressionStatementCheck.class,
      UselessIncrementCheck.class,
      UselessIntersectionCheck.class,
      UselessStringOperationCheck.class,
      ValidTypeOfCheck.class,
      ValuesNotConvertibleToNumbersCheck.class,
      VarDeclarationCheck.class,
      VariableDeclarationAfterUsageCheck.class,
      VariableDeclarationWithoutVarCheck.class,
      VariableNameCheck.class,
      VariableShadowingCheck.class,
      VoidUseCheck.class,
      WeakSslCheck.class,
      WebSQLDatabaseCheck.class,
      WildcardImportCheck.class,
      WithStatementCheck.class,
      WrongScopeDeclarationCheck.class,
      XMLParserXXEVulnerableCheck.class,
      XPoweredByCheck.class,
      XpathCheck.class
    );
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy