diff options
Diffstat (limited to 'src')
6 files changed, 5 insertions, 257 deletions
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheck.java index 20527fa7e..b5cf4a753 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheck.java @@ -30,11 +30,9 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; * and defaults to * <strong>^[a-z][a-zA-Z0-9]*$</strong>. * </p> - * <p>The check has the following options:</p> + * <p>The check has the following option:</p> * <p><b>ignoreOverridden</b> - allows to skip methods with Override annotation from - * validation. Default value is <b>false</b> .</p> - * <p><b>skipCatchParameter</b> - allows to skip catcj parameter from validation. Default value - * is <b>true</b> .</p> + * validation. Default values is <b>false</b> .</p> * <p> * An example of how to configure the check is: * </p> @@ -59,14 +57,6 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; * <property name="ignoreOverridden" value="true"/> * </module> * </pre> - * <p> - * An example of how to configure the check to skip catch parameter from validation: - * </p> - * <pre> - * <module name="ParameterName"> - * <property name="skipCatchParameter" value="true"/> - * </module> - * </pre> * * @author Oliver Burn * @author Andrei Selkin @@ -80,11 +70,6 @@ public class ParameterNameCheck private boolean ignoreOverridden; /** - * Allows to skip catch parameter from validation. - */ - private boolean skipCatchParameter = true; - - /** * Creates a new {@code ParameterNameCheck} instance. */ public ParameterNameCheck() { @@ -100,14 +85,6 @@ public class ParameterNameCheck this.ignoreOverridden = ignoreOverridden; } - /** - * Sets whether to skip catch parameter from validation. - * @param skipCatchParameter Flag for skipping catch parameter. - */ - public void setSkipCatchParameter(boolean skipCatchParameter) { - this.skipCatchParameter = skipCatchParameter; - } - @Override public int[] getDefaultTokens() { return getAcceptableTokens(); @@ -127,7 +104,7 @@ public class ParameterNameCheck protected boolean mustCheckName(DetailAST ast) { boolean checkName = true; if (ignoreOverridden && isOverriddenMethod(ast) - || skipCatchParameter && ast.getParent().getType() == TokenTypes.LITERAL_CATCH) { + || ast.getParent().getType() == TokenTypes.LITERAL_CATCH) { checkName = false; } return checkName; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckTest.java index 0d0fe084b..1c35fd32e 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckTest.java @@ -137,132 +137,4 @@ public class ParameterNameCheckTest }; verify(checkConfig, getPath("InputOverrideAnnotation.java"), expected); } - - @Test - public void testSkipCatchParameterTrue() - throws Exception { - final DefaultConfiguration checkConfig = - createCheckConfig(ParameterNameCheck.class); - checkConfig.addAttribute("format", "^h$"); - checkConfig.addAttribute("skipCatchParameter", "true"); - - final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - - verify(checkConfig, getPath("InputCatchParameter.java"), expected); - } - - @Test - public void testSkipCatchParameterFalse() - throws Exception { - final DefaultConfiguration checkConfig = - createCheckConfig(ParameterNameCheck.class); - checkConfig.addAttribute("format", "^h$"); - checkConfig.addAttribute("skipCatchParameter", "false"); - final String pattern = "^h$"; - - final String[] expected = { - "13:26: " + getCheckMessage(MSG_INVALID_PATTERN, "ex", pattern), - "22:64: " + getCheckMessage(MSG_INVALID_PATTERN, "ex", pattern), - }; - - verify(checkConfig, getPath("InputCatchParameter.java"), expected); - } - - @Test - public void testSkipCatchParameterTrueAndIgnoreOverriddenTrue() - throws Exception { - final DefaultConfiguration checkConfig = - createCheckConfig(ParameterNameCheck.class); - checkConfig.addAttribute("format", "^h$"); - checkConfig.addAttribute("skipCatchParameter", "true"); - checkConfig.addAttribute("ignoreOverridden", "true"); - final String pattern = "^h$"; - - final String[] expected = { - "13:29: " + getCheckMessage(MSG_INVALID_PATTERN, "object", pattern), - "17:30: " + getCheckMessage(MSG_INVALID_PATTERN, "aaaa", pattern), - "21:19: " + getCheckMessage(MSG_INVALID_PATTERN, "abc", pattern), - "21:28: " + getCheckMessage(MSG_INVALID_PATTERN, "bd", pattern), - "23:18: " + getCheckMessage(MSG_INVALID_PATTERN, "abc", pattern), - "30:43: " + getCheckMessage(MSG_INVALID_PATTERN, "field", pattern), - "30:62: " + getCheckMessage(MSG_INVALID_PATTERN, "packageNames", pattern), - }; - - verify(checkConfig, getPath("InputParameterNameMultipleOptions.java"), expected); - } - - @Test - public void testSkipCatchParameterFalseAndIgnoreOverriddenFalse() - throws Exception { - final DefaultConfiguration checkConfig = - createCheckConfig(ParameterNameCheck.class); - checkConfig.addAttribute("format", "^h$"); - checkConfig.addAttribute("skipCatchParameter", "false"); - checkConfig.addAttribute("ignoreOverridden", "false"); - final String pattern = "^h$"; - - final String[] expected = { - "8:34: " + getCheckMessage(MSG_INVALID_PATTERN, "o", pattern), - "13:29: " + getCheckMessage(MSG_INVALID_PATTERN, "object", pattern), - "17:30: " + getCheckMessage(MSG_INVALID_PATTERN, "aaaa", pattern), - "21:19: " + getCheckMessage(MSG_INVALID_PATTERN, "abc", pattern), - "21:28: " + getCheckMessage(MSG_INVALID_PATTERN, "bd", pattern), - "23:18: " + getCheckMessage(MSG_INVALID_PATTERN, "abc", pattern), - "30:43: " + getCheckMessage(MSG_INVALID_PATTERN, "field", pattern), - "30:62: " + getCheckMessage(MSG_INVALID_PATTERN, "packageNames", pattern), - "36:26: " + getCheckMessage(MSG_INVALID_PATTERN, "ex", pattern), - "45:64: " + getCheckMessage(MSG_INVALID_PATTERN, "ex", pattern), - }; - - verify(checkConfig, getPath("InputParameterNameMultipleOptions.java"), expected); - } - - @Test - public void testSkipCatchParameterTrueAndIgnoreOverriddenFalse() - throws Exception { - final DefaultConfiguration checkConfig = - createCheckConfig(ParameterNameCheck.class); - checkConfig.addAttribute("format", "^h$"); - checkConfig.addAttribute("skipCatchParameter", "true"); - checkConfig.addAttribute("ignoreOverridden", "false"); - final String pattern = "^h$"; - - final String[] expected = { - "8:34: " + getCheckMessage(MSG_INVALID_PATTERN, "o", pattern), - "13:29: " + getCheckMessage(MSG_INVALID_PATTERN, "object", pattern), - "17:30: " + getCheckMessage(MSG_INVALID_PATTERN, "aaaa", pattern), - "21:19: " + getCheckMessage(MSG_INVALID_PATTERN, "abc", pattern), - "21:28: " + getCheckMessage(MSG_INVALID_PATTERN, "bd", pattern), - "23:18: " + getCheckMessage(MSG_INVALID_PATTERN, "abc", pattern), - "30:43: " + getCheckMessage(MSG_INVALID_PATTERN, "field", pattern), - "30:62: " + getCheckMessage(MSG_INVALID_PATTERN, "packageNames", pattern), - }; - - verify(checkConfig, getPath("InputParameterNameMultipleOptions.java"), expected); - } - - @Test - public void testSkipCatchParameterFalseAndIgnoreOverriddenTrue() - throws Exception { - final DefaultConfiguration checkConfig = - createCheckConfig(ParameterNameCheck.class); - checkConfig.addAttribute("format", "^h$"); - checkConfig.addAttribute("skipCatchParameter", "false"); - checkConfig.addAttribute("ignoreOverridden", "true"); - final String pattern = "^h$"; - - final String[] expected = { - "13:29: " + getCheckMessage(MSG_INVALID_PATTERN, "object", pattern), - "17:30: " + getCheckMessage(MSG_INVALID_PATTERN, "aaaa", pattern), - "21:19: " + getCheckMessage(MSG_INVALID_PATTERN, "abc", pattern), - "21:28: " + getCheckMessage(MSG_INVALID_PATTERN, "bd", pattern), - "23:18: " + getCheckMessage(MSG_INVALID_PATTERN, "abc", pattern), - "30:43: " + getCheckMessage(MSG_INVALID_PATTERN, "field", pattern), - "30:62: " + getCheckMessage(MSG_INVALID_PATTERN, "packageNames", pattern), - "36:26: " + getCheckMessage(MSG_INVALID_PATTERN, "ex", pattern), - "45:64: " + getCheckMessage(MSG_INVALID_PATTERN, "ex", pattern), - }; - - verify(checkConfig, getPath("InputParameterNameMultipleOptions.java"), expected); - } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/InputCatchParameter.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/InputCatchParameter.java deleted file mode 100644 index 47388bef2..000000000 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/InputCatchParameter.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.puppycrawl.tools.checkstyle.checks.naming; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.sql.SQLException; - -public class InputCatchParameter { - - void foo1() { - try { - - } - catch (Exception ex) { - - } - } - - void foo2() { - try { - - } - catch (NullPointerException | IllegalArgumentException ex) { - // just to check how the ParentName's option 'skipCahcthParameter' deals with catching - // multiple exception types and - } - } -} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/InputOverrideAnnotation.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/InputOverrideAnnotation.java index 608b3a5c1..e4e40d126 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/InputOverrideAnnotation.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/InputOverrideAnnotation.java @@ -26,4 +26,6 @@ public class InputOverrideAnnotation { InputOverrideAnnotation() {} // No NPE here! InputOverrideAnnotation(int field, java.util.Set<String> packageNames) {} // No NPE here! + + } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/InputParameterNameMultipleOptions.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/InputParameterNameMultipleOptions.java deleted file mode 100644 index f42bd2125..000000000 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/InputParameterNameMultipleOptions.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.puppycrawl.tools.checkstyle.checks.naming; - -import java.util.Set; - -public class InputParameterNameMultipleOptions { - - @Override - public boolean equals(Object o) { - return super.equals(o); - } - - @SuppressWarnings("") - public void foo1(Object object) { - - } - - public void foo2(Integer aaaa) {} - - void foo3() {} // No NPE here! - - void foo4(int abc, int bd) {} // No NPE here! - - int foo5(int abc) {return 1;} // No NPE here! - - private int field; - private Set<String> packageNames; - - InputParameterNameMultipleOptions() {} // No NPE here! - - InputParameterNameMultipleOptions(int field, Set<String> packageNames) {} // No NPE here! - - void foo6() { - try { - - } - catch (Exception ex) { - - } - } - - void foo7() { - try { - - } - catch (NullPointerException | IllegalArgumentException ex) { - // just to check how the ParentName's option 'skipCahcthParameter' deals with catching - // multiple exception types and - } - } -} diff --git a/src/xdocs/config_naming.xml b/src/xdocs/config_naming.xml index f84615a02..03867b6e0 100644 --- a/src/xdocs/config_naming.xml +++ b/src/xdocs/config_naming.xml @@ -950,24 +950,6 @@ public boolean equals(Object o) { <td><a href="property_types.html#boolean">Boolean</a></td> <td><code>false</code></td> </tr> - <tr> - <td>skipCatchParameter</td> - <td> - Allows to skip <code>catch</code> parameter from validation. For example, the - following catch parameter will be skipped from validation, if - skipCatchParameter is true: - <pre> -try { - ... -} -catch (Exception ex) { - ... -} - </pre> - </td> - <td><a href="property_types.html#boolean">Boolean</a></td> - <td><code>true</code></td> - </tr> </table> </subsection> @@ -987,14 +969,6 @@ catch (Exception ex) { <property name="ignoreOverridden" value="true"/> </module> </source> - <p> - An example of how to configure the check to skip catch parameter from validation: - </p> - <source> -<module name="ParameterName"> - <property name="skipCatchParameter" value="true"/> -</module> - </source> </subsection> <subsection name="Example of Usage"> |