| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
| |
The Makefiles for the lint, lint_api and lint_check libraries were
*statically* linking in the Guava and ASM libraries. This made them
much larger than necessary (~1.6M instead of ~100K), and for no good
reason since the classes were already on the classpath, and of course
this duplicates them repeatedly.
Change-Id: Iec3ed623429ab8b7b8ba78f5d7a069853ae665c3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset contains fixes for several unrelated reported lint
bugs:
26505: Default disabled rules that are explicitly enabled do not
activate
26467: Lint says ByteBuffer.array is API 9+ but it's really API 1+
26501: Warning "This tag and its children can be replaced by one
<TextView/> and a compound drawable" is not always correct
(Partially fixed)
It also fixes the following bugs:
- The quickfix for the typography detector did not work for the
fraction warning (replacing 1/2 with the half unicode symbol etc)
- A couple of XML detectors did not check for SuppressLint on the
associated root node
- Add a --exitcode flag, and only set the exit code to non-zero if
that flag is specified. Also fix the code such that non-fatal errors
also contribute to the exit code.
- Make the HTML reporter classes public to help Maven integration.
Change-Id: I60f5fdcb2a465d51fa58bb918a195b373096d54b
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Make returns codes be positive (1..5).
- Explain return codes in the usage help.
- Support either env var or system properties for bindir.
- Add support for a workdir property/envvar that is set by
lint.bat with the original invocation directory.
- Use workdir to solve relative input/output argument paths
(on windows we cd to the lint.bat location and record the
original path in workdir.)
Change-Id: I8b2583de761ce9c4ebba250460de6c60f1ea6a84
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset fixes one more bug related to lint configurations and
library projects (see issue 26029).
Some lint checks, such as the MergeRootFrameLayoutDetector, computes
the warnings at the end of processing all files. At that point, the
context points to the master project, so any errors which were
actually found in a library project will instead be using the master
project's configuration. That means that any suppress rules applies to
the lint.xml in the library project will be ignored.
This changeset fixes this by moving the logic which looks up the
severity for a warning out of the lint clients and into the
context. Now it checks the current projects being scanned and looks up
the corresponding project for each file (based on the file prefix),
and retrieves the configuration that way.
This changeset also makes one more fix: It now consults *both* the
library project *and* the master project to see if a rule should be
ignored. This means that if you turn off a given check in your master
project, you will no longer see those warnings from library projects
either, which seems desirable.
Change-Id: Icb5cdf7696b4908b0553f86896793515cb06f29c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset makes @SuppressLint work for classfile based detectors
when the error is found in an inner class and the SuppressLint
annotations is on an outer class.
Innerclasses are actually separate classes from their outer classes,
so they are processed separately (each .class file is read and
analyzed independently).
This changeset processes the class files in alphabetical* order such
that it can maintain a stack of outerclasses when processing a
class. The suppress lint check can then visit the outer class'
annotations to see if the error should be suppressed. (*: The order
isn't exactly alphabetical: We want Foo$Bar.class to come after
Foo.class)
This changeset also tweaks the Add Annotation quickfix such that it
only offers per-method or per-class annotations, since class files do
not maintain annotation info for other granularities (such as on
variable declarations, so you cannot suppress classfile based issues
with annotations there.) We could make a lint check which ensures that
you don't try to put these annotations there :-)
(This is related to issue http://b.android.com/25948)
Change-Id: Ia9dbc39b1adc73a1b60e375edbf9b5618c7d2353
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset fixes a couple of Lint bugs:
(1) Handle BOMs (byte order marks) in Java files. We already handle
this for XML files (where it's common) but these can be present in
other file types as well, such as Java.
See http://code.google.com/p/android/issues/detail?id=25952
(2) Fix a bug (false positive) in the FloatMath detector; the visitor
approach can get confused; do simple ASM node iteration instead
(which is how all the other detectors work; this detector was
written before we had the ASM DOM model)
Change-Id: I65b4e6cd8d8e6c7e591433d8eb5aedf273e2caad
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If Lint cannot find the .class files for a project, it cannot run any
of the class-file based checks (such as the NewApi check).
This changeset adds a new category and issue id, "Lint Error", for
these types of issues. In HTML reports, these errors are listed at the
top. The issue explanation states that these errors don't represent
bugs in the user's code, but that lint was not able to check certain
things for the reasons given.
In the case of no .class files found, it asks whether the project
needs to be built first. It also uses these lint errors to emit
errors in processing lint.xml configuration files.
(Note that if you don't want to see these types of errors, you can
suppress it via --disable LintError.)
Change-Id: Ifc2f55566f3a0cd20189d43e4205201bc21ee280
|
|/
|
|
|
|
|
|
|
|
|
|
| |
A lint.xml file in a library project should be able to suppress lint
errors in that project. This changeset fixes a couple of bugs which
prevented this from working: In Eclipse, the configuration was cached,
which meant a single lint run through multiple projects would just use
the configuration of the first encountered project. And from the
command line driver, the code to handle --check handling would
override configuration severity in one scenario.
Change-Id: Ib08e2b14582ab53e5ab89244738d1bd77839610e
|
|
|
|
| |
Change-Id: I4e37e68661007a825c97948e6258201babcd2b79
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 makes lint properly handle the jar dependency scope for
issues. It also tweaks the API in a few minor ways.
Change-Id: Ibd7b943c9d3ce361e091af8f1e990709bb94d183
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- If specifying a report directory (rather than an HTML file name),
always write out an overview report. (Before this it only wrote an
overview report if issues were *found* in multiple projects).
- If checking *specific* issues (with the --check flag), don't write out
the list of suppressed issues.
- If no errors were found, write a message to that effect.
- Make some space between the explanation area and the More Info URL,
if any
- Code cleanup
Change-Id: I0c1a5cf14de15276904e8999323df443fc39dc9c
|
|
|
|
| |
Change-Id: Ic08e20bf6d729362fae7d82c84e664e05b6ba843
|
|
|
|
| |
Change-Id: Ib7b8914f05849db49dd9f25349be08e67eb7264d
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
First, include the suppress help as a section in the bottom of the
HTML report, and link to it from each issue explanation.
Second, tweak the generated HTML and CSS a bit: Fix <a> element
generation to be properly closed (which avoids issue where the first
link in each location list did not have the right style), make links
in the More Info have a blue color to stand out more, and add a Holo
like gradient in the background color for browsers that support it.
Change-Id: I3078cb1f1a5112dc6360816c4a6a6c37771ab6fc
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
Change-Id: Ia9dd344a8b12a8bce479aa19fed6c876c86b7b0c
|
|
|
|
| |
Change-Id: Ie00cb9e23098676db021d6cc4d2f3d99a5362dbc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
Change-Id: I14e997d4fb7a38a15b764d195c001506c6b73c6c
|
|
|
|
| |
Change-Id: I706443006cd6164718428cd1c6909303acda81dc
|
|
|
|
| |
Change-Id: I1e03d928e6abe306a6a861cbf80b896cb5cd864e
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
Change-Id: I2bf31a95fbb9835912df06eb9319820668019aeb
|
|
|
|
|
|
|
|
|
|
|
| |
If lint writes out multiple HTML reports (e.g. when specifying a directory to the --html flag), and
there are more projects than just one, write an overview doc which contains a table of all the
projects and the corresponding error and warning counts in decreasing order, with links to
the individual reports.
Also ensure that there are no case-insensitive filename clashes.
Change-Id: I4dcda14a625863e71022734088a027fc8ac357d0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|\ |
|
| |
| |
| |
| | |
Change-Id: Ic4131738e505861c8308f386c2673d9ee304f158
|
|/
|
|
| |
Change-Id: I671fe960fe61afc80ec305e05f7ffe7cbb5933c5
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
First, stop reporting Java-related parser errors as lint
errors. Lombok fails to parse a few files (see
http://code.google.com/p/projectlombok/issues/detail?id=311) and even
when it fails, the error messages aren't useful (see
http://code.google.com/p/projectlombok/issues/detail?id=313).
Second, the XML parser could throw an exception in some circumstances,
because it passes invalid column numbers at the end of the file. This
CL guards against that (and against any other potential errors by
wrapping all exceptions during parsing as a SAXEception).
Finally, fix the positions reported in text nodes for the ExtraText
check such that it points to the line containing the extra text, not
the beginning of the text node (which is frequently the previous
line).
Change-Id: I9630ea49d30d8afdc8bd9cf2c87ca0a0306b8ec5
|
|/
|
|
|
|
|
| |
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
|
|
|
|
| |
Change-Id: If271640953f7226ef1c03b28dd679dee34f03799
|
|
|
|
|
|
|
| |
Fix typo in the comparator code. This fixes issue
24297: lint may fail in jdk1.7 (comparison method violation)
Change-Id: I0d46c0810e28ea0493549c95e3c6f2ac88519e1c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|/
|
|
| |
Change-Id: Ica0de61c68f275b8847c79feb401ce6d9bb9960d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The XML DOM parser used by the lint CLI driver (which tracks
positions) is needed outside of lint, so pull it out of the lint/cli
project, and refactor it such that it does not directly reference the
lint Position APIs (but can utilize them when subclassed in lint).
In addition, handle non-UTF-8 file encodings. XML files can be encoded
in other character sets, and can specify this via the encoding
attribute in the XML prologue. Until now, the CLI lint runner would
just read the XML file contents in using the default encoding and
parse this. Now there's a new utility method which takes a byte[] and
infers the desired encoding and uses that to convert the byte[] into a
string using the correct encoding. (We can't just pass an InputStream
and let the SAX parser handle this on its own because the XML parser
needs to access the character stream in order to assign correct node
offsets.) This code now also handles the byte order mark more
cleanly.
There are some new unit tests too to check the new encoding, BOM and
offset handling.
Change-Id: Ib0badbbe72172e3408c6d5af2413be51280a7724
|
|
|
|
|
|
|
|
|
|
|
|
| |
This new lint check looks for XML text content in resource files where
text is not expected, such as layout files. This is typically the
result of a typo.
This CL also improves the command line XML parser's position handling
such that it can handle positions on text nodes (until now it just
supported element and attribute positions), and similarly for Eclipse.
Change-Id: I6f69a8dc725a5b5b19f8ad5bb889ae25ee82600a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a new @NonNull annotation, to match our existing
@Nullable annotation, and it adds configuration settings for Eclipse
3.8 / Eclipse 4.2 which configures the new null analysis there to use
our own annotations. Note that the annotations only have source
retention so there is no extra size or class-loading overhead. (To use
findbugs you'll need to temporarily change retention to class-level.)
In upcoming CL's I'll use these annotations to clarify the Lint API
and other APIs.
Change-Id: I99096d8b8a7e25ef002624d592da7700195a5872
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
| |
Lint's cli parser would throw an exception if handling a file that has
\r's without correspoding \n's. This changeset fixes that.
This addresses issue 22925: Lint: StringIndexOutOfBoundsException when
reading xml files containing incorrect line endings
Change-Id: I68c134e15d148f6f0bbcd477ec37b0fd2e70f0c0
|
|
|
|
|
|
|
|
|
| |
The Lint CLI driver stashes file contents (used to show code snippets
with the errors). However, for repeated errors in the same file this
could lead to a lot of extra memory usage (and OOM for large code
bases). This adds a file cache for the CLI driver.
Change-Id: Icfbca31457a6cf0b33c89a5ffd04b5079f8fed09
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|