Issue #2604: Update regexp pattern for ParameterName
This commit is contained in:
parent
5e0f360e7b
commit
3813f1ccbf
|
|
@ -337,7 +337,7 @@
|
|||
<module name="MethodTypeParameterName"/>
|
||||
<module name="PackageName"/>
|
||||
<module name="ParameterName">
|
||||
<property name="format" value="^[a-z][a-zA-Z0-9]+$"/>
|
||||
<property name="format" value="^(id)|([a-z][a-z0-9][a-zA-Z0-9]+)$"/>
|
||||
<property name="ignoreOverridden" value="true"/>
|
||||
</module>
|
||||
<module name="CatchParameterName">
|
||||
|
|
|
|||
|
|
@ -47,10 +47,10 @@ public final class LocalizedMessages {
|
|||
|
||||
/**
|
||||
* Logs a message to be reported.
|
||||
* @param aMsg the message to log
|
||||
* @param message the message to log
|
||||
**/
|
||||
public void add(LocalizedMessage aMsg) {
|
||||
messages.add(aMsg);
|
||||
public void add(LocalizedMessage message) {
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -401,14 +401,14 @@ public class TranslationCheck
|
|||
|
||||
/**
|
||||
* Helper method to log an io exception.
|
||||
* @param ex the exception that occurred
|
||||
* @param exception the exception that occurred
|
||||
* @param file the file that could not be processed
|
||||
*/
|
||||
private void logIoException(IOException ex, File file) {
|
||||
private void logIoException(IOException exception, File file) {
|
||||
String[] args = null;
|
||||
String key = "general.fileNotFound";
|
||||
if (!(ex instanceof FileNotFoundException)) {
|
||||
args = new String[] {ex.getMessage()};
|
||||
if (!(exception instanceof FileNotFoundException)) {
|
||||
args = new String[] {exception.getMessage()};
|
||||
key = "general.exception";
|
||||
}
|
||||
final LocalizedMessage message =
|
||||
|
|
@ -422,7 +422,7 @@ public class TranslationCheck
|
|||
final SortedSet<LocalizedMessage> messages = Sets.newTreeSet();
|
||||
messages.add(message);
|
||||
getMessageDispatcher().fireErrors(file.getPath(), messages);
|
||||
LOG.debug("IOException occurred.", ex);
|
||||
LOG.debug("IOException occurred.", exception);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -145,10 +145,10 @@ public abstract class AbstractComplexityCheck
|
|||
/**
|
||||
* Increments the current value by a specified amount.
|
||||
*
|
||||
* @param by the amount to increment by
|
||||
* @param amount the amount to increment by
|
||||
*/
|
||||
protected final void incrementCurrentValue(BigInteger by) {
|
||||
currentValue = currentValue.add(by);
|
||||
protected final void incrementCurrentValue(BigInteger amount) {
|
||||
currentValue = currentValue.add(amount);
|
||||
}
|
||||
|
||||
/** Push the current value on the stack. */
|
||||
|
|
|
|||
|
|
@ -201,10 +201,10 @@ public class CyclomaticComplexityCheck
|
|||
/**
|
||||
* Increments the current value by a specified amount.
|
||||
*
|
||||
* @param by the amount to increment by
|
||||
* @param amount the amount to increment by
|
||||
*/
|
||||
protected final void incrementCurrentValue(BigInteger by) {
|
||||
currentValue = currentValue.add(by);
|
||||
protected final void incrementCurrentValue(BigInteger amount) {
|
||||
currentValue = currentValue.add(amount);
|
||||
}
|
||||
|
||||
/** Push the current value on the stack. */
|
||||
|
|
|
|||
|
|
@ -62,12 +62,12 @@ public final class ScopeUtils {
|
|||
|
||||
/**
|
||||
* Returns the scope of the surrounding "block".
|
||||
* @param aAST the node to return the scope for
|
||||
* @param node the node to return the scope for
|
||||
* @return the Scope of the surrounding block
|
||||
*/
|
||||
public static Scope getSurroundingScope(DetailAST aAST) {
|
||||
public static Scope getSurroundingScope(DetailAST node) {
|
||||
Scope returnValue = null;
|
||||
for (DetailAST token = aAST.getParent();
|
||||
for (DetailAST token = node.getParent();
|
||||
token != null;
|
||||
token = token.getParent()) {
|
||||
final int type = token.getType();
|
||||
|
|
@ -95,14 +95,14 @@ public final class ScopeUtils {
|
|||
/**
|
||||
* Returns whether a node is directly contained within an interface block.
|
||||
*
|
||||
* @param aAST the node to check if directly contained within an interface block.
|
||||
* @param node the node to check if directly contained within an interface block.
|
||||
* @return a {@code boolean} value
|
||||
*/
|
||||
public static boolean isInInterfaceBlock(DetailAST aAST) {
|
||||
public static boolean isInInterfaceBlock(DetailAST node) {
|
||||
boolean returnValue = false;
|
||||
|
||||
// Loop up looking for a containing interface block
|
||||
for (DetailAST token = aAST.getParent();
|
||||
for (DetailAST token = node.getParent();
|
||||
token != null && !returnValue;
|
||||
token = token.getParent()) {
|
||||
|
||||
|
|
@ -125,14 +125,14 @@ public final class ScopeUtils {
|
|||
/**
|
||||
* Returns whether a node is directly contained within an annotation block.
|
||||
*
|
||||
* @param aAST the node to check if directly contained within an annotation block.
|
||||
* @param node the node to check if directly contained within an annotation block.
|
||||
* @return a {@code boolean} value
|
||||
*/
|
||||
public static boolean isInAnnotationBlock(DetailAST aAST) {
|
||||
public static boolean isInAnnotationBlock(DetailAST node) {
|
||||
boolean returnValue = false;
|
||||
|
||||
// Loop up looking for a containing interface block
|
||||
for (DetailAST token = aAST.getParent();
|
||||
for (DetailAST token = node.getParent();
|
||||
token != null && !returnValue;
|
||||
token = token.getParent()) {
|
||||
final int type = token.getType();
|
||||
|
|
@ -155,25 +155,25 @@ public final class ScopeUtils {
|
|||
* Returns whether a node is directly contained within an interface or
|
||||
* annotation block.
|
||||
*
|
||||
* @param aAST the node to check if directly contained within an interface
|
||||
* @param node the node to check if directly contained within an interface
|
||||
* or annotation block.
|
||||
* @return a {@code boolean} value
|
||||
*/
|
||||
public static boolean isInInterfaceOrAnnotationBlock(DetailAST aAST) {
|
||||
return isInInterfaceBlock(aAST) || isInAnnotationBlock(aAST);
|
||||
public static boolean isInInterfaceOrAnnotationBlock(DetailAST node) {
|
||||
return isInInterfaceBlock(node) || isInAnnotationBlock(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a node is directly contained within an enum block.
|
||||
*
|
||||
* @param aAST the node to check if directly contained within an enum block.
|
||||
* @param node the node to check if directly contained within an enum block.
|
||||
* @return a {@code boolean} value
|
||||
*/
|
||||
public static boolean isInEnumBlock(DetailAST aAST) {
|
||||
public static boolean isInEnumBlock(DetailAST node) {
|
||||
boolean returnValue = false;
|
||||
|
||||
// Loop up looking for a containing interface block
|
||||
for (DetailAST token = aAST.getParent();
|
||||
for (DetailAST token = node.getParent();
|
||||
token != null && !returnValue;
|
||||
token = token.getParent()) {
|
||||
final int type = token.getType();
|
||||
|
|
@ -195,14 +195,14 @@ public final class ScopeUtils {
|
|||
* Returns whether the scope of a node is restricted to a code block.
|
||||
* A code block is a method or constructor body, or a initializer block.
|
||||
*
|
||||
* @param aAST the node to check
|
||||
* @param node the node to check
|
||||
* @return a {@code boolean} value
|
||||
*/
|
||||
public static boolean isInCodeBlock(DetailAST aAST) {
|
||||
public static boolean isInCodeBlock(DetailAST node) {
|
||||
boolean returnValue = false;
|
||||
|
||||
// Loop up looking for a containing code block
|
||||
for (DetailAST token = aAST.getParent();
|
||||
for (DetailAST token = node.getParent();
|
||||
token != null;
|
||||
token = token.getParent()) {
|
||||
final int type = token.getType();
|
||||
|
|
@ -221,12 +221,12 @@ public final class ScopeUtils {
|
|||
/**
|
||||
* Returns whether a node is contained in the outer most type block.
|
||||
*
|
||||
* @param aAST the node to check
|
||||
* @param node the node to check
|
||||
* @return a {@code boolean} value
|
||||
*/
|
||||
public static boolean isOuterMostType(DetailAST aAST) {
|
||||
public static boolean isOuterMostType(DetailAST node) {
|
||||
boolean returnValue = true;
|
||||
for (DetailAST parent = aAST.getParent();
|
||||
for (DetailAST parent = node.getParent();
|
||||
parent != null;
|
||||
parent = parent.getParent()) {
|
||||
if (parent.getType() == TokenTypes.CLASS_DEF
|
||||
|
|
@ -245,22 +245,22 @@ public final class ScopeUtils {
|
|||
* Determines whether a node is a local variable definition.
|
||||
* I.e. if it is declared in a code block, a for initializer,
|
||||
* or a catch parameter.
|
||||
* @param aAST the node to check.
|
||||
* @param node the node to check.
|
||||
* @return whether aAST is a local variable definition.
|
||||
*/
|
||||
public static boolean isLocalVariableDef(DetailAST aAST) {
|
||||
public static boolean isLocalVariableDef(DetailAST node) {
|
||||
boolean localVariableDef = false;
|
||||
// variable declaration?
|
||||
if (aAST.getType() == TokenTypes.VARIABLE_DEF) {
|
||||
final DetailAST parent = aAST.getParent();
|
||||
if (node.getType() == TokenTypes.VARIABLE_DEF) {
|
||||
final DetailAST parent = node.getParent();
|
||||
final int type = parent.getType();
|
||||
localVariableDef = type == TokenTypes.SLIST
|
||||
|| type == TokenTypes.FOR_INIT
|
||||
|| type == TokenTypes.FOR_EACH_CLAUSE;
|
||||
}
|
||||
// catch parameter?
|
||||
if (aAST.getType() == TokenTypes.PARAMETER_DEF) {
|
||||
final DetailAST parent = aAST.getParent();
|
||||
if (node.getType() == TokenTypes.PARAMETER_DEF) {
|
||||
final DetailAST parent = node.getParent();
|
||||
localVariableDef = parent.getType() == TokenTypes.LITERAL_CATCH;
|
||||
}
|
||||
return localVariableDef;
|
||||
|
|
|
|||
|
|
@ -230,11 +230,11 @@ public class ImportControlCheckTest extends BaseCheckTestSupport {
|
|||
* and caught in test (it was caught and re-thrown twice after that)
|
||||
* Note: this is helper method with hard-coded structure of exception causes. It works
|
||||
* fine for methods mentioned, you may need to adjust it if you try to use it for other needs
|
||||
* @param ex Exception
|
||||
* @param exception Exception
|
||||
* @return String message of original exception
|
||||
*/
|
||||
private static String getInvocationTargetExceptionMessage(CheckstyleException ex) {
|
||||
return ((InvocationTargetException) ex.getCause().getCause())
|
||||
private static String getInvocationTargetExceptionMessage(CheckstyleException exception) {
|
||||
return ((InvocationTargetException) exception.getCause().getCause())
|
||||
.getTargetException().getMessage();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -278,8 +278,8 @@ public class JavadocParseTreeTest {
|
|||
compareTrees(expectedTree, generatedTree);
|
||||
}
|
||||
|
||||
private void compareTrees(ParseTree t1, ParseTree t2) {
|
||||
Assert.assertEquals(t1.toStringTree(parser), t2.toStringTree(parser));
|
||||
private void compareTrees(ParseTree first, ParseTree second) {
|
||||
Assert.assertEquals(first.toStringTree(parser), second.toStringTree(parser));
|
||||
}
|
||||
|
||||
private static class FailOnErrorListener extends BaseErrorListener {
|
||||
|
|
|
|||
Loading…
Reference in New Issue