spotbugs Filter file文件过滤器

参考网站:

Filter file — spotbugs 4.2.0 documentation

FindBugs filter 编写过滤文件配置 - viakiba - OSCHINA - 中文开源技术交流社区

Chapter 8. Filter Files (sourceforge.net)

メモ:

Filter files may be used to include or exclude bug reports for particular classes and methods.

A filter file is an XML document with a top-level FindBugsFilter element which has some number of Match elements as children. Each Match element represents a predicate which is applied to generated bug instances. Match elements contain children, which are conjuncts of the predicate. In other words, each of the children must be true for the predicate to be true.

<?xml version="1.0" encoding="UTF-8"?>
 <FindBugsFilter>
	<Match>
    	<Class name="com.foobar.ClassNotToBeAnalyzed" />
  	</Match>
</FindBugsFilter>

<Bug> 用来指定特殊规则的,规则之间使用逗号做分隔符。

可以使用 -xml或者 Bug descriptions来查看.[https://spotbugs.readthedocs.io/ja/latest/filter.html]
属性pattern:使用pattern作为key来指定匹配。例如:DLS_DEAD_LOCAL_STORE
属性code:使用code作为key来指定匹配。例如:DLS
属性category:最粗颗粒度匹配[category names: CORRECTNESS, MT_CORRECTNESS, BAD_PRACTICICE, PERFORMANCE, STYLE]
如果三个属性都有,则按照三个属性中全部设定的key来匹配

As a backwards compatibility measure, <BugPattern> and <BugCode> elements may be used instead of <Bug> element. Each of these uses a name attribute for specifying accepted values list.

<?xml version="1.0" encoding="UTF-8"?>
 <FindBugsFilter>
	<Match>
    	<Class name="com.foobar.ClassNotToBeAnalyzed" />
    	<Bug code="DE,UrF,SIC" pattern="DLS_DEAD_LOCAL_STORE" category="BAD_PRACTICICE" />
  	</Match>
</FindBugsFilter>

<Priority>
この要素は,警告を特定のバグ信頼度と照合します。
value 属性は,整数値でなければなりません。
1 は信頼度 (High),2 は信頼度 (Medium),3 は信頼度 (Low) の警告と一致します。
<Rank>
匹配錯誤等級。
value 属性は,整数値(1~20)でなければなりません。
1~4:scariest bugs.
5~9:scary bugs.
10~14:troubling bugs.
15~20:concern bugs.
<Package>
对指定package中的类进行警告。
name属性:设定指定package名
matching multiple packages can be achieved easily using regex name match。
<Class>
对特定类进行警告
name属性:指定类名,支持正则匹配
role属性: the class role
等同于Match元素上的class/classregex属性
如果match元素中没有class元素或者class/classregex属性,说明该规则适用于全体类。

<Source>
对指定的文件进行匹配。
name属性:指定特定源文件名,支持正则匹配
<Method>
This element specifies a method
name属性:指定方法名,支持正则匹配
params属性:指定方法参数,使用逗号做分隔符.class names must be fully qualified. (E.g., "java.lang.String" instead of just "String".)
returns属性:指定方法返回值.class names must be fully qualified. (E.g., "java.lang.String" instead of just "String".)
role属性:the method role
<Field>
This element specifies a field. 
name属性:指定field name,支持正则匹配。
type属性:通过fieldtype来批量匹配。must be fully qualified type 。
role属性:the field role。
<Local>
specifies a local variable
name属性:指定local variable name,支持正则匹配。
Local variables are variables defined within a method.
<Type>
This element matches warnings associated with a particular type.
The descriptor attribute is used to specify the exact or regex match pattern for type descriptor.
If the descriptor starts with the ~ character the rest of attribute content is interpreted as a Java regular expression.
The role attribute is the class role, and the typeParameters is the type parameters. Both of role and typeParameters are optional attributes.
<Or>
This element combines Match clauses as disjuncts. I.e., you can put two Method elements in an Or clause in order to match either method.
<And>
This element combines Match clauses which both must evaluate to true. I.e., you can put Bug and Confidence elements in an And clause in order to match specific bugs with given confidence only.
<Not>
This element inverts the included child Match. I.e., you can put a Bug element in a Not clause in order to match any bug excluding the given one.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值