summaryrefslogtreecommitdiff
path: root/java/lint.go
AgeCommit message (Collapse)Author
2025-03-13Change CommonModuleInfoProvider to a pointer. Yu Liu
Bug: 358427516 Test: Manually verified genereated ninja and mk files, unit tests. Change-Id: I53a6dd718232735decbeb93febfd269dd9449e86
2025-03-07Rename CommonModuleInfoKey to be consistent with others. Yu Liu
Bug: 377723687 Test: Unit tests and compare the ninja and mk files generated. Change-Id: I1ce8bc782666586633ded9cfaf1b9590e3c0efde
2025-02-25Convert the following singletons to use ModuleProxy: Yu Liu
buildTargetSingleton exportedJavaDeclarationsLibrarySingleton javaFuzzPackager kytheExtractAllSingleton kytheExtractJavaSingleton kytheExtractRustSingleton lintSingleton logtagsSingleton makeVarsSingleton ndkAbiDiffSingleton ndkAbiDumpSingleton phonySingleton platformCompatConfigSingleton sdkSingleton Bug: 377723687 Test: Unit tests and compare the ninja and mk files generated. Change-Id: I625ac8a209ca93755b2ba232202cfb44ecefde0a
2025-02-12Move dists to GenerateAndroidBuildActions Cole Faust
So that we're not as make-focused by disting in MakeVarsProviders. Bug: 395184523 Test: Verified ninja files were unchanged (on both m nothing and m nothing dist) Change-Id: I5fd94754d644162b355722fbb1e1fd6f085345b9
2025-01-15Convert initHiddenAPI, lint and proguardBuildActions to use ModuleProxy. Yu Liu
Bug: 377723687 Test: Unit tests and compare the ninja and mk files generated. Change-Id: Icde6331533685be54f7ee2e86696da05a77431b6
2025-01-10_test module types shouldn't override user-set test property Cole Faust
Android lint considers code "test" code depending on if the --test flag is passed. We pass it by default for *_test module types, but also allow the user to control it via the "lint: { test: true }" property. However, the module types were overriding the user-defined test property if the user-defined one was supplied via a defaults module. Split the test property into two so that modules can use a separate lower priority one from the user-controlled one. Fixes: 358643466 Test: m nothing --no-skip-soong-tests Change-Id: I1b1ef7a73ca9f413aa29e0c6025134fc52dc7caf
2025-01-06Increase lint JVM heap size to 4GB Jared Duke
This aligns with the heap sizes used for D8/R8/javac. If needed, we can increase further to 8GB to align with ErrorProne and avoid transient OOM issues for certain targets. Bug: 387971153 Test: m + presubmit Flag: EXEMPT bugfix Change-Id: I00f2d8f26121f7b48df80c5d14a222d550d9228c
2024-10-24Update DepSet references Colin Cross
Update all references to depset to use blueprint/depset, and to use DepSet instead of *DepSet. Bug: 375276086 Test: all soong tests pass Flag: EXEMPT refactor Change-Id: I59a7836d0975366ddc336225fb770ac7e6e0c8ea
2024-09-26Remove top down strict updatability checks Colin Cross
The enforce_strict_updatability_linting and apex_strict_updatability_lint are some of the last top down mutators, and removing them will help with incremental analysis. Both mutators are used to propagate a flag to transitive java dependencies that causes them to add extra checks to their lint rules to require that baselines not include any skipped NewApi checks. Instead of modifying dependencies to check the baselines, propagate the baselines up to the modules that are requesting the checks, and perform the checks on all transitive baselines there. Bug: 367784740 Test: TestJavaLintStrictUpdatabilityLinting Test: TestApexStrictUpdtabilityLint Flag: EXEMPT refactor Change-Id: Ief2e3b26d745da61f13e621d635a5879d9c56779
2024-09-25Use providers for lint Colin Cross
Bug: b/348040422 Test: lint_test.go Flag: EXEMPT refactor Change-Id: I420bee2c7056a3f4acee3af5955f79c504ea61d9
2024-08-12Merge SingletonProviderContext with OtherModuleProviderContext Yu Liu
Bug: 358425833 Test: CI Change-Id: I8e3f40dc3cfc5337008b419801f8e6bf2d48e8b2
2024-05-24Merge Android 24Q2 Release (ab/11526283) to aosp-main-future Xin Li
Bug: 337098550 Merged-In: I4a6dd1c5e48db7085ea41035def31f0844948a46 Change-Id: If8ad1d0d87495bbd685f5f9f03f5eb7ea78bf192
2024-05-03Correct lint error when it cannot find api_versions_* module Paul Duffin
Also, fixes the error when it cannot find a module containing the `annotations.zip` file. Bug: 336993217 Test: change `apiVersionsModule` setting in `lint.go` to refer to a non-existent module and then run `m nothing` to see the error message correctly lists the module name. Change-Id: I84a9e241d1c3bedebc26e119bd4b9861664c43c1
2024-02-05Revert "Print the modules that had strict_updatability_linting set" Cole Faust
This reverts commit ada543ed86dc4828cecdb937844c6468c872d3e3. Reason for revert: b/323773738 Change-Id: Iaddd35b275392c8d0eb7ce1cc65523467462d7b3
2024-02-02Print the modules that had strict_updatability_linting set Cole Faust
strict_updatability_linting imposes requirements on all of a module's transitive dependencies. So you may start getting errors on a module due to some random other module that is hard to track down. Print out the modules that caused the current module to use strict updatability linting so that these errors are easier to debug. Ignore-AOSP-First: The lint code in internal has diverged from AOSP quite a bit now Bug: 323366771 Test: m lint-check Change-Id: I43f2b1adb1ffa5b6e9516694c2bb87c7f94fed7d
2024-01-30Merge "Prevent disabling checks via flags property" into main am: 59739666e6 ↵ Treehugger Robot
am: 5fd64b9c70 Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2933578 Change-Id: I274a32a4cbadb85fadb192f7e60049506791e1e7 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-29Prevent disabling checks via flags property Cole Faust
strict_updatability_linting currently only checks that updatability checks aren't disabled via disabled_checks / warning_checks, you could get around it using the `flags` property. Only allow controlling checks via the *_checks properties. Bug: 322802379 Test: m nothing --no-skip-soong-tests Change-Id: Ia311622e1409f9cc201ab55f8749f2d13fccf551
2024-01-19Re-enable strict updatability linting Cole Faust
Now that all use cases where it would've errored on are removed. Ignore-AOSP-First: the properties were only removed in internal main to make the LSC smaller Bug: 320698986 Test: m nothing --no-skip-soong-tests, and also locally edited soong to add a quick build that runs all the strict updatability checks in the tree and ran that Change-Id: If9e23327a3c0944cc8c6849914fe51dc48bdb626
2024-01-17Promote the NewApi check to an error again Cole Faust
Now that all existing cases have been baselined. Ignore-AOSP-First: Requires a LSC that is difficult to do across branches. Bug: 268261262 Test: m lint-check Change-Id: I413f86ff7a1f33564465f3ba9cd52924a4242901
2024-01-05Add per-module phony targets for lint checks Colin Cross
Simplify running lint on a module by adding a per-module phony target, e.g. Gallery2-lint. Bug: 216462289 Test: m Gallery2-lint Change-Id: I9d4ab362bb116d49f00fc3f79d61d7239528d575
2024-01-04Merge "Use ApiLevel on min, target and compile Sdk version" into main Cole Faust
2024-01-04Don't implicitly pick up lint-baseline.xml Cole Faust
lintable modules currently pick up files named "lint-baseline.xml" to use as the lint baseline implicitly. This is confusing because you could end up using the baseline files in more modules than intended. Lint also has a feature where it requests you remove unnecessary findings from the baseline file, so something could be necessary for one module, but unnecessary for another that accidentally picked up the baseline. All modules that used to pick up the baseline implicitly have been fixed to specify it explicitly already. Fixes: 272769514 Test: Presubmits Change-Id: Id17202e2d119b87ab82c18cb35410b93ed8d5071
2023-12-14Convert ModuleProvder to generic providers API Colin Cross
Convert all of the callers of ModuleProvider/ModuleHasProvider to use the type-safe android.SingletonModuleProvider API. Bug: 316410648 Test: builds Change-Id: I6f11638546b64749e451cebbf33140248dc1d193
2023-12-14Convert OtherModuleProvider to generic providers API Colin Cross
Convert all of the callers of OtherModuleProvider/OtherModuleHasProvider to use the type-safe android.OtherModuleProvider API. Bug: 316410648 Test: builds Change-Id: Id77f514d68761a262d9ea830a601dbed804bbbe5
2023-12-11Merge "Add compile_data for android apps" into main Treehugger Robot
2023-12-08Add compile_data for android apps Cole Faust
Compile_data is a property on rust rules to declare extra files that are used by the compiler. In rust's case this happens commonly with `include_str!()`. Other compilers like javac or aapt2 don't often reach out to other files, so it's not as neccessary. But they will follow symlinks. We're making a change to only include symlinks themselves in sbox sandboxes, and the targets of the symlinks must be listed explicitly. For this, we need compile_data to list the targets of symlinks. Bug: 307824623 Test: m out/soong/.intermediates/frameworks/base/tools/aapt2/integration-tests/SymlinkTest/AaptSymlinkTest/android_common/lint/lint-baseline.xml with the symlink change Change-Id: I33eb9cbe4b6eb25e3f33ea0ac9dade88c3d4a624
2023-12-08303434307: Enable flagged API checking Tor Norbye
Also downgrade the new UseSdkSuppress check from error to warning. And temporarily downgrades FlaggedApi from error to warning until existing violations are resolved. Test: The build Bug: 303434307 Change-Id: Id7802621d567815470dee1aeb815abe214f098cd
2023-11-06Use ApiLevel on min, target and compile Sdk version Zi Wang
This change is a partial revert of aosp/2143082. The reason is that unreleased apis should be referenced by name instead of a number. link to xml reports before/after this cl: https://drive.google.com/drive/folders/1woIgVlHF6qude5RpW-0mEQLzcXo4isX4?usp=sharing Test: m lint-check Change-Id: I6d801f95a24400c9c5c23546e19d6440bd357873
2023-09-29Add lint.suppress_exit_code attribute Thiébaud Weksteen
The Android lint --exitcode parameter can be skipped using ANDROID_LINT_SUPPRESS_EXIT_CODE. Expose a similar attribute to Java modules to ignore the exit code. This is useful for integration testing. It is possible to build libraries that report an error when linted. Othewise, such module would break the checkbuild target. Bug: 302400088 Test: m nothing Change-Id: I372c42184f40d25753a688c380c0c63e9758ca00
2023-06-22Use generics for DepSets Colin Cross
Use Go's generics for DepSets so they don't require a type-specific wrapper and reflection. Test: depsets_test.go Change-Id: I22ba0b7d680d37d2cd05230b0f560d166c4dd20b
2023-05-19Parallelize singleton execution LaMont Jones
Bug: 281536768 Test: manual, presubmits Change-Id: I57fdc76ba6b277e88e196b506af87127a530fd37
2023-03-22Android Lint: allow local override of --exitcode flag mattgilbride
The --exitcode flag tells lint to exit with an error code if any incidents at ERROR level or above are found. Unfortunately, that means an invocation of lint against the entire tree will fail with whichever module fails first. This covers up any other failures and makes updating lint in AOSP more cumbersome. This change allows one to set `ANDROID_LINT_SUPPRESS_EXIT_CODE=true` to modify this behavior and collect full lint results even if there are errors in some modules. Bug: 274780888 Test: Tested manually by changing code to trigger lint errors, and settig/unsetting this flag. Change-Id: I71ab89c9bffafe6eb83171102c2c253171450266
2023-03-02Zip lint reference baselines Cole Faust
To make them easier to work with. Bug: 268261262 Test: m lint-check Change-Id: I42c69d5dd1dc74e1f1963cf72b00b8ee4d608e2a
2023-02-28Give lint the correct api levels database for the current module Cole Faust
Before this change, lint was always working off of the public api database. Now, it will have the system, module-lib, or system-server databases if the current module is compiling against those SDKs. This means that a lot more methods are going to start being checked for NewApi issues. Bug: 193460475 Test: Errorprone presubmit Change-Id: I3eb2c617cd61554cd2a3f9d15fd40b3ec91f961d
2023-02-28Disable strict_updatability_linting Cole Faust
strict_updatability_linting currently only makes it so that NewApi can't be added to the lint baseline. However, since we're updating NewApi to work on a lot more apis than before, we need to baseline many issues across the android tree. Temporarily disable strict_updatability_linting so that we can add these baselines. Bug: 193460475 Test: Presubmits Change-Id: I8d92df95a46e9b903f0cc0e3be56f17722c50430
2022-12-10Always run AndroidGlobalLintChecker.jar with lint invocations mattgilbride
AndroidGlobalLintChecker.jar provides a set of lint checks that should be run across the entire tree. Bug: 236558918 Test: manually tested, treehugger Change-Id: I2a868f1d78c969eefa2c29477fc8ecab1043df39
2022-11-18lint: always run module specified in ANDROID_LINT_CHECK_EXTRA_MODULES mattgilbride
Before this change, ANDROID_LINT_EXTRA_CHECK_MODULES was only read if ANDROID_LINT_CHECK was also set. This change allows an entire module of checks to be added to lint without having to specify all of the individuals with ANDROID_LINT_CHECK. This is part of a workaround to run some lint checks globally, but is useful to provide more flexibility generally. Bug: 236558918 Test: manually tested with AndroidFrameworkLintChecker Change-Id: I2d3ec8a997d902c9d00a577a56f4b152b10e078a
2022-10-26Allow all of libcore to have NewApi warnings Orion Hodson
Required due to minor refactor of libcore projects. Bug: 208656169 Bug: 255273691 Test: TH Change-Id: Ifd2ef6d3553ade5a059880398075c70635d428dd
2022-10-11Create suggested-fixes.zip before exiting on error Colin Cross
suggested-fixes.zip is useful even when lint is exiting with an error. Save the exit code from the lint executable, create the zip file, then re-exit with the exit code. Bug: 216456886 Test: Introduce lint error, verify suggested-fixes.zip is created. Change-Id: I0ba6190e3de0744e53b2a59ba3016861f2f115e2
2022-08-19Merge "Allow libcore to have NewApi warnings" Treehugger Robot
2022-08-17Allow libcore to have NewApi warnings Orion Hodson
The majority of libcore NewApi warnings come from references to new methods, constants, fields added in a file and then referenced in the same source file. Maintaining suppressions is not scalable: they need to work across multiple API versions in different branches. Bug: 208656169 Test: TH Change-Id: If5e746f25f1bd34931ee8c89b363aa92c81e23b3
2022-08-16Merge "Add lint test property" Treehugger Robot
2022-08-16Merge "Collect suggested modifications from lint" Colin Cross
2022-08-15Collect suggested modifications from lint Colin Cross
Pass --apply-suggestions to lint, which will cause it to apply suggested fixes to the source files in the sandbox. Zip up the modified sources and export them outside the sandbox. Test: examine suggested-fixes.zip Bug: 216456886 Change-Id: Iaeb406462c38cf4b10e51d641432ba1fda9327fa
2022-08-11Add lint test property Cole Faust
Some libraries are only used for tests, but are not test module types. These modules get warnings about @VisibleForTesting usages when they really shouldn't. Expose a test flag that module authors can use to make lint treat a module as test code. Bug: 235339747 Test: Manually tested applying it to SystemUI-tests Change-Id: I1356749a669dc80a7725605d7159da27c9a211b4
2022-07-12Downgrade/disable lint checks Cole Faust
Lint is being updated, and some of the new checks have many failures or false positives in the current android tree. Bug: 215567981 Bug: 238784089 Test: Presubmits Change-Id: I33a47d3c0404ca37f0334421a02bb80f745ae792
2022-07-01Merge "Revert^2 "Fix erroneous "Field requires API level 33 (current min is ↵ Cole Faust
32)" warnings""
2022-07-01Revert^2 "Fix erroneous "Field requires API level 33 (current min is 32)" ↵ Cole Faust
warnings" This reverts commit 5d80d895b6e99e881454919e7b40f4ae78696582. Reason for revert: The issue that broke the build the first time this was submitted has been fixed in ag/19125702. Also the errorprone build was added to presubmit for changes to these files so we should hopefully catch any other issues at presubmit now: cl/458501206 Change-Id: I80ca08df49c58a1ad70de917822301368d49fc67
2022-05-09Use lint database from api_versions_public Anton Hansson
These two databases are (nearly) identical but the latter is generated in a much more efficient way. The diffs are very minor and it's not clear to me which versions is more correct than the other, though I'm fairly confident they don't matter. https://paste.googleplex.com/5567994005553152 Bug: 187398174 Test: diff api-versions.xml Change-Id: I0fa35d4067bc06936b4a31bda0bca7fd41f26aae
2022-05-09Use merged annotations zip for lint Anton Hansson
The framework-doc-stubs annotations.zip is no longer the correct zip to use after b/187397779. It doesn't contain the module annotations. Test: presubmit Change-Id: I50e0bcc026c97886a31256e2387632c19d4b287f