aboutsummaryrefslogtreecommitdiffstats
path: root/lint/libs/lint_api
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge "Split ProGuard file into two halves"Tor Norbye2012-02-223-15/+67
|\
| * Split ProGuard file into two halvesTor Norbye2012-02-213-15/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-214-10/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 "Make API detector in XML files consider folder version"Tor Norbye2012-02-211-0/+23
|\ \
| * | Make API detector in XML files consider folder versionTor Norbye2012-02-211-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-212-2/+27
|\ \ \
| * | | Lint rule to catch edit-usage of TextViews (should be EditText)Tor Norbye2012-02-212-2/+27
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-214-7/+47
|\ \ \
| * | | Use lint error mechanism for config issues like no classes foundTor Norbye2012-02-214-7/+47
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-211-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | 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-212-1/+30
|\ \ | |/ |/|
| * Lint rule checking that activities and services are registeredTor Norbye2012-02-162-1/+30
| | | | | | | | | | | | | | | | | | | | | | 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-162-4/+19
|/ | | | | | | | 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 onClick check for lintTor Norbye2012-02-162-2/+107
| | | | | | | | | | | | | 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-141-9/+9
| | | | Change-Id: Ia8f0c1aebb4e797352a0513b8113b5d6b75ef0dc
* Add lint check for custom attributes in library projectsTor Norbye2012-02-141-0/+1
| | | | | | | | Also adds a lint check for unused namespace declarations, and migrates the TypoDetector code into this new namespace detector. Change-Id: I5ec2214ea4c59e14194f8eaecef422ea19baa35e
* Merge "Add Fatal severity"Tor Norbye2012-02-131-2/+7
|\
| * Add Fatal severityTor Norbye2012-02-131-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-131-1/+5
|\ \
| * | Add namespace-typo detectorTor Norbye2012-02-131-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-132-78/+195
|\ \ \ | | |/ | |/|
| * | Add superclass support to LintTor Norbye2012-02-132-78/+195
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-136-20/+164
|\ \ \ | |/ /
| * | Make lint process Java jar dependenciesTor Norbye2012-02-136-20/+164
| |/ | | | | | | | | | | | | 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-101-1/+1
|/ | | | Change-Id: I52662287ff86925629ea8f6f5bc13855d403b3e8
* Add support for suppressing lint via XML attributesTor Norbye2012-02-063-1/+96
| | | | | | | | | | | | | | | | | | | | | | | 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
* New button-related lint checksTor Norbye2012-02-063-1/+75
| | | | | | | | | | | | | | | | | | | | 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
* Add lint rule checking for showAsAction="always" in menusTor Norbye2012-02-031-0/+5
| | | | | | | | | | 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
* Fix type in Java parser interfaceTor Norbye2012-02-031-4/+3
| | | | Change-Id: Ic08e20bf6d729362fae7d82c84e664e05b6ba843
* Add lint abbreviation flagTor Norbye2012-02-022-1/+20
| | | | | | | | | | | | 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-021-1/+3
| | | | | | | | | | | 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
* A few simple name changesTor Norbye2012-02-026-14/+15
| | | | | | | | | | | | | | | | | | | | | 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
* Add marker resolution for adding @SuppressLint to Java filesTor Norbye2012-02-022-10/+14
| | | | | | | | | | | | | 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
* Attempt to use a common filepath root as the relative dirTor Norbye2012-02-012-5/+88
| | | | Change-Id: Ic49dc60284820ed01841a8fdbf09c4668e285169
* Lint HTML improvementsTor Norbye2012-02-013-10/+50
| | | | | | | | | | | 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
* Add @ApiTarget supportTor Norbye2012-01-311-1/+1
| | | | | | | The @ApiTarget annotation lets you annotate classes, constructors and methods with a temporary local version of a min sdk. Change-Id: Ic9d166d45fde45f1c97e503cebf07d5ae0635c73
* Add @SuppressLint support for Java parse tree detectorsTor Norbye2012-01-313-2/+158
| | | | | | | This changeset adds support for suppressing lint warnings by annotatating variable declarations, fields, methods and classes. Change-Id: If274d65bccdc5c7d6426566c635245d6b3aae147
* Add @SuppressLint support for Java bytecode detectorsTor Norbye2012-01-314-43/+224
| | | | | | | | | | | | | | | 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
* Support Android source tree directly in lint project supportTor Norbye2012-01-301-0/+206
| | | | | | | | 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
* Add support for exporting one HTML report for each linted projectTor Norbye2012-01-301-0/+16
| | | | | | | | | | | | | | | 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
* Add .jar support for bytecode checksTor Norbye2012-01-303-12/+101
| | | | | | | This changeset makes the lint driver able to process .jar files and run the detectors on the classes inside. Change-Id: Iaf7303197b953d6c6f925cdf83ad33a8ecd581a5
* Fix lint column offset handling, and add columns to API checkTor Norbye2012-01-302-0/+22
| | | | | | | | | | | | | | | | | | | | 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-272-7/+30
| | | | | | | | | | | | | | | 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
* Fix bug in WrongViewCast detectorTor Norbye2012-01-262-1/+9
| | | | Change-Id: I671fe960fe61afc80ec305e05f7ffe7cbb5933c5
* Add file resource lookup to the Lint Client APITor Norbye2012-01-263-2/+50
| | | | | | | This allows lint detector code to load file resources bundled with the tools (such as a permissions database file). Change-Id: If740206e8e0c5feeaf0e908bf823135114c9bd0d
* Add support for multi-pass lint checks, and chained locationsTor Norbye2012-01-2410-72/+361
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Limit <FrameLayout> to <merge> lint check to included layoutsTor Norbye2012-01-192-0/+33
| | | | | | | | | | | | | | | | | 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
* Add lint warning for hardcoded debuggable attribute in manifest filesTor Norbye2012-01-121-0/+1
| | | | Change-Id: I2409950f2c8618148f2b7cfaf693672021b09633
* Add annotations to the Lint APITor Norbye2012-01-1027-230/+542
| | | | Change-Id: I6222f3ef2909174d9111dcfc037a2e74ad093acd