Fixed bug in parameter name check. did not handle catch blocks.
This commit is contained in:
parent
303352fe2d
commit
d83cf71c6b
|
|
@ -18,6 +18,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
|
||||
/**
|
||||
|
|
@ -46,4 +47,12 @@ public class ParameterNameCheck
|
|||
{
|
||||
return new int[] {TokenTypes.PARAMETER_DEF};
|
||||
}
|
||||
|
||||
/** @see com.puppycrawl.tools.checkstyle.checks.AbstractNameCheck */
|
||||
protected boolean mustCheckName(DetailAST aAST)
|
||||
{
|
||||
return !(
|
||||
(aAST.getParent() != null)
|
||||
&& (aAST.getParent().getType() == TokenTypes.LITERAL_CATCH));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,19 @@ import com.puppycrawl.tools.checkstyle.checks.ParameterNameCheck;
|
|||
public class ParameterNameCheckTest
|
||||
extends BaseCheckTestCase
|
||||
{
|
||||
public void testCatch()
|
||||
throws Exception
|
||||
{
|
||||
final CheckConfiguration checkConfig = new CheckConfiguration();
|
||||
checkConfig.setClassname(ParameterNameCheck.class.getName());
|
||||
checkConfig.addProperty("format", "^NO_WAY_MATEY$");
|
||||
final Checker c = createChecker(checkConfig);
|
||||
final String fname = getPath("InputLeftCurlyOther.java");
|
||||
final String[] expected = {
|
||||
};
|
||||
verify(c, fname, expected);
|
||||
}
|
||||
|
||||
public void testSpecified()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue