diff options
Diffstat (limited to 'src/test')
2 files changed, 51 insertions, 0 deletions
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 c0bbc3860..e595e4999 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 @@ -92,4 +92,39 @@ public class ParameterNameCheckTest }; assertArrayEquals(expected, actual); } + + @Test + public void testSkipMethodsWithOverrideAnnotationTrue() + throws Exception { + final DefaultConfiguration checkConfig = + createCheckConfig(ParameterNameCheck.class); + checkConfig.addAttribute("format", "^h$"); + checkConfig.addAttribute("ignoreOverridden", "true"); + + final String pattern = "^h$"; + + final String[] expected = { + "11:28: " + getCheckMessage(MSG_INVALID_PATTERN, "object", pattern), + "15:30: " + getCheckMessage(MSG_INVALID_PATTERN, "aaaa", pattern), + }; + verify(checkConfig, getPath("InputOverrideAnnotation.java"), expected); + } + + @Test + public void testSkipMethodsWithOverrideAnnotationFalse() + throws Exception { + final DefaultConfiguration checkConfig = + createCheckConfig(ParameterNameCheck.class); + checkConfig.addAttribute("format", "^h$"); + checkConfig.addAttribute("ignoreOverridden", "false"); + + final String pattern = "^h$"; + + final String[] expected = { + "6:34: " + getCheckMessage(MSG_INVALID_PATTERN, "o", pattern), + "11:28: " + getCheckMessage(MSG_INVALID_PATTERN, "object", pattern), + "15:30: " + getCheckMessage(MSG_INVALID_PATTERN, "aaaa", pattern), + }; + verify(checkConfig, getPath("InputOverrideAnnotation.java"), expected); + } } 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 new file mode 100644 index 000000000..82d99508a --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/InputOverrideAnnotation.java @@ -0,0 +1,16 @@ +package com.puppycrawl.tools.checkstyle.checks.naming; + +public class InputOverrideAnnotation { + + @Override + public boolean equals(Object o) { + return super.equals(o); + } + + @SuppressWarnings("") + public void foo(Object object) { + + } + + public void foo2(Integer aaaa) {} +} |