aboutsummaryrefslogtreecommitdiffstats
path: root/lint
Commit message (Collapse)AuthorAgeFilesLines
* Fix warningsTor Norbye2012-06-0120-59/+105
| | | | | | | | | | | | | | | | | First, update our various project-specific Eclipse compiler settings configuration files to include the new Eclipse 4 flags. Second, turn off the "Unchecked conversion from non-annotated type to @NonNull" warnings; there are hundreds or thousands of these, and there isn't much we can do about them when they're coming from platform and library APIs. Third, make the lint projects warning-clean again by addressing various warnings Eclipse found (such as some unclosed resources and some null handling issues; yesterday's null annotation fixes only addressed errors, not warnings.) Change-Id: If75f7401a1cbeef1bf58b47ccaa9ad17bede7f91
* Fix nullness annotationsTor Norbye2012-05-3073-300/+380
| | | | | | | | | | | | | | | | | | | Eclipse 4.2 includes analysis support for @Nullable and @NonNull annotations. However, it requires these annotations to be *repeated* on every single method implementing or overriding a superclass or interface method (!). This changeset basically applies the quickfixes to inline these annotations. It also changes the retention of our nullness annotations from source to class, since without this Eclipse believes that a @NonNull annotation downstream is a redefinition of a @Nullable annotation. Finally, the null analysis revealed a dozen or so places where the nullness annotation was either wrong, or some null checking on parameters or return values needed to be done. Change-Id: I43b4e56e2d025a8a4c92a8873f55c13cdbc4c1cb
* Add new lint check to ensure that Fragments are instantiatableTor Norbye2012-05-3015-3/+273
| | | | | | | | | | | | | | Fragments should provide a default constructor, and only a default constructor, such that they can be recreated by the system on configuration changes. This changeset adds a lint check to catch cases where this is not the case -- such as fragments that are non-static innerclasses, or where the the class or constructor is not public. It also warns if the fragment contains any *other* constructors, since the fragment documentation strongly advises against it. Change-Id: I8cdd00fd7c74259f84977804e36ace7c43864026
* Lint infrastructure fixesTor Norbye2012-05-309-85/+263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset contains various unrelated fixes to the lint infrastructure: (1) Tweak the way the classpaths are computed in the default lint client method such that rather than reading and parsing the .classpath file 3 times, once for each of source-path, output-path and library-path, it's now processing it once and storing the results for all 3. (2) Override the lookup-classpath method in Eclipse to directly query the Eclipse APIs for obtaining the classpath info. (3) Add in user libraries found in libs/, since these don't necessarily show up in the .classpath file. (4) Fix a couple of bugs related to checking .class files: First, when locating the project for a .class file, lint would search upwards for the surrounding project, which meant looking for the nearest parent containing an AndroidManifest.xml file. However, in the case of .class files, it will first encounter the bin/ directory, which can contain a manifest file, so it would compute a project for the bin/ folder rather than its parent, which meant the source paths would be wrong. Second, the list of class entries to be processed by lint must be sorted prior to processing; the code dealing with innerclasses depends on that. (5) Some minor code cleanup: Move some generic utility code and some string literals out of specific detectors and into the generic utility and constant classes. (6) Cache results of the lint-project to eclipse-project lookup method since that method is called repeatedly with the same (current) project. Change-Id: I33603eed8381ca54314202620cb1bb033e70f775
* Fix interface method lookup in the API DetectorTor Norbye2012-05-223-5/+47
| | | | | | | | | | | | | | | The api-versions.xml file is being updated in a separate CL to pick up some metadata which was missing, such as some enumeration constants. As part of the update, it's also removing the duplication of all the interface methods in the classes that implement those methods. This changeset updates the API Lookup code to handle this correctly. It will now properly visit the interface hierarchy, not just the superclass hierarchy, when computing the full set of methods and fields inherited into a class, as well as when it determines the introduced-in API level for each method. Change-Id: If19697b9812eaa072536057daa5cffe3589a0c75
* 31592: "The <activity> xxx is not registered in the manifest"Tor Norbye2012-05-215-0/+47
| | | | | | | | Handle cases where the package name contains upper case characters. http://code.google.com/p/android/issues/detail?id=31592 Change-Id: I0db7831cc34fc4497de46df75f1e19e908ac13fd
* Add lint check for duplicate activity registrationsTor Norbye2012-05-164-1/+90
| | | | Change-Id: Ia1b023979d2c817e13a67cd5f3f85c1ddd4f65a2
* Run lint on save in Java files, checking .java and .class filesTor Norbye2012-05-1411-24/+240
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds support for per-save file checking in Java source files. It will run both source file and bytecode based checks, possibly at different times (since they are updated at different times). This required some changes to the incremental lint runner, since now incremental checking means possibly touching more than one file (multiple inner classes for a single source), as well as distinguishing between the source files containing markers (the .java file) and the actual files being analyzed (the .class files). This changeset also formalizes incremental lint checking a bit: it now distinguishes between the affected scope of an issue (all the various file types that can affect an issue), as well as the scope sets that are capable of analyzing the issue independently. Take the API check for example. Its affected scope includes both XML files and Java class files, since both can contain API references (in the case of XML, a <GridLayout> reference is an invocation of a constructor of the GridLayout class for example). However, we can analyze a standalone class file, or a standalone XML file, and incrementally update issues found in the file, without regard for the other. Therefore, the API detector has two separate analysis scopes: classes, and XML resources. The manifest registration detector on the other hand needs to look at both the manifest file and the class files; it cannot look at just a subset of these. Change-Id: Ibf5ca8a90846256e0817b419908ee53f8354412a
* Find constructors in source file from class filesTor Norbye2012-05-093-58/+88
| | | | | | | | | | | | | | | This changeset fixes the API detector such that references to a constructor (e.g. where the bytecode name of the method being called is "<init>") are properly located in the source code. This is done by altering the search pattern to look for the owner field instead. This changeset also pulls out the generic "find location for a class declaration" from the recent HandlerDetector and into a generic utility position in the ClassContext, and makes the case handling anonymous inner classes generic rather than being hardcoded for subclasses of Handler. Change-Id: I25f60fda77924edc02bb3029b301e484b0b24931
* Add lint rule looking for Handler leaksTor Norbye2012-05-088-1/+240
| | | | Change-Id: I9fd1669b91303b0f82c6abf2114b7e72a72697dd
* Merge "Fix nested linear layout weights lint check"Tor Norbye2012-05-024-11/+53
|\
| * Fix nested linear layout weights lint checkTor Norbye2012-04-284-11/+53
| | | | | | | | | | | | | | See issue http://code.google.com/p/android/issues/detail?id=22889 Change-Id: Ifd27764c0bb3360e52abb3334bdbfef820d231f7
* | Add lint check to make sure SharedPreference editors are committedTor Norbye2012-04-275-2/+274
|/ | | | Change-Id: Ifacc8df1ef9169c57725652ae9d921ed2b3129bd
* Fix NPE in icon checkTor Norbye2012-04-271-0/+3
| | | | | | | Fix for http://code.google.com/p/android/issues/detail?id=27966 Change-Id: I1a3e538644044ee0c02cb729aca40e15f5b23d22
* Fix 29263: ExtraTranslation incorrectly flags string-arraysTor Norbye2012-04-234-0/+39
| | | | | | Fixes http://code.google.com/p/android/issues/detail?id=29263 Change-Id: Id4e247ce751bca9ff54311126d64e1fbd0bfb312
* Lint: Don't check match_parent versus fill_parent in api checkTor Norbye2012-04-092-16/+0
| | | | | | | | Those constants are tied to the build target, not the minimum or target SDK versions (so compilation will already complain if you're using a too old version.) Change-Id: I54376eb7c44f749e1494ff8a39987ec1aa6117ad
* Merge "28319: Lint ignores tools:ignore="InefficientWeight""Tor Norbye2012-04-053-1/+32
|\
| * 28319: Lint ignores tools:ignore="InefficientWeight"Tor Norbye2012-04-053-1/+32
| | | | | | | | Change-Id: Ic8bbb084b08a3f35c651959217ee3d24c8ae61c5
* | Merge "28321: Lint didn't warn about "new Long(long)""Tor Norbye2012-04-052-5/+10
|\ \
| * | 28321: Lint didn't warn about "new Long(long)"Tor Norbye2012-04-052-5/+10
| |/ | | | | | | Change-Id: I69d053e4242e0af2080fdd9ed233fd10c8963d1b
* | Merge "Fix issue 28201: Check API levels through static dispatch as well"Tor Norbye2012-04-054-0/+41
|\ \
| * | Fix issue 28201: Check API levels through static dispatch as wellTor Norbye2012-04-054-0/+41
| |/ | | | | | | | | | | | | This CL fixes issue 28201: Lint API Level checks fail when static methods are called without stating class name Change-Id: I9b9e92e1d5e17acad1d37d8fd2684f0321132281
* | Fix issue 28330: Gracefully handle corrupt .class filesTor Norbye2012-04-053-8/+37
|/ | | | Change-Id: Icf9c3cdd105f1edb653260e0a76419bcfc9ef83d
* Merge "27471: Lint check for match_parent vs fill_parent on older APIs"Tor Norbye2012-04-024-10/+39
|\
| * 27471: Lint check for match_parent vs fill_parent on older APIsTor Norbye2012-04-024-10/+39
| | | | | | | | Change-Id: I2ff5e88fce13f9016b27878ece2c45ea1b58ad7a
* | Merge "Fix 27966: Android lint null pointer crash"Tor Norbye2012-04-021-1/+1
|\ \
| * | Fix 27966: Android lint null pointer crashTor Norbye2012-04-021-1/+1
| |/ | | | | | | Change-Id: I3ea0ce70ab0a3a191acd3f181878bb8ceb1538fe
* | Merge "27629: DrawAllocation doesn't catch allocations done in View.layout()"Tor Norbye2012-04-022-2/+74
|\ \
| * | 27629: DrawAllocation doesn't catch allocations done in View.layout()Tor Norbye2012-04-022-2/+74
| |/ | | | | | | Change-Id: I2784712f5b298e7103c12d04bc7ae7fbeefd9cdf
* | Add lint detector for Toast.makeText() without show()Tor Norbye2012-04-024-1/+242
| | | | | | | | | | | | | | | | | | | | | | This changeset looks for Toast.makeText() calls where there is no corresponding show() afterwards on the Toast object, which is a common mistake. It also looks for attempts to pass a custom duration value, which is wrong: only Toast.LENGTH_SHORT or Toast.LENGTH_LONG are valid. Change-Id: I3a68e8934ddac76d1277f0fd292c329f30b192ee
* | Add exported content provider check to registryJon Larimer2012-04-021-1/+2
| | | | | | | | Change-Id: I3d3f0ead1397ee994ea58d57228457421ca9411a
* | Merge "Add content provider permission check"Jon Larimer2012-04-025-2/+160
|\ \ | |/ |/|
| * Add content provider permission checkJon Larimer2012-04-015-2/+160
| | | | | | | | | | | | This check looks for exported content providers with no permissions. Change-Id: I1b318b80dc8dc560c42a05db2e4dfa5bd7f45f9d
* | Merge "27584: Detect misplaced <uses-library> manifest tag at build time"Tor Norbye2012-04-025-3/+108
|\ \
| * | 27584: Detect misplaced <uses-library> manifest tag at build timeTor Norbye2012-03-235-3/+108
| | | | | | | | | | | | | | | | | | | | | (Also identifies other misplaced elements -- activities, services, uses-screens, etc etc) Change-Id: Ie9fee95c05715001be6af23c1cdd86e895e43509
* | | Merge "27441: LINT: Incorrect WrongViewCast message"Tor Norbye2012-04-025-4/+71
|\ \ \ | |_|/ |/| |
| * | 27441: LINT: Incorrect WrongViewCast messageTor Norbye2012-03-235-4/+71
| |/ | | | | | | Change-Id: I9687c0c59e13c340b2d564d5aa17635153d88d07
* | 27613: Lint false alarm on android:enabled being deprecatedTor Norbye2012-03-232-3/+6
|/ | | | Change-Id: I871f390c964cfbb8d6c4883ce426bbaa8869f446
* Add guava dependency to test projectTor Norbye2012-03-191-1/+1
| | | | Change-Id: Ic9fb4ab0838e8039e591007867df869d6130b88f
* Merge "Fix lint issues 27108, 27109 and 27110"Tor Norbye2012-03-1911-56/+132
|\
| * Fix lint issues 27108, 27109 and 27110Tor Norbye2012-03-1911-56/+132
| | | | | | | | | | | | | | | | | | | | 27108: lint confused by escaped percent signs 27109: Lint misreports resources as unused when the fully qualified class name is used 27110: Lint attribute to ignore an unused resource doesn't work for reference XML drawables Change-Id: Id8457d8305e5d2770bc8ab547a0735c63117682c
* | Dynamically link Guava and ASM in lint jarsTor Norbye2012-03-193-6/+3
|/ | | | | | | | | | The Makefiles for the lint, lint_api and lint_check libraries were *statically* linking in the Guava and ASM libraries. This made them much larger than necessary (~1.6M instead of ~100K), and for no good reason since the classes were already on the classpath, and of course this duplicates them repeatedly. Change-Id: Iec3ed623429ab8b7b8ba78f5d7a069853ae665c3
* Add getSharedPreferences to worldreadable/writable checkJon Larimer2012-03-153-9/+26
| | | | | | | Add getSharedPreferences() to the method list in the WorldReadable/WorldWritable file checks in lint. Change-Id: Ia2922e4bfe9faf70b46b239726a6c65aa9abd3dc
* Added detection for the creation of world-readable files to lintSebastian Porst2012-03-154-5/+30
| | | | Change-Id: I521d53cc23a35c11db3ccff949916c77f3f6f9bd
* Added detection of android.webkit.WebSettings.setJavaScriptEnabled to the ↵Sebastian Porst2012-03-144-1/+133
| | | | | | lint tool. Change-Id: I8be9fadfe2de26ac6f4a3bd299054a9678697f27
* Lint check tests: fix windows path separators.Raphael2012-03-121-2/+13
| | | | | | | | | | The output from the lint check typically contains a few directory/filenames. On Windows we need to change the separators to the unix-style forward slash to make the test as OS-agnostic as possible. Change-Id: I6f223fda8c294eaee2f4e522df1cc10a6145ef22
* 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