Eclipse duplication annotation @SurpressWarnings for PMD

荒凉一梦 提交于 2019-12-11 08:35:45

问题


I am trying to disable several arbitrary PMD warnings for my class.

How can I list several PMD rules to be ignored? I was not able to find with Google.

@SuppressWarnings("PMD.OnlyOneReturn")
@SuppressWarnings("PMD.ShortVariable")
public class MyClass {

it gives Eclipse compile time error:

Duplicate annotation @SurpressWarnings

This is compilable but ignored

@SuppressWarnings("PMD.OnlyOneReturn, PMD.ShortVariable")

This

@SuppressWarnings("PMD.OnlyOneReturn", "PMD.ShortVariable")

result is

Syntax error on token ,

Eclipse is configured to accept PMD type:

Unsupported @SuppressWarnings ( "PMD.DoNotCallSystemExit" )


回答1:


You have to list them in an array.

Like this:

@SuppressWarnings({
    "PMD.OnlyOneReturn",
    "PMD.ShortVariable"  })



回答2:


Found just now in Annotation Type SuppressWarnings.

This seems to work, note { and }, since it is String[]:

@SuppressWarnings({"PMD.OnlyOneReturn", "PMD.ShortVariable"})


来源:https://stackoverflow.com/questions/14702932/eclipse-duplication-annotation-surpresswarnings-for-pmd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!