diff options
author | Tor Norbye <tnorbye@google.com> | 2011-12-08 20:35:56 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-01-09 16:22:39 -0800 |
commit | 37d5a9bbdc2895921cd0f636777efe2d3bad4e5b (patch) | |
tree | 941efa58cc919aaae6f029f5579f2e0ccc67b0d9 /eclipse | |
parent | 14312a9603fab9e711639cfc19d5ea1de17250b1 (diff) | |
download | sdk-37d5a9bbdc2895921cd0f636777efe2d3bad4e5b.zip sdk-37d5a9bbdc2895921cd0f636777efe2d3bad4e5b.tar.gz sdk-37d5a9bbdc2895921cd0f636777efe2d3bad4e5b.tar.bz2 |
Add lint checks: String format, Casts, Security, Imports, /sdcard
This changeset adds several new Java parsetree-based lint detectors:
(1) String format checker. This checks several issues related to
formatting strings (%1$s), such as
- Is the string format valid?
- Is the string format consistent between different translations,
e.g. if argument #1 is of type "s" in locale A, is it also of
type "s" in locale B?
- Is the string format being called from Java with arguments of
the right type?
- Are strings which are not supposed to be formatted (e.g. ends
with a %) passed to String.format?
(2) View Cast checker. Looks at the views associated with specific
id's in layouts, and makes sure that any casts to views returned
by findViewById in Java is cast-compatible with the type in the
layout. For example, if you have a layout containing a <Button
id="foo">, then a cast to an EditText of findViewById(R.id.foo)
would be invalid.
(3) A security check which flags file creation calls that pass a
context of world-writeable.
(4) An "import android.R" checker. This looks for "import android.R"
in .java files and warns that this is potentially confusing.
(5) A hardcoded "/sdcard" string checker which looks for this prefix
in string literals and when found warns that the method
Environment.getExternalStorageDirectory().getPath() should be
used instead.
Change-Id: I14a4656f0ff6a58f25cde1b4bb23f6c47c47fdba
Diffstat (limited to 'eclipse')
-rw-r--r-- | eclipse/dictionary.txt | 1 | ||||
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/eclipse/dictionary.txt b/eclipse/dictionary.txt index a70810f..3beaa53 100644 --- a/eclipse/dictionary.txt +++ b/eclipse/dictionary.txt @@ -235,6 +235,7 @@ scrollable scrollbar scrollbars scrubbing +sdcard sdk se searchable diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java index c223b79..115fb7a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java @@ -734,7 +734,7 @@ public class EclipseLintClient extends LintClient implements IDomParser { // There could be more than one node when there are errors; pick out the // compilation unit node for (lombok.ast.Node node : nodes) { - if (node instanceof CompilationUnit) { + if (node instanceof lombok.ast.CompilationUnit) { return node; } } |