aboutsummaryrefslogtreecommitdiffstats
path: root/lint/libs/lint_api
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-12-12 12:43:35 -0800
committerTor Norbye <tnorbye@google.com>2012-12-12 12:43:35 -0800
commit9aa0c5d207ec2eb5098fc9d7ee09710838066ac6 (patch)
tree0d15888c8e20f6a0bf1e7fa8c50f2e4e72074021 /lint/libs/lint_api
parent2bf1426955bcd41afa726200e2da9f76d46f25c6 (diff)
downloadsdk-9aa0c5d207ec2eb5098fc9d7ee09710838066ac6.zip
sdk-9aa0c5d207ec2eb5098fc9d7ee09710838066ac6.tar.gz
sdk-9aa0c5d207ec2eb5098fc9d7ee09710838066ac6.tar.bz2
Code cleanup
Ran some static analysis on the lint code and fixed various issues - some typos, made some fields final, made some methods static, sorted modifier order etc. Change-Id: Ibdcdec5745f040eb7b0880cf6999c0f0ea7f7e6f
Diffstat (limited to 'lint/libs/lint_api')
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/AsmVisitor.java9
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/Configuration.java2
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/DefaultConfiguration.java12
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/IssueRegistry.java6
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/JavaVisitor.java14
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintClient.java12
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintDriver.java57
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintListener.java6
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/XmlVisitor.java34
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Category.java44
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/ClassContext.java12
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Context.java2
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Detector.java15
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Issue.java2
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/LintUtils.java8
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Location.java29
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Project.java22
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Severity.java5
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Speed.java2
19 files changed, 135 insertions, 158 deletions
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/AsmVisitor.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/AsmVisitor.java
index 81e2934..e8a4bb5 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/AsmVisitor.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/AsmVisitor.java
@@ -62,14 +62,13 @@ class AsmVisitor {
* there isn't a max-constant there, so update this along with ASM library
* updates.
*/
- public final static int TYPE_COUNT = AbstractInsnNode.LINE + 1;
+ private static final int TYPE_COUNT = AbstractInsnNode.LINE + 1;
private final Map<String, List<ClassScanner>> mMethodNameToChecks =
new HashMap<String, List<ClassScanner>>();
private final Map<String, List<ClassScanner>> mMethodOwnerToChecks =
new HashMap<String, List<ClassScanner>>();
private final List<Detector> mFullClassChecks = new ArrayList<Detector>();
- private final LintClient mClient;
private final List<? extends Detector> mAllDetectors;
private List<ClassScanner>[] mNodeTypeDetectors;
@@ -78,7 +77,6 @@ class AsmVisitor {
// but it makes client code tricky and ugly.
@SuppressWarnings("unchecked")
AsmVisitor(@NonNull LintClient client, @NonNull List<? extends Detector> classDetectors) {
- mClient = client;
mAllDetectors = classDetectors;
// TODO: Check appliesTo() for files, and find a quick way to enable/disable
@@ -117,11 +115,10 @@ class AsmVisitor {
int[] types = scanner.getApplicableAsmNodeTypes();
if (types != null) {
checkFullClass = false;
- for (int i = 0, n = types.length; i < n; i++) {
- int type = types[i];
+ for (int type : types) {
if (type < 0 || type >= TYPE_COUNT) {
// Can't support this node type: looks like ASM wasn't updated correctly.
- mClient.log(null, "Out of range node type %1$d from detector %2$s",
+ client.log(null, "Out of range node type %1$d from detector %2$s",
type, scanner);
continue;
}
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/Configuration.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/Configuration.java
index ad1c7e1..d233be7 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/Configuration.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/Configuration.java
@@ -111,7 +111,7 @@ public abstract class Configuration {
/**
* Marks the beginning of a "bulk" editing operation with repeated calls to
- * {@link #setSeverity} or {@link #ignore}. After all the values haver been
+ * {@link #setSeverity} or {@link #ignore}. After all the values have been
* set, the client <b>must</b> call {@link #finishBulkEditing()}. This
* allows configurations to avoid doing expensive I/O (such as writing out a
* config XML file) for each and every editing operation when they are
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/DefaultConfiguration.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/DefaultConfiguration.java
index 5a8a973..db82556 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/DefaultConfiguration.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/DefaultConfiguration.java
@@ -78,7 +78,7 @@ public class DefaultConfiguration extends Configuration {
private static final String TAG_IGNORE = "ignore"; //$NON-NLS-1$
private final Configuration mParent;
- protected final Project mProject;
+ private final Project mProject;
private final File mConfigFile;
private boolean mBulkEditing;
@@ -237,7 +237,7 @@ public class DefaultConfiguration extends Configuration {
Node node = issues.item(i);
Element element = (Element) node;
String id = element.getAttribute(ATTR_ID);
- if (id.length() == 0) {
+ if (id.isEmpty()) {
formatError("Invalid lint config file: Missing required issue id attribute");
continue;
}
@@ -269,7 +269,7 @@ public class DefaultConfiguration extends Configuration {
if (child.getNodeType() == Node.ELEMENT_NODE) {
Element ignore = (Element) child;
String path = ignore.getAttribute(ATTR_PATH);
- if (path.length() == 0) {
+ if (path.isEmpty()) {
formatError("Missing required %1$s attribute under %2$s",
ATTR_PATH, id);
} else {
@@ -305,7 +305,7 @@ public class DefaultConfiguration extends Configuration {
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + //$NON-NLS-1$
"<lint>\n"); //$NON-NLS-1$
- if (mSuppressed.size() > 0 || mSeverity.size() > 0) {
+ if (!mSuppressed.isEmpty() || !mSeverity.isEmpty()) {
// Process the maps in a stable sorted order such that if the
// files are checked into version control with the project,
// there are no random diffs just because hashing algorithms
@@ -331,7 +331,7 @@ public class DefaultConfiguration extends Configuration {
}
List<String> paths = mSuppressed.get(id);
- if (paths != null && paths.size() > 0) {
+ if (paths != null && !paths.isEmpty()) {
writer.write('>');
writer.write('\n');
// The paths are already kept in sorted order when they are modified
@@ -358,7 +358,7 @@ public class DefaultConfiguration extends Configuration {
// Move file into place: move current version to lint.xml~ (removing the old ~ file
// if it exists), then move the new version to lint.xml.
File oldFile = new File(mConfigFile.getParentFile(),
- mConfigFile.getName() + "~"); //$NON-NLS-1$
+ mConfigFile.getName() + '~'); //$NON-NLS-1$
if (oldFile.exists()) {
oldFile.delete();
}
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/IssueRegistry.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/IssueRegistry.java
index d6f0579..dcfed69 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/IssueRegistry.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/IssueRegistry.java
@@ -70,7 +70,7 @@ public abstract class IssueRegistry {
@NonNull
public static final Issue LINT_ERROR = Issue.create(
"LintError", //$NON-NLS-1$
- "Isues related to running lint itself, such as failure to read files, etc",
+ "Issues related to running lint itself, such as failure to read files, etc",
"This issue type represents a problem running lint itself. Examples include " +
"failure to find bytecode for source files (which means certain detectors " +
"could not be run), parsing errors in lint configuration files, etc." +
@@ -234,8 +234,8 @@ public abstract class IssueRegistry {
* @return true if the given string is a valid category
*/
public final boolean isCategoryName(@NonNull String name) {
- for (Category c : getCategories()) {
- if (c.getName().equals(name) || c.getFullName().equals(name)) {
+ for (Category category : getCategories()) {
+ if (category.getName().equals(name) || category.getFullName().equals(name)) {
return true;
}
}
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/JavaVisitor.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/JavaVisitor.java
index b1d8832..b74693a 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/JavaVisitor.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/JavaVisitor.java
@@ -138,7 +138,7 @@ public class JavaVisitor {
new ArrayList<VisitingDetector>();
private final List<VisitingDetector> mAllDetectors;
private final List<VisitingDetector> mFullTreeDetectors;
- private Map<Class<? extends Node>, List<VisitingDetector>> mNodeTypeDetectors =
+ private final Map<Class<? extends Node>, List<VisitingDetector>> mNodeTypeDetectors =
new HashMap<Class<? extends Node>, List<VisitingDetector>>();
private final IJavaParser mParser;
@@ -181,8 +181,8 @@ public class JavaVisitor {
if (detector.appliesToResourceRefs()) {
mResourceFieldDetectors.add(v);
- } else if ((names == null || names.size() == 0)
- && (nodeTypes == null || nodeTypes.size() ==0)) {
+ } else if ((names == null || names.isEmpty())
+ && (nodeTypes == null || nodeTypes.isEmpty())) {
mFullTreeDetectors.add(v);
}
}
@@ -214,10 +214,10 @@ public class JavaVisitor {
}
}
- if (mMethodDetectors.size() > 0 || mResourceFieldDetectors.size() > 0) {
+ if (!mMethodDetectors.isEmpty() || !mResourceFieldDetectors.isEmpty()) {
AstVisitor visitor = new DelegatingJavaVisitor(context);
compilationUnit.accept(visitor);
- } else if (mNodeTypeDetectors.size() > 0) {
+ } else if (!mNodeTypeDetectors.isEmpty()) {
AstVisitor visitor = new DispatchVisitor();
compilationUnit.accept(visitor);
}
@@ -1113,8 +1113,8 @@ public class JavaVisitor {
public DelegatingJavaVisitor(JavaContext context) {
mContext = context;
- mVisitMethods = mMethodDetectors.size() > 0;
- mVisitResources = mResourceFieldDetectors.size() > 0;
+ mVisitMethods = !mMethodDetectors.isEmpty();
+ mVisitResources = !mResourceFieldDetectors.isEmpty();
}
@Override
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintClient.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintClient.java
index 461e64f..7843aa1 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintClient.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintClient.java
@@ -294,14 +294,14 @@ public abstract class LintClient {
* @return A new File corresponding to {@link LintClient#PROP_BIN_DIR} or null.
*/
@Nullable
- private File getLintBinDir() {
+ private static File getLintBinDir() {
// First check the Java properties (e.g. set using "java -jar ... -Dname=value")
String path = System.getProperty(PROP_BIN_DIR);
- if (path == null || path.length() == 0) {
+ if (path == null || path.isEmpty()) {
// If not found, check environment variables.
path = System.getenv(PROP_BIN_DIR);
}
- if (path != null && path.length() > 0) {
+ if (path != null && !path.isEmpty()) {
return new File(path);
}
return null;
@@ -472,7 +472,7 @@ public abstract class LintClient {
}
}
- if (classes.size() == 0) {
+ if (classes.isEmpty()) {
File folder = new File(projectDir, CLASS_FOLDER);
if (folder.exists()) {
classes.add(folder);
@@ -485,7 +485,7 @@ public abstract class LintClient {
// If it's maven, also correct the source path, "src" works but
// it's in a more specific subfolder
- if (sources.size() == 0) {
+ if (sources.isEmpty()) {
File src = new File(projectDir,
"src" + File.separator //$NON-NLS-1$
+ "main" + File.separator //$NON-NLS-1$
@@ -512,7 +512,7 @@ public abstract class LintClient {
}
// Fallback, in case there is no Eclipse project metadata here
- if (sources.size() == 0) {
+ if (sources.isEmpty()) {
File src = new File(projectDir, SRC_FOLDER);
if (src.exists()) {
sources.add(src);
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintDriver.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintDriver.java
index 463562b..a92a9a2 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintDriver.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintDriver.java
@@ -78,6 +78,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
+import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
@@ -120,8 +121,8 @@ public class LintDriver {
private static final String SUPPRESS_LINT_VMSIG = '/' + SUPPRESS_LINT + ';';
private final LintClient mClient;
+ private final IssueRegistry mRegistry;
private volatile boolean mCanceled;
- private IssueRegistry mRegistry;
private EnumSet<Scope> mScope;
private List<? extends Detector> mApplicableDetectors;
private Map<Scope, List<Detector>> mScopeDetectors;
@@ -283,7 +284,7 @@ public class LintDriver {
mScope = scope;
Collection<Project> projects = computeProjects(files);
- if (projects.size() == 0) {
+ if (projects.isEmpty()) {
mClient.log(null, "No projects found for %1$s", files.toString());
return;
}
@@ -332,7 +333,7 @@ public class LintDriver {
// The set of available detectors varies between projects
computeDetectors(project);
- if (mApplicableDetectors.size() == 0) {
+ if (mApplicableDetectors.isEmpty()) {
// No detectors enabled in this project: skip it
continue;
}
@@ -382,7 +383,7 @@ public class LintDriver {
// those that apply for the configuration.
computeRepeatingDetectors(mRepeatingDetectors, project);
- if (mApplicableDetectors.size() == 0) {
+ if (mApplicableDetectors.isEmpty()) {
// No detectors enabled in this project: skip it
continue;
}
@@ -415,7 +416,7 @@ public class LintDriver {
Map<Class<? extends Detector>, EnumSet<Scope>> detectorToScope =
new HashMap<Class<? extends Detector>, EnumSet<Scope>>();
Map<Scope, List<Detector>> scopeToDetectors =
- new HashMap<Scope, List<Detector>>();
+ new EnumMap<Scope, List<Detector>>(Scope.class);
List<Detector> detectorList = new ArrayList<Detector>();
// Compute the list of detectors (narrowed down from mRepeatingDetectors),
@@ -426,7 +427,7 @@ public class LintDriver {
for (Detector detector : detectors) {
Class<? extends Detector> detectorClass = detector.getClass();
Collection<Issue> detectorIssues = issueMap.get(detectorClass);
- if (issues != null) {
+ if (detectorIssues != null) {
boolean add = false;
for (Issue issue : detectorIssues) {
// The reason we have to check whether the detector is enabled
@@ -480,7 +481,7 @@ public class LintDriver {
mCurrentVisitor = null;
Configuration configuration = project.getConfiguration();
- mScopeDetectors = new HashMap<Scope, List<Detector>>();
+ mScopeDetectors = new EnumMap<Scope, List<Detector>>(Scope.class);
mApplicableDetectors = mRegistry.createDetectors(mClient, configuration,
mScope, mScopeDetectors);
@@ -815,7 +816,7 @@ public class LintDriver {
if (mScope.contains(Scope.ALL_RESOURCE_FILES) || mScope.contains(Scope.RESOURCE_FILE)) {
List<Detector> checks = union(mScopeDetectors.get(Scope.RESOURCE_FILE),
mScopeDetectors.get(Scope.ALL_RESOURCE_FILES));
- if (checks != null && checks.size() > 0) {
+ if (checks != null && !checks.isEmpty()) {
List<ResourceXmlDetector> xmlDetectors =
new ArrayList<ResourceXmlDetector>(checks.size());
for (Detector detector : checks) {
@@ -823,13 +824,13 @@ public class LintDriver {
xmlDetectors.add((ResourceXmlDetector) detector);
}
}
- if (xmlDetectors.size() > 0) {
+ if (!xmlDetectors.isEmpty()) {
List<File> files = project.getSubset();
if (files != null) {
checkIndividualResources(project, main, xmlDetectors, files);
} else {
File res = project.getResourceFolder();
- if (res != null && xmlDetectors.size() > 0) {
+ if (res != null && !xmlDetectors.isEmpty()) {
checkResFolder(project, main, res, xmlDetectors);
}
}
@@ -844,7 +845,7 @@ public class LintDriver {
if (mScope.contains(Scope.JAVA_FILE) || mScope.contains(Scope.ALL_JAVA_FILES)) {
List<Detector> checks = union(mScopeDetectors.get(Scope.JAVA_FILE),
mScopeDetectors.get(Scope.ALL_JAVA_FILES));
- if (checks != null && checks.size() > 0) {
+ if (checks != null && !checks.isEmpty()) {
List<File> files = project.getSubset();
if (files != null) {
checkIndividualJavaFiles(project, main, checks, files);
@@ -1026,7 +1027,7 @@ public class LintDriver {
List<File> libraries = project.getJavaLibraries();
List<ClassEntry> libraryEntries;
- if (libraries.size() > 0) {
+ if (!libraries.isEmpty()) {
libraryEntries = new ArrayList<ClassEntry>(64);
findClasses(libraryEntries, libraries);
Collections.sort(libraryEntries);
@@ -1036,7 +1037,7 @@ public class LintDriver {
List<File> classFolders = project.getJavaClassFolders();
List<ClassEntry> classEntries;
- if (classFolders.size() == 0) {
+ if (classFolders.isEmpty()) {
String message = String.format("No .class files were found in project \"%1$s\", "
+ "so none of the classfile based checks could be run. "
+ "Does the project need to be built first?", project.getName());
@@ -1101,7 +1102,7 @@ public class LintDriver {
}
}
- if (entries.size() > 0) {
+ if (!entries.isEmpty()) {
Collections.sort(entries);
// No superclass info available on individual lint runs, unless
// the client can provide it
@@ -1123,7 +1124,7 @@ public class LintDriver {
Project project, Project main) {
if (mScope.contains(scope)) {
List<Detector> classDetectors = mScopeDetectors.get(scope);
- if (classDetectors != null && classDetectors.size() > 0 && entries.size() > 0) {
+ if (classDetectors != null && !classDetectors.isEmpty() && !entries.isEmpty()) {
AsmVisitor visitor = new AsmVisitor(mClient, classDetectors);
String sourceContents = null;
@@ -1333,7 +1334,7 @@ public class LintDriver {
}
}
- private void addClassFiles(@NonNull File dir, @NonNull List<File> classFiles) {
+ private static void addClassFiles(@NonNull File dir, @NonNull List<File> classFiles) {
// Process the resource folder
File[] files = dir.listFiles();
if (files != null && files.length > 0) {
@@ -1359,14 +1360,14 @@ public class LintDriver {
return;
}
- assert checks.size() > 0;
+ assert !checks.isEmpty();
// Gather all Java source files in a single pass; more efficient.
List<File> sources = new ArrayList<File>(100);
for (File folder : sourceFolders) {
gatherJavaFiles(folder, sources);
}
- if (sources.size() > 0) {
+ if (!sources.isEmpty()) {
JavaVisitor visitor = new JavaVisitor(javaParser, checks);
for (File file : sources) {
JavaContext context = new JavaContext(this, project, main, file);
@@ -1405,7 +1406,7 @@ public class LintDriver {
}
}
- private void gatherJavaFiles(@NonNull File dir, @NonNull List<File> result) {
+ private static void gatherJavaFiles(@NonNull File dir, @NonNull List<File> result) {
File[] files = dir.listFiles();
if (files != null) {
for (File file : files) {
@@ -1443,7 +1444,7 @@ public class LintDriver {
return mCurrentVisitor;
}
- if (applicableChecks.size() == 0) {
+ if (applicableChecks.isEmpty()) {
mCurrentVisitor = null;
return null;
}
@@ -1472,9 +1473,8 @@ public class LintDriver {
// same time
Arrays.sort(resourceDirs);
- ResourceFolderType type = null;
for (File dir : resourceDirs) {
- type = ResourceFolderType.getFolderType(dir.getName());
+ ResourceFolderType type = ResourceFolderType.getFolderType(dir.getName());
if (type != null) {
checkResourceFolder(project, main, dir, type, checks);
}
@@ -1566,7 +1566,7 @@ public class LintDriver {
*/
public void removeLintListener(@NonNull LintListener listener) {
mListeners.remove(listener);
- if (mListeners.size() == 0) {
+ if (mListeners.isEmpty()) {
mListeners = null;
}
}
@@ -1574,8 +1574,7 @@ public class LintDriver {
/** Notifies listeners, if any, that the given event has occurred */
private void fireEvent(@NonNull LintListener.EventType type, @Nullable Context context) {
if (mListeners != null) {
- for (int i = 0, n = mListeners.size(); i < n; i++) {
- LintListener listener = mListeners.get(i);
+ for (LintListener listener : mListeners) {
listener.update(this, type, context);
}
}
@@ -1583,8 +1582,7 @@ public class LintDriver {
/**
* Wrapper around the lint client. This sits in the middle between a
- * detector calling for example
- * {@link LintClient#report(Context, Issue, Location, String, Object)} and
+ * detector calling for example {@link LintClient#report} and
* the actual embedding tool, and performs filtering etc such that detectors
* and lint clients don't have to make sure they check for ignored issues or
* filtered out warnings.
@@ -1669,8 +1667,9 @@ public class LintDriver {
return mDelegate.getJavaClassFolders(project);
}
+ @NonNull
@Override
- public @NonNull List<File> getJavaLibraries(@NonNull Project project) {
+ public List<File> getJavaLibraries(@NonNull Project project) {
return mDelegate.getJavaLibraries(project);
}
@@ -1900,7 +1899,7 @@ public class LintDriver {
return false;
}
- private boolean isSuppressed(@Nullable Issue issue, List<AnnotationNode> annotations) {
+ private static boolean isSuppressed(@Nullable Issue issue, List<AnnotationNode> annotations) {
for (AnnotationNode annotation : annotations) {
String desc = annotation.desc;
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintListener.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintListener.java
index 2247a6d..8195d36 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintListener.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintListener.java
@@ -30,7 +30,7 @@ import com.google.common.annotations.Beta;
@Beta
public interface LintListener {
/** The various types of events provided to lint listeners */
- public enum EventType {
+ enum EventType {
/** A lint check is about to begin */
STARTING,
@@ -51,7 +51,7 @@ public interface LintListener {
/** The lint check is done */
COMPLETED,
- };
+ }
/**
* Notifies listeners that the event of the given type has occurred.
@@ -65,6 +65,6 @@ public interface LintListener {
* @param type the type of event that occurred
* @param context the context providing additional information
*/
- public void update(@NonNull LintDriver driver, @NonNull EventType type,
+ void update(@NonNull LintDriver driver, @NonNull EventType type,
@Nullable Context context);
}
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/XmlVisitor.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/XmlVisitor.java
index 816c028..2e64118 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/XmlVisitor.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/XmlVisitor.java
@@ -109,9 +109,9 @@ class XmlVisitor {
}
}
- if ((attributes == null || (attributes.size() == 0
+ if ((attributes == null || (attributes.isEmpty()
&& attributes != XmlScanner.ALL))
- && (elements == null || (elements.size() == 0
+ && (elements == null || (elements.isEmpty()
&& elements != XmlScanner.ALL))) {
mDocumentDetectors.add(xmlDetector);
}
@@ -145,8 +145,8 @@ class XmlVisitor {
check.visitDocument(context, context.document);
}
- if (mElementToCheck.size() > 0 || mAttributeToCheck.size() > 0
- || mAllAttributeDetectors.size() > 0 || mAllElementDetectors.size() > 0) {
+ if (!mElementToCheck.isEmpty() || !mAttributeToCheck.isEmpty()
+ || !mAllAttributeDetectors.isEmpty() || !mAllElementDetectors.isEmpty()) {
visitElement(context, context.document.getDocumentElement());
}
@@ -165,19 +165,17 @@ class XmlVisitor {
List<Detector.XmlScanner> elementChecks = mElementToCheck.get(element.getTagName());
if (elementChecks != null) {
assert elementChecks instanceof RandomAccess;
- for (int i = 0, n = elementChecks.size(); i < n; i++) {
- Detector.XmlScanner check = elementChecks.get(i);
+ for (XmlScanner check : elementChecks) {
check.visitElement(context, element);
}
}
- if (mAllElementDetectors.size() > 0) {
- for (int i = 0, n = mAllElementDetectors.size(); i < n; i++) {
- Detector.XmlScanner check = mAllElementDetectors.get(i);
+ if (!mAllElementDetectors.isEmpty()) {
+ for (XmlScanner check : mAllElementDetectors) {
check.visitElement(context, element);
}
}
- if (mAttributeToCheck.size() > 0 || mAllAttributeDetectors.size() > 0) {
+ if (!mAttributeToCheck.isEmpty() || !mAllAttributeDetectors.isEmpty()) {
NamedNodeMap attributes = element.getAttributes();
for (int i = 0, n = attributes.getLength(); i < n; i++) {
Attr attribute = (Attr) attributes.item(i);
@@ -187,14 +185,12 @@ class XmlVisitor {
}
List<Detector.XmlScanner> list = mAttributeToCheck.get(name);
if (list != null) {
- for (int j = 0, max = list.size(); j < max; j++) {
- Detector.XmlScanner check = list.get(j);
+ for (XmlScanner check : list) {
check.visitAttribute(context, attribute);
}
}
- if (mAllAttributeDetectors.size() > 0) {
- for (int j = 0, max = mAllAttributeDetectors.size(); j < max; j++) {
- Detector.XmlScanner check = mAllAttributeDetectors.get(j);
+ if (!mAllAttributeDetectors.isEmpty()) {
+ for (XmlScanner check : mAllAttributeDetectors) {
check.visitAttribute(context, attribute);
}
}
@@ -212,14 +208,12 @@ class XmlVisitor {
// Post hooks
if (elementChecks != null) {
- for (int i = 0, n = elementChecks.size(); i < n; i++) {
- Detector.XmlScanner check = elementChecks.get(i);
+ for (XmlScanner check : elementChecks) {
check.visitElementAfter(context, element);
}
}
- if (mAllElementDetectors.size() > 0) {
- for (int i = 0, n = mAllElementDetectors.size(); i < n; i++) {
- Detector.XmlScanner check = mAllElementDetectors.get(i);
+ if (!mAllElementDetectors.isEmpty()) {
+ for (XmlScanner check : mAllElementDetectors) {
check.visitElementAfter(context, element);
}
}
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Category.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Category.java
index ba8e5b5..c267420 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Category.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Category.java
@@ -29,7 +29,6 @@ import com.google.common.annotations.Beta;
@Beta
public final class Category implements Comparable<Category> {
private final String mName;
- private final String mExplanation;
private final int mPriority;
private final Category mParent;
@@ -38,17 +37,14 @@ public final class Category implements Comparable<Category> {
*
* @param parent the name of a parent category, or null
* @param name the name of the category
- * @param explanation an optional explanation of the category
* @param priority a sorting priority, with higher being more important
*/
private Category(
@Nullable Category parent,
@NonNull String name,
- @Nullable String explanation,
int priority) {
mParent = parent;
mName = name;
- mExplanation = explanation;
mPriority = priority;
}
@@ -61,7 +57,7 @@ public final class Category implements Comparable<Category> {
*/
@NonNull
public static Category create(@NonNull String name, int priority) {
- return new Category(null, name, null, priority);
+ return new Category(null, name, priority);
}
/**
@@ -69,17 +65,12 @@ public final class Category implements Comparable<Category> {
*
* @param parent the name of a parent category, or null
* @param name the name of the category
- * @param explanation an optional explanation of the category
* @param priority a sorting priority, with higher being more important
* @return a new category
*/
@NonNull
- public static Category create(
- @Nullable Category parent,
- @NonNull String name,
- @Nullable String explanation,
- int priority) {
- return new Category(parent, name, null, priority);
+ public static Category create(@Nullable Category parent, @NonNull String name, int priority) {
+ return new Category(parent, name, priority);
}
/**
@@ -101,15 +92,6 @@ public final class Category implements Comparable<Category> {
}
/**
- * Returns an explanation for this category, or null
- *
- * @return an explanation for this category, or null
- */
- public String getExplanation() {
- return mExplanation;
- }
-
- /**
* Returns a full name for this category. For a top level category, this is just
* the {@link #getName()} value, but for nested categories it will include the parent
* names as well.
@@ -137,34 +119,34 @@ public final class Category implements Comparable<Category> {
}
/** Issues related to running lint itself */
- public static final Category LINT = Category.create("Lint", 110);
+ public static final Category LINT = create("Lint", 110);
/** Issues related to correctness */
- public static final Category CORRECTNESS = Category.create("Correctness", 100);
+ public static final Category CORRECTNESS = create("Correctness", 100);
/** Issues related to security */
- public static final Category SECURITY = Category.create("Security", 90);
+ public static final Category SECURITY = create("Security", 90);
/** Issues related to performance */
- public static final Category PERFORMANCE = Category.create("Performance", 80);
+ public static final Category PERFORMANCE = create("Performance", 80);
/** Issues related to usability */
- public static final Category USABILITY = Category.create("Usability", 70);
+ public static final Category USABILITY = create("Usability", 70);
/** Issues related to accessibility */
- public static final Category A11Y = Category.create("Accessibility", 60);
+ public static final Category A11Y = create("Accessibility", 60);
/** Issues related to internationalization */
- public static final Category I18N = Category.create("Internationalization", 50);
+ public static final Category I18N = create("Internationalization", 50);
// Sub categories
/** Issues related to icons */
- public static final Category ICONS = Category.create(USABILITY, "Icons", null, 73);
+ public static final Category ICONS = create(USABILITY, "Icons", 73);
/** Issues related to typography */
- public static final Category TYPOGRAPHY = Category.create(USABILITY, "Typography", null, 76);
+ public static final Category TYPOGRAPHY = create(USABILITY, "Typography", 76);
/** Issues related to messages/strings */
- public static final Category MESSAGES = Category.create(CORRECTNESS, "Messages", null, 95);
+ public static final Category MESSAGES = create(CORRECTNESS, "Messages", 95);
}
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/ClassContext.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/ClassContext.java
index 2b3ce34..800e969 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/ClassContext.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/ClassContext.java
@@ -51,9 +51,9 @@ import java.util.List;
public class ClassContext extends Context {
private final File mBinDir;
/** The class file DOM root node */
- private ClassNode mClassNode;
+ private final ClassNode mClassNode;
/** The class file byte data */
- private byte[] mBytes;
+ private final byte[] mBytes;
/** The source file, if known/found */
private File mSourceFile;
/** The contents of the source file, if source file is known/found */
@@ -444,7 +444,7 @@ public class ClassContext extends Context {
if (node.methods != null && !node.methods.isEmpty()) {
MethodNode firstMethod = getFirstRealMethod(node);
if (firstMethod != null) {
- return ClassContext.findLineNumber(firstMethod);
+ return findLineNumber(firstMethod);
}
}
@@ -498,7 +498,7 @@ public class ClassContext extends Context {
}
}
- if (classNode.methods.size() > 0) {
+ if (!classNode.methods.isEmpty()) {
return (MethodNode) classNode.methods.get(0);
}
}
@@ -605,7 +605,7 @@ public class ClassContext extends Context {
* @return a user-readable string
*/
public static String createSignature(String owner, String name, String desc) {
- StringBuilder sb = new StringBuilder();
+ StringBuilder sb = new StringBuilder(100);
if (desc != null) {
Type returnType = Type.getReturnType(desc);
@@ -659,7 +659,7 @@ public class ClassContext extends Context {
@NonNull
public static String getInternalName(@NonNull String fqcn) {
String[] parts = fqcn.split("\\."); //$NON-NLS-1$
- StringBuilder sb = new StringBuilder();
+ StringBuilder sb = new StringBuilder(fqcn.length());
String prev = null;
for (String part : parts) {
if (prev != null) {
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Context.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Context.java
index 40c9d1f..a379dd0 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Context.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Context.java
@@ -333,7 +333,7 @@ public class Context {
}
/** Pattern for version qualifiers */
- private final static Pattern VERSION_PATTERN = Pattern.compile("^v(\\d+)$"); //$NON-NLS-1$
+ private static final Pattern VERSION_PATTERN = Pattern.compile("^v(\\d+)$"); //$NON-NLS-1$
private static File sCachedFolder = null;
private static int sCachedFolderVersion = -1;
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Detector.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Detector.java
index e2c5907..443746d 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Detector.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Detector.java
@@ -21,6 +21,7 @@ import com.android.annotations.Nullable;
import com.android.tools.lint.client.api.LintDriver;
import com.google.common.annotations.Beta;
+import lombok.ast.Node;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodInsnNode;
@@ -115,7 +116,7 @@ public abstract class Detector {
* @return the list of applicable node types (AST node classes), or null
*/
@Nullable
- List<Class<? extends lombok.ast.Node>> getApplicableNodeTypes();
+ List<Class<? extends Node>> getApplicableNodeTypes();
/**
* Return the list of method names this detector is interested in, or
@@ -129,7 +130,7 @@ public abstract class Detector {
* This makes it easy to write detectors that focus on some fixed calls.
* For example, the StringFormatDetector uses this mechanism to look for
* "format" calls, and when found it looks around (using the AST's
- * {@link lombok.ast.Node#getParent()} method) to see if it's called on
+ * {@link Node#getParent()} method) to see if it's called on
* a String class instance, and if so do its normal processing. Note
* that since it doesn't need to do any other AST processing, that
* detector does not actually supply a visitor.
@@ -190,7 +191,7 @@ public abstract class Detector {
void visitResourceReference(
@NonNull JavaContext context,
@Nullable AstVisitor visitor,
- @NonNull lombok.ast.Node node,
+ @NonNull Node node,
@NonNull String type,
@NonNull String name,
boolean isFramework);
@@ -367,7 +368,7 @@ public abstract class Detector {
* invoked on all elements or all attributes
*/
@NonNull
- public static final List<String> ALL = new ArrayList<String>(0); // NOT Collections.EMPTY!
+ List<String> ALL = new ArrayList<String>(0); // NOT Collections.EMPTY!
// We want to distinguish this from just an *empty* list returned by the caller!
}
@@ -477,7 +478,7 @@ public abstract class Detector {
public void visitDocument(@NonNull XmlContext context, @NonNull Document document) {
// This method must be overridden if your detector does
// not return something from getApplicableElements or
- // getApplicableATtributes
+ // getApplicableAttributes
assert false;
}
@@ -524,7 +525,7 @@ public abstract class Detector {
}
@Nullable @SuppressWarnings("javadoc")
- public List<Class<? extends lombok.ast.Node>> getApplicableNodeTypes() {
+ public List<Class<? extends Node>> getApplicableNodeTypes() {
return null;
}
@@ -540,7 +541,7 @@ public abstract class Detector {
@SuppressWarnings("javadoc")
public void visitResourceReference(@NonNull JavaContext context, @Nullable AstVisitor visitor,
- @NonNull lombok.ast.Node node, @NonNull String type, @NonNull String name,
+ @NonNull Node node, @NonNull String type, @NonNull String name,
boolean isFramework) {
}
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Issue.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Issue.java
index 70d3cf7..e5856b9 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Issue.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Issue.java
@@ -521,7 +521,7 @@ public final class Issue implements Comparable<Issue> {
return sb.toString();
}
- static void appendEscapedText(StringBuilder sb, String text, boolean html,
+ private static void appendEscapedText(StringBuilder sb, String text, boolean html,
int start, int end) {
if (html) {
for (int i = start; i < end; i++) {
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/LintUtils.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/LintUtils.java
index 17ea37e..9dec569 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/LintUtils.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/LintUtils.java
@@ -58,6 +58,10 @@ import lombok.ast.ImportDeclaration;
*/
@Beta
public class LintUtils {
+ // Utility class, do not instantiate
+ private LintUtils() {
+ }
+
/**
* Format a list of strings, and cut of the list at {@code maxItems} if the
* number of items are greater.
@@ -335,7 +339,7 @@ public class LintUtils {
*
* @param path the path variable to split, which can use both : and ; as
* path separators.
- * @return the individual path components as an iterable of strings
+ * @return the individual path components as an Iterable of strings
*/
public static Iterable<String> splitPath(String path) {
if (path.indexOf(';') != -1) {
@@ -447,7 +451,7 @@ public class LintUtils {
return PositionXmlParser.getXmlString(bytes);
}
- return LintUtils.getEncodedString(bytes);
+ return getEncodedString(bytes);
}
/**
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Location.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Location.java
index 183e7c1..e255ede 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Location.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Location.java
@@ -172,7 +172,7 @@ public class Location {
@Override
public String toString() {
return "Location [file=" + mFile + ", start=" + mStart + ", end=" + mEnd + ", message="
- + mMessage + "]";
+ + mMessage + ']';
}
/**
@@ -256,7 +256,7 @@ public class Location {
}
prev = c;
}
- return Location.create(file);
+ return create(file);
}
/**
@@ -298,7 +298,7 @@ public class Location {
while (currentLine < line) {
offset = contents.indexOf('\n', offset);
if (offset == -1) {
- return Location.create(file);
+ return create(file);
}
currentLine++;
offset++;
@@ -306,13 +306,12 @@ public class Location {
if (line == currentLine) {
if (patternStart != null) {
- int index = offset;
-
SearchDirection direction = SearchDirection.NEAREST;
if (hints != null) {
direction = hints.mDirection;
}
+ int index;
if (direction == SearchDirection.BACKWARD) {
index = findPreviousMatch(contents, offset, patternStart, hints);
line = adjustLine(contents, line, offset, index);
@@ -379,7 +378,7 @@ public class Location {
return new Location(file, position, position);
}
- return Location.create(file);
+ return create(file);
}
private static int findPreviousMatch(@NonNull String contents, int offset, String pattern,
@@ -526,7 +525,7 @@ public class Location {
* actual locations later (if needed). This makes it possible to for example
* delay looking up line numbers, for locations that are offset based.
*/
- public static interface Handle {
+ public interface Handle {
/**
* Compute a full location for the given handle
*
@@ -542,7 +541,7 @@ public class Location {
*
* @param clientData the data to store with this location
*/
- public void setClientData(@Nullable Object clientData);
+ void setClientData(@Nullable Object clientData);
/**
* Returns the client data associated with this location - an optional field
@@ -552,15 +551,15 @@ public class Location {
* @return the data associated with this location
*/
@Nullable
- public Object getClientData();
+ Object getClientData();
}
/** A default {@link Handle} implementation for simple file offsets */
public static class DefaultLocationHandle implements Handle {
- private File mFile;
- private String mContents;
- private int mStartOffset;
- private int mEndOffset;
+ private final File mFile;
+ private final String mContents;
+ private final int mStartOffset;
+ private final int mEndOffset;
private Object mClientData;
/**
@@ -580,7 +579,7 @@ public class Location {
@Override
@NonNull
public Location resolve() {
- return Location.create(mFile, mContents, mStartOffset, mEndOffset);
+ return create(mFile, mContents, mStartOffset, mEndOffset);
}
@Override
@@ -632,7 +631,7 @@ public class Location {
* {@code patternStart} is non null)
*/
@NonNull
- private SearchDirection mDirection;
+ private final SearchDirection mDirection;
/** Whether the matched pattern should be a whole word */
private boolean mWholeWord;
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Project.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Project.java
index b2ac0d1..c31a499 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Project.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Project.java
@@ -152,7 +152,7 @@ public class Project {
for (int i = 1; i < 1000; i++) {
String key = String.format(ANDROID_LIBRARY_REFERENCE_FORMAT, i);
String library = properties.getProperty(key);
- if (library == null || library.length() == 0) {
+ if (library == null || library.isEmpty()) {
// No holes in the numbering sequence is allowed
break;
}
@@ -171,13 +171,13 @@ public class Project {
// the reference dir as well
libraryReferenceDir = libraryReferenceDir.getCanonicalFile();
if (!libraryDir.getPath().startsWith(referenceDir.getPath())) {
- File f = libraryReferenceDir;
- while (f != null && f.getPath().length() > 0) {
- if (libraryDir.getPath().startsWith(f.getPath())) {
- libraryReferenceDir = f;
+ File file = libraryReferenceDir;
+ while (file != null && !file.getPath().isEmpty()) {
+ if (libraryDir.getPath().startsWith(file.getPath())) {
+ libraryReferenceDir = file;
break;
}
- f = f.getParentFile();
+ file = file.getParentFile();
}
}
}
@@ -206,7 +206,7 @@ public class Project {
@Override
public String toString() {
- return "Project [dir=" + mDir + "]";
+ return "Project [dir=" + mDir + ']';
}
@Override
@@ -570,7 +570,7 @@ public class Project {
@NonNull
public List<Project> getAllLibraries() {
if (mAllLibraries == null) {
- if (mDirectLibraries.size() == 0) {
+ if (mDirectLibraries.isEmpty()) {
return mDirectLibraries;
}
@@ -776,7 +776,7 @@ public class Project {
}
}
- if (sources.size() == 0) {
+ if (sources.isEmpty()) {
mClient.log(null,
"Warning: Could not find sources or generated sources for project %1$s",
getName());
@@ -800,7 +800,7 @@ public class Project {
}
}
- if (classDirs.size() == 0) {
+ if (classDirs.isEmpty()) {
mClient.log(null,
"No bytecode found: Has the project been built? (%1$s)", getName());
}
@@ -886,7 +886,7 @@ public class Project {
private static int sCurrentVersion;
/** In an AOSP build environment, identify the currently built image version, if available */
- private int findCurrentAospVersion() {
+ private static int findCurrentAospVersion() {
if (sCurrentVersion < 1) {
File apiDir = new File(getAospTop(), "frameworks/base/api" //$NON-NLS-1$
.replace('/', File.separatorChar));
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Severity.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Severity.java
index cde61bd..f74e6b5 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Severity.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Severity.java
@@ -62,7 +62,7 @@ public enum Severity {
@NonNull
private final String mDisplay;
- private Severity(@NonNull String display) {
+ Severity(@NonNull String display) {
mDisplay = display;
}
@@ -71,7 +71,8 @@ public enum Severity {
*
* @return a description of the severity
*/
- public @NonNull String getDescription() {
+ @NonNull
+ public String getDescription() {
return mDisplay;
}
} \ No newline at end of file
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Speed.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Speed.java
index 8c20a19..c68dab0 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Speed.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Speed.java
@@ -36,7 +36,7 @@ public enum Speed {
/** The detector might take a long time to run */
SLOW("Slow");
- private String mDisplayName;
+ private final String mDisplayName;
Speed(@NonNull String displayName) {
mDisplayName = displayName;