Conversation
|
Build is failing due to a formatting error. |
I ran |
|
Fixed the test and run |
|
btw. any comments on the changes to |
spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/AnnotationMatcherTest.java
Outdated
Show resolved
Hide resolved
|
Thanks for the valuable comments. I applied the requested changes. |
| } | ||
|
|
||
| if (!getJavaAnnotationNames().isEmpty()) { | ||
| attributeList.addAttribute("classjas", // similar to classname, short for classJavaAnnotations |
There was a problem hiding this comment.
@phisad is 'classjas' just made up naming? Seems odd even from change log. Why not just 'classAnnotations'? We already know its java, that is redundant. At least then it follows the idea you have there and is more clear on name without new jargon. Then you probably don't need to describe why its named that way...
There was a problem hiding this comment.
Thanks for the comment! I was also thinking about "classAnnotations" but felt that it might be confused with the ClassAnnotation from spotbugs. But I think you are right, that a user of the XML file will not know that the term "classAnnotation" is also otherwise used. If you say that this is clearer, then I will certainly adjust it to "classannotation" (to comply with classname which is also not camelcase).
There was a problem hiding this comment.
Good point, thanks for calling that out, that certainly would cause unnecessary confusion. how about 'classAnnotationNames' which is more in line with what its loading there?
There was a problem hiding this comment.
OK, I changed the attribute name in the XMLs from classjas to classAnnotationNames
spotbugs/etc/findbugsfilter.xsd
Outdated
| </annotation> | ||
| <attribute name="name" type="string"> | ||
| <annotation> | ||
| <documentation>The exact or regex match pattern for a java class annotation name. If the name starts with the ~ character the rest of attribute content is interpreted as a Java regular expression.</documentation> |
There was a problem hiding this comment.
"the rest of attribute content" -> "the rest of the attribute content
There was a problem hiding this comment.
Adjusted. Note that this is a copy paste error (that still exists in the other documentation tags as well).
| // map annotation entry type to dotted class name, for example | ||
| // Lorg/immutables/value/Generated; -> org.immutables.value.Generated | ||
| String annotationType = ae.getAnnotationType().substring(1); // remove starting L | ||
| annotationType = annotationType.replace("/", "."); |
There was a problem hiding this comment.
These two lines could be combined.
CHANGELOG.md
Outdated
|
|
||
| #### Security | ||
| ### Added | ||
| * New simple name-based AnnotationMatcher for exclude files (now bug annotations store the class java annotations in an attribute called `classjas`). For example, use like <Match><Annotation name="org.immutables.value.Generated" /></Match> in an excludeFilter.xml to ignore classes generated by the Immutable framework. This ignores all class, method or field bugs in classes with that annotation. |
There was a problem hiding this comment.
@phisad Please fix the classjas part here too, please double check to make sure all is where needed then I think we will be good.
|
Changelog needs to be deconflicted and merged. |
|
Rebased on upstream/master. Adjusted CHANGELOG. |
|
@phisad Fix fix formatting issues GH-actions raised. The following files had format violations: |
|
Did run './gradlew :spotbugs:spotlessApply' to fix the violations. |
|
@hazendaz Does it look fine now? |
|
|
||
| <element name="Annotation" type="fb:AnnotationType"> | ||
| <annotation> | ||
| <documentation>This element matches warnings associated with a particular class that is annoted with a |
There was a problem hiding this comment.
@phisad See a spelling mistake here, should 'annoted' be 'annotated'?
|
Supserseded by #2395 |
Hello all,
I added a simple AnnotationMatcher that matches classes annotated with that annotation name.
For example, use in an
excludeFilter.xmlas followsto ignore classes generated by the Immutable framework.
Request For Comments
The main issue was to add the java class annotation names of the analysed classes to the PackageMemberAnnotation for later use during exclude file filtering. For this I simply changed the
BugInstance.add()method as this seemed to me a central point to get this information and avoiding to re-write all the detectors. For better performance I access theIAnalysisCache.Please suggest a better place for this, if necessary, because I do not know the codebase too well.
The PR includes:
javaAnnotationNamesattribute to PackageMemberAnnotationaddJavaAnnotationNames()method toBugInstanceas a central point to get the java annotations that a class is annotated withwriteXml()is called on ClassAnnotation, MethodAnnotation or FieldAnnotation; a test case is added to BugInstanceTestMake sure these boxes are checked before submitting your PR -- thank you!
CHANGELOG.mdif you have changed SpotBugs code