aboutsummaryrefslogtreecommitdiffstats
path: root/lint/libs/lint_checks/src/com/android
Commit message (Collapse)AuthorAgeFilesLines
...
* Warn when there are more uses sdk elements than oneTor Norbye2012-02-142-5/+50
| | | | Change-Id: Iecad10d5c33f6b7649e686633c9ff9f5541e9799
* Add Java performance lint checksTor Norbye2012-02-1312-12/+460
| | | | | | | | | | | | | | | | | | | | This changeset adds two new checks for Java performance suggestions: (1) It identifies object allocation within draw methods (onDraw(Canvas)) and warns that it's a bad idea. It also looks for certain factory methods, such as Bitmap.createBitmap(), which have the same issue. The lint detector also checks to make sure that the allocation isn't part of lazy initialization: if the return value is stored into a field, it checks that the allocation is surrounded by a null check on that field. (2) It identifies usages of HashMap<Integer, X> and suggests replacing it with SparseArray (or SparseIntArray or SparseBooleanArray, depending on the second type variable of the map initialization). Change-Id: I3bcbb182404b1eeaaa8c9e5209d889694d88f216
* Merge "Add per-node ignore handling for more lint checks"Tor Norbye2012-02-131-8/+16
|\
| * Add per-node ignore handling for more lint checksTor Norbye2012-02-131-8/+16
| | | | | | | | | | | | | | | | | | | | | | A handful of lint checks still don't support per-node suppress checking (because the computation does not have node information at the time when the final warnigns are produced). This checkin uses the new location client data facility to add scope checking for a few more of the lint checks. Change-Id: I0ca48e91441dcd753834ad4777959f728b74ac71
* | Merge "Add Fatal severity"Tor Norbye2012-02-136-6/+6
|\ \ | |/
| * Add Fatal severityTor Norbye2012-02-136-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Add namespace-typo detector"Tor Norbye2012-02-132-0/+96
|\ \ | |/ |/|
| * Add namespace-typo detectorTor Norbye2012-02-132-0/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Add superclass support to LintTor Norbye2012-02-133-47/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Make lint process Java jar dependenciesTor Norbye2012-02-132-1/+2
|/ | | | | | | 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
* Merge "Lint detector warning about missing <uses-sdk> min or target SDK ↵Tor Norbye2012-02-072-4/+57
|\ | | | | | | settings"
| * Lint detector warning about missing <uses-sdk> min or target SDK settingsTor Norbye2012-02-072-4/+57
| | | | | | | | Change-Id: I9401318afe771d11ef6f211ee3f9cb6c62df8f83
* | Merge "Make the lint string-format check ignore date strings"Tor Norbye2012-02-071-46/+157
|\ \
| * | Make the lint string-format check ignore date stringsTor Norbye2012-02-071-46/+157
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The string format lint check might be processing strings not intended for String.format (but intended for example for android.text.format.Time#format), in which case it will be wrong about whether two conversions are incompatible. (This does not fix all scenarios; if a date string looks like a String.format in the sense that all of its formatting characters are defined by String.format then the string will assume to be intended for String.format.) This changeset attempts to recognize this, and also make the "is incompatible" check a bit more nuanced: it will now consider "d" compatible with "x" for example. Change-Id: I63ce082f40169e4033809d25cae3cf116c9e2044
* | Merge "Suppress UselessLeaf warnings for root layouts"Tor Norbye2012-02-071-0/+5
|\ \
| * | Suppress UselessLeaf warnings for root layoutsTor Norbye2012-02-071-0/+5
| |/ | | | | | | Change-Id: I997ad6f1348e9884b56a60ef453cd02754c936bb
* | Make ButtonOrder lint rule consider minSdk and targetSdk and v14Tor Norbye2012-02-071-43/+96
|/ | | | | | | | | | | | | | | | This changeset enables the button order check by default, and makes the rule consider the minimum and target SDK more carefully. * If both the min and target SDK >= 14, the rule enforces the new button order. * If both the min and target SDK <= 14, then the rule does nothing. * Otherwise, if warns if the wrong button order is in a layout that is in a layout*-v14 or higher folder, or if it's in a non-v14 folder and there is no corresponding v14 layout. Change-Id: Idf54f86d7a004fdb073486160e4d5ff5fd1cd45c
* Add support for suppressing lint via XML attributesTor Norbye2012-02-0633-49/+74
| | | | | | | | | | | | | | | | | | | | | | | 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
* Update expected size icon detector to new action bar sizeTor Norbye2012-02-062-6/+11
| | | | | | | This addresses 25176: LINT: Incorrectly flags Action Bar icons as wrong size Change-Id: I1309c60f48585dd118951d928e3cd3d06a1d2939
* New button-related lint checksTor Norbye2012-02-062-0/+643
| | | | | | | | | | | | | | | | | | | | 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
* Merge "Add lint rule checking for showAsAction="always" in menus"Tor Norbye2012-02-063-1/+226
|\
| * Add lint rule checking for showAsAction="always" in menusTor Norbye2012-02-033-1/+226
| | | | | | | | | | | | | | | | | | | | 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
* | Merge "The inefficient layout weights check only applies for horizontal ↵Tor Norbye2012-02-061-2/+3
|\ \ | |/ | | | | LinearLayouts"
| * The inefficient layout weights check only applies for horizontal LinearLayoutsTor Norbye2012-02-031-2/+3
| | | | | | | | Change-Id: I648e0adde917e47da02f181c019bf0302ebab643
* | SDK: verbose log for CommonXmlEditor.Raphael2012-02-061-1/+1
|/ | | | | | | | | | This just adds a simple printf of the resFolder + type when the CommonXmlEditor can't find a matching delegate. Also a 1-character typo fix in a lint message and ignore bin/gen folders for the sdk controller app. Change-Id: If43877e6c4d4158c475507671993fe29716a7c5e
* Disable String.format construction checkTor Norbye2012-02-031-8/+12
| | | | Change-Id: I2b0b118c2f4c3e64fb4c2e68ae594bb5e18a5938
* Add lint abbreviation flagTor Norbye2012-02-022-3/+5
| | | | | | | | | | | | 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
* Add Quickfix to add @TargetApi.Tor Norbye2012-02-022-5/+9
| | | | | | | | | | | 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
* Add has-autofix info to HTML reportTor Norbye2012-02-021-1/+42
| | | | Change-Id: I14e997d4fb7a38a15b764d195c001506c6b73c6c
* Skip android.support packages in AOSP buildsTor Norbye2012-02-021-2/+15
| | | | Change-Id: I7b5b2c8031a21ad255c835607a1394541e89e73a
* Remove obsolete issue limitation description from UnusedResource detectorTor Norbye2012-02-011-10/+1
| | | | Change-Id: Id4caccd3f38f41288cc84dfe94546f18316631a2
* Add @ApiTarget supportTor Norbye2012-01-311-1/+49
| | | | | | | The @ApiTarget annotation lets you annotate classes, constructors and methods with a temporary local version of a min sdk. Change-Id: Ic9d166d45fde45f1c97e503cebf07d5ae0635c73
* Merge "Add @SuppressLint support for Java parse tree detectors"Tor Norbye2012-01-315-8/+9
|\
| * Add @SuppressLint support for Java parse tree detectorsTor Norbye2012-01-315-8/+9
| | | | | | | | | | | | | | This changeset adds support for suppressing lint warnings by annotatating variable declarations, fields, methods and classes. Change-Id: If274d65bccdc5c7d6426566c635245d6b3aae147
* | Merge "Add @SuppressLint support for Java bytecode detectors"Tor Norbye2012-01-313-119/+114
|\ \ | |/
| * Add @SuppressLint support for Java bytecode detectorsTor Norbye2012-01-313-119/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Allow bitmaps in res/drawable/ when minSdk < 4Tor Norbye2012-01-311-1/+4
|/ | | | Change-Id: Ic02970df139fdb87ab56e46e95155c18e9aa6ccc
* Find API database when running in AOSP build environment with SDKTor Norbye2012-01-311-0/+9
| | | | Change-Id: Ic884ec376d99d9b10a123f9b8a084987dd398e0e
* Error messages for no-dpi warnings were tagged with the wrong issueTor Norbye2012-01-301-1/+1
| | | | Change-Id: I8d70800ae7902851139c620c64b2abe27ba01450
* Convert ApiCheck internal JVM signature to external in error messageTor Norbye2012-01-301-2/+2
| | | | Change-Id: Ia76b2fb5693d7e36fed2258791eda9c59a48ff49
* Fix lint column offset handling, and add columns to API checkTor Norbye2012-01-302-8/+14
| | | | | | | | | | | | | | | | | | | | 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
* API check hooked up to lintTor Norbye2012-01-277-195/+1232
| | | | | | | | | | | | | | | 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
* Merge "Fix a few misc Lint issues"Tor Norbye2012-01-261-1/+35
|\
| * Fix a few misc Lint issuesTor Norbye2012-01-261-1/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Add quick fix for the UseCompoundDrawable lint warning"Tor Norbye2012-01-261-1/+3
|\ \ | |/ |/|
| * Add quick fix for the UseCompoundDrawable lint warningTor Norbye2012-01-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds a quickfix for the "Use Compound Drawable" lint warning. That warning identifies a LinearLayout which contains exactly one TextView and one ImageView (in either order, and the linear layout can be in either orientation), and suggests replacing it by just the single TextView along with a drawable attribute. The description alone wasn't clear, so the quickfix performs the conversion automatically. In addition to the conversion it also needs to transfer any layout param references from the old LinearLayout to the TextView (and assign it an id if necessary), so the quickfix is implemented as a visual refactoring. It's also made available from the Visual Refactoring menu. This changeset also updates a couple of unrelated golden files in the refactoring unit tests to track a message change a few months back. Change-Id: Iecb544d196fdd4bcabf13a3fdb82ef1ea063f4c2
* | Merge "Add support for multi-pass lint checks, and chained locations"Tor Norbye2012-01-262-114/+173
|\ \
| * | Add support for multi-pass lint checks, and chained locationsTor Norbye2012-01-242-114/+173
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | First version of the ApiChecker.Xavier Ducrohet2012-01-264-0/+437
|/ | | | | | | | | | | | - Reads frameworks/base/api xml/txt file to build a representation of package/class/method/field to figure out at what API level they were added. - Writes down (and read back) this in a simpler XML format (only the info we need). - Simple API to query when a class/method/field was added to the API. Change-Id: Ie854ed6d0c8c371990a913f949039f4c14c0b9cb
* Fix build.Tor Norbye2012-01-191-1/+1
| | | | | | Worked on Mac but not elsewhere (and should really use the ASM version of the class) Change-Id: Iae7dcbeed445a182fa32debc4eca9c9f26a76ab4