Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe0b246f authored by Peter Kalauskas's avatar Peter Kalauskas
Browse files

Remove obsolete sysui lint tools

The lint tools in packages/SystemUI/tools/lint no longer worked, and
they were not being used for upload hooks as the comments suggested.

The new way to run lint manually is via Soong. Append '-lint' to the
relevant Soong module (the one that has the extra_check_modules
pointing to "SystemUILintChecker"), then use aninja to list the
path.

For example,

 $ m SystemUI-core-lint
 $ aninja -t query SystemUI-core-lint
SystemUI-core-lint:
  input: phony
    out/soong/.intermediates/frameworks/base/packages/SystemUI/SystemUI-core/android_common/lint/lint-report.xml
  outputs:

Then, in the out/soong/.../lint directory, there will be an html report
and lint-baseline.xml file.

Bug: 398194411
Test: m SystemUI-core-lint && aninja -t query SystemUI-core-lint
Flag: EXEMPT lint only
Change-Id: I0b8a7a647159aaa06f7efba8defb25dc1fd15e27
parent eecb809c
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
This directory contains configuration files for lint, which is run
in as an upload hook for repo upload.

lint.xml contains checks that are turned on or off, or whitelisted /
blacklisted for particular directories, if they are different from
the default.

baseline.xml contains the list of existing "grandfathered" lint
errors in the codebase. It is generated using ./tools/lint/update_baseline.sh

When you hit a lint error that should not be triggered, there are 3
possible resolutions:
1. Use tools:ignore or @SuppressLint annotation. This is preferred
   for cases where the lint violation is intended, so that reviewers
   can review whether the suppression is appropriate.
2. Use tools/lint.xml to ignore a lint check which we don't care
   about for any file, or checks that are not actionable by the
   CL author (e.g. translation issues)
3. If there are lint errors that should be fixed, but cannot be done
   immediately for some reason, the issue should be added to
   baseline.xml.


References
- https://developer.android.com/studio/write/lint.html
- http://tools.android.com/tips/lint-checks
+0 −89764

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −77
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<lint>

    <!-- Translations are done in separate CLs from source changes, so typically it's not actionable
         by CL authors -->
    <issue id="MissingTranslation" severity="ignore" />
    <issue id="ExtraTranslation" severity="ignore" />

    <!-- SystemUI is a priviledged app -->
    <issue id="ProtectedPermissions" severity="ignore" />

    <!-- SystemUI doesn't have launcher presence -->
    <issue id="MissingApplicationIcon" severity="ignore" />

    <!-- Make system inserts these attributes -->
    <issue id="UsesMinSdkAttributes" severity="ignore" />
    <issue id="MissingVersion" severity="ignore" />

    <!-- Translation import automatically generates all of them -->
    <issue id="UnusedQuantity" severity="ignore" />
    <!-- This lint check misses the format used in TextUtils.expandTemplate (^1),
         so it's not very useful (b/37128132) -->
    <issue id="ImpliedQuantity" severity="ignore" />
    <!-- SystemUI's SDK version is always latest so these are not relevant -->
    <issue id="UnusedAttribute" severity="ignore" />
    <issue id="NewApi" severity="ignore" />

    <!-- We don't care about WebP for now (having a lint for optiPNG will be great though) -->
    <issue id="ConvertToWebp" severity="ignore" />

    <!-- b/37129369: MissingRegistered doesn't take libraries into account -->
    <issue id="MissingRegistered" severity="ignore" />


    <!-- We don't care about app indexing -->
    <issue id="GoogleAppIndexingWarning" severity="ignore" />
    <issue id="GoogleAppIndexingUrlError" severity="ignore" />

    <!-- Issues under out/ typically comes from libraries -->
    <issue id="ClickableViewAccessibility" severity="error">
        <ignore regexp=".*/out/soong/.intermediates/frameworks/base/packages/SystemUI/SystemUI-core/android_common/combined/.*" />
    </issue>

    <!-- Turn on stop ship check -->
    <issue id="StopShip" severity="warning" />


    <issue id="UnusedResources" severity="error">
        <!-- Nested script references are not picked up by lint -->
        <ignore regexp="res/xml/wizard_script.*\.xml" />
        <!-- Ignore translation files -->
        <ignore regexp="res/values(-[a-zA-Z0-9]+)*-(\w\w|b+[a-zA-Z0-9+]+)(-[a-zA-Z0-9]+)*/strings.xml" />
        <!-- Ignore translations arrays that are no longer used-->
        <ignore regexp="res/values(-[a-zA-Z0-9]+)*-(\w\w|b+[a-zA-Z0-9+]+)(-[a-zA-Z0-9]+)*/arrays.xml" />
    </issue>

    <!-- Ignore translations when linting strings -->
    <issue id="TypographyQuotes" severity="error">
        <ignore regexp="res/values(-[a-zA-Z0-9]+)*-(\w\w|b+[a-zA-Z0-9+]+)(-[a-zA-Z0-9]+)*/strings.xml" />
        <ignore regexp="res/values(-[a-zA-Z0-9]+)*-(\w\w|b+[a-zA-Z0-9+]+)(-[a-zA-Z0-9]+)*/arrays.xml" />
    </issue>
    <issue id="TypographyEllipsis" severity="error">
        <ignore regexp="res/values(-[a-zA-Z0-9]+)*-(\w\w|b+[a-zA-Z0-9+]+)(-[a-zA-Z0-9]+)*/strings.xml" />
        <ignore regexp="res/values(-[a-zA-Z0-9]+)*-(\w\w|b+[a-zA-Z0-9+]+)(-[a-zA-Z0-9]+)*/arrays.xml" />
    </issue>
    <issue id="TypographyDashes" severity="error">
        <ignore regexp="res/values(-[a-zA-Z0-9]+)*-(\w\w|b+[a-zA-Z0-9+]+)(-[a-zA-Z0-9]+)*/strings.xml" />
        <ignore regexp="res/values(-[a-zA-Z0-9]+)*-(\w\w|b+[a-zA-Z0-9+]+)(-[a-zA-Z0-9]+)*/arrays.xml" />
    </issue>

    <issue id="Wakelock" severity="error">
        <ignore regexp=".*/out/soong/.intermediates/frameworks/base/packages/SystemUI/SystemUI-core/android_common/classes/android/support" />
    </issue>

    <issue id="InconsistentArrays" severity="ignore" />
    <issue id="StringFormatCount" severity="ignore" />
</lint>
+0 −59
Original line number Diff line number Diff line
#! /bin/bash

if [[ $# -ne 2 ]]; then
    echo "Error: Incorrect number of arguments" >&2
    echo "Usage: ./run_lint.sh <repo_root> <CL_SHA>" >&2
    exit 100
fi

git show --name-only --pretty=format: $2 | grep packages/SystemUI/ > /dev/null
exitcode=$?
if [[ exitcode -eq 1 ]];  then
    exit 0
fi

if [[ -z $ANDROID_BUILD_TOP ]]; then
    echo "Error: ANDROID_BUILD_TOP must be set" >&2
    echo "Try setting up your environment first:" >&2
    echo "    source build/envsetup.sh && lunch <target>" >&2
    exit 101
fi

# TODO: Run lint as part of the build so we can specify the dependency properly
systemuijarpath="out/soong/.intermediates/frameworks/base/packages/SystemUI/SystemUI-core/android_common/combined/SystemUI-core.jar"
if [[ ! -f $ANDROID_BUILD_TOP/$systemuijarpath ]]; then
    echo "Error: Classes.jar file not found" >&2
    echo "Try building that jar file manually:" >&2
    echo "    m -j16 out/soong/.intermediates/frameworks/base/packages/SystemUI/SystemUI-core/android_common/combined/SystemUI-core.jar" >&2
    exit 102
fi

REPO_ROOT=$1
${REPO_ROOT}/prebuilts/devtools/tools/lint \
       . \
       --exitcode \
       -Werror \
       --config ${REPO_ROOT}/frameworks/base/packages/SystemUI/tools/lint/lint.xml \
       --html ${REPO_ROOT}/out/lint_output.html \
       --baseline ${REPO_ROOT}/frameworks/base/packages/SystemUI/tools/lint/baseline.xml \
       --remove-fixed
exitcode=$?
if [[ exitcode -eq 1 ]];  then
    cat >&2 <<EOF

Please check the HTML results file and fix the errors.
If the error cannot be fixed immediately, there are 3 possible resolutions:
1. Use tools:ignore or @SuppressLint annotation. This is preferred
   for cases where the lint violation is intended, so that reviewers
   can review whether the suppression is appropriate.
2. Use tools/lint.xml to ignore a lint check which we don't care
   about for any file, or checks that are not actionable by the
   CL author (e.g. translation issues)
3. If there are lint errors that should be fixed, but cannot be done
   immediately for some reason, run ./tools/lint/update_baseline.sh to
   add them to baseline.xml.

EOF
fi

exit $exitcode
+0 −18
Original line number Diff line number Diff line
#! /bin/bash

if [[ $PWD != *"/frameworks/base/packages/SystemUI" ]]; then
    echo "Please run this in frameworks/base/packages/SystemUI" >&2
    exit 1
fi

# Empty the baseline file so the baseline-generation run below do not ignore any existing errors.
echo '' > tools/lint/baseline.xml

lint . -Werror --exitcode --config tools/lint/lint.xml --html /tmp/lint_output.html \
  --baseline tools/lint/baseline.xml --remove-fixed &

# b/37579990 - The file needs to be removed *while* lint is running
sleep 0.5
rm tools/lint/baseline.xml

wait