From d83cf71c6ba2f3345feaa1a1cf03eee38a5339ce Mon Sep 17 00:00:00 2001 From: Oliver Burn Date: Fri, 22 Nov 2002 13:35:49 +0000 Subject: [PATCH] Fixed bug in parameter name check. did not handle catch blocks. --- .../tools/checkstyle/checks/ParameterNameCheck.java | 9 +++++++++ .../tools/checkstyle/ParameterNameCheckTest.java | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/ParameterNameCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/ParameterNameCheck.java index 78bc2425f..1c0c87004 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/ParameterNameCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/ParameterNameCheck.java @@ -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)); + } } diff --git a/src/tests/com/puppycrawl/tools/checkstyle/ParameterNameCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/ParameterNameCheckTest.java index a2fb08c50..079f52c8b 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/ParameterNameCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/ParameterNameCheckTest.java @@ -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 {