Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/checkstyle-examples-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@
<suppress checks="PackageDeclaration"
files="packagedeclaration[\\/]Example\d+.*"/>

<!-- violation messages are long by design to show full text -->
<suppress checks="LineLength"
files="googlemethodname[\\/]Example\d+.*"/>
<suppress id="discouragedRegexpInViolationMessage"
files="googlemethodname[\\/]Example\d+.*"/>

<!-- File length suppressed to keep JavadocStyle examples consistent -->
<suppress checks="FileLength"
files=".*[\\/]javadocstyle[\\/]Example7\.java$"/>
Expand Down
2 changes: 2 additions & 0 deletions config/checkstyle-non-main-files-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@
files="src[\\/]site[\\/]xdoc[\\/]checks[\\/]coding[\\/]equalshashcode.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]site[\\/]xdoc[\\/]checks[\\/]coding[\\/]innerassignment.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]site[\\/]xdoc[\\/]checks[\\/]naming[\\/]googlemethodname.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]site[\\/]xdoc[\\/]checks[\\/]coding[\\/]missingctor.xml.template"/>
<suppress id="propertiesMacroMustExist"
Expand Down
1 change: 1 addition & 0 deletions config/jsoref-spellchecker/whitelist.words
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ google
googleblog
googleecommon
googlegroups
googlemethodname
googlesource
govstrangefolder
GPath
Expand Down
2 changes: 2 additions & 0 deletions config/linkcheck-suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@
<a href="apidocs/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheck.html#%3Cinit%3E()">#%3Cinit%3E()</a>: doesn't exist.
<a href="apidocs/com/puppycrawl/tools/checkstyle/checks/naming/ClassTypeParameterNameCheck.html#%3Cinit%3E()">#%3Cinit%3E()</a>: doesn't exist.
<a href="apidocs/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheck.html#%3Cinit%3E()">#%3Cinit%3E()</a>: doesn't exist.
<a href="apidocs/com/puppycrawl/tools/checkstyle/checks/naming/GoogleMethodNameCheck.html#%3Cinit%3E()">#%3Cinit%3E()</a>: doesn't exist.
<a href="apidocs/com/puppycrawl/tools/checkstyle/checks/naming/IllegalIdentifierNameCheck.html#%3Cinit%3E()">#%3Cinit%3E()</a>: doesn't exist.
<a href="apidocs/com/puppycrawl/tools/checkstyle/checks/naming/InterfaceTypeParameterNameCheck.html#%3Cinit%3E()">#%3Cinit%3E()</a>: doesn't exist.
<a href="apidocs/com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheck.html#%3Cinit%3E()">#%3Cinit%3E()</a>: doesn't exist.
Expand Down Expand Up @@ -1175,6 +1176,7 @@
<a href="com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheck.html#%3Cinit%3E()">com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheck.html#%3Cinit%3E()</a>: doesn't exist.
<a href="com/puppycrawl/tools/checkstyle/checks/naming/ClassTypeParameterNameCheck.html#%3Cinit%3E()">com/puppycrawl/tools/checkstyle/checks/naming/ClassTypeParameterNameCheck.html#%3Cinit%3E()</a>: doesn't exist.
<a href="com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheck.html#%3Cinit%3E()">com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheck.html#%3Cinit%3E()</a>: doesn't exist.
<a href="com/puppycrawl/tools/checkstyle/checks/naming/GoogleMethodNameCheck.html#%3Cinit%3E()">com/puppycrawl/tools/checkstyle/checks/naming/GoogleMethodNameCheck.html#%3Cinit%3E()</a>: doesn't exist.
<a href="com/puppycrawl/tools/checkstyle/checks/naming/IllegalIdentifierNameCheck.html#%3Cinit%3E()">com/puppycrawl/tools/checkstyle/checks/naming/IllegalIdentifierNameCheck.html#%3Cinit%3E()</a>: doesn't exist.
<a href="com/puppycrawl/tools/checkstyle/checks/naming/InterfaceTypeParameterNameCheck.html#%3Cinit%3E()">com/puppycrawl/tools/checkstyle/checks/naming/InterfaceTypeParameterNameCheck.html#%3Cinit%3E()</a>: doesn't exist.
<a href="com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheck.html#%3Cinit%3E()">com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheck.html#%3Cinit%3E()</a>: doesn't exist.
Expand Down
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4274,6 +4274,9 @@
<excludedTestClasses>
<param>*.Input*</param>
</excludedTestClasses>
<avoidCallsTo>
<avoidCallsTo>com.puppycrawl.tools.checkstyle.utils.NullUtil</avoidCallsTo>
</avoidCallsTo>
<coverageThreshold>100</coverageThreshold>
<mutationThreshold>99</mutationThreshold>
<timeoutFactor>${pitest.plugin.timeout.factor}</timeoutFactor>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code and other text files for adherence to a set of rules.
// Copyright (C) 2001-2026 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///////////////////////////////////////////////////////////////////////////////////////////////

package org.checkstyle.suppressionxpathfilter.naming;

import java.io.File;
import java.util.List;

import org.checkstyle.suppressionxpathfilter.AbstractXpathTestSupport;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.checks.naming.GoogleMethodNameCheck;

public class XpathRegressionGoogleMethodNameTest extends AbstractXpathTestSupport {

private static final Class<GoogleMethodNameCheck> CLASS = GoogleMethodNameCheck.class;

@Override
protected String getCheckName() {
return CLASS.getSimpleName();
}

@Override
public String getPackageLocation() {
return "org/checkstyle/suppressionxpathfilter/naming/googlemethodname";
}

@Test
public void testRegularMethodName() throws Exception {
final File fileToProcess = new File(
getPath("InputXpathGoogleMethodName.java"));

final DefaultConfiguration moduleConfig = createModuleConfig(CLASS);

final String[] expectedViolation = {
"5:10: " + getCheckMessage(CLASS, GoogleMethodNameCheck.MSG_KEY_FORMAT_REGULAR,
"Foo"),
};

final List<String> expectedXpathQueries = List.of(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='InputXpathGoogleMethodName']]"
+ "/OBJBLOCK/METHOD_DEF/IDENT[@text='Foo']"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
expectedXpathQueries);
}

@Test
public void testTestMethodName() throws Exception {
final File fileToProcess = new File(
getPath("InputXpathGoogleMethodNameTest.java"));

final DefaultConfiguration moduleConfig = createModuleConfig(CLASS);

final String[] expectedViolation = {
"8:10: " + getCheckMessage(CLASS, GoogleMethodNameCheck.MSG_KEY_FORMAT_TEST,
"Test_Fo"),
};

final List<String> expectedXpathQueries = List.of(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='InputXpathGoogleMethodNameTest']]"
+ "/OBJBLOCK/METHOD_DEF/IDENT[@text='Test_Fo']"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
expectedXpathQueries);
}
}
Loading
Loading