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
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
-- 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
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
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
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
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
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
-- 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
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
Incremental API parsing works on a single class at a time, which
greatly reduces memory pressure. For example, linting a typical
current.txt would use ~100MB before; now it only uses about ~15MB!
Change-Id: Id084b3dd2f6513d0e919790d5a5d629f80637ce8
Updated boolean set/get tests to handle isFoo() and hasFoo() style
methods.
When listeners are passed as method argument, they should come near
the end of the argument list.
Verify that resources are named consistently.
Slightly clearer message wording overall.
Change-Id: Id22947bd932d82222ce3e6c6e2012dade348fb56
When overloading methods, verify that common arguments always come
first and have consistent ordering.
When methods register listeners or callbacks (outside of the UI
toolkit), verify that an overload exists that takes a Handler to
deliver events through.
When a method accepts a Context argument, it must be the first
argument.
Change-Id: I6a6f94a3a0a8c48987835e47eb87564e569db2af
When reporting lint errors/warnings, reference the relevant
underlying rule. Also adds a few more lint rules, and removes a few
aggressive checks.
Change-Id: I1bdadf5fd4df9cd28bb7dfe1c7bb1f9055398315
Also create separate class to describe failures, which can be
consumed by other tools. Still offers to render itself for console
output by default.
Change-Id: Ib0555cc289ae08a0e446489509cc964c866c564e
Ignore deprecation, synchronized, and throws definitions. Look
through full inheritance hierarchy to catch refactored classes like
BaseBundle.
Change-Id: I10ab0b4a0ef64e7508f38d0c223f08711293d643
Now offers to parse the output of git blame, and includes the last
person to modify that API for each reported failure.
Add more exemptions, and check for boolean setFoo() method inside a
separate Builder inner class.
Change-Id: Id32dcbd5edf17d2360e4f782110bc1c445f7936e
When offering a helper Service, etc, all platform provided methods
should be marked final. Otherwise, if available for developer to
override, they should follow onFoo() style naming.
Catch anyone returning concrete collections types, and look for
overlapping flags.
Change-Id: I29d95f3dff78a4da968a46f10be89eada509648c
Now it can identify layering violations, like when something deep in
android.os depends on android.app.
Change-Id: I94606c642195b3ed7558ff6979ed4a181cd85fa2
Detects common public API mistakes, making it easy to quickly scan
across all changes in a new API level.
Builds in-memory representation of the current API, then runs various
detectors over the classes. It collects failures, and can ignore
known failures from a previous API level.
Example usage:
$ python frameworks/base/tools/apilint/apilint.py \
frameworks/base/api/current.txt \
prebuilts/sdk/api/21.txt
Change-Id: Ie1f88894baf9f79e4b11e78c47f848ea5e25fc25