aboutsummaryrefslogtreecommitdiffstats
path: root/lint
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Update unit testcode to copy test files as binaries"Tor Norbye2012-03-091-30/+9
|\
| * Update unit testcode to copy test files as binariesTor Norbye2012-03-091-30/+9
| | | | | | | | | | | | | | This should fix unit tests dealing with binary data on Windows (where CRLF conversions were getting in the way.) Change-Id: Ib8e79c8643720fadaf6080a4ccb2b466dff748a4
* | Fix issue 26663: Avoid rewriting memory mapped files on WindowsTor Norbye2012-03-091-1/+5
|/ | | | Change-Id: Ie19113652a70b55ea2db545eacd0de8c7be798c9
* Make GridLayout support work with the support libraryTor Norbye2012-03-082-1/+4
| | | | | | | Also fix the paste operation to target the parent if the paste target does not accept children. Change-Id: Id084db376e5ff9b4a374e6d2145bc890a925a078
* Fix the duplicate id detectorTor Norbye2012-03-073-247/+532
| | | | | | | | | | | | | | The duplicate id detector now handles locations properly (so you get line numbers), it handles suppressing errors via annotations, and it's better about avoiding false positives because it handles configuration variations independently. It also attempts to filter out obvious cases that aren't problems such as portrait versus landscape layouts. Related issues: http://code.google.com/p/android/issues/detail?id=22885 http://code.google.com/p/android/issues/detail?id=26454 Change-Id: Id178d08818b6cce1ebbeff6ca10e95e2906175a5
* Misc Lint FixesTor Norbye2012-03-0614-53/+222
| | | | | | | | | | | | | | | | | | | | | | | | | 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-063-34/+147
| | | | | | | | | | | | | - 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
* Merge "Remove R.attr resources from UnusedResource detector (26174)"Xavier Ducrohet2012-03-011-3/+4
|\
| * Remove R.attr resources from UnusedResource detector (26174)Tor Norbye2012-03-011-3/+4
| | | | | | | | Change-Id: I46abcb93537b3d288234729dd01005c41394d227
* | Update lint custom view rule to reflect new res-auto namespaceTor Norbye2012-03-014-7/+46
|/ | | | Change-Id: If74938a7e607ef6e1ffbc00cb0e5d191a672b0c5
* Fix outerclass handling for the @TargetApi annotationTor Norbye2012-03-019-5/+108
| | | | | | | | | | | | | | This changeset adds outerclass handling for the @TargetApi annotation, such that the API checker takes outerclasses (and outermethods, in the case of anonymous inner classes) into account when computing the effective minimum SDK For a method. This also fixes the handling of nested anonymous innerclasses for the @SuppressLint annotation. http://code.google.com/p/android/issues/detail?id=26262 Change-Id: Iafb0fd88cc41042ea1727c3882e3ddd1ebfc1f09
* Merge "Add lint check for calling native wrapper class constructors"Xavier Ducrohet2012-02-284-5/+62
|\
| * Add lint check for calling native wrapper class constructorsTor Norbye2012-02-274-5/+62
| | | | | | | | Change-Id: I59c2a64e4453c4d05bebaba1cfa4fcb31b9592e2
* | Fix configuration information for library projectsTor Norbye2012-02-288-15/+81
|/ | | | | | | | | | | | | | | | | | | | | | | | | | 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-2412-9/+222
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-246-107/+271
| | | | | | | | | | | | | | | | | 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
* Fix typoTor Norbye2012-02-232-9/+9
| | | | Change-Id: I16fadfbf801bcb60e0d7edda6af163bf158a4c21
* Merge "Lint API check should use main project's SDK version"Tor Norbye2012-02-233-4/+3
|\
| * Lint API check should use main project's SDK versionTor Norbye2012-02-233-4/+3
| | | | | | | | | | | | | | | | When the Lint API check is analyzing code in a library project, it should use the min sdk version from the main project (unless you are linting just a library project without including a main project). Change-Id: I6d09f2d3e406213014df55832e781813c96aedfd
* | 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