2013-02-05 35 views
1

我正在嘗試爲我的類禁用幾個任意的PMD警告。Eclipse複製註釋@SurpressWarnings for PMD

如何列出幾個要忽略的PMD規則?我無法使用Google查找。

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

它爲Eclipse編譯時錯誤:

Duplicate annotation @SurpressWarnings 

這是編譯但忽略

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

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

結果是

Syntax error on token , 

的Eclipse配置爲接受PMD類型:剛纔在Annotation Type SuppressWarnings

Unsupported @SuppressWarnings ("PMD.DoNotCallSystemExit")

回答

6

你必須列出它們在數組中。

像這樣:

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

對,我會接受你的答案。謝謝 –

0

找到。

這似乎是工作,注意{},因爲它是String[]

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