Update documentation

This commit is contained in:
Travis CI (pmd-bot)
2017-12-04 04:41:05 +00:00
parent 2ff93cc82e
commit e8023e8913
2 changed files with 3 additions and 87 deletions

View File

@ -19,9 +19,7 @@ folder: pmd/rules
* [ConstantsInInterface](pmd_rules_java_bestpractices.html#constantsininterface): Avoid constants in interfaces. Interfaces should define types, constants are implementation detai...
* [DefaultLabelNotLastInSwitchStmt](pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitchstmt): By convention, the default label should be the last label in a switch statement.
* [ForLoopCanBeForeach](pmd_rules_java_bestpractices.html#forloopcanbeforeach): Reports loops that can be safely replaced with the foreach syntax. The rule considers loops overl...
* [GuardDebugLogging](pmd_rules_java_bestpractices.html#guarddebuglogging): When log messages are composed by concatenating strings, the whole section should be guardedby a ...
* [GuardLogStatement](pmd_rules_java_bestpractices.html#guardlogstatement): Whenever using a log level, one should check if the loglevel is actually enabled, orotherwise ski...
* [GuardLogStatementJavaUtil](pmd_rules_java_bestpractices.html#guardlogstatementjavautil): Whenever using a log level, one should check if the loglevel is actually enabled, orotherwise ski...
* [JUnit4SuitesShouldUseSuiteAnnotation](pmd_rules_java_bestpractices.html#junit4suitesshouldusesuiteannotation): In JUnit 3, test suites are indicated by the suite() method. In JUnit 4, suites are indicatedthro...
* [JUnit4TestShouldUseAfterAnnotation](pmd_rules_java_bestpractices.html#junit4testshoulduseafterannotation): In JUnit 3, the tearDown method was used to clean up all data entities required in running tests....
* [JUnit4TestShouldUseBeforeAnnotation](pmd_rules_java_bestpractices.html#junit4testshouldusebeforeannotation): In JUnit 3, the setUp method was used to set up all data entities required in running tests. JUni...

View File

@ -5,7 +5,7 @@ permalink: pmd_rules_java_bestpractices.html
folder: pmd/rules/java
sidebaractiveurl: /pmd_rules_java.html
editmepath: ../pmd-java/src/main/resources/category/java/bestpractices.xml
keywords: Best Practices, AbstractClassWithoutAbstractMethod, AccessorClassGeneration, AccessorMethodGeneration, ArrayIsStoredDirectly, AvoidPrintStackTrace, AvoidReassigningParameters, AvoidStringBufferField, AvoidUsingHardCodedIP, CheckResultSet, ConstantsInInterface, DefaultLabelNotLastInSwitchStmt, ForLoopCanBeForeach, GuardDebugLogging, GuardLogStatement, GuardLogStatementJavaUtil, JUnit4SuitesShouldUseSuiteAnnotation, JUnit4TestShouldUseAfterAnnotation, JUnit4TestShouldUseBeforeAnnotation, JUnit4TestShouldUseTestAnnotation, JUnitAssertionsShouldIncludeMessage, JUnitTestContainsTooManyAsserts, JUnitTestsShouldIncludeAssert, JUnitUseExpected, LooseCoupling, MethodReturnsInternalArray, OneDeclarationPerLine, PositionLiteralsFirstInCaseInsensitiveComparisons, PositionLiteralsFirstInComparisons, PreserveStackTrace, ReplaceEnumerationWithIterator, ReplaceHashtableWithMap, ReplaceVectorWithList, SwitchStmtsShouldHaveDefault, SystemPrintln, UnusedFormalParameter, UnusedImports, UnusedLocalVariable, UnusedPrivateField, UnusedPrivateMethod, UseAssertEqualsInsteadOfAssertTrue, UseAssertNullInsteadOfAssertTrue, UseAssertSameInsteadOfAssertTrue, UseAssertTrueInsteadOfAssertEquals, UseCollectionIsEmpty, UseVarargs
keywords: Best Practices, AbstractClassWithoutAbstractMethod, AccessorClassGeneration, AccessorMethodGeneration, ArrayIsStoredDirectly, AvoidPrintStackTrace, AvoidReassigningParameters, AvoidStringBufferField, AvoidUsingHardCodedIP, CheckResultSet, ConstantsInInterface, DefaultLabelNotLastInSwitchStmt, ForLoopCanBeForeach, GuardLogStatement, JUnit4SuitesShouldUseSuiteAnnotation, JUnit4TestShouldUseAfterAnnotation, JUnit4TestShouldUseBeforeAnnotation, JUnit4TestShouldUseTestAnnotation, JUnitAssertionsShouldIncludeMessage, JUnitTestContainsTooManyAsserts, JUnitTestsShouldIncludeAssert, JUnitUseExpected, LooseCoupling, MethodReturnsInternalArray, OneDeclarationPerLine, PositionLiteralsFirstInCaseInsensitiveComparisons, PositionLiteralsFirstInComparisons, PreserveStackTrace, ReplaceEnumerationWithIterator, ReplaceHashtableWithMap, ReplaceVectorWithList, SwitchStmtsShouldHaveDefault, SystemPrintln, UnusedFormalParameter, UnusedImports, UnusedLocalVariable, UnusedPrivateField, UnusedPrivateMethod, UseAssertEqualsInsteadOfAssertTrue, UseAssertNullInsteadOfAssertTrue, UseAssertSameInsteadOfAssertTrue, UseAssertTrueInsteadOfAssertEquals, UseCollectionIsEmpty, UseVarargs
---
## AbstractClassWithoutAbstractMethod
@ -407,55 +407,6 @@ public class MyClass {
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach" />
```
## GuardDebugLogging
**Since:** PMD 4.3
**Priority:** Medium (3)
When log messages are composed by concatenating strings, the whole section should be guarded
by a isDebugEnabled() check to avoid performance and memory issues.
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.GuardDebugLoggingRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/GuardDebugLoggingRule.java)
**Example(s):**
``` java
public class Test {
private static final Log __log = LogFactory.getLog(Test.class);
public void test() {
// okay:
__log.debug("log something");
// okay:
__log.debug("log something with exception", e);
// bad:
__log.debug("log something" + " and " + "concat strings");
// bad:
__log.debug("log something" + " and " + "concat strings", e);
// good:
if (__log.isDebugEnabled()) {
__log.debug("bla" + "",e );
}
}
}
```
**This rule has the following properties:**
|Name|Default Value|Description|
|----|-------------|-----------|
|guardsMethods|[]|method use to guard the log statement|
|logLevels|[]|LogLevels to guard|
**Use this rule by referencing it:**
``` xml
<rule ref="category/java/bestpractices.xml/GuardDebugLogging" />
```
## GuardLogStatement
**Since:** PMD 5.1.0
@ -479,47 +430,14 @@ otherwise skip the associate String creation and manipulation.
|Name|Default Value|Description|
|----|-------------|-----------|
|guardsMethods|[]|method use to guard the log statement|
|logLevels|[]|LogLevels to guard|
|guardsMethods|[isTraceEnabled, isDebugEnabled, isInfoEnabled, isWarnEnabled, isErrorEnabled, isLoggable]|method use to guard the log statement|
|logLevels|[trace, debug, info, warn, error, log, finest, finer, fine, info, warning, severe]|LogLevels to guard|
**Use this rule by referencing it:**
``` xml
<rule ref="category/java/bestpractices.xml/GuardLogStatement" />
```
## GuardLogStatementJavaUtil
**Since:** PMD 5.1.0
**Priority:** Medium High (2)
Whenever using a log level, one should check if the loglevel is actually enabled, or
otherwise skip the associate String creation and manipulation.
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.GuardLogStatementJavaUtilRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/GuardLogStatementJavaUtilRule.java)
**Example(s):**
``` java
//...
// Add this for performance
if (log.isLoggable(Level.FINE)) {
log.fine("log something" + " and " + "concat strings");
}
```
**This rule has the following properties:**
|Name|Default Value|Description|
|----|-------------|-----------|
|guardsMethods|[]|method use to guard the log statement|
|logLevels|[]|LogLevels to guard|
**Use this rule by referencing it:**
``` xml
<rule ref="category/java/bestpractices.xml/GuardLogStatementJavaUtil" />
```
## JUnit4SuitesShouldUseSuiteAnnotation
**Since:** PMD 4.0