Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class SpotBugsXmlReportReader {
private final ExternalRuleLoader defaultRuleLoader;
private final Map<String, ExternalRuleLoader> otherLoaders;

private List<String> sourceDirs = new ArrayList<>();
private final List<String> sourceDirs = new ArrayList<>();
private String bugInstanceType = "";
private String bugInstanceLongMessage = "";
private String sourceLinePath = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private static boolean isPassedAsArgument(IdentifierTree identifier) {

private static class CallChainVisitor extends BaseTreeVisitor {
protected boolean methodIsInvoked;
private MethodMatchers target;
private final MethodMatchers target;

CallChainVisitor(MethodMatchers matcher) {
this.target = matcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ private static boolean isStrictAssignmentOrDeclaration(ExpressionTree expression

public static class ValueResolution<T> {
private T value;
private List<JavaFileScannerContext.Location> valuePath = new ArrayList<>();
private Set<Symbol> evaluatedSymbols = new HashSet<>();
private final List<JavaFileScannerContext.Location> valuePath = new ArrayList<>();
private final Set<Symbol> evaluatedSymbols = new HashSet<>();
private final String locationMessage;

public ValueResolution() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ enum IssueAttribute {
FLOWS(multiValueAttribute(Function.identity())),
QUICK_FIXES(multiValueAttribute(Function.identity()));

private Function<String, ?> setter;
private final Function<String, ?> setter;
private Function<Object, Object> getter = Function.identity();

IssueAttribute(Function<String, ?> setter) {
Expand Down Expand Up @@ -247,7 +247,7 @@ private static int getColumnOffset(@Nullable Object o, String position, int line
private boolean collectQuickFixes = false;
private final Map<AnalyzerMessage.TextSpan, List<JavaQuickFix>> quickFixes = new HashMap<>();

private Set<String> seenFlowIds = new HashSet<>();
private final Set<String> seenFlowIds = new HashSet<>();

Expectations() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import java.util.Objects;

public class InternalCacheContext implements CacheContext {
private boolean isEnabled;
private JavaReadCache readCache;
private JavaWriteCache writeCache;
private final boolean isEnabled;
private final JavaReadCache readCache;
private final JavaWriteCache writeCache;

public InternalCacheContext(boolean isEnabled, @Nullable JavaReadCache readCache, @Nullable JavaWriteCache writeCache) {
this.isEnabled = isEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class InternalCheckVerifier implements CheckVerifier {
private Consumer<Set<AnalyzerMessage>> customIssueVerifier = null;
private boolean collectQuickFixes = false;

private Expectations expectations = new Expectations();
private final Expectations expectations = new Expectations();
@VisibleForTesting
CacheContext cacheContext = null;
private ReadCache readCache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public static JavaCheckVerifier newInstance() {

private List<JavaFileScanner> checks = null;
private List<File> classpath = null;
private List<String> jarsToAdd = new ArrayList<>();
private List<String> jarsToRemove = new ArrayList<>();
private final List<String> jarsToAdd = new ArrayList<>();
private final List<String> jarsToRemove = new ArrayList<>();
@VisibleForTesting
List<File> actualClasspath = null;
private JavaVersion javaVersion = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.util.List;

public abstract class AbstractInSynchronizeChecker extends AbstractMethodDetection {
private Deque<Boolean> withinSynchronizedBlock = new LinkedList<>();
private final Deque<Boolean> withinSynchronizedBlock = new LinkedList<>();

@Override
public void setContext(JavaFileScannerContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class AccessibilityChangeOnRecordsCheck extends AbstractAccessibilityChan
private static final String MESSAGE = "Remove this private field update which will never succeed";
private static final String SECONDARY_MESSAGE = "Remove this accessibility bypass which will never succeed";

private Map<Symbol, MethodInvocationTree> primaryTargets = new HashMap<>();
private Map<Symbol, List<MethodInvocationTree>> secondaryTargets = new HashMap<>();
private final Map<Symbol, MethodInvocationTree> primaryTargets = new HashMap<>();
private final Map<Symbol, List<MethodInvocationTree>> secondaryTargets = new HashMap<>();

@Override
public List<Tree.Kind> nodesToVisit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private static boolean isVarTypeErrorProne(Type varType) {
}

private class ReturnStatementVisitor extends BaseTreeVisitor {
private Type returnType;
private final Type returnType;

public ReturnStatementVisitor(Type returnType) {
this.returnType = returnType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@Rule(key = "S1104")
public class ClassVariableVisibilityCheck extends BaseTreeVisitor implements JavaFileScanner {

private Deque<Boolean> isClassStack = new ArrayDeque<>();
private final Deque<Boolean> isClassStack = new ArrayDeque<>();

private JavaFileScannerContext context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public class CollapsibleIfCandidateCheck extends BaseTreeVisitor implements JavaFileScanner {

private JavaFileScannerContext context;
private Deque<IfStatementTree> outerIf = new ArrayDeque<>();
private final Deque<IfStatementTree> outerIf = new ArrayDeque<>();

@Override
public void scanFile(JavaFileScannerContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private static class TypeChecker {
private final String methodOwnerType;
private final MethodMatchers methodMatcher;
private final int argumentIndex;
private boolean argumentIsACollection;
private final boolean argumentIsACollection;
private final int parametrizedTypeIndex;

private TypeChecker(String methodOwnerType, MethodMatchers methodMatcher, int argumentIndex, boolean argumentIsACollection, int parametrizedTypeIndex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void visitNode(Tree tree) {

private class ConstructorBodyVisitor extends BaseTreeVisitor {

private Symbol.TypeSymbol constructorType;
private final Symbol.TypeSymbol constructorType;

public ConstructorBodyVisitor(Symbol.TypeSymbol constructorType) {
this.constructorType = constructorType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
public class DiamondOperatorCheck extends SubscriptionVisitor implements JavaVersionAwareVisitor {

/** Nodes to check in Java 7. */
private static final Tree.Kind[] JAVA_7_KINDS = new Tree.Kind[] {
private static final Tree.Kind[] JAVA_7_KINDS = {
Tree.Kind.VARIABLE,
Tree.Kind.TYPE_CAST,
Tree.Kind.RETURN_STATEMENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public List<Kind> nodesToVisit() {
return Arrays.asList(Tree.Kind.LOGICAL_COMPLEMENT, Tree.Kind.BITWISE_COMPLEMENT, Tree.Kind.UNARY_PLUS, Tree.Kind.UNARY_MINUS);
}

private Set<ExpressionTree> prefixSet = new HashSet<>();
private final Set<ExpressionTree> prefixSet = new HashSet<>();

@Override
public void setContext(JavaFileScannerContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@Rule(key = "S1849")
public class HasNextCallingNextCheck extends IssuableSubscriptionVisitor {

private HasNextBodyVisitor hasNextBodyVisitor = new HasNextBodyVisitor();
private final HasNextBodyVisitor hasNextBodyVisitor = new HasNextBodyVisitor();

@Override
public List<Kind> nodesToVisit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
public class InnerStaticClassesCheck extends BaseTreeVisitor implements JavaFileScanner {

private JavaFileScannerContext context;
private Deque<Symbol> outerClasses = new LinkedList<>();
private Deque<Boolean> atLeastOneReference = new LinkedList<>();
private final Deque<Symbol> outerClasses = new LinkedList<>();
private final Deque<Boolean> atLeastOneReference = new LinkedList<>();

@Override
public void scanFile(final JavaFileScannerContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void visitNode(Tree tree) {
}

private static class ReturnThis extends BaseTreeVisitor {
private List<Tree> issueLocations = new ArrayList<>();
private final List<Tree> issueLocations = new ArrayList<>();

@Override
public void visitClass(ClassTree tree) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static String[] testMethodNames(String[] lowerCaseNames) {
}

private JavaFileScannerContext context;
private Deque<Tree> treeStack = new ArrayDeque<>();
private final Deque<Tree> treeStack = new ArrayDeque<>();
private boolean foundReturnStatementInsideLevelTest = false;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@Rule(key = "S2234")
public class MethodParametersOrderCheck extends IssuableSubscriptionVisitor {

private Map<Symbol, ParametersList> parametersByMethod = new HashMap<>();
private final Map<Symbol, ParametersList> parametersByMethod = new HashMap<>();

@Override
public List<Tree.Kind> nodesToVisit() {
Expand Down Expand Up @@ -124,9 +124,9 @@ private static List<VariableTree> matchingTypesWrongOrder(ParametersList formalP

private static class ParametersList {

private List<String> parameterNames;
private List<Type> parameterTypes;
private List<VariableTree> parameters;
private final List<String> parameterNames;
private final List<Type> parameterTypes;
private final List<VariableTree> parameters;

public ParametersList(MethodTree methodTree) {
parameterNames = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@DeprecatedRuleKey(ruleKey = "ModifiersOrderCheck", repositoryKey = "squid")
@Rule(key = "S1124")
public class ModifiersOrderCheck extends IssuableSubscriptionVisitor {
private Set<Tree> alreadyReported = new HashSet<>();
private final Set<Tree> alreadyReported = new HashSet<>();

@Override
public void setContext(JavaFileScannerContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@Rule(key = "S2197")
public class ModulusEqualityCheck extends IssuableSubscriptionVisitor {

private Set<Symbol> methodParams = new HashSet<>();
private final Set<Symbol> methodParams = new HashSet<>();

@Override
public void leaveFile(JavaFileScannerContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class NestedTryCatchCheck extends BaseTreeVisitor implements JavaFileScanner {

private JavaFileScannerContext context;
private Deque<Deque<Tree>> nestingLevel = new ArrayDeque<>();
private final Deque<Deque<Tree>> nestingLevel = new ArrayDeque<>();

@Override
public void scanFile(JavaFileScannerContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class OperatorPrecedenceCheck extends BaseTreeVisitor implements JavaFile
Tree.Kind.UNSIGNED_RIGHT_SHIFT
);

private static final Tree.Kind[] CONDITIONAL_EXCLUSIONS = new Tree.Kind[]{
private static final Tree.Kind[] CONDITIONAL_EXCLUSIONS = {
Tree.Kind.METHOD_INVOCATION, Tree.Kind.IDENTIFIER, Tree.Kind.MEMBER_SELECT,
Tree.Kind.PARENTHESIZED_EXPRESSION, Tree.Kind.TYPE_CAST, Tree.Kind.NEW_CLASS,
Tree.Kind.ARRAY_ACCESS_EXPRESSION, Tree.Kind.NEW_ARRAY, Tree.Kind.METHOD_REFERENCE
Expand All @@ -90,8 +90,8 @@ public class OperatorPrecedenceCheck extends BaseTreeVisitor implements JavaFile
}

private JavaFileScannerContext context;
private Deque<Tree.Kind> stack = new LinkedList<>();
private Set<Integer> reportedLines = new HashSet<>();
private final Deque<Tree.Kind> stack = new LinkedList<>();
private final Set<Integer> reportedLines = new HashSet<>();

private static void put(Iterable<Tree.Kind> firstSet, Iterable<Tree.Kind> secondSet) {
for (Tree.Kind first : firstSet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private static class CollectionAndKey {
private final Tree keyTree;
private final Object key;
private final boolean isArray;
private ExpressionTree rhs;
private final ExpressionTree rhs;

private CollectionAndKey(Symbol collection, Tree keyTree, Object key, boolean isArray, @Nullable ExpressionTree expression) {
this.collection = collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private static Set<Type> thrownExceptionsFromBody(MethodTree methodTree) {
}

private static class ThrownExceptionVisitor extends BaseTreeVisitor {
private Set<Type> thrownExceptions = new HashSet<>();
private final Set<Type> thrownExceptions = new HashSet<>();
private boolean visitedUnknown = false;
private boolean visitedOtherConstructor = false;
private final MethodTree methodTree;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@Rule(key = "S2183")
public class ShiftOnIntOrLongCheck extends IssuableSubscriptionVisitor {

private List<Tree> shiftTrees = new ArrayList<>();
private final List<Tree> shiftTrees = new ArrayList<>();

@Override
public List<Kind> nodesToVisit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
@Rule(key = "S2444")
public class StaticFieldInitializationCheck extends AbstractInSynchronizeChecker {

private Deque<Boolean> classWithSynchronizedMethod = new LinkedList<>();
private Deque<Boolean> withinStaticInitializer = new LinkedList<>();
private Deque<Boolean> methodUsesLocks = new LinkedList<>();
private MethodMatchers locks = MethodMatchers.create()
private final Deque<Boolean> classWithSynchronizedMethod = new LinkedList<>();
private final Deque<Boolean> withinStaticInitializer = new LinkedList<>();
private final Deque<Boolean> methodUsesLocks = new LinkedList<>();
private final MethodMatchers locks = MethodMatchers.create()
.ofTypes("java.util.concurrent.locks.Lock")
.names("lock", "tryLock")
.addWithoutParametersMatcher()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
@Rule(key = "S2696")
public class StaticFieldUpateCheck extends AbstractInSynchronizeChecker {

private static final Kind[] UNARY_EXPRESSIONS = new Kind[]{
private static final Kind[] UNARY_EXPRESSIONS = {
Kind.POSTFIX_DECREMENT,
Kind.POSTFIX_INCREMENT,
Kind.PREFIX_DECREMENT,
Kind.PREFIX_INCREMENT};

private Deque<Boolean> withinStaticMethod = new LinkedList<>();
private final Deque<Boolean> withinStaticMethod = new LinkedList<>();

@Override
public List<Kind> nodesToVisit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class StaticMethodCheck extends BaseTreeVisitor implements JavaFileScanne
};

private JavaFileScannerContext context;
private Deque<MethodReference> methodReferences = new LinkedList<>();
private final Deque<MethodReference> methodReferences = new LinkedList<>();

@Override
public void scanFile(JavaFileScannerContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
public class StringConcatenationInLoopCheck extends BaseTreeVisitor implements JavaFileScanner {

private JavaFileScannerContext context;
private Deque<Tree> loopLevel = new LinkedList<>();
private final Deque<Tree> loopLevel = new LinkedList<>();

@Override
public void scanFile(JavaFileScannerContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@Rule(key = "S1191")
public class SunPackagesUsedCheck extends BaseTreeVisitor implements JavaFileScanner {

private List<Tree> reportedTrees = new ArrayList<>();
private final List<Tree> reportedTrees = new ArrayList<>();

private static final String DEFAULT_EXCLUDE = "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private static boolean isMethodFromJavaPackage(String fqn) {

private class DeprecatedTypeVisitor extends BaseTreeVisitor {

private Deque<Set<String>> overridingMethodTypes = new ArrayDeque<>();
private final Deque<Set<String>> overridingMethodTypes = new ArrayDeque<>();

@Override
public void visitClass(ClassTree tree) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void visitNode(Tree tree) {
}

private class ConstructorBodyVisitor extends BaseTreeVisitor {
private Symbol owner;
private final Symbol owner;

public ConstructorBodyVisitor(Symbol owner) {
this.owner = owner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@Rule(key = "S1162")
public class ThrowCheckedExceptionCheck extends IssuableSubscriptionVisitor {

private Deque<MethodTree> methods = new LinkedList<>();
private final Deque<MethodTree> methods = new LinkedList<>();

@Override
public List<Tree.Kind> nodesToVisit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@Rule(key = "S1158")
public class ToStringUsingBoxingCheck extends IssuableSubscriptionVisitor {

private static final String[] PRIMITIVE_WRAPPERS = new String[]{
private static final String[] PRIMITIVE_WRAPPERS = {
"java.lang.Byte",
"java.lang.Character",
"java.lang.Short",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@Rule(key = "S2274")
public class WaitInWhileLoopCheck extends AbstractMethodDetection {

private Deque<Boolean> inWhileLoop = new LinkedList<>();
private final Deque<Boolean> inWhileLoop = new LinkedList<>();

@Override
protected void clearState() {
Expand Down
Loading
Loading