aboutsummaryrefslogtreecommitdiffstats
path: root/lint/cli
Commit message (Collapse)AuthorAgeFilesLines
* 38838: lint -fullpaths doesn't always workTor Norbye2012-11-021-0/+60
| | | | Change-Id: I09500947973897b412b61da17284f04acb8ece20
* Update compiler flags.Tor Norbye2012-10-261-2/+2
| | | | | | | | | | Turns off the ability to use @SuppressWarnings with optional errors is available, but off by default (see Eclipse issue 392875). This turns that off, makes missing enums in switch statements a warning, and synchronizes the settings file to all projects (except tests.) Change-Id: Iad7060523b6ee2cbbca97e0a6ffedb264b185222
* Update maven artifacts and add lint.Xavier Ducrohet2012-10-191-0/+85
| | | | | | | | | Updated the groupId of most artifacts to be more reflective of their sub-projects status in the SDK tools. Added lint artifacts. Change-Id: I900a165647a9b7d3c55b473f63c4ca4469762d7b
* Misc improvements to the multi-configuration editingTor Norbye2012-10-151-42/+3
| | | | | | | | | | | | | * Fix bug in switching to preview configurations * Don't draw drop shadows for thumbnails in Dialog themes * Move the preview title labels to sit above each preview thumbnail * Make error thumbnails include rendering error messages (and wrap if necessary), plus tweak appearance * Make switch animation show rectangles animating in both directions Change-Id: I0995617fa277b48419a88c5203abf5b1d49af711
* Code cleanupTor Norbye2012-09-172-4/+4
| | | | | | Replace "this.mFoo = foo" with just "mFoo = foo". Change-Id: I44d537ebb62cd7e5c8493a0b50dcb527cd20f91c
* Constants refactoring.Tor Norbye2012-09-133-6/+6
| | | | | | | | | | | | | | | | This changeset moves most constants into the SdkConstants class, and gets rid of AndroidConstants and LintConstants. It also migrates all non-ADT specific constants from AdtConstants into SdkConstants. It furthermore moves various other constants (such as those in XmlUtils and ValuesDescriptors) into the constants class. It also fixes the modifier order to be the canonical modifier order (JLS 8.x). Finally, it removes redundancy and combines various constant aliases such that we don't have both NAME_ATTR and ATTR_NAME pointing to "name", etc. Change-Id: Ifd1755016f62ce2dd80e5c76130d6de4b0e32161
* Add lint flag for setting a custom library pathTor Norbye2012-09-111-5/+34
| | | | Change-Id: Ie36bcb31be87a7cd16ab1b958c0264ca8b51e385
* Don't report unused resources in projects with errorsTor Norbye2012-09-101-1/+3
| | | | | | | | | | | | | | | | | | | If a project contains errors in the source code, lint won't be able to parse the source code, and in that case it might draw the wrong conclusions about unused resources. This can also happen if there's an actual bug in the Java parser, which is sometimes the case; see for example http://code.google.com/p/projectlombok/issues/detail?id=415 http://code.google.com/p/projectlombok/issues/detail?id=311 In both cases, when we encounter a failure to parse a Java file, we record the fact that not all Java files were properly processed, and rules, such as the UnusedResource detector, can (and now does) use this to for example skip reporting unused resources in this case since it is operating with incomplete data. Change-Id: I00991c10d05965ce151fb0dd322f32229dcd12cd
* Also check SimpleDateFormat calls for explicit localeTor Norbye2012-08-301-1/+1
| | | | | | | | | | | This changeset expands on the lint check for calling String convenience methods that are locale sensitive without an explicit locale (issue 36822). It checks whether a SimpleDateFormat constructor that uses the default locale is called, and if so suggests either specifying a locale or using one of the pre-configured locale sensitive instances of SimpleDateFormat. Change-Id: Ic4fcb72c2ee6b31d1534b4d909493fef7dcff867
* Update Guava from 10.0.1 to 13.0.1Tor Norbye2012-08-292-2/+2
| | | | Change-Id: Ia51e3e2280c3d360496550df50a540571b9b7582
* Merge "Use simple markup for bold and monospace in lint issues"Tor Norbye2012-08-272-7/+10
|\
| * Use simple markup for bold and monospace in lint issuesTor Norbye2012-08-232-7/+10
| | | | | | | | | | | | | | | | | | The explanation text for issues can now contain some simple markup such as * around sentences for bold and ` for monospace. In the HTML report this is converted to HTML markup using <b> and <code> spans, as well as <a> for http:// links. Change-Id: I875a55a0ab9a61c2e8bb493ad94d5e4d51dd1072
* | Merge "Warn about non-recent targetSdkVersions"Tor Norbye2012-08-273-6/+8
|\ \ | |/
| * Warn about non-recent targetSdkVersionsTor Norbye2012-08-233-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset changes the default targetSdkVersion written into new projects from being hardcoded to "15" to being the same level as the build target's API level. It also adds a new lint check which looks at the targetSdkVersion and complains if it's not the same as the highest known version (currently 16). The issue explanation points to the javadocs for the android.os.Build.VERSION_CODES class for details on how to upgrade the app. Change-Id: I00c2bd7cd8fa239b9fd1de9b2d35ff9faf87d25f
* | Merge "Lint: Include "Return to top" in HTML reports"Tor Norbye2012-08-272-5/+37
|\ \ | |/ |/|
| * Lint: Include "Return to top" in HTML reportsMarius Volkhart2012-07-222-5/+37
| | | | | | | | | | | | | | | | When categories and ids are clicked the page will return to the top. Added formatting to CSS to maintain consistency. There is currently no way of returning to top. Change-Id: I539138c90a6ef3e7f4b7095190a307f8266fb0bf
* | Preserve fatal severity for Lint XML reportsTor Norbye2012-08-222-7/+9
| | | | | | | | | | | | | | | | | | | | The Lint CLI does not distinguish between errors and fatal errors in the error output. However, changing the severity was happening when the issue was reported rather in the output reporter itself, which meant that it accidentally changed the severity in the XML report, where all metadata should be preserved. Change-Id: Ib3ee9a20a7b1d2413ed85e1952f5f3d1783a8826
* | Refactor common.jarXavier Ducrohet2012-08-072-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move resources and com.android.util.Pair into layoutlib_api where they belong since layoutlib depends on them and we need to control the API. Made a copy of Pair to stay in common.jar but moved it to com.android.utils.Pair (the one in com.android.util.Pair is marked as deprecated to prevent usage where applicable). Also moved XmlUtil and PositionXmlParser to com.android.utils to match Pair. Change-Id: I21d7057d3f2ce604f86a3bb1fa3c130948c93b89
* | Update lint unit test golden files to contain more detailsTor Norbye2012-08-061-22/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The lint golden files was using a custom unit test reporter which wrote out the test strings in alphabetical order. However, this output was missing some information such as the actual source lines containing the error and the particular error range underlined, which the CLI prints. This changeset replaces the unit test reporter with the CLI one, which not only has the benefit of providing more details in the unit tests (which for example shows that bytecode based issues correctly identify the right source level range), but it also tests the CLI reporter itself such as its sorting. Other than a minor fix to handling \r's in the CLI error output, this changeset does not contain any changes to any of the lint detectors, it just updates the golden files. Change-Id: Iae8f13a47efe6ba5e5cfd84af0dd548f78513879
* | Merge "Allow lint cli --sources to specify a path, and use from ant lint"Tor Norbye2012-08-061-21/+27
|\ \
| * | Allow lint cli --sources to specify a path, and use from ant lintTor Norbye2012-08-061-21/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | First, this changeset allows the arguments passed to --sources and --classpath (renamed from --classes) to specify not just a directory, but to specify a path as well. This might make it easier to invoke lint from scripts if you have a path variable, so you don't have to split it into multiple arguments. Second, it makes the lint task in ant use these, such that any build.xml customizations to the source paths or class paths are automatically used rather than relying on lint's default structure check. Change-Id: Id8e4caf0010d7fd7245844b3099b5dc0607f0aba
* | | Add support for additional languages in the typo detectorTor Norbye2012-08-031-2/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This checkin adds typo databases for six additional languages, as well as several fixes to the infrastructure. First, it now supports "globbing", since for example the German typo database contains glob patterns of the form "asymetrisch*->asymmetrisch*". Second, it supports multiword typos (such as "all zu->allzu") which caused some complications (since this means that the typo detector can match beyond the word boundary it was passed in). Third, it adds a bunch of validation code to the type dictionaries, which uncovered a bunch of inconsistencies (duplicate entries, using "-" instead of "->" for some separators, etc). There's now a unit test which produces a cleaned up version of each dictionary file, as well as tests to ensure that the ASCII and the UTF-8 comparison methods are in sync (and this uncovered some bugs which were fixed.) Finally, it fixes the HTML reporter such that it properly handles UTF-8. Change-Id: Ie32cbbe489687a7b50184696a027f87c2e21c409
* | Merge "Allow custom source and class folders"Tor Norbye2012-08-021-0/+82
|\ \
| * | Allow custom source and class foldersTor Norbye2012-08-021-0/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Maven places the source files and class files in different locations than our default Eclipse and ant build systems. This changeset adds --sources and --classes arguments to the lint CLI to allow a build script to point to these custom locations. It also also looks in Maven's default location if it doesn't find the normal bin/classes/ folder such that out of the box it might just work even in Maven projects. Change-Id: Ia91b05f0fc9d2c7e504c962d2e794c768085754c
* | | Include additional metadata in the XML reportTor Norbye2012-08-022-10/+56
|/ / | | | | | | | | | | | | | | | | | | | | | | This CL adds additional metadata into the lint XML report, such as the full issue explanation, the issue priority, the issue summary, the additional information URL, and the error line. This allows for example the Jenkins plugin to provide all this information for a build report without having to bundle a (possibly out of date) snapshot of lint's metadata the way it does right now. Change-Id: Iaf674ffa6bbef318ce3f636404d72c74de4b1c50
* | Fix lint-on-save for .class file detectors in Java filesTor Norbye2012-08-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset fixes the lint-on-save behavior in Java files such that the classfile based checks are run after the .class files are up to date. It also makes lint-on-save work when Project > Build Automatically is turned off, by adding a new resource listener, and it modifies the IFileListener interface to make resource listening more efficient; in particular, it passes the flag mask such that listeners can ignore events such as markers getting added or removed from a file without the content changing. It also makes some improvements to the lint infrastructure. First, it adds an indirection in the LintClient such that reading bytes from files can be customized by the client (to for example add caching or to read contents from memory not yet flushed to disk). It also allows inner classes to share the contents of the source file between each context (while debugging the above I noticed that each inner class node had its own class context and therefore would re-read the source file repeatedly.) Change-Id: Ib9572cebe1269fe05c3af1369610525ea3b44061
* | Add lint target for antTor Norbye2012-07-233-16/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running "ant lint" will now run lint on the project, and dump out the errors to the console as well as also export the errors to lint.xml and lint.html int the bin/ directory. This changeset also modifies the lint CLI to allow multiple simultaneous result reporters - so you don't have to run lint twice in order to get both an .xml and an .html report for example (which is useful when you're running lint on a continuous integration server, and you want the .xml file for the lint plugin trend graph and the html file as a user readable report to click through to from the build page.) Change-Id: Idf8f3f5de0857eb9e7180267a066ae933640682d
* | Tweaks to the lint CLI offsetsTor Norbye2012-07-231-1/+17
| | | | | | | | Change-Id: I20592372d41235b36227a0d36014d77c23c7fc58
* | Add basic flow analysis support to lintTor Norbye2012-07-233-1/+3
|/ | | | | | | | | | | This changeset adds in the ASM analysis library (an optional part of the ASM package lint is already using to process bytecode). It also adds some basic flow analysis to the SecureRandom detector to detect whether a given dispatch to a field of type java.util.Random is actually pointing to a java.security.SecureRandom, in which case it flags calls on it to setSeed() where the argument is a fixed integer. Change-Id: If85ab9f8db0e801a01f1a3ea845865b4f98e259c
* Bump up available memory to lint cliTor Norbye2012-07-162-2/+2
| | | | | | | | | | | | The lint cli can require a lot of memory when it's run on a large directory full of project, since it accumulates all the errors as well as source contents in order to be able to sort them and to emit source code snippets in the HTML report. The default of 256 Mb isn't always enough, so bump it up a bit. For more, see http://code.google.com/p/android/issues/detail?id=34734 Change-Id: Ib7f0fd7a5a2d149221a43bb47490b44b46d39de0
* Fix lint attribute positions in the CLITor Norbye2012-07-021-1/+1
| | | | Change-Id: I795a93b5d4b3041ba9892d5d3eb226de1873a88c
* Add typo detectorTor Norbye2012-06-221-1/+12
| | | | | | | | | | | This changeset adds a new typo detector. There are also some lint infrastructure fixes to better handle positions within text nodes, and to allow Eclipse lint quickfixes to supply multiple fixes for a single issue (such as multiple misspelling alternative replacements.) Change-Id: Ie26f0bafc571e02ae09ff27a7f4b221fe0c2ea5b
* Fix warningsTor Norbye2012-06-013-7/+12
| | | | | | | | | | | | | | | | | First, update our various project-specific Eclipse compiler settings configuration files to include the new Eclipse 4 flags. Second, turn off the "Unchecked conversion from non-annotated type to @NonNull" warnings; there are hundreds or thousands of these, and there isn't much we can do about them when they're coming from platform and library APIs. Third, make the lint projects warning-clean again by addressing various warnings Eclipse found (such as some unclosed resources and some null handling issues; yesterday's null annotation fixes only addressed errors, not warnings.) Change-Id: If75f7401a1cbeef1bf58b47ccaa9ad17bede7f91
* Fix nullness annotationsTor Norbye2012-05-303-28/+49
| | | | | | | | | | | | | | | | | | | Eclipse 4.2 includes analysis support for @Nullable and @NonNull annotations. However, it requires these annotations to be *repeated* on every single method implementing or overriding a superclass or interface method (!). This changeset basically applies the quickfixes to inline these annotations. It also changes the retention of our nullness annotations from source to class, since without this Eclipse believes that a @NonNull annotation downstream is a redefinition of a @Nullable annotation. Finally, the null analysis revealed a dozen or so places where the nullness annotation was either wrong, or some null checking on parameters or return values needed to be done. Change-Id: I43b4e56e2d025a8a4c92a8873f55c13cdbc4c1cb
* Dynamically link Guava and ASM in lint jarsTor Norbye2012-03-191-2/+1
| | | | | | | | | | 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
* Misc Lint FixesTor Norbye2012-03-066-38/+105
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Change lint error codes + Windows path fixes.Raphael2012-03-062-30/+118
| | | | | | | | | | | | | - 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
* Fix configuration information for library projectsTor Norbye2012-02-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix SuppressLint annotations in outer classesTor Norbye2012-02-241-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Lint bug fixesTor Norbye2012-02-241-10/+2
| | | | | | | | | | | | | | | | | 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
* Merge "Use lint error mechanism for config issues like no classes found"Tor Norbye2012-02-211-1/+6
|\
| * Use lint error mechanism for config issues like no classes foundTor Norbye2012-02-211-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix lint library project configuration handlingTor Norbye2012-02-212-1/+3
|/ | | | | | | | | | | | 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
* Fix for lint cli relative output pathsTor Norbye2012-02-141-1/+4
| | | | Change-Id: I4e37e68661007a825c97948e6258201babcd2b79
* Add Fatal severityTor Norbye2012-02-133-4/+9
| | | | | | | | | | | | | | 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
* Make lint process Java jar dependenciesTor Norbye2012-02-133-1/+28
| | | | | | | 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
* Add support for suppressing lint via XML attributesTor Norbye2012-02-061-3/+12
| | | | | | | | | | | | | | | | | | | | | | | 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
* HTML report tweaksTor Norbye2012-02-063-53/+58
| | | | | | | | | | | | | | | | | | - 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
* Fix type in Java parser interfaceTor Norbye2012-02-031-2/+1
| | | | Change-Id: Ic08e20bf6d729362fae7d82c84e664e05b6ba843
* Include .9.png files in HTML reportTor Norbye2012-02-031-2/+1
| | | | Change-Id: Ib7b8914f05849db49dd9f25349be08e67eb7264d