Skip to content

Commit

Permalink
Issue #1: Create a application what parses xdocs with example config …
Browse files Browse the repository at this point in the history
…specified
  • Loading branch information
piyush kumar sadangi authored and piyush kumar sadangi committed Jun 21, 2024
1 parent 7c15dd4 commit 11d72fe
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 3 deletions.
34 changes: 34 additions & 0 deletions AbstractClassName/Example1/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name = "Checker">
<property name="charset" value="UTF-8"/>

<!-- do not change severity to 'error', as that will hide errors caused by exceptions -->
<property name="severity" value="warning"/>

<!-- haltOnException is required for exception fixes and reporting of all exceptions -->
<property name="haltOnException" value="false"/>

<!-- BeforeExecutionFileFilters is required for sources of java9 -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$" />
</module>

<module name="TreeWalker">
<module name="AbstractClassName"/>

<!-- usuppress javadoc parsing errors, as we test Check not a parser -->
<module name="SuppressionXpathSingleFilter">
<property name="message" value="Javadoc comment at column \d+ has parse error"/>
</module>
</module>

<!-- as we run on regression even on non-compiled files we need to skip exceptions on them -->
<module name="SuppressionSingleFilter">
<property name="checks" value="Checker"/>
<property name="message" value="Exception occurred while parsing"/>
</module>
</module>
36 changes: 36 additions & 0 deletions AbstractClassName/Example2/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name = "Checker">
<property name="charset" value="UTF-8"/>

<!-- do not change severity to 'error', as that will hide errors caused by exceptions -->
<property name="severity" value="warning"/>

<!-- haltOnException is required for exception fixes and reporting of all exceptions -->
<property name="haltOnException" value="false"/>

<!-- BeforeExecutionFileFilters is required for sources of java9 -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$" />
</module>

<module name="TreeWalker">
<module name="AbstractClassName">
<property name="ignoreModifier" value="true"/>
</module>

<!-- usuppress javadoc parsing errors, as we test Check not a parser -->
<module name="SuppressionXpathSingleFilter">
<property name="message" value="Javadoc comment at column \d+ has parse error"/>
</module>
</module>

<!-- as we run on regression even on non-compiled files we need to skip exceptions on them -->
<module name="SuppressionSingleFilter">
<property name="checks" value="Checker"/>
<property name="message" value="Exception occurred while parsing"/>
</module>
</module>
36 changes: 36 additions & 0 deletions AbstractClassName/Example3/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name = "Checker">
<property name="charset" value="UTF-8"/>

<!-- do not change severity to 'error', as that will hide errors caused by exceptions -->
<property name="severity" value="warning"/>

<!-- haltOnException is required for exception fixes and reporting of all exceptions -->
<property name="haltOnException" value="false"/>

<!-- BeforeExecutionFileFilters is required for sources of java9 -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$" />
</module>

<module name="TreeWalker">
<module name="AbstractClassName">
<property name="ignoreName" value="true"/>
</module>

<!-- usuppress javadoc parsing errors, as we test Check not a parser -->
<module name="SuppressionXpathSingleFilter">
<property name="message" value="Javadoc comment at column \d+ has parse error"/>
</module>
</module>

<!-- as we run on regression even on non-compiled files we need to skip exceptions on them -->
<module name="SuppressionSingleFilter">
<property name="checks" value="Checker"/>
<property name="message" value="Exception occurred while parsing"/>
</module>
</module>
36 changes: 36 additions & 0 deletions AbstractClassName/Example4/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name = "Checker">
<property name="charset" value="UTF-8"/>

<!-- do not change severity to 'error', as that will hide errors caused by exceptions -->
<property name="severity" value="warning"/>

<!-- haltOnException is required for exception fixes and reporting of all exceptions -->
<property name="haltOnException" value="false"/>

<!-- BeforeExecutionFileFilters is required for sources of java9 -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$" />
</module>

<module name="TreeWalker">
<module name="AbstractClassName">
<property name="format" value="^Generator.+$"/>
</module>

<!-- usuppress javadoc parsing errors, as we test Check not a parser -->
<module name="SuppressionXpathSingleFilter">
<property name="message" value="Javadoc comment at column \d+ has parse error"/>
</module>
</module>

<!-- as we run on regression even on non-compiled files we need to skip exceptions on them -->
<module name="SuppressionSingleFilter">
<property name="checks" value="Checker"/>
<property name="message" value="Exception occurred while parsing"/>
</module>
</module>
5 changes: 3 additions & 2 deletions extractor/src/main/java/com/example/extractor/Main.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package com.example.extractor;

import java.nio.file.*;
Expand Down Expand Up @@ -27,7 +28,7 @@ public static void main(String[] args) throws Exception {
String inputDirectory = checkstyleRepoPath + "/" + pathInRepo;

System.out.println("PROJECT_ROOT: " + PROJECT_ROOT);
Path outputDirectory = PROJECT_ROOT.resolve("AbbreviationAsWordInName");
Path outputDirectory = PROJECT_ROOT.resolve("AbstractClassName");

// Process files in the input directory and save results to the output directory
processFiles(inputDirectory, outputDirectory.toString());
Expand Down Expand Up @@ -103,4 +104,4 @@ private static void processFile(String exampleFile, Path outputPath) {
e.printStackTrace();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class MainsLauncherTest {
@Test
public void testMain() throws Exception {
// Define the path in repo you want to test
String pathInRepo = "src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/abbreviationaswordinname";
String pathInRepo = "src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/abstractclassname";

// Pass the path as an argument
Main.main(new String[]{pathInRepo});
Expand Down

0 comments on commit 11d72fe

Please sign in to comment.