summaryrefslogtreecommitdiff
path: root/tools/apilint
AgeCommit message (Collapse)Author
2021-05-26Reintroduce "Deprecated at Birth" linter.Jeff Sharkey
Earlier this year the "apilint.py" script was removed from the build, since it's been replaced by Metalava. However, several features haven't been ported yet, so this change revives them to support the SDK finalization process. This change also updates the script to handle "Signature format: 2.0" files, and reads the API surface from a directory which contains several ".txt" files to support the new Mainline API structuring. Bug: 189224267 Test: manual Change-Id: Ifc4c24a7e159db6725897800d67947d1fd8b9880
2019-11-01API Lint: remove obsolete python linterAdrian Roos
Linting is performed by metalava as part of the build now. Test: n/a Change-Id: I6223549657912fdf305a17f66f55b97561f7f7ac
2019-10-10Merge "apilint: suppress certain nullability lints"Adrian Roos
2019-05-08Apilint updatesJoe Onorato
- Make apilint not print in color when added to file. - Make apilint able to filter for classes or packages - Add frameworks/base/tools/apilint/apilint script that has convenient commandline interface for the main common use cases. Bug: 132198274 Test: apilint_test.py Test: manual Change-Id: I78341f42b0fdf4b73a724423b14545b1861a3293
2019-04-29Handle removed classes when looking for deprecated at birth APIs.Michael Wright
Removed APIs cause a KeyError when looking them up in the current API surface. Instead, check if they're there first and if not just move on since they no longer exist. Bug: 129975435 Test: looked for new and deprecated system APIs Change-Id: I46daa83ec8376190112418720f848afdf7cd7df2
2019-03-26Also need to filter second pass.Jeff Sharkey
Bug: 116802409 Test: manual Change-Id: I874cea7987684a8f7dca5c4d03d226568f355d8d
2019-03-06apilint: suppress certain nullability lintsAdrian Roos
Fixes: 126699235 Test: python tools/apilint/apilint.py api/current.txt Change-Id: Ifdce2d8c6da7c8fbfc9288d8d0eed4cfad49ebe1
2019-03-06apilint: Lint unhidden @IntDef and @LongDefAdrian Roos
@IntDefs and @LongDefs cannot be stored in a .class file, because the constant names are lost. Instead, they are packaged out-of-band. Therefore, they should never be in the API. Test: python tools/apilint/apilint.py api/current.txt Change-Id: If22e0cf7db0bb90dae6174bf546f2ec8be4e5458
2019-03-05Merge "Apilint: No longer flag interface callbacks"Adrian Roos
2019-03-05Apilint: No longer flag interface callbacksAdrian Roos
With default interfaces, this is no longer necessary. Test: python apilint_test.py Change-Id: Ifa9ba24511a82797089934009d9096c3a589e7f6
2019-03-05apilint: decorator-based verifier registrationAdrian Roos
Registers verifiers via a decorator to avoid error-prone registration elsewhere. Test: Run apilint before and after the change, verify identical output Change-Id: I77ae47a2f3f1a486bb78d3167f8439ade6fc28ab
2019-03-05Apilint: lint for URL/URIAdrian Roos
Test: python apilint_test.py Change-Id: Iebe3b48df7ed69e0b5f5ff372b72f68ca9f8efec
2019-02-28Apilint: report all implemented interfaces and fix false positivesAdrian Roos
Test: python apilint_test.py
2019-02-28Apilint: properly parse packages with numbersAdrian Roos
Test: python apilint_tests.py Change-Id: Ib0ad635e3994bbcbfecefddbd4899c3551ab65cf
2019-02-28Apilint: Lint missing nullability annotationsAdrian Roos
Also adds support for limited range blame parsing. Bug: 124882145 Test: python apilint_test.py Change-Id: Idbc7f67eeff27902c37ec482278f5888781c6e78
2019-02-28Apilint: Enforce final buildersAdrian Roos
Test: run apilint Bug: 124883027 Change-Id: I7f2866e46bc40be60487846b2af9f8fd7edb7623
2019-02-27Merge "apilint: Correctly parse packages with annotations"Adrian Roos
2019-02-26apilint: Correctly parse packages with annotationsAdrian Roos
Test: python apilint_test.py Change-Id: Ifce9fe3836b2bb46b0d0a255b912fd8bf0195621
2019-01-29apilint: Allow parsing 3.0 signature filesAdrian Roos
Test: python apilint_test.py Change-Id: I59df950229c05329afde93f94efc13adb4640ad7
2019-01-22apilint: correctly parse enum_constantAdrian Roos
Change-Id: I1a243caa3a01837ff989d21926478f20d70372ae Fixes: 120132045 Test: python apilint_test.py (cherry picked from commit 373df11baab1fbbd9f6986e38a1a929abc901d63)
2019-01-22ApiLint: Add operator keyword and property parsingAdrian Roos
Also fix up some issues with expression parsing, type use annotations, etc. Test: python tools/apilint/apilint_test.py Change-Id: I38145a51470ce6c3e5813a546d681489fd87fc19 (cherry picked from commit 403c8e35d8e7cc0f81a0a2c42d038c47e1b2703f)
2019-01-22ApiLint: Add Kotlin-style type supportAdrian Roos
Test: tools/apilint/apilint_sha.sh HEAD && python tools/apilint/apilint_test.py Change-Id: Iac1fdabcbeffe57c8288d73b2359e8ce0b2bc3eb (cherry picked from commit 7884d6b9090c586ac0d72abe0e6efab191a143a7)
2019-01-22ApiLint: Performance improvements for verificationAdrian Roos
Test: tools/apilint/apilint_sha.sh HEAD Test: python tools/apilint/apilint_test.py Change-Id: I90f18181cd0d3c43f176d7c9d1b198f6f5172390 (cherry picked from commit 7f8886a9933abbb6f1fdd97d920185b80d439339)
2019-01-22ApiLint: Performance improvements for 2.0 signature format parsingAdrian Roos
Test: tools/apilint/apilint_sha.sh HEAD Test: python tools/apilint/apilint_test.py Change-Id: I76b979dd81702afce6468ac377230e589a25e08f (cherry picked from commit a30d062775da3812589a6ce3e49be9d697ef0d6d)
2019-01-22ApiLint: Allow parsing 2.0 API signature filesAdrian Roos
Test: tools/apilint/apilint_sha.sh HEAD Test: python tools/apilint/apilint_test.py Change-Id: Id2e1792392b3626746f1ec99f481d0cb27e523a1 (cherry picked from commit d170961b02bf67189ddd14f358c9f263009df786)
2019-01-22apilint: Fix API lint issues 2/2Adrian Roos
Fixes false positives that occur when a class in current.txt is faulty, and an entry for that class is then added to system-current.txt. This was so because when parsing the previous revison's system-current.txt, we did not know about the class and thus didn't look for it in current.txt, and thus never recorded that the error is preexisting. To avoid that, we track all classes in system-current.txt with a matching entry in current.txt in the current revision, and later use that to look up all classes we may have missed when examining the previous revision. Test: python tools/apilint/apilint_test.py Change-Id: Ibe09f1159e351e56b35b8816ce0db760de4ef791 (cherry picked from commit 61e3730bc07e04181a01760d2eb1db834a854683)
2019-01-22apilint: Fix API lint issuesAdrian Roos
Fixes a bug where only the name instead of the fully qualified name was considered when looking for a class, which lead to faulty results for inner classes. Test: python tools/apilint/apilint_test.py Change-Id: Ib015669ed3faef21d2bdd16f1e27bc55c8669d70 (cherry picked from commit 2c5cacfd36128f43f5fab4f0665acf69ac049a44)
2019-01-22API Lint: Add support for base current.txtAdrian Roos
Allows specifying a base current.txt and previous.txt file when linting system-current.txt and test-current.txt to avoid false positive error messages due to public API members not being duplicated in the respective non-public APIs Test: python tools/apilint/apilint.py --base-current=api/current.txt api/system-current.txt Change-Id: I306a99b1423584ef3fcdc9272a83cb5eacc37227 (cherry picked from commit 7690d0d4eea0ffa429351b0b1caa34cdb3e0d37f)
2019-01-22Guide towards Context.createPackageContextAsUser().Jeff Sharkey
It's a better alternative that should be used instead of adding new "ForUser" or "AsUser" methods. Bug: 115654727 Test: manual Change-Id: I8742c2ef42d743ef69f8f7a91378f498fdc81e43 (cherry picked from commit 86445841ac90e04941dbc8dad34f2a893a2e0f8b)
2019-01-22Moar lint rulez!Jeff Sharkey
Bug: 37534642, 116675691, 116798271, 72059458, 111790177 Test: manual Change-Id: Ib079ae580a827f225be08f90dbdddeee7d341c48 (cherry picked from commit daac37f229f84ed844adcf1ffd3432b235524d9b)
2019-01-22Update lint rules for graphics/text package layeringSiyamed Sinir
Test: N/A Bug: 77347886 Change-Id: I907d99b4a1dee0c69b914e55a033d3d9c4eebe56 (cherry picked from commit e23aeb802409cb337ad66454049c9e3b6af0db9a)
2019-01-22Handle new current.txt format.Jeff Sharkey
We're starting to see "@interface" show up, so handle them like any other interface. We're also seeing more details argument lists with names and annotations; ignore them for now, since all our existing lint checks work on the "real" data type. Verified that it handles new support library current.txt files without causing any regressions against existing framework current.txt files. Test: manual inspection Bug: 111555356 Change-Id: Id11c3561edd317e4ba1a9b43993fd96d8243e00d (cherry picked from commit bd2611916990b0d18a36483060365207fdd94c13)
2019-01-22Extend lint script to emit API statistics.Jeff Sharkey
Bug: 77588754 Test: manual Change-Id: I240dba5fae1a8635a4265a1af903517f00dec54c (cherry picked from commit daa7cf3a365c24e3a81d0df178c188b12e6d3a91)
2018-04-11Lint to identify "deprecated at birth" APIs.Jeff Sharkey
When API council requests changes, teams regularly perform the requested refactoring, but simply mark the old APIs as @Deprecated without @removed, due to internal users. As part of finalizing an SDK, we should ensure that no new APIs are marked @Deprecated, since they're typically cleanup that someone forgot to finish. This extension to the lint script makes it easy to identify these cases. $ python tools/apilint/apilint.py --show-deprecations-at-birth \ api/current.txt ../../prebuilts/sdk/api/28.txt $ python tools/apilint/apilint.py --show-deprecations-at-birth \ api/system-current.txt ../../prebuilts/sdk/system-api/28.txt Bug: 77588754 Test: manual inspection Change-Id: Ie9658006bb08f780bee0e503481d3bafec1038a1
2018-02-16Recommend ICU replacements, no clone, no Impl.Jeff Sharkey
When ICU has a better replacement class, recommend that APIs use that instead. Yell if someone implements clone(), and point them towards a copy constructor instead. Yell if someone exposes "Impl" classes. Test: manual Bug: 73392214, 71906588, 62627348 Change-Id: I75dcba2c4ab7ca426057eefb0335c935c3ced79a
2018-01-12Add another pass of commont lint rules.Jeff Sharkey
-- Parcelables should be inflated through CREATOR -- Methods with no arguments should throw ISE -- Examine constructors for Executors -- Listeners should always be last for lambdas -- Verify naming of UserHandle methods -- Verify naming of Params objects -- Verify naming of Context service constants -- Verify tense of enabled methods Better exception tracking. Test: manual inspection Bug: 37784434, 37749454, 37705832 Bug: 37705176, 37536230, 37533040, 71866617 Change-Id: If2f19784c46a4d99f54577a7365babfd357ca3f7
2017-12-05Executors instead of Handlers; collections.Jeff Sharkey
New API council guidance is to have developers provide an Executor instead of a Handler for specifying where a callback should be dispatched. Recommend that raw arrays be switched to Collections<> instead. Disable overload checking, since it's far too noisy. Test: sanity-checked linter output Bug: 37893784, 34192159 Change-Id: Ifc9a69bfed1a1004c6604e12987a606d1d3fd6af
2017-11-20Collect set of "changed" classes.Jeff Sharkey
Generate hash of each class to quickly identify which classes have been touched between two API files. Test: manually verified Bug: 69115817 Change-Id: I0be92ec8a4e9ef6ca603e70c8164e10a2eaf4161
2017-11-13Add api lint to upload checksJason Monk
Currently will never block upload, only considered a warning, but will print out any lint issues discovered. Test: do an upload Bug: 69115822 Change-Id: I69b8e5a3f92ac28ee3c954408e88a1056c33af65
2017-08-23Add checks for Kotlin keywords and operator functions.Jake Wharton
Test: Ran against current.txt and observed warnings. Change-Id: I071d564885be3a0c97bca77d93c9a107ecde583c
2017-05-04Stop deprecated parcelables triggering Error FW8Joe LaPenna
Test: Ran against system-current with and without the cl. Change-Id: I492e211701b16e660bbc57913220a93df1ed31ac
2017-04-19Bunch of new API lint rules.Jeff Sharkey
Test: manual verification Fixes: 34709091 Fixes: 36699437 Fixes: 36737455 Fixes: 36737419 Fixes: 37279778 Fixes: 37283667 Fixes: 37473581 Fixes: 37505566 Fixes: 37509300 Change-Id: Ie5dbcc2932313225e5cbc1f4aa6961e4db2f3d45
2016-12-21Tighter equals/hashCode method checking.Jeff Sharkey
Test: false-positive no longer triggered Bug: 32721082 Change-Id: I49b6225a7282d0bb84b0dfb4cabe56e9f68186a9
2016-12-21Detect non-static abstract inner classes.Jeff Sharkey
Test: script detects issue Bug: 32982018 Change-Id: I4e3521bf603f6272bfe5583e3d4977dd5b59afe8
2016-11-29Adds keyword "default" to the API-linter.Filip Pavlis
This will fix issue when linting Java 8 default methods on interfaces, e.g. Ie46a876dcb14b46b8b2584735c106c25655ec6cf. Test: Manualy tried that the linter no longer gives the error. Change-Id: I68ade6ba6401439667408076a5454caef77ef72d
2016-03-30Make Parcelable classes final, API cleanup.Jeff Sharkey
Remove some Context methods that leaked through. Add lint rule to recommend using List<? extends Parcelable> instead of Parcelable[]. Bug: 27932224, 27930145, 27932911 Change-Id: Ia302de46cdb0c5101fa175a09316df91aeefcf0d
2016-02-29More lint checks.Jeff Sharkey
-- Error if Parcelable classes aren't final. -- Warn that MIN_/MAX_ constants that should be dynamic. -- Error if throwing raw RemoteException. -- Warn if methods accept File without stream variants. -- Ignore upstream ICU project. Bug: 27410989 Change-Id: I12d843e63078dc696c1798a20e088608f1ba9ed1
2015-04-10Relax apilint FW1 error to a warningAdam Powell
This rule was catching simple getters ("getIntent") as errors even if the method is a true property get method. Relax to warning until we can make this a bit more clever. Change-Id: If183ad5bdc076ce2252399d4abcc8a3a6cbb55c3
2015-03-27Add support for GmsCore to apilint.pyAdam Metcalf
Add flag to allow references to google. Refactor argument parsing to use argparse. Change-Id: I5fd3b6628a00113b9644dcae2919632db056909d
2015-02-25Relax Handler lint check slightly.Jeff Sharkey
This way we avoid yelling at support library APIs. Change-Id: I20bab887fe8b1c7f4d197273ddedbcda48c5a429