mojohaus / animal-sniffer

https://www.mojohaus.org/animal-sniffer/animal-sniffer-maven-plugin/
MIT License
86 stars 44 forks source link

CheckSignatureTask.process() does not sort file names #130

Open Marcono1234 opened 4 years ago

Marcono1234 commented 4 years ago

CheckSignatureTask.process() does not sort the path elements, it just processes them in the order they are returned by Path.list(): https://github.com/mojohaus/animal-sniffer/blob/364fc20773cfdde514a212a683c344d3a253bb8b/animal-sniffer-ant-tasks/src/main/java/org/codehaus/mojo/animal_sniffer/ant/CheckSignatureTask.java#L215-L219

This causes issues when the list first contains the file name of a nested class and afterwards the file name of the enclosing class. In that case forbidden API usage could be detected for the nested class despite the enclosing class being annotated. Other methods first sort the file names to make sure enclosing classes are processed first (e.g. here).

Is that intended? I am not quite sure how org.apache.tools.ant.types.Path is supposed to be used. Is it legit to directly store class file names in it, or is it only intended to be a collection of directory paths?

Marcono1234 commented 1 year ago

@slachiewicz, it looks like this specific code was not changed. So is this not considered an issue, and path should only contain the directories to be checked, but not individual files? (as mentioned in https://github.com/xvik/gradle-animalsniffer-plugin/issues/25)

Or did you close this issue by accident?

slachiewicz commented 1 year ago

Ok, by mistake only - cleanup. Pr welcome