Skip to content

Commit

Permalink
Issue #12716: Make config filenames kebab-case
Browse files Browse the repository at this point in the history
  • Loading branch information
stoyanK7 authored and romani committed Feb 25, 2023
1 parent b0499dc commit 739d833
Show file tree
Hide file tree
Showing 38 changed files with 248 additions and 238 deletions.
2 changes: 1 addition & 1 deletion .ci/codenarc.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import java.lang.Object
org.codenarc.CodeNarc.main([
"-basedir=${args[0]}",
"-includes=**/${args[1]}",
'-rulesetfiles=./config/StarterRuleSet-AllRulesByCategory.groovy.txt',
'-rulesetfiles=./config/codenarc-rules.groovy.txt',
'-report=console',
] as String[])
16 changes: 8 additions & 8 deletions .ci/validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ case $1 in
all-sevntu-checks)
working_dir=.ci-temp/all-sevntu-checks
mkdir -p $working_dir
xmlstarlet sel --net --template -m .//module -v "@name" -n config/checkstyle_sevntu_checks.xml \
xmlstarlet sel --net --template -m .//module -v "@name" -n config/checkstyle-sevntu-checks.xml \
| grep -vE "Checker|TreeWalker|Filter|Holder" | grep -v "^$" \
| sed "s/com\.github\.sevntu\.checkstyle\.checks\..*\.//" \
| sort | uniq | sed "s/Check$//" > $working_dir/file.txt
Expand Down Expand Up @@ -338,7 +338,7 @@ verify-no-exception-configs)
| grep -vE $MODULES_WITH_EXTERNAL_FILES | grep -v "^$" >> $working_dir/temp.txt
sort $working_dir/temp.txt | uniq | sed "s/Check$//" > $working_dir/web.txt

xmlstarlet fo -D -n config/checkstyle_checks.xml \
xmlstarlet fo -D -n config/checkstyle-checks.xml \
| xmlstarlet sel --net --template -m .//module -n -v "@name" \
| grep -vE $MODULES_WITH_EXTERNAL_FILES | grep -v "^$" \
| sort | uniq | sed "s/Check$//" > $working_dir/file.txt
Expand Down Expand Up @@ -367,7 +367,7 @@ verify-no-exception-configs)
fi
else
diff -u $working_dir/web.txt $working_dir/file.txt | cat
echo 'file config/checkstyle_checks.xml contains Check that is not present at:'
echo 'file config/checkstyle-checks.xml contains Check that is not present at:'
echo 'https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/checks-nonjavadoc-error.xml'
echo 'https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/checks-only-javadoc-error.xml'
echo 'Please add new Check to one of such files to let Check participate in auto testing'
Expand Down Expand Up @@ -692,8 +692,8 @@ no-error-sevntu-checks)
cd .ci-temp/sevntu.checkstyle/sevntu-checks
mvn -e --no-transfer-progress -Pno-validations verify -Dcheckstyle.ant.skip=false \
-Dcheckstyle.version="${CS_POM_VERSION}" \
-Dcheckstyle.configLocation=../../../config/checkstyle_checks.xml \
-Dcheckstyle.nonMain.configLocation=../../../config/checkstyle_non_main_files_checks.xml \
-Dcheckstyle.configLocation=../../../config/checkstyle-checks.xml \
-Dcheckstyle.nonMain.configLocation=../../../config/checkstyle-non-main-files-checks.xml \
-Dcheckstyle.non-main-files-suppressions.file=config/checkstyle_non_main_files_suppressions.xml
cd ../../
removeFolderWithProtectedFiles sevntu.checkstyle
Expand All @@ -709,11 +709,11 @@ no-error-contribution)
cd .ci-temp/contribution
cd patch-diff-report-tool
mvn -e --no-transfer-progress verify -DskipTests -Dcheckstyle.version="${CS_POM_VERSION}" \
-Dcheckstyle.configLocation=../../../config/checkstyle_checks.xml
-Dcheckstyle.configLocation=../../../config/checkstyle-checks.xml
cd ../
cd releasenotes-builder
mvn -e --no-transfer-progress verify -DskipTests -Dcheckstyle.version="${CS_POM_VERSION}" \
-Dcheckstyle.configLocation=../../../config/checkstyle_checks.xml
-Dcheckstyle.configLocation=../../../config/checkstyle-checks.xml
cd ../../
removeFolderWithProtectedFiles contribution
;;
Expand All @@ -727,7 +727,7 @@ no-error-methods-distance)
checkout_from https://github.com/sevntu-checkstyle/methods-distance.git
cd .ci-temp/methods-distance
mvn -e --no-transfer-progress verify -DskipTests -Dcheckstyle-version="${CS_POM_VERSION}" \
-Dcheckstyle.configLocation=../../config/checkstyle_checks.xml
-Dcheckstyle.configLocation=../../config/checkstyle-checks.xml
cd ..
removeFolderWithProtectedFiles methods-distance
;;
Expand Down
2 changes: 1 addition & 1 deletion config/ant-phase-verify-sevntu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<target name="execute" if="run">
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"/>

<property name="check.config" location="config/checkstyle_sevntu_checks.xml"/>
<property name="check.config" location="config/checkstyle-sevntu-checks.xml"/>

<tstamp>
<format property="STARTED" pattern="dd/MM/yyyy hh:mm:ss aa" />
Expand Down
28 changes: 14 additions & 14 deletions config/ant-phase-verify.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
classpath="${mvn.runtime_classpath}"
/>

<property name="check.config" location="config/checkstyle_checks.xml"/>
<property name="check.config" location="config/checkstyle-checks.xml"/>
<property name="check.config_non_main"
location="config/checkstyle_non_main_files_checks.xml"/>
location="config/checkstyle-non-main-files-checks.xml"/>
<property name="check.config_resources"
location="config/checkstyle_resources_checks.xml"/>
location="config/checkstyle-resources-checks.xml"/>
<property name="check.config_input"
location="config/checkstyle_input_checks.xml"/>
location="config/checkstyle-input-checks.xml"/>

<tstamp>
<format property="STARTED" pattern="dd/MM/yyyy hh:mm:ss aa" />
</tstamp>
<echo level="info">Checkstyle started (checkstyle_checks.xml): ${STARTED}</echo>
<echo level="info">Checkstyle started (checkstyle-checks.xml): ${STARTED}</echo>

<checkstyle config="${check.config}"
failOnViolation="false"
Expand All @@ -43,7 +43,7 @@
<formatter type="sarif" toFile="${mvn.project.build.directory}/cs_errors.sarif"/>
<property key="checkstyle.cache.file" file="${mvn.project.build.directory}/cachefile"/>
<property key="checkstyle.header.file" file="config/java.header"/>
<property key="checkstyle.regexp.header.file" file="config/java_regexp.header"/>
<property key="checkstyle.regexp.header.file" file="config/java-regexp.header"/>
<property key="checkstyle.importcontrol.file" file="config/import-control.xml"/>
<property key="checkstyle.importcontroltest.file" file="config/import-control-test.xml"/>
<property key="checkstyle.suppressions.file"
Expand All @@ -55,20 +55,20 @@
<tstamp>
<format property="FINISHED" pattern="dd/MM/yyyy hh:mm:ss aa"/>
</tstamp>
<echo level="info">Checkstyle finished (checkstyle_checks.xml) : ${FINISHED}</echo>
<echo level="info">Checkstyle finished (checkstyle-checks.xml) : ${FINISHED}</echo>

<tstamp>
<format property="STARTED" pattern="dd/MM/yyyy hh:mm:ss aa"/>
</tstamp>
<echo level="info">Checkstyle started (checkstyle_non_main_files_checks.xml): ${STARTED}</echo>
<echo level="info">Checkstyle started (checkstyle-non-main-files-checks.xml): ${STARTED}</echo>

<checkstyle config="${check.config_non_main}"
failOnViolation="true"
failureProperty="checkstyle.failure.property"
executeIgnoredModules="true"
>
<property key="checkstyle.non-main-files-suppressions.file"
file="config/checkstyle_non_main_files_suppressions.xml"/>
file="config/checkstyle-non-main-files-suppressions.xml"/>
<path>
<fileset dir="${basedir}" includes="**/*">
<exclude name=".git/**/*"/>
Expand Down Expand Up @@ -138,13 +138,13 @@
<tstamp>
<format property="FINISHED" pattern="dd/MM/yyyy hh:mm:ss aa"/>
</tstamp>
<echo level="info">Checkstyle finished (checkstyle_non_main_files_checks.xml): ${FINISHED}
<echo level="info">Checkstyle finished (checkstyle-non-main-files-checks.xml): ${FINISHED}
</echo>

<tstamp>
<format property="STARTED" pattern="dd/MM/yyyy hh:mm:ss aa"/>
</tstamp>
<echo level="info">Checkstyle started (checkstyle_resources_checks.xml): ${STARTED}</echo>
<echo level="info">Checkstyle started (checkstyle-resources-checks.xml): ${STARTED}</echo>

<checkstyle config="${check.config_resources}"
failOnViolation="true"
Expand Down Expand Up @@ -172,7 +172,7 @@
<tstamp>
<format property="FINISHED" pattern="dd/MM/yyyy hh:mm:ss aa"/>
</tstamp>
<echo level="info">Checkstyle finished (checkstyle_resources_checks.xml): ${FINISHED}</echo>
<echo level="info">Checkstyle finished (checkstyle-resources-checks.xml): ${FINISHED}</echo>

<fail if="checkstyle.failure.property"
message="Checkstyle failed: ${checkstyle.failure.property}"
Expand All @@ -181,7 +181,7 @@
<tstamp>
<format property="STARTED" pattern="dd/MM/yyyy hh:mm:ss aa"/>
</tstamp>
<echo level="info">Checkstyle started (checkstyle_input_checks.xml): ${STARTED}</echo>
<echo level="info">Checkstyle started (checkstyle-input-checks.xml): ${STARTED}</echo>

<checkstyle config="${check.config_input}"
failOnViolation="true"
Expand Down Expand Up @@ -235,7 +235,7 @@
<tstamp>
<format property="FINISHED" pattern="dd/MM/yyyy hh:mm:ss aa"/>
</tstamp>
<echo level="info">Checkstyle finished (checkstyle_input_checks.xml): ${FINISHED}</echo>
<echo level="info">Checkstyle finished (checkstyle-input-checks.xml): ${FINISHED}</echo>

<fail if="checkstyle.failure.property"
message="Checkstyle failed: ${checkstyle.failure.property}"
Expand Down
2 changes: 1 addition & 1 deletion config/archunit-store/stored.rules
Original file line number Diff line number Diff line change
@@ -1 +1 @@
slices\ matching\ 'com.puppycrawl.tools.checkstyle.(**)'\ should\ be\ free\ of\ cycles=slices_should_be_free_of_cycles_suppressions
slices\ matching\ 'com.puppycrawl.tools.checkstyle.(**)'\ should\ be\ free\ of\ cycles=slices-should-be-free-of-cycles-suppressions
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<!-- Suppressions for resources -->
<module name="SuppressionFilter">
<property name="file"
value="config/checkstyle_input_suppressions.xml"/>
value="config/checkstyle-input-suppressions.xml"/>
</module>

<module name="RegexpSingleline">
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@
<message key="regexp.filename.mismatch"
value="Filename should be in kebab-case."/>
</module>
<module name="RegexpOnFilename">
<property name="id" value="kebabCaseFileNamingInConfigFolder"/>
<property name="folderPattern" value="[\\/]config([\\/]|$)"/>
<property name="fileNamePattern" value="^[a-z][a-z0-9]*(\-[a-z0-9\.]+)*\.[a-z]+$"/>
<property name="match" value="false"/>
<property name="fileExtensions"
value="xml, xsd, config, words, files, properties, header, pl, yaml, txt, rb"/>
<message key="regexp.filename.mismatch"
value="Filename should be in kebab-case."/>
</module>

<module name="RegexpSingleline">
<property name="id" value="lineLength"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<!-- ArchUnit store is automatically updated by ArchUnit which
does not add new line at the end. -->
<suppress checks="NewlineAtEndOfFile"
files="config[\\/]archunit-store[\\/]slices_should_be_free_of_cycles_suppressions"/>
files="config[\\/]archunit-store[\\/]slices-should-be-free-of-cycles-suppressions"/>

<!-- till https://issues.apache.org/jira/browse/MRELEASE-1008 -->
<suppress id="lineLength" files="pom.xml"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<!-- Suppressions for resources -->
<module name="SuppressionFilter">
<property name="file"
value="config/checkstyle_resources_suppressions.xml"/>
value="config/checkstyle-resources-suppressions.xml"/>
</module>
<module name="FileTabCharacter"/>
<module name="RegexpSingleline">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<!-- Filters -->
<module name="SuppressionFilter">
<property name="file" value="config/sevntu_suppressions.xml"/>
<property name="file" value="config/sevntu-suppressions.xml"/>
</module>

<module name="TreeWalker">
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1576,13 +1576,13 @@
<dir>config</dir>
<excludes>
<exclude>java.header</exclude>
<exclude>java_regexp.header</exclude>
<exclude>java-regexp.header</exclude>
<exclude>org.eclipse.jdt.core.prefs</exclude>
<exclude>intellij-idea-inspections.properties</exclude>
<exclude>markdownlint.rb</exclude>
<exclude>signatures.txt</exclude>
<exclude>signatures-test.txt</exclude>
<exclude>StarterRuleSet-AllRulesByCategory.groovy.txt</exclude>
<exclude>codenarc-rules.groovy.txt</exclude>
<exclude>archunit-store/**</exclude>
<exclude>jsoref-spellchecker/**</exclude>
<exclude>projects-to-test/**</exclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,15 @@ public void testAllModulesAreReferencedInConfigFile() throws Exception {
moduleNames.stream().filter(check -> !modulesReferencedInConfig.contains(check))
.forEach(check -> {
final String errorMessage = String.format(Locale.ROOT,
"%s is not referenced in checkstyle_checks.xml", check);
"%s is not referenced in checkstyle-checks.xml", check);
assertWithMessage(errorMessage).fail();
});
}

@Test
public void testAllCheckTokensAreReferencedInCheckstyleConfigFile() throws Exception {
final Configuration configuration = ConfigurationUtil
.loadConfiguration("config/checkstyle_checks.xml");
.loadConfiguration("config/checkstyle-checks.xml");

validateAllCheckTokensAreReferencedInConfigFile("checkstyle", configuration,
CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE, false);
Expand Down Expand Up @@ -506,7 +506,7 @@ public void testAllCheckstyleModulesInCheckstyleConfig() throws Exception {
final Set<String> moduleNames = CheckUtil.getSimpleNames(CheckUtil.getCheckstyleModules());
moduleNames.removeAll(INTERNAL_MODULES);
for (String moduleName : moduleNames) {
assertWithMessage("checkstyle_checks.xml is missing module: " + moduleName)
assertWithMessage("checkstyle-checks.xml is missing module: " + moduleName)
.that(configChecks)
.contains(moduleName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ private static void validateUsageExample(String fileName, String sectionName, No
if ("Checkstyle Style".equals(linkText)) {
hasCheckstyle = true;
expectedUrl = "https://github.com/search?q="
+ "path%3Aconfig+filename%3Acheckstyle_checks.xml+"
+ "path%3Aconfig+filename%3Acheckstyle-checks.xml+"
+ "repo%3Acheckstyle%2Fcheckstyle+" + sectionName;
}
else if ("Google Style".equals(linkText)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private CheckUtil() {
}

public static Set<String> getConfigCheckStyleModules() {
return getCheckStyleModulesReferencedInConfig("config/checkstyle_checks.xml");
return getCheckStyleModulesReferencedInConfig("config/checkstyle-checks.xml");
}

public static Set<String> getConfigSunStyleModules() {
Expand Down Expand Up @@ -91,11 +91,11 @@ public static Set<String> getSimpleNames(Set<Class<?>> checks) {
}

/**
* Gets a set of names of checkstyle's checks which are referenced in checkstyle_checks.xml.
* Gets a set of names of checkstyle's checks which are referenced in checkstyle-checks.xml.
*
* @param configFilePath
* file path of checkstyle_checks.xml.
* @return names of checkstyle's checks which are referenced in checkstyle_checks.xml.
* file path of checkstyle-checks.xml.
* @return names of checkstyle's checks which are referenced in checkstyle-checks.xml.
*/
private static Set<String> getCheckStyleModulesReferencedInConfig(String configFilePath) {
try {
Expand Down
8 changes: 4 additions & 4 deletions src/xdocs/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@
Sun Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+Checker">
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle-checks.xml+repo%3Acheckstyle%2Fcheckstyle+Checker">
Checkstyle Style</a>
</li>
</ul>
Expand Down Expand Up @@ -613,7 +613,7 @@
Sun Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+TreeWalker">
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle-checks.xml+repo%3Acheckstyle%2Fcheckstyle+TreeWalker">
Checkstyle Style</a>
</li>
</ul>
Expand Down Expand Up @@ -1021,8 +1021,8 @@
that checks the coding conventions.
Example of all Checks/Modules usage could be found at checkstyle's code convention at file
<a
href="https://github.com/checkstyle/checkstyle/blob/master/config/checkstyle_checks.xml">
checkstyle_checks.xml
href="https://github.com/checkstyle/checkstyle/blob/master/config/checkstyle-checks.xml">
checkstyle-checks.xml
</a>
</p>

Expand Down
Loading

0 comments on commit 739d833

Please sign in to comment.