summaryrefslogtreecommitdiff
path: root/java/lint.go
AgeCommit message (Collapse)Author
2022-04-29Revert "Fix erroneous "Field requires API level 33 (current min is 32)" ↵ Nataniel Borges
warnings" This reverts commit 8b7f627f30df90cdc0ab27fcd26fbc0dfedebbe7. Reason for revert: b/230821289 Change-Id: I3032103b174c78586b38b64d2748ec5a42fa9522
2022-04-27Fix erroneous "Field requires API level 33 (current min is 32)" warnings Cole Faust
Bug: 215567981 Bug: 204776549 Test: m out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/lint/lint-report.xml, then check that that file doesn't have any of these warnings Change-Id: I39aa2228474630c93250bf5833ac6bd9bbadcc7f
2022-04-25Enforce newapi check only if min_sdk_version < compile_sdk_version Spandan Das
- NewApi check should be enforced only if min_sdk_version is less than the compile_sdk_version (the opposite direction should be a different build-time error) - Change the datatype of *sdkVersion to android.ApiLevel (from string) to support version comparisons Test: go build ./java Test: no changes in ninja file Bug: 228956345 Change-Id: Ic408857db7760d912ef4694d2ed72c0b7106eb04
2022-02-08Export LintDepSetsIntf from java package Spandan Das
This interface will be used in the apex package to propagate strict_updatability_linting to transitive deps of mainline code Test: In build/soong, go test ./java Bug: 182349282 Change-Id: I30151217e843e4e9fe82db572a066918414ed3a0
2021-09-09Pass --write-reference-baseline to lint Colin Cross
Make lint write a baseline file to the output directory that can be used as a starting point when baselining new errors. Bug: 197238141 Test: out/soong/.intermediates/cts/apps/CtsVerifier/cts-verifier-framework/android_common/lint/lint-report.html Change-Id: I72033bb870bff5a72b648737219d11315fabf134
2021-07-05make system server modules use filtered lint database Pedro Loureiro
Bug: 188851704 Test: m Change-Id: Ie8f63286aeeb4cdbec5b9320c2ba41c8e37c7345 Merged-In: Ie8f63286aeeb4cdbec5b9320c2ba41c8e37c7345
2021-06-25Use trimmed lint database for mainline modules Pedro Loureiro
Lint's NewApi checks currently produce a lot of false positive findings. The filtered lint database removes information of classes defined by mainline modules which are the cases that might become a false positive. This commit updates soong to use this database instead of the normal one when linting mainline modules. Test: m lint-check Fixes: 186478867 Change-Id: Ica646081b9189303c393b36b2f02914d69eee291
2021-06-09Always propagate some environment variables to RBE Colin Cross
Always propagate LANG, LC_MESSAGES and PYTHONDONTWRITEBYTECODE to RBE to get more consistent behavior between local actions and RBE. Bug: 182415460 Bug: 190593001 Test: treehugger Change-Id: I726e6f02fd3ef77e158baf6fde77ffb7247a1375
2021-05-10Strict updatability linting against dependencies. Jaewoong Jung
Propagate strict_updatability_linting to transitive dependencies using a top-down mutator. Test: lint_test.go Bug: 182349282 Change-Id: Ifc9e58f1a597e3c7725ee49b4027afb6f42f45cb
2021-04-22Fix minor issues in updatability lint CLs. Jaewoong Jung
Test: TreeHugger Bug: 182349282 Change-Id: Ifae282d51b088d0562605b41a09696d75c5138f1
2021-04-21Add lint.strict_updatability_linting Jaewoong Jung
The flag prevents developers from skipping updatability lint checks with baseline files Test: lint_test.go & manual Bug: 182349282 Change-Id: Ia74a2b83c7ef686124128bdf16f7b85a919d9e8d
2021-04-21Forbid bypassing updatability lint checks. Jaewoong Jung
Test: lint_test.go Bug: 182349282 Change-Id: Iac7c01493b449c2ddd6df6c68f8a74dfe72dfd7a
2021-04-20Rename lint-project-xml.py to remove dashes. Jaewoong Jung
So that a future test can import it without a dirty syntax. Test: m lint-check Bug: 182349282 Change-Id: I520a5af49543801ab2a8ee888ff235876546dc74
2021-04-19Extract getBaselineFilepath method. Jaewoong Jung
Test: m nothing Bug: 182349282 Change-Id: Id3ab0f3b7d398af9dcfd66ee3c0bda64d999178d
2021-04-13Introduce NewApi lint checks Pedro Loureiro
We are enabling NewApi lint check where the min sdk != compile sdk. At the same time, we are introducing baseline files for existing projects that fail this check in order to keep the build running. At the very least we stop introducing new problems and teams might realise of risks in their projects they were not aware of. Bug: 150847901 Test: m lint-check Change-Id: Icfa5eb98cc6b6708149f0c52fac8fc1440d9c3b0 Merged-In: Icfa5eb98cc6b6708149f0c52fac8fc1440d9c3b0
2021-04-07Merge "Update soong for new lint version" Pedro Loureiro
2021-04-06Update soong for new lint version Pedro Loureiro
Test: m nothing Change-Id: Iaa9d37ef73f1fef5f2dbb8a840e774bb86c65bf7
2021-04-05Make lint HTML output deterministic Colin Cross
Remove a date from the lint HTML output to make it deterministic. Bug: 183509050 Test: m out/soong/.intermediates/packages/apps/DocumentsUI/DocumentsUI/android_common/lint/lint-report.html Change-Id: I796c0b571780814b657b9427a17c248668053983
2021-03-25Simplify lint rules using improved RuleBuilder rsp support Colin Cross
With the improved RuleBuilder rsp support a manual resources.list file is not necessary, use FlagWithRspFileInputList instead. The switch to RBE support in RuleBuilder in Iab4e09d961891ef182643583d4d456e413bc5e39 obsoleted tracking remoteInputs and remoteRSPInputs, remove them. writeLintProjectXML was written to allow it to be applied to a separate rule than the one that ran lint, but it is not used that way. Using the same rule for both means that manual tracking of the input dependencies described by the project.xml rule but read by the lint rule is not necessary, just treat them as inputs to the single rule. Test: m lint-check Test: m USE_RBE=true RBE_LINT=true RBE_LINT_EXEC_STRATEGY=remote lint-check Change-Id: If1827b9dede3ebcd0792b6b4b8114d3199f6570b
2021-03-18Run lint actions in sbox Colin Cross
Run lint actions in sbox with RuleBuilder.SandboxInputs. This copies all input files into the sandbox, which prevents the lint tool from finding nearby source files that were not presented to it. Using SandboxInputs requires use of PathForInput or PathForOutput anywhere a path is used outside of the RuleBuilderCommand methods that take paths so that they can be translated to the paths that will be used in the sandbox. Bug: 181681346 Test: lint_test.go Test: m lint-check dist Test: m USE_RBE=true RBE_LINT=true lint-check dist Test: m USE_RBE=true RBE_LINT=true RBE_LINT_EXEC_STRATEGY=remote lint-check dist Change-Id: Iab4e09d961891ef182643583d4d456e413bc5e39
2021-03-18Move android package on top of remotexec Colin Cross
Remove the references to the android package in remotexec so that the android package can reference the remoteexec package. This will allow RuleBuilder to integrate directly with remoteexec. Bug: 182612695 Test: m checkbuild Change-Id: I15be5ef126d8aacbd605518638f341daf6f31bb3
2021-03-16Add explicit rspfile argument to RuleBuilderCommand.FlagWithRspFileInputList Colin Cross
Using $out.rsp as the rsp file adds extra complexity around keeping the $ unescaped. Make callers to FlagWithRspFileInputList provide an explicit path for the rsp file instead. Bug: 182612695 Test: rule_builder_test.go Change-Id: I3f531d80c1efa8a9d09aac0a63790c5b11a9f0c6
2021-03-10Propagate LANG environment variable to lint in RBE Colin Cross
Without LANG, lint's text output is ASCII instead of UTF-8, causing differences between local and remote execution. Bug: 181681346 Bug: 182415460 Test: m USE_RBE=true RBE_LINT=true Change-Id: I0ad54aa731582c9b54abb80f50ba508c75992b91
2021-03-10Default lint RBE to local exec strategy Colin Cross
Match other tools by defaulting to local exec strategy. Also use the local absolute path when using the local exec strategy. Bug: 181681346 Test: m USE_RBE=true RBE_LINT=true Test: m USE_RBE=true RBE_LINT=true RBE_LINT_EXEC_STRATEGY=remote Change-Id: I1d6d20ec69663b99d6d9af1d8e5e67b48a5cd050
2021-03-10Add comment to lintPaths Colin Cross
Test: none Change-Id: Ia7db6e27fedd95df2ebfc573e35a44a93acb031b
2021-03-05Support remoting lint commands with RBE Colin Cross
Bug: 181681346 Bug: 181912787 Test: m USE_RBE=true RBE_LINT=true lint-check Change-Id: I10596c40dc5e29075ba0cab51ea9a98cc58b3188
2021-03-04Remove lint outputs to prevent showing old lint results on error Colin Cross
The lint rules dumped the text output file to stdout on error. If the lint binary exited without updating the output file it would show old results. Remove the output files before running lint, and only dump the text output file if it exists. Bug: 181681346 Test: m lint-check Change-Id: I4fa962b1212e8715f234912a9a5e049d5c1540e8
2021-03-04Make common dependencies of lint use restat Colin Cross
Use restat for the api_versions.xml and annotations.zip dependencies of lint so that frameworks/base changes don't always result in rerunning lint on every module. Bug: 181681346 Test: m lint-check Change-Id: Ic6a540b41cf79b21441311a8baefe528a3d90d8b
2021-03-04Use repackaged lint binary Colin Cross
Lint references lint-classpath.jar, which does not contain any classes by has a manifest that points to other jars for the classpath. This breaks dependency tracking during the build. Use a lint tool that is repackaged into a single jar. Bug: 181681346 Test: m lint-check Change-Id: I07d2b7404c18626e03c5af3ef5a75dd7f899cb0e
2021-02-18Merge "Add support for lint baseline files" Pedro Loureiro
2021-02-18Add support for lint baseline files Pedro Loureiro
Test: m droid Test: go test ^TestJavaLint # (from soong/build/java) Change-Id: I249a0a0597b0bf8495460ed283b476ad2eb36edc
2021-02-09Convert java.Dependency to JavaInfo provider Colin Cross
Export information about java dependencies through a Provider instead of accessing the module directly. Test: java_test.go Test: no changes to build.ninja Change-Id: Ifc5d566bf6f6ebc0ad399e948effaa1ef6a22876
2020-12-01Pass pctx and ctx to NewRuleBuilder Colin Cross
Enable the RuleBuilder and RuleBuilderCommand methods to access the BuilderContext by passing it to NewRuleBuilder instead of RuleBuilder.Build. Test: genrule_test.go Test: rule_builder_test.go Test: m checkbuild Change-Id: I63e6597e19167393876dc2259d6f521363b7dabc
2020-11-23Refactor 'in_make' to mean Kati is not skipped. Jingwen Chen
In Nougat and before, Make wrote a marker file to indicate that soong_build was invoked from Make to change certain behaviors of Soong at build time. https://cs.android.com/android/platform/superproject/+/android-7.1.2_r36:build/core/soong.mk;l=70-73;drc=ae18638b0406ad107b0882a02a13cdd8b92f2a4e Things have changed, and now soong_build is invoked from soong_ui, which supports a --skip-make configuration flag: https://cs.android.com/android/platform/superproject/+/master:build/soong/ui/build/build.go;l=31-33;drc=680387bf1d3ce7cbc77f535be7c42cec411b1687 Thus, the various remnants of 'EmbeddedInMake' and 'inMake' configuration are misleading, since soong_build is no longer invoked from Make. This CL refactors all instances to actually mean that Kati is enabled (not skipped with --skip-make), and will run after soong_build finishes, so Kati-specific behavior like the AndroidMk singleton should run. Test: TH presubmit Change-Id: I576ab8e54f99f5c8ddf9feaf9a828019b279e266
2020-10-06Remove global state from apex modules Colin Cross
A global variant was used to store the global mapping between modules and APEXes. Replace it with storing pointers to APEX contents inside each module so that they can query the contents of any APEXes they belong to. Bug: 146393795 Test: all Soong tests Test: single line change to build.ninja host install dependency ordering Test: no Android-${TARGET_PRODUCT}.mk, make_vars-${TARGET_PRODUCT}.mk or late-${TARGET_PRODUCT}.mk Change-Id: Id2d7b73ea27f8c3b41d30820bdd86b65c539bfa4
2020-08-19Support ninja rsp files in soong_zip Colin Cross
Add a -r argument to soong_zip that reads a list of files from a file like the -l argument but treats it as a Ninja rsp file with escaping. Replace the -l arguments in Soong that are using rsp files with -r. Fixes: 162435077 Test: TestReadRespFile, TestZip Change-Id: I4605312e99406ab1bd0c37af9c5ad212393f0403
2020-08-12Merge "Increase heap size for lint tool" Treehugger Robot
2020-08-07Introduce AlwaysUsePrebuiltSdks Jeongik Cha
Instead of UnbundledBuild, use AlwaysUsePrebuiltSdks to determine if java modules needs to be built against prebuilt sdks. And rename UnbundledBuildUsePrebuiltSdks to AlwaysUsePrebuiltSdks to express its behavior more correctly.(It can be orthgonal to "Unbundled") Bug: 160390776 Test: TARGET_BUILD_UNBUNDLED_IMAGE=true m vendorimage Change-Id: I0be7265c1959d8774c295372cd7a9250169f6df9
2020-07-28Update language to comply with inclusive guidance Liz Kammer
See https://source.android.com/setup/contribute/respectful-code for reference Bug: 161896447 Test: m nothing Change-Id: Ie1d0d63d27f1b1b48680922b7202aa6df04f4696
2020-07-22Build transitive lint reports for apex modules Colin Cross
Build and export transitive lint report zips for apex modules. Bug: 153485543 Test: m TARGET_BUILD_APPS=com.google.android.wifi lint-check dist Change-Id: I5a1805440452301a7e2c4ca91482b989638b54fb
2020-07-16Add environment variables to control lint checks Colin Cross
Set ANDROID_LINT_CHECK to a comma-separated list of lint issues that should be checked instead of the defaults. This will disable all lint checks and enable only the given list. Set ANDROID_LINT_CHECK_EXTRA_MODULES to a list of modules that provide lint checks that should added to all modules when ANDROID_LINT_CHECK is specified. Bug: 153485543 Test: m ANDROID_LINT_CHECK=JavaKotlinApiUsedByModule ANDROID_LINT_CHECK_EXTRA_MODULES=JavaKotlinApiFinder TARGET_BUILD_APPS=Gallery2 lint-check dist Change-Id: Ifdf9bf972b8550104315b0f5e98b34ad699dcb67
2020-07-16Build a zip of transitive lint reports for apps Colin Cross
Add a rule to build a zip containing the lint reports from transitive dependencies for apps, and pass it to Make. Bug: 153485543 Test: m TARGET_BUILD_APPS=Gallery2 lint-check Change-Id: I523c09016251377ff89d76084769be7401b95425
2020-07-14Increase heap size for lint tool Colin Cross
We perodically get java.lang.OutOfMemoryError: Java heap space errors on the build servers, increase the lint heap size from 2GB to 3GB. Bug: 161151611 Test: m lint-check Change-Id: Id6cb97871e01780ac8761647c6d3a504fbfb49f2
2020-07-10Support lint on unbundled builds Colin Cross
Use prebuilts of the annotations.zip and api-versions.xml files when running lint in an unbundled build. Test: m TARGET_BUILD_APPS=Gallery2 lint-check Change-Id: Idacf3758a2769678a635941486183673e95b43f8
2020-06-23Set root dir in lint project.xml Colin Cross
Set the root dir in the project.xml for lint so that the paths in the lint report are relative to the top of the tree instead of relative to the project.xml. Bug: 153485543 Test: run lint Change-Id: Ie163a4dadd976e708f798855de73e58084931a91
2020-06-23Set ANDROID_SDK_HOME when running lint Colin Cross
Lint tries to create ~/.android, set ANDROID_SDK_HOME to keep it from attempting to write to the home directory, which may not be writable. Test: run lint Bug: 159676171 Change-Id: I16375b88d309a8fa416b3a8efeabe15759889ae3
2020-06-18Support adding extra lint checks Colin Cross
Add a lint.extra_check_modules property to list modules to use as plugins to Lint. Bug: 153485543 Test: m checkbuild Change-Id: I25c7799438cfec43163e757637c65b8657488d36
2020-06-16Add support for running Android lint on java and android modules. Colin Cross
Add a rule that runs Android lint on each java and android module and produces reports in xml, html and text formats. Bug: 153485543 Test: m out/soong/.intermediates/packages/apps/Settings/Settings-core/android_common/lint-report.html Change-Id: I5a530975b73ba767fef45b257d4f9ec901a19fcb