Package org.sonar.javascript.checks
Class AbstractAnyPathSeCheck
- java.lang.Object
-
- org.sonar.javascript.se.SeCheck
-
- org.sonar.javascript.checks.AbstractAnyPathSeCheck
-
- All Implemented Interfaces:
JavaScriptCheck
- Direct Known Subclasses:
ArrayCallbackWithoutReturnCheck,ArrayMutatingOperationCheck,CallabilityCheck,InOperatorTypeErrorCheck,NonExistentPropertyAccessCheck,NonNumberInArithmeticExpressionCheck,ReturnValueNotIgnoredCheck,ValuesNotConvertibleToNumbersCheck
public abstract class AbstractAnyPathSeCheck extends SeCheck
Base class for check classes which must ensure that the same issue is never raised more than once for the same tree.
-
-
Constructor Summary
Constructors Constructor Description AbstractAnyPathSeCheck()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PreciseIssueaddIssue(Tree tree, String message)Subclasses should not use this function, as this function bypasses the non-duplication mechanism implemented by this class.<T extends Issue>
TaddIssue(T issue)Optional<PreciseIssue>addUniqueIssue(Tree tree, String message)Creates an issue for the specified tree and message, then adds the issue to the list of issues.Optional<PreciseIssue>addUniqueIssue(Tree tree, String message, Tree... secondaryLocations)Same contract as methodaddIssue(Tree, String).Optional<PreciseIssue>addUniqueIssue(Tree tree, String message, IssueLocation... secondaryLocations)Same contract as methodaddIssue(Tree, String).booleanalreadyHasIssueOn(Tree tree)Returnstrueif an issue has already been reported for the specified tree.voiddoStartOfExecution(Scope functionScope)Override this method to perform actions before the start of execution.voidstartOfExecution(Scope functionScope)-
Methods inherited from class org.sonar.javascript.se.SeCheck
addLineIssue, afterBlockElement, beforeBlockElement, checkConditions, cleanupAndStartFileAnalysis, endOfExecution, endOfFile, getContext, scanFile, setContext, startOfFile, toString
-
-
-
-
Method Detail
-
startOfExecution
public final void startOfExecution(Scope functionScope)
- Overrides:
startOfExecutionin classSeCheck
-
doStartOfExecution
public void doStartOfExecution(Scope functionScope)
Override this method to perform actions before the start of execution. This method is called for each execution, i.e. for each function in the file. Note this method is called even if the execution limit was reached later.- Parameters:
functionScope- scope corresponding to the function which will be executed
-
addIssue
public final PreciseIssue addIssue(Tree tree, String message)
Subclasses should not use this function, as this function bypasses the non-duplication mechanism implemented by this class. They should use one of theaddUniqueIssue(org.sonar.plugins.javascript.api.tree.Tree, java.lang.String)methods.- Specified by:
addIssuein interfaceJavaScriptCheck- Overrides:
addIssuein classSeCheck
-
addIssue
public final <T extends Issue> T addIssue(T issue)
- Specified by:
addIssuein interfaceJavaScriptCheck- Overrides:
addIssuein classSeCheck
-
addUniqueIssue
public Optional<PreciseIssue> addUniqueIssue(Tree tree, String message)
Creates an issue for the specified tree and message, then adds the issue to the list of issues. Does nothing if an issue has already been added for the specified tree.- Returns:
- the created issue, or nothing if no issue was created
-
addUniqueIssue
public Optional<PreciseIssue> addUniqueIssue(Tree tree, String message, Tree... secondaryLocations)
Same contract as methodaddIssue(Tree, String).
-
addUniqueIssue
public Optional<PreciseIssue> addUniqueIssue(Tree tree, String message, IssueLocation... secondaryLocations)
Same contract as methodaddIssue(Tree, String).
-
alreadyHasIssueOn
public boolean alreadyHasIssueOn(Tree tree)
Returnstrueif an issue has already been reported for the specified tree. This method does not have to be invoked prior to invoking methodaddUniqueIssue(org.sonar.plugins.javascript.api.tree.Tree, java.lang.String): this method is just an optimization tool that allows subclasses not to perform useless operations when an issue has already been reported.
-
-