aboutsummaryrefslogtreecommitdiffstats
path: root/lint
Commit message (Collapse)AuthorAgeFilesLines
...
* | Handle nulls from Element.getAttribute (fix for issue 25668)Tor Norbye2012-02-231-0/+4
|/ | | | | | | | | | | | | | | | | | Element.getAttribute isn't supposed to return null, but in Eclipse it sometimes does. It was common in 3.5.2, which we've dropped support for, but issue 25668 shows that it can happen in Eclipse 3.7.1 too though it's rare. This changeset attempts to address the issue in two ways: (1) Spotfix the specific NPE (2) Hold the readlock on the XML document while the detectors are using the DOM nodes (this is in case the nulls are related to this, which is not certain given that the issue is rare and not reproducible) Change-Id: I14727531ea9e08abf45d70013248e702cf5a15eb
* Wrong category metadata for the color detectorTor Norbye2012-02-221-1/+1
| | | | Change-Id: Id62e675e467a4c9754515640194c836ab4cb9a83
* Add lint check for "old" proguard configurations with generic Android configTor Norbye2012-02-229-15/+254
| | | | Change-Id: I79cbdf874cffe78eb62f9af2e22e6cc780853e6a
* Merge "Split ProGuard file into two halves"Tor Norbye2012-02-226-18/+88
|\
| * Split ProGuard file into two halvesTor Norbye2012-02-216-18/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset splits the proguard.cfg into two halves: (1) All the general Android settings go into $ANDROID_SDK/proguard/proguard-android.txt. This defines shrinking rules like keep custom views, etc. The crucial point is that this information is maintained and updated by Tools updates, so whenever new APIs are added to Android, or whenever bugs are found in the configuration such as flags needed to work with Dalvik, we can make the updates - we don't have old snapshots living on in projects. (2) Any project specific settings go to proguard-project.txt in the project. (3) The proguard.config property in project.properties now refers to a *path* of configuration files, which are all passed to ProGuard in the given order. The code which processes this setting will substitute android.sdk.home and user.home variables, so the path does not have to be hardcoded to point to the project-android.txt file. The default project templates have been updated to include a commented out configuration setting up proguard as described above. The default proguard file name was changed from proguard.cfg to proguard-project.txt such that it can be directly opened in Eclipse and to make it clear it's an editable text file. Lint was updated to find the Proguard file via the proguard.config property as well as via the old and new default names for projects not enabled with ProGuard. A subsequent CL will add a lint check which identifies projects containing the old setup (full local configuration) and offer to replace it with the new setup. Change-Id: I44b4c97a160114c2382f02f843c95486a0dc9d6b
* | Add lint rule to catch incorrect setColor callsTor Norbye2012-02-2110-17/+199
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Android has various setColor methods (such as setTextColor) which take an integer, where it expects RGB values in the bytes. Since this is an integer, and since color resources are integers, sometimes code incorrectly passes the color resource id rather than a resolved color to the setter: paint.setColor(R.color.red) Obviously, the color should be "resolved" first via getResource().getColor(). This changeset adds a lint detector which catches these kinds of bugs. Change-Id: I2970e5220d24ad3b844a9f19fbe99b932d9f7fb4
* | Merge "Suppress support and location tracking for translation detector"Tor Norbye2012-02-215-77/+222
|\ \
| * | Suppress support and location tracking for translation detectorTor Norbye2012-02-215-77/+222
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds support for suppressing lint errors on translations. For a missing translation, place the suppress attribute on the default language key. For strings defined in other languages but not the default locale, place the attribute on the extra translation. This required adding better location tracking (which is also beneficial in that the translation warnings will show up as editor underlines in Eclipse etc). Instead of having errors generated for each locale ("the following strings are missing from locale X") it now generates a unique error for each string, listing which locales it's missing from. This also solves a different issue where the list of missing strings was truncated when large; there's no more truncation now. Change-Id: If63e92a6a750a5314af2f11441347cf9fc0b0a15
* | | Merge "Make API detector in XML files consider folder version"Tor Norbye2012-02-214-20/+55
|\ \ \ | |/ / |/| |
| * | Make API detector in XML files consider folder versionTor Norbye2012-02-214-20/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | Take the folder version into account when checking the API level in XML files. For example, even if minSdkVersion=5, it's okay to have a <GridLayout> element in a layout if that layout is in a layout-v14 (or higher) folder. Change-Id: Idbd3647c1145e4b3d03f90626339ef7e6b10c827
* | | Merge "Lint rule to catch edit-usage of TextViews (should be EditText)"Tor Norbye2012-02-219-6/+485
|\ \ \
| * | | Lint rule to catch edit-usage of TextViews (should be EditText)Tor Norbye2012-02-219-6/+485
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TextView provides a number of attributes related to text editing. However, these are generally intended for the EditText subclass of EditText. This lint check looks for <TextView> elements in layouts where one or more of the edit-related attributes (such as inputType) are defined. It also updates the deprecation detector to check various deprecated attributes (it only checked for deprecated elements before this.) Change-Id: I1b94902d906cd0bee6a6564368125a68b3c9bb2a
* | | Merge "Use lint error mechanism for config issues like no classes found"Tor Norbye2012-02-216-13/+66
|\ \ \
| * | | Use lint error mechanism for config issues like no classes foundTor Norbye2012-02-216-13/+66
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-213-2/+4
|/ / | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Lint rule checking that activities and services are registered"Tor Norbye2012-02-2119-2/+501
|\ \ | |/ |/|
| * Lint rule checking that activities and services are registeredTor Norbye2012-02-1619-2/+501
| | | | | | | | | | | | | | | | | | | | | | This changeset adds a lint rule checking that any named, non-abstract classes which extend Activity, Service or ContentProvider have a corresponding registration in the manifest file. It also ensures that the registration is under the right kind of tag (<activity>, <service>, <provider> or <receiver>). Change-Id: Ifbb587ae7b3eb6529d5099b33245d0478d48c41f
* | Add @android resource version checking to the lint API detectorTor Norbye2012-02-168-35/+159
|/ | | | | | | | 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
* Add suppress-scope handling for more XML detectorsTor Norbye2012-02-1620-73/+457
| | | | | | | | | | | | | | | | This changeset adds is-suppressed checking to most of the remaining XML detectors. These are detectors which do post processing on data in order to compute the warnings, at which point they no longer have access to the original DOM node context. This changeset adds various checks to handle this, such as storing the DOM node in the location handle client data and checking explicitly before using the handles. It adds various unit tests for the suppress scenarios too. There are now two remaining detectors which don't properly handle suppression: the TranslateDetector, and the DuplicateIdDetector (in cross layout scenarios). These will be addressed in a separate CL. Change-Id: I53e792dd2f2802c7dce16beb73127f20d9b2dba8
* Build fix: fix import packageTor Norbye2012-02-162-2/+4
| | | | Change-Id: Id8f467c5a088101e6b50c33fa0703520e31bdede
* Add onClick check for lintTor Norbye2012-02-169-28/+521
| | | | | | | | | | | | | 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
* Tweak category orderTor Norbye2012-02-141-1/+1
| | | | Change-Id: If83a942f99da90d061529092feaab3be94a8e0ad
* Fix HTML export category handlingTor Norbye2012-02-144-11/+14
| | | | Change-Id: Ia8f0c1aebb4e797352a0513b8113b5d6b75ef0dc
* Merge "Add lint check for custom attributes in library projects"Tor Norbye2012-02-149-105/+319
|\
| * Add lint check for custom attributes in library projectsTor Norbye2012-02-149-105/+319
| | | | | | | | | | | | | | | | Also adds a lint check for unused namespace declarations, and migrates the TypoDetector code into this new namespace detector. Change-Id: I5ec2214ea4c59e14194f8eaecef422ea19baa35e
* | Fix JavaPerformanceDetector to only report enabled issuesTor Norbye2012-02-141-8/+17
|/ | | | Change-Id: I6a68b28b610ebdfc31b779b7b66e49a70a5e1a01
* Fix for lint cli relative output pathsTor Norbye2012-02-141-1/+4
| | | | Change-Id: I4e37e68661007a825c97948e6258201babcd2b79
* Warn when there are more uses sdk elements than oneTor Norbye2012-02-144-5/+88
| | | | Change-Id: Iecad10d5c33f6b7649e686633c9ff9f5541e9799
* Add Java performance lint checksTor Norbye2012-02-1315-13/+653
| | | | | | | | | | | | | | | | | | | | 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-133-8/+82
|\
| * Add per-node ignore handling for more lint checksTor Norbye2012-02-133-8/+82
| | | | | | | | | | | | | | | | | | | | | | 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-1311-12/+26
|\ \ | |/
| * Add Fatal severityTor Norbye2012-02-1311-12/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-138-1/+261
|\ \
| * | Add namespace-typo detectorTor Norbye2012-02-138-1/+261
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge "Add superclass support to Lint"Tor Norbye2012-02-1314-125/+359
|\ \ \ | | |/ | |/|
| * | Add superclass support to LintTor Norbye2012-02-1314-125/+359
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge "Make lint process Java jar dependencies"Tor Norbye2012-02-1313-22/+218
|\ \ \ | |/ /
| * | Make lint process Java jar dependenciesTor Norbye2012-02-1313-22/+218
| |/ | | | | | | | | | | | | 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
* | Fix typo in security check (and add regression unit test)Tor Norbye2012-02-103-1/+34
|/ | | | Change-Id: I52662287ff86925629ea8f6f5bc13855d403b3e8
* Merge "Lint detector warning about missing <uses-sdk> min or target SDK ↵Tor Norbye2012-02-075-5/+126
|\ | | | | | | settings"
| * Lint detector warning about missing <uses-sdk> min or target SDK settingsTor Norbye2012-02-075-5/+126
| | | | | | | | Change-Id: I9401318afe771d11ef6f211ee3f9cb6c62df8f83
* | Merge "Make the lint string-format check ignore date strings"Tor Norbye2012-02-075-47/+209
|\ \
| * | Make the lint string-format check ignore date stringsTor Norbye2012-02-075-47/+209
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-073-0/+17
|\ \
| * | Suppress UselessLeaf warnings for root layoutsTor Norbye2012-02-073-0/+17
| |/ | | | | | | Change-Id: I997ad6f1348e9884b56a60ef453cd02754c936bb
* | Make ButtonOrder lint rule consider minSdk and targetSdk and v14Tor Norbye2012-02-074-49/+202
|/ | | | | | | | | | | | | | | | 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-0639-53/+258
| | | | | | | | | | | | | | | | | | | | | | | 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-063-7/+12
| | | | | | | This addresses 25176: LINT: Incorrectly flags Action Bar icons as wrong size Change-Id: I1309c60f48585dd118951d928e3cd3d06a1d2939
* 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