Status Update
Comments
gh...@google.com <gh...@google.com>
tn...@google.com <tn...@google.com> #2
The path one does not use regexes -- only the regexp= one. I'm not sure why it's not matching the paths; there are some unit tests in lint around this, such as
<issue id="ObsoleteLayoutParam">
<ignore regexp="x.*onclick" />
<ignore regexp="res/.*layout.*/activation.xml" />
</issue>
Can you share a specific path here that it failed against?
NOTE that in 4.2 you can also nest lint.xml files. Is there a single directory root containing all the projects where you could move it to (or add an additional lint.xml file there) ?
ws...@gmail.com <ws...@gmail.com> #3
The path one does not use regexes -- only the regexp= one.
I know it's is old, but
Can you share a specific path here that it failed against?
Here's a path from the report.
../../../src/androidTest/java/com/domain/android/lever/RepositoryShould.java
This report is at project/build/reports/lint/lint-report.html
, so this path relative to lint.xml is really project/src/androidTest/...
.
The most obvious way to demonstrate this is that path="project1/src/androidTest"
works, but regexp=".*/src/androidTest/.*"
does not. Do you have a test like that?
NOTE that in 4.2 you can also nest lint.xml files. Is there a single directory root containing all the projects where you could move it to (or add an additional lint.xml file there) ?
The lint.xml is currently in the directory root. The tree looks like:
/common/root/
├── project1
│ ├── src
│ │ ├── main ...
│ │ ├── test ...
│ │ └── androidTest ...
│ └── build.gradle
├── project2
│ ├── src
│ │ ├── main ...
│ │ ├── test ...
│ │ └── androidTest ...
│ └── build.gradle
└── lint.xml
tn...@google.com <tn...@google.com> #4
Thanks for the clear details!
I took a look at this, and the configuration lookup will relativize paths to the lint.xml file; that's how it can do matching relative to the config file.
However, that means that in the test case I ran into, the path started with "src/androidTest/...". Note that "src" is not a match for ".*/src" -- there's an extra "/" in there, so the relative path would have to be "/src" to match.
If you change the regex to ".src/androidTest/." it should work. Of course that means it would also match something like "gensrc/androidTest"; not sure if that makes it impractical as an immediate workaround for you. You can probably also construct a regex which will match either ^src or /src.
It would be nice if this was cleaner. I can't think of a really clean way to solve this; if you have ideas let me know -- but right now I'm thinking to maybe special casing some knowledge in the matcher to recognize patterns which start with ".*/" and for those allow matches without the /. Another option is to just run the ignore checks twice -- both with relative paths and with absolute paths (it already runs it twice on Windows, checking with both forwards and backwards file separators).
tn...@google.com <tn...@google.com> #5
By the way, yes, globbing is supposed to work. Internally, I just convert the glob pattern to a regex, which explains why this didn't work; it has the exact same issue :-)
tn...@google.com <tn...@google.com> #6
Actually a pretty small patch for this just checks the pattern to see if it starts with <match-anything>+/ and if so will match against /+relative path.
ws...@gmail.com <ws...@gmail.com> #7
It sounds like the real problem here is that "regexp" is still relative to the project, whereas "path" is relative to lint.xml? As in, you're relativizing the config paths, and you can't relativize a regexp? Seems like you would want to relativize the source paths to lint.xml before checking regexp, not the config paths.
ws...@gmail.com <ws...@gmail.com> #8
But you're right -- regexp="src/androidTest"
works, even though path="src/androidTest"
does not. Thank you!
tn...@google.com <tn...@google.com> #9
Yes, good point -- I'm fixing both -- making sure that the path is relativized to lint.xml as is already done for path comparisons, and also allow implicit "^./" matching.
mo...@gmail.com <mo...@gmail.com> #10
an...@microsoft.com <an...@microsoft.com> #11
Running into a related issue trying to ignore by regexp, but relativeness of the path is not predictable when we're ignoring errors from gradle cache which will differ on people's machines depending where their git repo and gradle cache live. The old ignore regexp doesn't work anymore:
<issue id="UseOfJavaxJetBrainsAnnotation">
<ignore regexp=".*\.gradle.*" />
Is there a different regexp that would work, or a fix is required?
Description
Using 4.2-beta03.
We use lint.xml to ignore some directories for certain issues:
In AGP 4.2, the paths seem to be relative to the lint.xml file, not the project root. That's fine -- makes sense. However, we tend to use the same lint.xml for multiple projects, like this:
Now our ignore paths need to include project1/project2. I tried a few approaches, none of which seem to work:
<ignore path="*/src/androidTest"/>
<ignore regexp=".*/src/androidTest"/>
<ignore regexp=".*/src/androidTest/.*"/>
The reports are giving errors for paths which clearly match these regexes / globs. (Note: using
path="project1/src/androidTest"
still works, but is not ideal since we have so many projects.) Are globs or regexps still supported?