| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|/
|
|
|
|
|
|
| |
This changeset makes the API lint detector look at XML attribute
values and XML value text nodes and check any references to @android
resources to ensure that they are available in all supported versions.
Change-Id: Iab0d23423c30381e06b32f54aa902a31cc1f9a1c
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This lint check makes sure that if a layout references
android:onClick="foo" then one of the Java classes provide a
public void foo(View)
method. It also looks for simple typos, and warns if the access
modifiers are not right.
(It also moves some ASM-related utility code out of specific detectors
and into the ClassContext class)
Change-Id: Ifb0820221175a0760b83992f54e99f761b4d7097
|
|
|
|
| |
Change-Id: If83a942f99da90d061529092feaab3be94a8e0ad
|
|
|
|
| |
Change-Id: Ia8f0c1aebb4e797352a0513b8113b5d6b75ef0dc
|
|
|
|
|
|
|
|
| |
Also adds a lint check for unused namespace declarations,
and migrates the TypoDetector code into this new namespace
detector.
Change-Id: I5ec2214ea4c59e14194f8eaecef422ea19baa35e
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This changeset adds a new severity, "Fatal", and shifts the abort-on-
export feature from using the Error severity to the Fatal severity.
This gives the user (and lint check developers) a bit more control
over which errors should fail a build. You can now leave some issues
as "error", but not have it block export. This can be useful for
checks which are extremely slow, or for checks that generally
represent errors but where the rule cannot know for sure (such as
attempts to figure out reflection calls in Java).
Change-Id: Ie44d5efcb605091ba8c1c67aa720edbbde416ca5
|
|\ \ |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This changeset adds a new lint detector which looks for typos in the
namespace declaration for Android. If it sees the prefix "android" it
ensures that the URI matches exactly (and case-sensitively)
http://schemas.android.com/apk/res/android
If the prefix is "a", it also checks for the above prefix, but only
warns if the difference is "close" (edit distance <= 3) such that
it belives it's a typo, not some unrelated prefix bound to "a".
(This was requested in http://b.android.com/25449)
Change-Id: Ic6dee77a300fc048cb9bee3e455f533b858ef6bb
|
|\ \ \
| | |/
| |/| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This changeset adds a preprocessing state to the class handling.
Instead of processing each class sequentially, all the class byte
arrays are read in first, and then a lightweight class visitor
(skipping methods and debug symbols) skims through all the classes to
build up a superclass map up front.
The byte arrays are then processed sequentially as before, but the
detectors can now query the lint driver for class hierarchies.
A couple of lint checks are now taking advantage of this. For
eexample, the API checker can properly handle virtual methods where a
local class extends some other local (or library) class which
eventually extends an Android API class. (Until this checkin, only
classes directly extending an Android API class were supported).
Change-Id: I972172a61268dd2530979a93b2f289c1dcf94d63
|
|\ \ \
| |/ / |
|
| |/
| |
| |
| |
| |
| |
| | |
This changeset makes lint properly handle the jar dependency scope for
issues. It also tweaks the API in a few minor ways.
Change-Id: Ibd7b943c9d3ce361e091af8f1e990709bb94d183
|
|/
|
|
| |
Change-Id: I52662287ff86925629ea8f6f5bc13855d403b3e8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds support for suppressing in XML files:
(1) Lint will ignore errors found in attributes and elements if the
element (or any surrounding parent elements) specifies a
tools:ignore="id-list" attribute where the id-list matches the id
of the reported issue (or "all"). The "tools" prefix can be any
prefix bound to the namespace "http://schemas.android.com/tools"
(2) There's a new quickfix shown for XML lint warnings which offers to
add a lint suppress attribute for a given lint warning (setting
the id to the id of the warning, and adding the tools namespace
binding if necessary).
(3) The XML formatter now handles namespaces a bit better: after the
preferred attributes (id, name, style, layout params, etc) have
been handled, attributes are sorted by namespace prefix before
they are sorted by local name -- which effectively will sort any
new tools:ignore attributes to the end.
Change-Id: Id7474cde5665d9bd29bdd4e0d0cc89ed4d422aea
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds 3 new lint checks related to buttons:
(1) Order. This looks for "wrong" button orders, where either the
Cancel button is not on the left, or the OK button is not on the
right. (These are checked separately since it's possible to have
for example "Cancel | Send".)
(2) Case. This looks at OK and Cancel button labels and ensure
that they're using the "standard" capitalization - this
catches dialogs which use "CANCEL | ABORT" or "Cancel | Ok".
(Yes, lint found several existing cases of this!)
(3) Back. This looks for button with the label "Back" and warns to use
the Android-specific naviagation approach instead.
Change-Id: Ic0e4fe3a0347647fdba7c25d8e2290ec0e6bdd39
http://developer.android.com/design/building-blocks/dialogs.html
|
|
|
|
|
|
|
|
|
|
| |
It's better to use "ifRoom" instead. The check allows a menu to have a
couple of "always" items if there is also at least one "ifRoom" item
in the menu. In Java code, the lint check will complain if it finds
one or more references to MenuItem.SHOW_AS_ACTION_ALWAYS but no
references to SHOW_AS_ACTION_IF_ROOM.
Change-Id: Ib13f89920bd3919ffd7fc0f0137e90103e8850c3
|
|
|
|
| |
Change-Id: Ic08e20bf6d729362fae7d82c84e664e05b6ba843
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add a new flag, --showall, to turn off the abbreviation handling which
truncates long lists (such as all missing translation keys, or
additional resource locations).
In HTML reports, always include full location lists, but by default
hide them via a JavaScript reveal button. Also style buttons a bit
more holo-like.
Change-Id: I6e4ac7f910d1161981c48c7c4c766f03e650fdf6
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a quickfix for adding @TargetApi(N) for lint
warnings where API <N> required by the given access is too high for
the current min SDK.
It also tweaks the add annotation label format to be similar to the
regular javac one.
Change-Id: Ia38f94c58cb59ae0cdd2416c1d019c9e7174797b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset contains no semantic changes, just a couple of simple
refactorings:
(1) Rename the "Lint" class to "LintDriver". "Lint" is a bit generic
(there's already LintClient for example), and this object was
already referred to as a driver from various other API's, such as
Context.getDriver().
(2) Rename LintRunner in Eclipse to EclipseLintRunner, similar to the
other EclipseLintClient in the same package - and to avoid
confusion with LintDriver.
(3) Move all the lint fix inner classes inside the LintFix class out
as top level classes. The class was getting really large and
there's really no good reason to keep all the individual fixes as
inner classes; there's already a separate lint package for them.
Change-Id: Ifc0004bfb38f8e11e33e9ddc477b6cf07ca319f2
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a new marker resolution for adding @SuppressLint
annotation (or modifying an existing @SuppressLint) in the method,
field or class surrounding a lint warning. It searches up in scope
and adds one suggestion for each enclosing applicable scope.
This changeset also makes the suppress id's be case insensitive such
that a codestyle similar to the one used by @SuppressWarnings is
possible.
Change-Id: I0a6a80c4e2d526f1c8fc6aedd95674a25e6a22f0
|
|
|
|
| |
Change-Id: Ic49dc60284820ed01841a8fdbf09c4668e285169
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset makes various improvements to the Lint error report:
the styles are now in a separate stylesheet, and the default style is
Holo-like. Paths are handled better when linting multiple projects
such that the report title includes the root-relative project path,
and all filenames are then relative to the project root. The table of
contents is now a table, and includes error and warning icons.
Change-Id: I4e49f7b226bfa4d7b46e3a29e006fe78a504e9ef
|
|
|
|
|
|
|
| |
The @ApiTarget annotation lets you annotate classes, constructors
and methods with a temporary local version of a min sdk.
Change-Id: Ic9d166d45fde45f1c97e503cebf07d5ae0635c73
|
|
|
|
|
|
|
| |
This changeset adds support for suppressing lint warnings by
annotatating variable declarations, fields, methods and classes.
Change-Id: If274d65bccdc5c7d6426566c635245d6b3aae147
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds support for suppressing lint warnings by
annotatating classes and methods. (Finer granularity will be available
for Java source detectors, but does not work for byte code detectors
since those annotations disappear from the .class file).
It also rewrites two of the existing bytecode detectors to use the ASM
DOM instead of the old visitor pattern such that it can pass a
MethodNode to the Lint driver to check for suppress annotations.
While doing that I also make the field getter detector print the name
of the field that the getter call can be replaced with.
Change-Id: I8f7accb0219e6e9b3c499f16e7c0eb46853bbe04
|
|
|
|
|
|
|
|
| |
This changeset makes lint recognize when it's invoked in an Android
build environment, and if so locate the generated sources and bytecode
output locations automatically.
Change-Id: If217a49b7c7168cb762a36494d1aedbbb0fdbb6a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If you point the --html flag to a directory rather than a file (or to
a nonexistent file which does not have a file extension, such as
/tmp/lintoutput/) then lint will create a separate report for each
linted project and write each one into the export directory.
It also writes the project name into the report title.
(This changeset also performs some other cleanup to make delegating
HTML reporting easier now that it's done by the multi-project
exporter.)
Change-Id: I460e9fad5ae7176d066550f6193ba79a7668e416
|
|
|
|
|
|
|
| |
This changeset makes the lint driver able to process .jar files and
run the detectors on the classes inside.
Change-Id: Iaf7303197b953d6c6f925cdf83ad33a8ecd581a5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The Lint API specifies that columns should be 0-based (like line
numbers), but in a number of places this was not the case; it was
1-based instead (both in the detector code and in the output code,
which is why things looked okay). This changeset cleans this up such
that the columns are properly 0-based (and adds unit tests for it).
The Location API has a mechanism to search in the source code for
tokens, which is useful for bytecode detectors where we only have line
numbers. This changeset adds tokens to the API detectors such that it
identifies the corresponding method, class or field reference in the
source, not just the corresponding line. It also improves the pattern
search to also look backwards a few lines, since some bytecode
references appear a few lines later than the source code reference (at
the nearest executable code; this is the case for parameter local
variables for example).
Change-Id: I3adac20d5f0075e0a919be15dfb68658d5b7bb11
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This checkin hooks up the API check to lint, such that class
references, method calls and field access are checked with the
database and generates warnings if the project min SDK is lower than
that required by the API. It also checks layout references to ensure
that the widgets are supported by the minimum API.
NOTE: There's no flow analysis to avoid classes that are deliberately
accessing later APIs (and where the referencing class is loaded
conditionally). Therefore, for now the lint check is disabled by
default; enable with "lint --check NewApi".
Change-Id: Ia3160f81b45b5baed3caa46cdffe56735ebedd44
|
|
|
|
| |
Change-Id: I671fe960fe61afc80ec305e05f7ffe7cbb5933c5
|
|
|
|
|
|
|
| |
This allows lint detector code to load file resources bundled with the
tools (such as a permissions database file).
Change-Id: If740206e8e0c5feeaf0e908bf823135114c9bd0d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds support for multi-pass lint checking. A detector
can indicate that it is interested in a second pass through the source
code.
A good example of where this is needed is the Unused Resource
detector. In the first pass, it tracks declarations and references,
and at the end of the first pass it knows which resources are
unused. However, at this point it's too late to compute detailed
location information about each unused resource. Without multi-pass
checks, it would have to track detailed location information for *all*
resources, and computing locations can be costly.
With multi-pass support, it just computes the unused resource names in
the first pass, and then in the second pass it computes details about
the locations of those resources found to be unused.
This now includes *chained locations*. For example, for an unused
string, all the different translations of the unused string are
marked. These do not generate separate unused messages, it simply adds
to the location chain for the original unused warning.
This changeset also updates all the error reporters (text, HTML and
XML) to include all the locations, not just the ones with messages.
This changeset also cleans up the API a little: context classes now
track the lint runner instead of the lint client (which can point to
the lint client), and the SDK info lives with the project rather than
with the context.
Change-Id: I14ca3310bd1165b7dff655486157d770a36c4eff
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The lint check which suggests replacing root <FrameLayout>'s with a
<merge> tag was a bit simplistic. When the layout is used in a
ListView etc the replacement doesn't work.
This changeset limits the scenarios where the <FrameLayout> to <merge>
conversion suggestion is made to:
- Layouts that are <include>'ed from other layouts
- Layouts that are directly named in a setContentView() call
(This changeset also moves some code around to reuse the layout name
method from the DuplicateIdDetector and cleans up some constants)
Change-Id: Ic365f5ab2dc3cc7749ccab79f188a44829415802
|
|
|
|
| |
Change-Id: I2409950f2c8618148f2b7cfaf693672021b09633
|
|
|
|
| |
Change-Id: I6222f3ef2909174d9111dcfc037a2e74ad093acd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds Java AST support to Lint. There are new interfaces
for Java parser and specialized Java detectors. Java detectors can
either visit a full parse tree, or they can register interest in
specific methods, or Android resource references, or specific AST node
types -- or a combination of these. They will then be invoked during
an AST visit with the relevant info.
This changeset also rewrites the existing detectors that were using
String-based pattern checking on Java files to using real AST
traversal instead (and it removes the custom Eclipse-specific unused
resource detector since the plain one now does the same AST-based
analysis that the Eclipse one did.)
Change-Id: I4d85f8b785bf41a88dbb29e7017b9c0f588880bc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds support for library projects to lint. Lint now
checks all the library projects for errors as well, and projects that
depend on global analysis (such as the unused resource detector) will
properly handle resource declarations and references across projects.
This changeset also cleans up the multi-project handling for the Lint
window in Eclipse. The "Run Lint" toolbar action, in addition to
operating on multiple selection, now has a dropdown menu for choosing
which projects to check (and there are also actions for checking all
projects, the current file, and clearing markers). Running lint on a
project will also automatically include dependent library projects.
Finally, some misc UI improvements: The Lint preference dialog
includes buttons for quickly enabling and disabling all the checks;
the Lint View includes a Project column which is shown when more than
one project is checked, and the file and linenumber columns are now
blank when the location does not correspond to a specific file.
Change-Id: I733f5258102dfb0aebbc2b75cb02b9ba6ef974e8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset fixes issue
23747: i and İ character problem in turkish operating Systems...
and probably many other bugs in the Turkish locale.
Basically, we had a lot of String.toLowerCase() and
String.toUpperCase() calls. This performs locale sensitive
conversions, which in many cases is NOT what we want; for "machine
readable" conversions we should be using Locale.US which performs no
special cases.
For more, see
http://developer.android.com/reference/java/util/Locale.html#default_locale
Change-Id: I996b0e70fb377e8dae484c5811deb8bc9afb684c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset makes the SDK codebase compile with source=1.6 (which
means it also requires JDK 6). This means that methods implementing an
interface requires @Override's. It also means we can start using APIs
like the ArrayDeque class and methods like String#isEmpty().
This changeset looks big but the change is trivial: it's basically
adding @Override in all the places that need it, along with some other
automatic Eclipse cleanup in certain files (such as reordering imports
where they were incorrectly ordered (because older versions of Eclipse
didn't always handle inner classes right)), as well as cleaning up
trailing whitespace and removing some $NON-NLS-1$ markers on lines
where there aren't any string literals anymore.
This changeset also sets the source and target JDK level to 6 in the
Eclipse compiler .settings file, and synchronizes this file to all the
other Eclipse SDK projects.
Change-Id: I6a9585aa44c3dee9a5c00739ab22fbdbcb9f8275
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset fixes this issue:
http://code.google.com/p/android/issues/detail?id=23214
The icon detector makes sure that if an icon appears in a given -dpi
folder, it appears in all the other -dpi folders as well (except for
-nodpi). However, in the set comparison it would use the full filename
(including file extension), which is not correct since it's okay to
have an .9.png in one folder and a .gif in another (and as reported in
this bug, an .xml file).
This changeset also associates a file location with folder warnings
for a missing density folder (it uses the res folder), which made
various unit tests need updates since the results sort differently.
Change-Id: I7f09772f3a54683a9d0c5c5d93ae2499707f533a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a new layout rule which finds cases where
you have RelativeLayout attributes pointing to id names that do
not exist, such as
layout_alignLeft="@+id/navbar"
The +id/ syntax here creates the id on the fly, so aapt does not
complain, but the new lint rule makes sure that at least one layout
actually defines this id as its id.
If no match is found, it looks for spelling mistakes and suggests
other similar ids in the error message.
This condition is flagged as an error. The detector also issues a
related warning if it finds an id reference that is not defined in the
same layout. This is sometimes okay (where you have deliberately
referred to an element which will be included into this layout, or is
in a layout including this one), but it's usually an accident.
Change-Id: I7f3fa6f4cb5cef6dcd307256050fb9580887addd
|
|
|
|
| |
Change-Id: Idc81f7a2d033675a03209eeabda0216babc35ebe
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds the Guava library to ADT and lint. (It is also a
prerequisite for the Lombok AST library which is added by a later CL.)
This changeset also uses the library in a few simple ways: It replaces
some custom I/O and collections code with calls into the equivalent
Guava methods, and it also adds the @Beta annotation on the various
"API" classes which are not yet stable.
Change-Id: I2f50febfa075c32818404e888578a2e1e447d408
|
|
|
|
| |
Change-Id: Ifcc1d88dabb07dc05b2e5c934743ad52f9b6dc1d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset fixes a bunch of issues in the infrastructure:
(1) It cleans up the Context class quite a bit. It had some hardcoded
XML stuff in it, which is now in a separate XmlContext class (and
there will be a JavaContext class in the Java support CL).
It also hides a bunch of public fields, cleans up some unused
stuff, and introduces a couple of wrapper methods to make detector
code cleaner; in particular, rather than calling
context.client.report(context, ...
you can now just call
context.report(...
and similarly there are wrappers for logging and checking for
disabled issues.
(2) The IParser interface is renamed to IDomParser since in the next
CL there will also be an IJavaParser. Some other related cleanup.
(3) There is now a "Location.Handle" interface. This allows detectors
to create light-weight location holders, and later on call
handle.resolve() to create a full-fledged Location. This is useful
when detectors don't yet know whether they'll need a location for
a node, but want to store it for later in case they do. As an
example, the unused resource detector creates location handles for
declaration and only resolves full locations for those that are
found to be unused.
Locations can now carry custom messages. For example, for a
duplicate id error, the secondary location now contains a
"original declaration here" message. And the CLI and HTML reports
now include alternate locations in the output.
Some other location cleanup too; using factory methods to make the
code cleaner, some default implementations that can be shared,
etc.
(4) There's a new SDK info class intended to provide SDK information
from a tool client (such as resource resolution). It currently
just contains parent-view information, used for the
ObsoleteLayoutParams detector and an upcoming CL for a
ViewTypeDetector.
(5) The Detector class now provides dummy implementations for the
inner-interfaces, so we no longer need the adapter classes. This
makes it easy to implement the XmlScanner or JavaScanner
interfaces without needing to also stub out a bunch of methods.
Change-Id: I4b3aaabe51febb25b000f9086703653bea6cf7c9
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add gcc-style flags -w, -Wall and -Werror, and javac-style --nowarn
(identical to -w) to turn off warnings (only check for errors), enable
all warnings, and to turn all warnings into errors respectively.
Also cleans up the print-usage code a little bit such that the format
is nicer: the arguments all appear on the left and the explanations
are all aligned on the right.
Change-Id: I247f9e81ebe5322c7b19af2f043c7a82133c18a1
|