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 @@ -35,7 +35,7 @@
* An accessor for information about a single bug checker, including the metadata in the check's
* {@code @BugPattern} annotation and the class that implements the check.
*/
public class BugCheckerInfo implements Serializable {
public final class BugCheckerInfo implements Serializable {

/** The BugChecker class. */
private final Class<? extends BugChecker> checker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

/** A {@link TaskListener} that runs Error Prone over attributed compilation units. */
@Trusted
public class ErrorProneAnalyzer implements TaskListener {
public final class ErrorProneAnalyzer implements TaskListener {

// The set of trees that have already been scanned.
private final Set<Tree> seen = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public ErrorProneFlags plus(ErrorProneFlags other) {
}

/** Builder for Error Prone command-line flags object. Parses flags from strings. */
public static class Builder {
public static final class Builder {

private final HashMap<String, String> flagsMap = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*
* @author eaftan@google.com (Eddie Aftandilian)
*/
public class ErrorProneOptions {
public final class ErrorProneOptions {

private static final String PREFIX = "-Xep";
private static final String SEVERITY_PREFIX = "-Xep:";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*
* @author alexeagle@google.com (Alex Eagle)
*/
public class JavacErrorDescriptionListener implements DescriptionListener {
public final class JavacErrorDescriptionListener implements DescriptionListener {
private final Log log;
private final JavaFileObject sourceFile;
private final BiFunction<Description, Fix, AppliedFix> fixToAppliedFix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import java.util.logging.Logger;

/** A container of fixes that have been collected during a single compilation phase. */
public class RefactoringCollection implements DescriptionListener.Factory {
public final class RefactoringCollection implements DescriptionListener.Factory {

private static final Logger logger = Logger.getLogger(RefactoringCollection.class.getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
@Immutable
@CheckReturnValue
public class SuppressionInfo {
public final class SuppressionInfo {
public static final SuppressionInfo EMPTY =
new SuppressionInfo(ImmutableSet.of(), ImmutableSet.of(), false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
/**
* @author alexeagle@google.com (Alex Eagle)
*/
public class VisitorState {
public /* TODO: cl/931120620 - final */ class VisitorState {

private final SharedState sharedState;
public final Context context;
Expand Down Expand Up @@ -606,7 +606,7 @@ public AutoCloseable timingSpan(Suppressible suppressible) {
return sharedState.timings.span(suppressible);
}

private static class Cache<T> implements Supplier<T> {
private static final class Cache<T> implements Supplier<T> {
private final Supplier<T> impl;
/* Uses T instead of Optional<T> because we don't want to cache null results
(b/138753468). These inline caches persist between compilation units, and a type that fails to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import org.jspecify.annotations.Nullable;

/** Utilities to extract {@link Nullness} from annotations. */
public class NullnessAnnotations {
public final class NullnessAnnotations {
// TODO(kmb): Correctly handle JSR 305 @Nonnull(NEVER) etc.
private static final Predicate<String> ANNOTATION_RELEVANT_TO_NULLNESS =
Pattern.compile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
*
* @author bennostein@google.com (Benno Stein)
*/
public class NullnessQualifierInference extends TreeScanner<Void, Void> {
public final class NullnessQualifierInference extends TreeScanner<Void, Void> {

private static final LoadingCache<Tree, InferredNullability> inferenceCache =
Caffeine.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*
* @author andrewrice@google.com (Andrew Rice)
*/
public class BranchedSuggestedFixes {
public final class BranchedSuggestedFixes {

private final ImmutableList<SuggestedFix> fixes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,7 @@ public static VariableNamer variableNamer(VisitorState state) {
}

/** Helper class for avoiding variable name shadowing. */
public static class VariableNamer {
public static final class VariableNamer {
private final Set<String> idents;

private VariableNamer(VisitorState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* @author mwacker@google.com (Mike Wacker)
*/
public class AnnotationMatcherUtils {
public final class AnnotationMatcherUtils {

/**
* Gets the value for an argument, or null if the argument does not exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*
* @author alexeagle@google.com (Alex Eagle)
*/
public class Description {
public final class Description {
/** Describes the sentinel value of the case where the match failed. */
public static final Description NO_MATCH =
new Description(
Expand Down Expand Up @@ -151,7 +151,7 @@ public static Builder builder(
}

/** Builder for {@code Description}s. */
public static class Builder {
public static final class Builder {
private final ErrorPronePosition position;
private final String name;
private String linkUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @author alexeagle@google.com (Alex Eagle)
*/
public class Enclosing {
public final class Enclosing {
private Enclosing() {}

private abstract static class EnclosingMatcher<T extends Tree, U extends Tree>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
*
* @author alexeagle@google.com (Alex Eagle)
*/
public class Matchers {
public final class Matchers {

private Matchers() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @author bhagwani@google.com (Sumit Bhagwani)
*/
public class TestNgMatchers {
public final class TestNgMatchers {

/**
* Checks if a method, or any overridden method, is annotated with any annotation from the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* The machinery and type definitions necessary to model and compile a single efficient matcher out
* of a list of {@link com.google.errorprone.matchers.method.MethodMatchers.MethodMatcher}s.
*/
public class MethodInvocationMatcher {
public final class MethodInvocationMatcher {

record Context(MethodSymbol sym, ExpressionTree tree) {
static Optional<Context> create(ExpressionTree tree) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @author eaftan@google.com (Eddie Aftandilian)
*/
public class LevenshteinEditDistance {
public final class LevenshteinEditDistance {

private LevenshteinEditDistance() {
/* disallow instantiation */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@
import org.jspecify.annotations.Nullable;

/** This class contains utility methods to work with the javac AST. */
public class ASTHelpers {
@SuppressWarnings("IdentifierName") // should have been "AstHelpers" but too disruptive to change
public final class ASTHelpers {
/**
* Determines whether two expressions refer to the same variable. Note that returning false
* doesn't necessarily mean the expressions do *not* refer to the same field. We don't attempt to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private static boolean canHaveTargetType(Tree tree) {
}

@VisibleForTesting
static class TargetTypeVisitor extends SimpleTreeVisitor<Type, Void> {
static final class TargetTypeVisitor extends SimpleTreeVisitor<Type, Void> {
private final VisitorState state;
private final TreePath parent;
private final ExpressionTree current;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private static boolean isValidInitializerOrNotAByteBuffer(
* Scan for a call to ByteBuffer.arrayOffset() or check if buffer was initialized with either
* ByteBuffer.wrap() or ByteBuffer.allocate().
*/
private static class ValidByteBufferArrayScanner extends TreeScanner<Void, VisitorState> {
private static final class ValidByteBufferArrayScanner extends TreeScanner<Void, VisitorState> {

private final Symbol searchedBufferSymbol;
private boolean visited;
Expand Down Expand Up @@ -185,7 +185,7 @@ private void checkForInitializer(
}

/** Scan for a call to ByteBuffer.wrap() or ByteBuffer.allocate(). */
private static class ValidByteBufferInitializerScanner
private static final class ValidByteBufferInitializerScanner
extends TreeScanner<Boolean, VisitorState> {

static Boolean scan(ExpressionTree tree, VisitorState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import java.util.Set;

/** Analyzes trees for references to their enclosing instance. */
public class CanBeStaticAnalyzer extends TreeScanner {
public final class CanBeStaticAnalyzer extends TreeScanner {

/** Returns true if the tree references its enclosing class. */
public static boolean referencesOuter(Tree tree, Symbol owner, VisitorState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState
return describeMatch(methodTree, fixer.getFix());
}

private static class EqualsFixer extends TreePathScanner<Void, Void> {
private static final class EqualsFixer extends TreePathScanner<Void, Void> {

private static final Matcher<ExpressionTree> GET_CLASS =
instanceMethod().onDescendantOf("java.lang.Object").named("getClass").withNoParameters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private static String getMessage(
+ " are incompatible.";
}

private static class TypeStringPair {
private static final class TypeStringPair {
private String receiverTypeString;
private String argumentTypeString;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState s
}

/** Record assignments to possibly-final variables in a compilation unit. */
private class FinalScanner extends TreePathScanner<Void, InitializationContext> {
private final class FinalScanner extends TreePathScanner<Void, InitializationContext> {

private final VariableAssignmentRecords writes;
private final VisitorState compilationState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState s
return Description.NO_MATCH;
}

private class NullComparisonScanner extends TreePathScanner<Void, Void> {
private final class NullComparisonScanner extends TreePathScanner<Void, Void> {
private final Map<Symbol, ExpressionTree> effectivelyFinalValues = new HashMap<>();
private final VisitorState state;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private static boolean isUpperCaseAndStatic(Symbol symbol) {
* Matcher for all fields of the given class node that are either instance members or not all
* upper case.
*/
private static class FieldScanner extends TreeScanner<Void, Void> {
private static final class FieldScanner extends TreeScanner<Void, Void> {

static ImmutableSet<Symbol> findFields(ClassTree tree) {
ImmutableSet.Builder<Symbol> fieldsBuilder = ImmutableSet.builder();
Expand Down Expand Up @@ -177,7 +177,7 @@ public Void visitVariable(VariableTree tree, Void unused) {
* Matcher for all parameters (methods, constructors, lambda expressions) that have the same name
* as one of the provided fields but with different capitalization.
*/
private static class MatchingParametersScanner extends TreePathScanner<Void, Void> {
private static final class MatchingParametersScanner extends TreePathScanner<Void, Void> {

static ImmutableMap<TreePath, Symbol> findMatchingParameters(
ImmutableMap<String, Symbol> fieldNamesMap, TreePath path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public Description matchMethod(MethodTree tree, VisitorState state) {
}

/** Scans a tree looking for calls to a method that is overridden by the given one. */
private static class FindSuperTreeScanner extends TreeScanner<Boolean, Void> {
private static final class FindSuperTreeScanner extends TreeScanner<Boolean, Void> {
private final String overridingMethodName;

private FindSuperTreeScanner(String overridingMethodName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ private static boolean newFluentChain(ExpressionTree tree, VisitorState state) {
.orElse(false);
}

private static class UnusedScanner extends TreePathScanner<Void, Void> {
private static final class UnusedScanner extends TreePathScanner<Void, Void> {
private final Symbol symbol;
private final VisitorState state;
private final Matcher<IdentifierTree> matcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ private boolean exemptedByName(Name name) {
|| exemptNames.contains(nameString);
}

private class VariableFinder extends TreePathScanner<Void, Void> {
private final class VariableFinder extends TreePathScanner<Void, Void> {
private final Map<Symbol, TreePath> unusedElements = new HashMap<>();

private final Set<Symbol> onlyCheckForReassignments = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ private static boolean isDefinitionOfZeroArgSelf(MethodSymbol methodSymbol) {
}

private static boolean methodReturnsIgnorableValues(MethodTree tree, VisitorState state) {
class ReturnValuesFromMethodAreIgnorable extends TreeScanner<Void, Void> {
final class ReturnValuesFromMethodAreIgnorable extends TreeScanner<Void, Void> {
private final VisitorState state;
private final Type enclosingClassType;
private final Type methodReturnType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.List;

/** Error messages used by {@link com.google.errorprone.bugpatterns.CheckReturnValue}. */
public class ErrorMessages {
public final class ErrorMessages {
private ErrorMessages() {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class FloggerArgumentToString extends BugChecker implements MethodInvocat
private static final Character HEX_FORMAT = 'x';
private static final Character UPPER_HEX_FORMAT = 'X';

static class Parameter {
static final class Parameter {

final Supplier<String> source;
final Type type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* Format string validation utility that fails on more cases than {@link FormatStringValidation} to
* enforce strict format string checking.
*/
public class StrictFormatStringValidation {
public final class StrictFormatStringValidation {

private static final Matcher<ExpressionTree> MOCKITO_MATCHERS =
staticMethod().onClassAny("org.mockito.Matchers", "org.mockito.ArgumentMatchers");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public String guardString() {
/** A simple 'this literal. */
// Don't use AutoValue here, since sym and type need to be 'null'. (And since
// it's a singleton we don't need to implement equals() or hashCode()).
public static class ThisLiteral extends GuardedByExpression {
public static final class ThisLiteral extends GuardedByExpression {

static final ThisLiteral INSTANCE = new ThisLiteral();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*
* @author cushon@google.com (Liam Miller-Cushon)
*/
public class GuardedBySymbolResolver implements GuardedByBinder.Resolver {
public final class GuardedBySymbolResolver implements GuardedByBinder.Resolver {

private final ClassSymbol enclosingClass;
private final MethodInfo method;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private static HeldLockSet handleMonitorGuards(VisitorState state, HeldLockSet l
.orElse(locks);
}

private static class LockScanner extends TreePathScanner<Void, HeldLockSet> {
private static final class LockScanner extends TreePathScanner<Void, HeldLockSet> {

private final VisitorState visitorState;
private final LockEventListener listener;
Expand Down Expand Up @@ -306,7 +306,7 @@ static LockResource create(String className, String unlockMethod) {
LockResource.create("com.google.common.util.concurrent.Monitor", "leave"),
LockResource.create("java.util.concurrent.Semaphore", "release"));

private static class LockOperationFinder extends TreeScanner<Void, Void> {
private static final class LockOperationFinder extends TreeScanner<Void, Void> {

static Collection<GuardedByExpression> find(
Tree tree, VisitorState state, Matcher<ExpressionTree> lockOperationMatcher) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @author cushon@google.com (Liam Miller-Cushon)
*/
class HeldLockSet {
final class HeldLockSet {

final PSet<GuardedByExpression> locks;

Expand Down
Loading
Loading