aboutsummaryrefslogtreecommitdiffstats
path: root/lint/libs/lint_checks/src/com
Commit message (Collapse)AuthorAgeFilesLines
...
* | Add lint checks for wakelock and secure random problemsTor Norbye2012-07-233-1/+258
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds new two lint bytecode-based detectors. The WakelockDetector looks for problems with wakelocks: - Calling release() in onDestroy() rather than in onPause() - Calling acquire() but never calling release() anywhere in the app. The SecureRandomDetector looks for problems with the SecureRandom random number generator: - Calling setSeed() with a fixed number, such as a string literal, or something equivalent (such as a static field reference of this or some other class) - Calling setSeed() and passing in System.nanoTime or currentTimeMillis since these are considered predictable seeds. These are both using the new fast-dispatch mechanism for bytecode detectors in lint. In both cases, there are more complex control flow we should be checking using flow analysis; that's for an upcoming CL where we add ASM's analysis library. Change-Id: Iec2a95b042b8a3e4e976923cc62e9dccf2dfeca5
* | Add bytecode method call dispatch for lint rulesTor Norbye2012-07-238-201/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds shared dispatch for bytecode based rules. We already have this for XML and Java source trees: detectors can register interest in a particular element or attribute name, or a particular method call name, and then the source is processed in a single pass, and a quick map lookup dispatches to any detectors interested in that particular item. This has the important property that adding new detectors does not linearly slow down lint: it does not process each XML document an extra time for each newly added rule: the new rule just adds one more entry into a dispatch table, and only for the specifically interesting tag name (for example) is there an extra dispatch to the new detector. This changeset adds a similar mechanism for the ASM based bytecode detectors. Until now, each detector would be handed the class node of the outer class. This changeset adds a couple of new dispatch methods: First, a way to register interests in method calls of a particular type, and second, a way to registere interest in types of ASM nodes. In addition to the new visitor, this changeset rewrites a couple of detectors to use the new dispatch approach (there are new detectors in the pipeline which will also take advantage of this), and cleans up handling of positions a bit. Change-Id: Ib115bd3418b6c63bdcd49fec046e91a73daf38a9
* | Added a lint check that makes sure no private keys are packaged in an app.Sebastian Porst2012-07-192-1/+123
| | | | | | | | Change-Id: I65d7064efb36002713a3083378af9200331ce793
* | 35190: Lint doesn't detect illegal API usage in constructorTor Norbye2012-07-192-7/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | Constructors are not like methods: they are not inherited into subclasses. The Lint API check needed some special handling of constructors to avoid this, since it was looking up inherited constructors and treating them as accessible. In particular that meant it wouldn't flag new IOException(Throwable) as requiring API 9, since its superclass had a constructor which also took a Throwable (with API 1). Change-Id: I268752be506f12399ce4855d2cf7bec76012e4c2
* | Merge "35054: lint reports resources as unused when used in plurals"Tor Norbye2012-07-171-1/+4
|\ \ | |/ |/|
| * 35054: lint reports resources as unused when used in pluralsTor Norbye2012-07-171-1/+4
| | | | | | | | Change-Id: Id437ef30e1488c96a46ccea45459694fd23db582
* | Merge "Detect incorrect state lists"Tor Norbye2012-07-171-11/+43
|\ \
| * | Detect incorrect state listsTor Norbye2012-07-171-11/+43
| |/ | | | | | | | | | | | | | | | | | | | | Lint already had a check for <selector> lists where it detects the case where you have an empty child not in the last position; this will match everything, and hide all subsequent states. This changeset generalizes this check: It makes sure that no state is fully matched by a previous state. Change-Id: I43b80beb531e68008d82f6c620739ca179d0f8f8
* | Change field getter threshold from API 8 to API 9Tor Norbye2012-07-161-5/+5
|/ | | | | | | The Dalvik optimization to automatically inline getters was introduced in Gingerbread, not Froyo. Change-Id: If14288aa398206d4eebfa57ccc7ddfabc6dde83d
* Add code completion and API checks for theme references (?attr)Tor Norbye2012-07-161-15/+24
| | | | | | | | | | | | | This checkin improves the handling of ?attr and ?android:attr theme references, such that (1) The API check considers theme references, and for example flags usage of ?android:attr/dividerHorizontal if your minSdkVersion is lower than 11 (2) Adds theme reference completion to the XML code completion. Change-Id: I2049b828e413802ac81579294f515fb0a4faccdf
* Make API check also look at <view> tagsTor Norbye2012-07-161-0/+9
| | | | Change-Id: I3d1e4e75aef44886185521fca57bc54b0b1e7cc0
* Only report field getter issues when targeting pre-Froyo targetsTor Norbye2012-07-161-1/+10
| | | | Change-Id: Ibc8756c2580a9e263b63b3507224acdf09f264ed
* Improvements to bytecode-to-source offset computationTor Norbye2012-07-165-17/+29
| | | | | | | | This changeset improves the way lint searches for the correct source offsets (and line numbers) for symbols found in .class files. Among other improvements this also fixes issue 34686. Change-Id: I7a2f40f0d930a4786dc69a7f0e0bbf5367a30ad4
* Merge "Add lint check for usages of dp instead of sp for textSizes"Tor Norbye2012-07-022-8/+43
|\
| * Add lint check for usages of dp instead of sp for textSizesTor Norbye2012-07-022-8/+43
| | | | | | | | Change-Id: I9cc1899491b49dbc9e62287dd23efd0efa128fce
* | Merge "- Fixed a bug in the lint check for unprotected broadcast receivers ↵Tor Norbye2012-07-021-1/+18
|\ \ | | | | | | | | | to ignore unprotected receivers for default Android actions."
| * | - Fixed a bug in the lint check for unprotected broadcast receivers to ↵Sebastian Porst2012-07-021-1/+18
| |/ | | | | | | | | | | ignore unprotected receivers for default Android actions. Change-Id: I4c5c72e25d299fbfb9b13140aae9b14650166313
* | 33792: UseCompoundDrawables incorrectly flags if scaleType is usedTor Norbye2012-07-021-0/+10
| | | | | | | | Change-Id: I3499900277b108ac9d2a214d1078a20d29409c5a
* | Fix lint attribute positions in the CLITor Norbye2012-07-021-1/+1
|/ | | | Change-Id: I795a93b5d4b3041ba9892d5d3eb226de1873a88c
* Add typo detectorTor Norbye2012-06-223-1/+731
| | | | | | | | | | | This changeset adds a new typo detector. There are also some lint infrastructure fixes to better handle positions within text nodes, and to allow Eclipse lint quickfixes to supply multiple fixes for a single issue (such as multiple misspelling alternative replacements.) Change-Id: Ie26f0bafc571e02ae09ff27a7f4b221fe0c2ea5b
* Launcher activities are not flagged as unprotected anymore if they are not ↵Sebastian Porst2012-06-151-1/+20
| | | | | | protected by permissions. Change-Id: I4811757779ca8048cd84f51173d8325d9f4af3d7
* Merge "Added lint checks for unprotected activities and export receivers, ↵Tor Norbye2012-06-132-25/+84
|\ | | | | | | analogous to the existing lint check for unprotected services."
| * Added lint checks for unprotected activities and export receivers, analogous ↵Sebastian Porst2012-06-132-25/+84
| | | | | | | | | | | | to the existing lint check for unprotected services. Change-Id: I661c7a28853a521cd02e869a3dde97e56684dd56
* | Fix license headers.Tor Norbye2012-06-123-8/+10
|/ | | | Change-Id: I95c209535f39c1ef1384f75e19b9ab54f099a58c
* Added detection code for malformed phone numbers that are passed to the SMS ↵Sebastian Porst2012-06-122-1/+104
| | | | | | sending API functions Change-Id: Iad5fd3e1e9c0add65da6717a601fad8ea2e9b84e
* Fix warningsTor Norbye2012-06-017-26/+39
| | | | | | | | | | | | | | | | | 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-3056-237/+271
| | | | | | | | | | | | | | | | | | | 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-302-1/+170
| | | | | | | | | | | | | | 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-303-44/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-222-5/+38
| | | | | | | | | | | | | | | 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-211-0/+11
| | | | | | | | 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-162-1/+59
| | | | Change-Id: Ia1b023979d2c817e13a67cd5f3f85c1ddd4f65a2
* Run lint on save in Java files, checking .java and .class filesTor Norbye2012-05-147-16/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-092-55/+11
| | | | | | | | | | | | | | | 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-082-1/+176
| | | | Change-Id: I9fd1669b91303b0f82c6abf2114b7e72a72697dd
* Merge "Fix nested linear layout weights lint check"Tor Norbye2012-05-021-6/+5
|\
| * Fix nested linear layout weights lint checkTor Norbye2012-04-281-6/+5
| | | | | | | | | | | | | | 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-273-2/+180
|/ | | | 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-231-0/+11
| | | | | | 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-091-15/+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-051-1/+1
|\
| * 28319: Lint ignores tools:ignore="InefficientWeight"Tor Norbye2012-04-051-1/+1
| | | | | | | | Change-Id: Ic8bbb084b08a3f35c651959217ee3d24c8ae61c5
* | Merge "28321: Lint didn't warn about "new Long(long)""Tor Norbye2012-04-051-5/+9
|\ \
| * | 28321: Lint didn't warn about "new Long(long)"Tor Norbye2012-04-051-5/+9
| |/ | | | | | | Change-Id: I69d053e4242e0af2080fdd9ed233fd10c8963d1b
* | Fix issue 28201: Check API levels through static dispatch as wellTor Norbye2012-04-051-0/+3
|/ | | | | | | This CL fixes issue 28201: Lint API Level checks fail when static methods are called without stating class name Change-Id: I9b9e92e1d5e17acad1d37d8fd2684f0321132281
* Merge "27471: Lint check for match_parent vs fill_parent on older APIs"Tor Norbye2012-04-021-0/+16
|\
| * 27471: Lint check for match_parent vs fill_parent on older APIsTor Norbye2012-04-021-0/+16
| | | | | | | | 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