is there any way to configure gradle to check spelling in strings.xml?

Viewed 719

I'd like strings.xml to be checked for spelling while building with gradle. Since we use continuous integration we need it to be configured for building from command-line not just in Android Studio. Any way to do it?

PS. I've tried:

lintOptions {
    abortOnError false

    // check *only* the given issue id's
    check 'Typos'
}

strings.xml:

<resources>
    <string name="app_name">Project</string>

    <!-- Common Words -->
    <string name="test_spelling">sdfsdfdfds</string>

and

./gradlew assembleDebug lint

but got nothing:

:app:lint
Ran lint on variant release: 0 issues found
Ran lint on variant debug: 0 issues found
Wrote HTML report to     file:/Users/asmirnov/Documents/dev/src/Project/app/build/outputs/lint-results.html
Wrote XML report to /Users/asmirnov/Documents/dev/src/Project/app/build/outputs/lint-results.xml

Also i've checked lint --show :

...

Typos
-----
Summary: Spelling error

Priority: 7 / 10
Severity: Warning
Category: Correctness:Messages

This check looks through the string definitions, and if it finds any words
that look like likely misspellings, they are flagged.

...

PPS. If i add another rule to check (check 'Typos', 'TypographyEllipsis') i'm getting warnings (for TypographyEllipsis) as expected, so in general linting works. For some reason "Typos" rule is not working only

2 Answers

I am currently working on something similar, so have not completed my work. Not sure if you have an answer as yet, as it was asked a while ago. Here is what I have.

The code you have here:

lintOptions {
abortOnError false

// check *only* the given issue id's
check 'Typos'
}

should be fine. You can also add it within a flavor, to be more restrictive, if you are using them.

To get the report from the command line, you need to execute:

./gradlew lintAssembleDebug

or whatever your flavor is, e.g. ./gradlew lintAssembleMyFlavorDebug

I am trying to make use of the lintOptions.check() method, to programmatically add the checks I want, but no luck yet. Another alternative is as described here by Jason Atwood. I am looking at this, adding the blank file:

ext.lintCheckList = [
    // Blank default list
] as String[]

to the repo, and replacing that in the CI job, as needed.

Hope that helps.

Update:

The command is incorrect. It should be

./gradlew lintDebug

or

./gradlew lintMyFlavorDebug

etc

Related