简体   繁体   中英

Eclipse duplication annotation @SurpressWarnings for PMD

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" )

You have to list them in an array.

Like this:

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

Found just now in Annotation Type SuppressWarnings .

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM