Python知識分享網(wǎng) - 專業(yè)的Python學(xué)習(xí)網(wǎng)站 學(xué)Python,上Python222
JAVA PMD規(guī)則 詳解 PDF 下載
發(fā)布于:2023-09-11 10:32:21
(假如點(diǎn)擊沒反應(yīng),多刷新兩次就OK!)

JAVA PMD規(guī)則 詳解 PDF 下載  圖1

 

 

 

 

資料內(nèi)容:

 

The Basic Ruleset contains a collection of good practices which everyone should follow. · EmptyCatchBlock: Empty Catch Block finds instances where an exception is caught, but nothing is done. In most circumstances, this swallows an exception which should either be acted on or reported. 翻譯 空的 catch 塊:發(fā)現(xiàn)空的 catch 塊沒做任何異常處理的事,在大多數(shù)情形下,這會 吞噬一些應(yīng)該被處理或報告的異常 · EmptyIfStmt: Empty If Statement finds instances where a condition is checked but nothing is done about it. 翻譯 空的 if 表達(dá)式:發(fā)現(xiàn)使用 if 進(jìn)行了條件判斷,但是判斷之后沒做任何處理 · EmptyWhileStmt: Empty While Statement finds all instances where a while statement does nothing. If it is a timing loop, then you should use Thread.sleep() for it; if it's a while loop that does a lot in the exit expression, rewrite it to make it clearer. 翻譯 空的 while 表達(dá)式:發(fā)現(xiàn)空的 while 表達(dá)式,如果是一個定時的循環(huán),你應(yīng)該在循 環(huán)體內(nèi)使用 Thread.sleep() ;如果是對于退出處理做的一個處理大量事情的 while 循環(huán),重 寫代碼使它更清晰 · EmptyTryBlock: Avoid empty try blocks - what's the point? 翻譯 空的 try 塊:避免空的 try 塊 · EmptyFinallyBlock: Avoid empty finally blocks - these can be deleted. 翻譯 空的 finally 塊:避免空的 finally 塊 - 這些是可以刪掉的 · EmptySwitchStatements: Avoid empty switch statements. 翻譯 空的 switch 表達(dá)式:避免空的 switch 表達(dá)式 · JumbledIncrementer: Avoid jumbled loop incrementers - it's usually a mistake, and it's confusing even if it's what's intended. 翻譯 避免混亂的循環(huán) 增量 - 它常常是一個錯誤,而且容易讓人迷惑 錯誤代碼示例: public class JumbledIncrementerRule1 { public void foo() { for (int i = 0; i < 10; i++) { for (int k = 0; k < 20; i++) { System.out.println("Hello"); } } } } 父子循環(huán)都用 i++ · ForLoopShouldBeWhileLoop: Some for loops can be simplified to while loops - this makes them more concise. 翻譯 有些 for 循環(huán)可以簡化為 while 循環(huán) - 這樣可以更加簡明 代碼示例: public class Foo { void bar() { for (;true;) true; // 沒有初始化塊和變化塊,相當(dāng)于 : while (true) } } · UnnecessaryConversionTemporary: Avoid unnecessary temporaries when converting primitives to Strings 翻譯 將原始類型轉(zhuǎn)換為字符串類型時不必要的臨時轉(zhuǎn)換 代碼示例: public String convert(int x) { // 多了一個創(chuàng)建對象環(huán)節(jié) String foo = new Integer(x).toString(); // 下面這種寫法就好了 return Integer.toString(x); }