Issue #1288: 'ParameterNameCheck' refactored, UT coverage improved

This commit is contained in:
Ruslan Diachenko 2015-07-07 23:37:16 +01:00 committed by Roman Ivanov
parent 4fd6b3ee59
commit fa8b3ed7e1
3 changed files with 18 additions and 7 deletions

View File

@ -877,7 +877,6 @@
<regex><pattern>.*.checks.naming.MemberNameCheck</pattern><branchRate>91</branchRate><lineRate>85</lineRate></regex>
<regex><pattern>.*.checks.naming.MethodNameCheck</pattern><branchRate>100</branchRate><lineRate>93</lineRate></regex>
<regex><pattern>.*.checks.naming.PackageNameCheck</pattern><branchRate>100</branchRate><lineRate>88</lineRate></regex>
<regex><pattern>.*.checks.naming.ParameterNameCheck</pattern><branchRate>75</branchRate><lineRate>80</lineRate></regex>
<regex><pattern>.*.checks.regexp.CommentSuppressor</pattern><branchRate>75</branchRate><lineRate>100</lineRate></regex>
<regex><pattern>.*.checks.regexp.DetectorOptions</pattern><branchRate>100</branchRate><lineRate>96</lineRate></regex>

View File

@ -69,8 +69,6 @@ public class ParameterNameCheck
@Override
protected boolean mustCheckName(DetailAST ast) {
return !(
ast.getParent() != null
&& ast.getParent().getType() == TokenTypes.LITERAL_CATCH);
return ast.getParent().getType() != TokenTypes.LITERAL_CATCH;
}
}

View File

@ -19,11 +19,14 @@
package com.puppycrawl.tools.checkstyle.checks.naming;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import org.junit.Assert;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
public class ParameterNameCheckTest
extends BaseCheckTestSupport {
@ -64,4 +67,15 @@ public class ParameterNameCheckTest
};
verify(checkConfig, getPath("InputSimple.java"), expected);
}
@Test
public void testGetAcceptableTokens() {
ParameterNameCheck parameterNameCheckObj = new ParameterNameCheck();
int[] actual = parameterNameCheckObj.getAcceptableTokens();
int[] expected = new int[] {
TokenTypes.PARAMETER_DEF,
};
Assert.assertNotNull(actual);
Assert.assertArrayEquals(expected, actual);
}
}