aboutsummaryrefslogtreecommitdiffstats
path: root/lint/libs
Commit message (Collapse)AuthorAgeFilesLines
* Lint bug fixesTor Norbye2013-01-229-69/+100
| | | | | | | | | | | | | | | | | | | | | | | This CL contains a number of unrelated lint bug fixes: * Fix API detector such that it warns about ?android:name attrs * Fix API detector for inlined constants such that it's more rigorous in how it determines whether a constant is used in a valid (if conditional or case value) context * Fix 43070: Analytics resources should not be flagged as needing translations * Fix 42994: Android lint should not complain about 'Custom view is missing constructor used by tools' for classes that are declared abstract * Finally, pass in the right node context for a few places it was missing it (when missing, adding suppress annotations only works on the root class AST node) Change-Id: I044140c865dbd3d0e964dae7f13c66eeb450509e
* Lint tweaksTor Norbye2013-01-223-11/+40
| | | | | | | | Fix missing dispose() call for manifest files, and add a method to the TypographyDetector such that clients don't need a DOM node to look up the suggested replacement. Change-Id: If048a62a6b0b1c8af83a3e0b62a28876d4449764
* Fix other file visitor to handle incremental analysis properlyTor Norbye2013-01-223-27/+99
| | | | | | | | | | | The other file visitor would unconditionally scan the full project contents for each scope, even when project.getSubset() (used for incremental analysis in IDEs) was non null. Also avoid NPE when lint is scanning a java file without a package declaration. Change-Id: I74e813b41c2e32acac879b277dc974619156adbd
* Fix Eclipse classpath for projects moved to tools/base or swt.Raphael Moll2013-01-162-2/+2
| | | | Change-Id: Ibc54b1a23688217666b60ce7dc692f0bba00419a
* 42798: lint miscounts String.format()Tor Norbye2013-01-151-3/+14
| | | | Change-Id: Ibd997301864981ceb863a30b36034a784ab13392
* Update Eclipse Add Target API annotations for new InlinedApi checkTor Norbye2013-01-141-0/+1
| | | | Change-Id: I180cba4a0f71d86ae7b61643bd0b36cc8c4c6b28
* Add support for checking lint on other filesTor Norbye2013-01-1410-51/+269
| | | | | | | | | | This adds a new scope, Scope.OTHER, which can be used to indicate that the check wants to investigate files other than the ones specially handled as XML, Java, manifest or ProGuard files. The PrivateKeyDetector now uses this such that it doesn't have to perform its own directory iteration. Change-Id: Ic38bf2db656f00c01d94c0c4e0112bc77218ea08
* 27869: Don't require a LinearLayout orientation when style is setTor Norbye2013-01-141-1/+2
| | | | Change-Id: I783e001fe84d825e116c6b2a882bcf2d22c61884
* Fix commit transation detectorTor Norbye2013-01-141-26/+26
| | | | | | | | | | | | | | | | | | | | | First, fix the error message; it was sharing code with the recycle detector and accidentally mentioned recycle rather than commit in the error message. Second, fix a bug where it would fail to find committed transactions if the commit() was reached through setter chaining (where each setter returns this). Also, remove checking for recycling of Message objects; according to the following thread it looks unnecessary: https://groups.google.com/forum/?fromgroups=#!\ topic/android-developers/9pHuc7lGunY Finally, the unit test class had the wrong name (was not moved when the recycle detector was generalized to handle other types of cleanup.) Change-Id: I80f4bf65acf304660c8a7e7a5b9e1b4f932e25c0
* 42565: Lint reports Analytics resource as unusedTor Norbye2013-01-141-2/+19
| | | | Change-Id: I27f5714539f1d28efc6ace1b9c9918fbd5f47825
* 42661: Split API check constant warnings into a separate issueTor Norbye2013-01-143-32/+202
| | | | | | | | | The issue has severity warning instead of error. Also, deliberately filter out constants which moved to a base class. Change-Id: I4976c421aa589cdb0a673c2d49bcafdd80ff005e
* Api Detector: Flag style definitionsTor Norbye2013-01-141-24/+47
| | | | | | | This should help track down problems like https://github.com/JakeWharton/ActionBarSherlock/issues/446 Change-Id: I5ed721189fcdd1090b2dfd5f64d2222e223aa4c5
* Delete ALL the build.gradle from sdk.gitRaphael Moll2013-01-092-139/+0
| | | | Change-Id: Ib923638c305105e84f79a18a79ece48d391129c5
* Make resource folders customizeableTor Norbye2013-01-046-28/+36
| | | | | | | | | | | | | | | | Until now, lint has hardcoded where the project resources are to be found: in $project/res. With the new build system this will no longer necessarily be the case; there can be multiple resource folders, and the locations might not be just res/. Therefore, this CL generalizes lint's handling of resource folders: it is now provided by the LintClient, and the command line lint tool uses this to offer a new --resources flag which can be used to set the resource directory/directories for a project. Change-Id: I3717c6474141776ee5541d476f9bad5bb8e1a9c7
* Bug fix: Use JVM signature for custom viewsTor Norbye2013-01-031-2/+3
| | | | | | | | Without this the lint check for instantiatable classes might incorrectly conclude that a custom view should have a default constructor. Change-Id: I5c2281d5681e3b344c9dc78e13960408886f383c
* Merge "27869: Lint rule for LinearLayout which doesn't specify orientation"Tor Norbye2013-01-032-3/+57
|\
| * 27869: Lint rule for LinearLayout which doesn't specify orientationTor Norbye2013-01-032-3/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a check for cases where you have a LinearLayout which does not specify an orientation (meaning it's horizontal), yet it contains multiple children, and one of the children prior to the last one sets its width to fill_parent or match_parent (without a weight). This is a common pitfall for new developers who create the layout and assume it's vertical, and at runtime only see the first child, not realizing the remainder are off screen to the right. Change-Id: Ief9604d8a8fc84849d1a8f2df6d7ec0b75b13eaa
* | Code cleanupTor Norbye2013-01-022-3/+7
|/ | | | | | | | Fix typos, remove redundant semicolons, fix incorrect names (using an m prefix where they should be using s, turn fields with constant names into actual constants), etc. Change-Id: I44a5ab82c1158007d0803d43ce14b361aff240b8
* Update fragment issue from warning to errorTor Norbye2013-01-022-4/+8
| | | | | | Also update constants to stay in sync with sdk/ version. Change-Id: I8e454a03d83c81036bf8cc73609babc96a9c7739
* 42173: New Lint Check: <Fragment> instead of <fragment>Tor Norbye2013-01-022-0/+84
| | | | Change-Id: I33f3284368a9dd199b2cd70c023d6a22f2426c00
* 42169: New Lint Check: ACQUIRE_CAUSES_WAKEUP with PARTIAL_WAKE_LOCKTor Norbye2013-01-021-6/+39
| | | | Change-Id: I55ec4385e782ec8d5eff80b2206a0bcfe755201a
* 41753: Lint API Check: Consult source files for constantsTor Norbye2013-01-025-14/+621
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Lint currently checks the .class files for field references and method references to APIs that require a version higher than the minSdkVersion in the manifest. However, constants (such as final static integers) will be copied into the .class file, so there is no reference to the original API and its API version, which means lint can't flag these. In some cases, such as referencing LayoutParams.MATCH_PARENT, that's no problem; the constant value works on older versions, and there is no problem, since the value rather than the reference is used. However, in other cases this may lead to runtime crashes. This CL updates lint to look at the source files and flag field references. It excludes some constants that are known to be okay (such as referencing say android.os.Build.VERSION_CODES.JELLY_BEAN_MR1 (which is typically done precisely to conditionally branch based on the current device's version). It also ignores usages as case constants or in conditional if checks. We may need to do additional tweaks to this in the future, since unlike method and field references there are probably many cases where referencing these constants are fine on older devices, but there are also cases where it's dangerous. For now, we're erring on the side of warning the developer rather than being certain that it's not a problem. Change-Id: Ieba4c15d7fdda02756b7b7f5a1b79f7698c1915b
* Remove ExportedActivity checkJon Larimer2012-12-272-27/+0
| | | | Change-Id: I428628956c7790b5206d83310211411c4ea54c68
* Prevent circular dependencies in library project dependenciesTor Norbye2012-12-214-8/+114
| | | | Change-Id: Ia43c2436e01032ace7e2b13e59d60d10f71e7004
* Add lint check for suspicious onMeasure/onLayout/onDraw callsTor Norbye2012-12-213-4/+102
| | | | | | Cherrypick from https://android-review.googlesource.com/#/c/48540/ Change-Id: Ic3d4552324c319899f908c4741ed263514713c1a
* Lint check for valid class referencesTor Norbye2012-12-193-40/+140
| | | | | | | | | | | | | | Lint already checks that classes registered in the manifest (such as activities and services) exist and are instantiatable. This lint check expands this check to also make sure that custom views and fragments referenced in layouts also exist, as well as class names registered in analytics config files (requested in issue 41567). It also fixes the typography detector to not flag IDs as needing em dashes. Change-Id: Idd42be60dae6c0747324d600d15b01d6d8a3240f
* Look for missing commit calls on fragment managersTor Norbye2012-12-192-27/+86
| | | | | | | | | | This implements 41339: Forgetting .commit() after .beginTransaction() Also renames the RecycleDetector to something more generic since it checks for other types of cleanup as well. Change-Id: I19ca6537ba88745845ad452f87b6562085a47fe5
* Lint: Flag using @dimen where not allowed in manifestTor Norbye2012-12-192-4/+85
| | | | | | | Adds a lint check which flags using resource ids for versionName, versionCode, minSdkVersion and targetSdkVersion in the manifest. Change-Id: I5b4e25d0b114cdf84f446a193fe5d3a095b2f415
* Code cleanupTor Norbye2012-12-12100-497/+545
| | | | | | | | Ran some static analysis on the lint code and fixed various issues - some typos, made some fields final, made some methods static, sorted modifier order etc. Change-Id: Ibdcdec5745f040eb7b0880cf6999c0f0ea7f7e6f
* Add lint recycle detectorTor Norbye2012-12-114-10/+493
| | | | | | | | | | | | | | | This lint check looks for missing recycle() calls on resources such as TypedArrays, MotionEvents, and Messages. 41140 New Lint Check: Check Recycling VelocityTracker 41138 New Lint Check: Check Recycling Message 41137 New Lint Check: Check Recycling MotionEvent 41136 New Lint Check: Check Recycling TypedArray In addition, it also flags cases where a method is called on a resource after the resource has been recycled. Change-Id: Ia06a1779519971d5459f1cd98914a6aededc4b83
* 41154: Handle allowBackup properly for target < 4Tor Norbye2012-12-101-1/+2
| | | | | | | | This fixes 41154: Template Android Application Project for API v3 reports AAPT problem with android:allowBackup="true" Change-Id: I74b4cd0f8df9a74fe9221250cc83b1d15821ce51
* Move lint unit tests into lint/cliTor Norbye2012-12-07537-20021/+0
| | | | | | | | | | | The unit tests for lint have lived in the lint/libs/lint_checks library, but that's not a natural place since the cli library depends on the lint_checks library, yet the lint_check *tests* also depend on cli. Furthermore, the tests also test stuff in the cli library. Thus, move the test sources over to the cli library, which also pulls in the lint_checks library. Change-Id: Ia8527ea894b287915ad12c04c16daf80ace67bdc
* Refactor lint folder structure.Xavier Ducrohet2012-12-06656-68/+28
| | | | | | | | | | Move folders around to match default gradle/maven folder structure. The custom structure confused some IDEs when importing the project as a Gradle project. Change-Id: I5c059cc6fdf0ac2444b03d435f83f853363cfa32
* Findbugs cleanupTor Norbye2012-12-067-17/+10
| | | | | | | Fix a couple of issues found by findbugs, and some test stability fixes. Change-Id: I97390ea606ea25d6a68e5b7f8245e5e689117995
* Fix gradle build of sdk libs by adding testutils.Xavier Ducrohet2012-12-061-0/+1
| | | | Change-Id: I2cb3a51e2ddf914acb9129a82294b75c568c3949
* Fix handling of custom namespace attributes in lintTor Norbye2012-12-046-25/+113
| | | | | | | | | | | | First, don't complain about an unexpected namespace if the offending attribute is a layout parameter, since it applies to the parent, not the current view. Second, for the res-auto warning, report the error only on the xmlns namespace declaration, not each usage of that namespace. Change-Id: If6a7576cf56c0936a24be851cfc48bc54d374ea4
* 40876: Lint should flag "extension" pattern specifiers in SimpleDateFormatTor Norbye2012-12-035-22/+109
| | | | Change-Id: I427e498a314aeaeb2a302811bfde1dc719e435d5
* Merge "Add override detector"Tor Norbye2012-12-039-2/+201
|\
| * Add override detectorTor Norbye2012-11-309-2/+201
| | | | | | | | | | | | | | | | | | | | This lint detector finds method declarations which are likely to clash and accidentally override framework classes defined on newer platforms Also, fix method position computation in class files. Change-Id: If0d03feb55e44816f75938dae3164c53ed5b3183
* | Merge "API check: Only check calls and field accesses, not declarations"Tor Norbye2012-12-032-118/+64
|\ \ | |/
| * API check: Only check calls and field accesses, not declarationsTor Norbye2012-11-302-118/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It appears Dalvik is very forgiving and doesn't try to preload classes until actually needed, so there is no need to flag variable and field declarations, and in fact, patterns used for supporting new and old versions sometimes declares these methods and only conditionally end up actually accessing methods and fields, so only check method and field accesses. Also fix lint such that it doesn't flag XML resource warnings for tools URI namespace elements, such as ListView preview layout selections. Change-Id: I9018a64845b5b29744926e3d0be371801bbdd167
* | Merge "Add tools:targetApi to control local minSdk (like @TargetApi)"Tor Norbye2012-12-035-5/+137
|\ \ | |/
| * Add tools:targetApi to control local minSdk (like @TargetApi)Tor Norbye2012-11-305-5/+137
| | | | | | | | | | | | | | Also add XML editor quickfix to set the attribute on an API violation. Change-Id: Ife95d73659656e98a6fb1a322354f5fcfcef1888
* | Merge "Close resource"Tor Norbye2012-12-031-1/+10
|\ \
| * | Close resourceTor Norbye2012-12-031-1/+10
| |/ | | | | | | Change-Id: I4683dc68a9f74ad8a2c709c8313c17ccbfbd64a1
* | Fix typo in issue idTor Norbye2012-11-303-88/+88
|/ | | | Change-Id: I0e96e4b3d5d9c3fa14e4f84d73a6bd023f44162a
* Make inefficient weight detector identify more candidatesTor Norbye2012-11-295-5/+110
| | | | | | | | | | | | | | | | | The inefficient weight detector looks for horizontal layouts with weights where all the children are layouts. It didn't have a very good heuristic for finding out whether all children are layouts; it just looked for whether the tag name contains "Layout". This changeset generalizes this a bit, adding other layouts, as well as <fragment> tags to the lint check. It also updates the Master/Detail template to set the baseline alignment attribute to false (to avoid triggering the updated lint check), as well as android:textIsSelectable to clear another recent new lint rule. Change-Id: I887962b5e29a9ad0c5b5c01970b0c66f884125d8
* Check for unsupported Java packagesTor Norbye2012-11-288-17/+480
| | | | | | | | | | | | | | | | | | | If you include a library in your class path which was not built as an Android project it's possible for it to include references to classes in the java.* and javax.* namespace which are not valid in Android. This changeset adds a new lint detector for this. It augments the API database used by the API Checker to record the set of platform packages, and to be able to quickly query whether an internal class reference is in one of the valid packages. The new lint check runs only on libraries (since tools will typically set up the right classpath to give immediate errors if you try to access invalid packages from your own code). This was requested in issue 39109. Change-Id: Id1ce7982e683bae9a484e7b75d7e77a256ca4414
* Add lint check ensuring that buttons in bars are borderlessTor Norbye2012-11-284-4/+186
| | | | Change-Id: Ie99e3e7b75f1ac8cf6447c70afc5901437e2d600
* Don't report missing layout_width/height if set in themeTor Norbye2012-11-284-3/+115
| | | | Change-Id: I48ecfea6304abedb942161bf2fec1d9867ddf0c6