GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Issue #18556: updating multifileregexpheader and adding external xml … by ZaheerAhmadDev · Pull Request #18802 · checkstyle/checkstyle

Issue #18556: updating multifileregexpheader and adding external xml … #18802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
romani merged 1 commit into checkstyle:master from ZaheerAhmadDev:just-something
Jan 31, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Issue #18556: updating multifileregexpheader and adding external xml … #18802

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
d84bc45
Issue #18556: updating multifileregexpheader and adding external xml …
ZaheerAhmadDev Jan 31, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

36 changes: 23 additions & 13 deletions 36 src/site/xdoc/checks/header/multifileregexpheader.xml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,19 @@ public class Example1 { }
</code></pre></div>
<hr class="example-separator"/>

<p id="Example2-config">
<p id="Example2-raw">
To configure the check to use multiple header files:
</p>
<div class="wrapper"><pre class="prettyprint"><code class="language-xml">
&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd"&gt;
&lt;module name="Checker"&gt;
&lt;module name="MultiFileRegexpHeader"&gt;
&lt;property name="fileExtensions" value="java"/&gt;
&lt;property name="headerFiles" value="${config.folder}/java.header,
${config.folder}/apache.header"/&gt;
&lt;/module&gt;
&lt;module name="MultiFileRegexpHeader"&gt;
&lt;property name="fileExtensions" value="java"/&gt;
&lt;property name="headerFiles" value="${config.folder}/java.header, ${config.folder}/apache.header"/&gt;
&lt;/module&gt;
&lt;/module&gt;
</code></pre></div>

Expand All @@ -99,17 +102,20 @@ public class Example2 { }
</code></pre></div>
<hr class="example-separator"/>

<p id="Example3-config">
<p id="Example3-raw">
To configure the check to verify that each file starts with one of
multiple headers.
</p>
<div class="wrapper"><pre class="prettyprint"><code class="language-xml">
&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd"&gt;
&lt;module name="Checker"&gt;
&lt;module name="MultiFileRegexpHeader"&gt;
&lt;property
name="headerFiles" value="${config.folder}/java.header,
${config.folder}/apache.header"/&gt;
&lt;/module&gt;
&lt;module name="MultiFileRegexpHeader"&gt;
&lt;property name="headerFiles"
value="${config.folder}/java.header, ${config.folder}/apache.header"/&gt;
&lt;/module&gt;
&lt;/module&gt;
</code></pre></div>

Expand All @@ -121,10 +127,14 @@ public class Example3 { }
</code></pre></div>
<hr class="example-separator"/>

<p id="Example4-config">
<p id="Example4-raw">
For a configuration where any header is accepted:
</p>
<div class="wrapper"><pre class="prettyprint"><code class="language-xml">
&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd"&gt;
&lt;module name="Checker"&gt;
&lt;module name="MultiFileRegexpHeader"&gt;
&lt;property
Expand Down
18 changes: 9 additions & 9 deletions 18 src/site/xdoc/checks/header/multifileregexpheader.xml.template
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
</macro>
<hr class="example-separator"/>

<p id="Example2-config">
<p id="Example2-raw">
To configure the check to use multiple header files:
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/header/multifileregexpheader/Example2.java"/>
<param name="type" value="config"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/header/multifileregexpheader/Example2.xml"/>
<param name="type" value="raw"/>
</macro>

<p id="java-raw">content of <code>java.header</code> file:</p>
Expand All @@ -77,14 +77,14 @@
</macro>
<hr class="example-separator"/>

<p id="Example3-config">
<p id="Example3-raw">
To configure the check to verify that each file starts with one of
multiple headers.
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/header/multifileregexpheader/Example3.java"/>
<param name="type" value="config"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/header/multifileregexpheader/Example3.xml"/>
<param name="type" value="raw"/>
</macro>

<p id="Example3-code">Example3:</p>
Expand All @@ -95,13 +95,13 @@
</macro>
<hr class="example-separator"/>

<p id="Example4-config">
<p id="Example4-raw">
For a configuration where any header is accepted:
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/header/multifileregexpheader/Example4.java"/>
<param name="type" value="config"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/header/multifileregexpheader/Example4.xml"/>
<param name="type" value="raw"/>
</macro>

<p id="universal-raw">content of <code>universal.header</code> file:</p>
Expand Down
22 changes: 22 additions & 0 deletions 22 src/test/java/com/puppycrawl/tools/checkstyle/AbstractModuleTestSupport.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,28 @@ protected final void verifyWithInlineXmlConfig(String filePath, String... expect
verify(xmlConfig, filePath, expected);
}

/**
* Performs verification of the file with the given file path using configuration,
* loaded from an external XML resource and the array of expected messages.
*
* @param configPath path to the XML configuration resource.
* @param filePath file path to verify.
* @param expected an array of expected messages.
* @throws Exception if exception occurs during verification process.
*/
protected void verifyWithExternalXmlConfig(
String configPath,
String filePath,
String... expected)
throws Exception {
final Configuration config =
ConfigurationLoader.loadConfiguration(
configPath,
new PropertiesExpander(System.getProperties()),
ConfigurationLoader.IgnoredModulesOptions.EXECUTE);
verify(config, filePath, expected);
}

/**
* Performs verification of the file with the given file path using specified configuration
* and the array expected messages. Also performs verification of the config specified in
Expand Down
37 changes: 21 additions & 16 deletions 37 ...com/puppycrawl/tools/checkstyle/checks/header/MultiFileRegexpHeaderCheckExamplesTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,47 @@ public void testExample1() throws Exception {

@Test
public void testExample2() throws Exception {
final String[] expected = {
"1: " + getCheckMessage(MultiFileRegexpHeaderCheck.MSG_HEADER_MISMATCH,
"// Checkstyle - Java code style checker."
+ " Copyright (C) 20XX-20XX the authors.",
final String path =
"src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/header/"
+ "multifileregexpheader/java.header, "
+ "src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/header/"
+ "multifileregexpheader/apache.header"),
+ "multifileregexpheader/apache.header";
final String[] expected = {
"1: " + getCheckMessage(MultiFileRegexpHeaderCheck.MSG_HEADER_MISMATCH,
"// Checkstyle - Java code style checker."
+ " Copyright (C) 20XX-20XX the authors.", path),
};

System.setProperty("config.folder", "src/xdocs-examples/resources/" + getPackageLocation());
verifyWithInlineConfigParser(getPath("Example2.java"), expected);

verifyWithExternalXmlConfig(getPath("Example2.xml"),
getPath("Example2.java"),
expected);
}

@Test
public void testExample3() throws Exception {
final String[] expected = {
"1: " + getCheckMessage(MultiFileRegexpHeaderCheck.MSG_HEADER_MISMATCH,
"// Checkstyle - Java code style checker."
+ " Copyright (C) 20XX-20XX the authors.",
final String path =
"src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/header/"
+ "multifileregexpheader/java.header, "
+ "src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/header/"
+ "multifileregexpheader/apache.header"),
+ "multifileregexpheader/apache.header";
final String[] expected = {
"1: " + getCheckMessage(MultiFileRegexpHeaderCheck.MSG_HEADER_MISMATCH,
"// Checkstyle - Java code style checker."
+ " Copyright (C) 20XX-20XX the authors.", path),
};

System.setProperty("config.folder", "src/xdocs-examples/resources/" + getPackageLocation());
verifyWithInlineConfigParser(getPath("Example3.java"), expected);
verifyWithExternalXmlConfig(getPath("Example3.xml"),
getPath("Example3.java"),
expected);
}

@Test
public void testExample4() throws Exception {
final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
System.setProperty("config.folder", "src/xdocs-examples/resources/" + getPackageLocation());
verifyWithInlineConfigParser(getPath("Example4.java"), expected);
verifyWithExternalXmlConfig(getPath("Example4.xml"),
getPath("Example4.java"),
expected);
}
}

9 changes: 1 addition & 8 deletions 9 ...sources/com/puppycrawl/tools/checkstyle/checks/header/multifileregexpheader/Example2.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
/*xml
<module name="Checker">
<module name="MultiFileRegexpHeader">
<property name="fileExtensions" value="java"/>
<property name="headerFiles" value="${config.folder}/java.header,
${config.folder}/apache.header"/>
</module>
</module>
*/
// xdoc section -- start
package com.puppycrawl.tools.checkstyle.checks.header.multifileregexpheader;
/* violation on first line 'Header mismatch, expected line content was' */
// because headerFile is bigger then target java file
public class Example2 { }
// xdoc section -- end
// violation 15 lines above 'Header mismatch, expected line content was'
// violation 8 lines above 'Header mismatch, expected line content was'
11 changes: 11 additions & 0 deletions 11 ...esources/com/puppycrawl/tools/checkstyle/checks/header/multifileregexpheader/Example2.xml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="MultiFileRegexpHeader">
<property name="fileExtensions" value="java"/>
<property name="headerFiles" value="${config.folder}/java.header, ${config.folder}/apache.header"/>
</module>
</module>

9 changes: 1 addition & 8 deletions 9 ...sources/com/puppycrawl/tools/checkstyle/checks/header/multifileregexpheader/Example3.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
/*xml
<module name="Checker">
<module name="MultiFileRegexpHeader">
<property
name="headerFiles" value="${config.folder}/java.header,
${config.folder}/apache.header"/>
</module>
</module>
*/
// xdoc section -- start
package com.puppycrawl.tools.checkstyle.checks.header.multifileregexpheader;
/* violation on first line 'Header mismatch, expected line content was' */
public class Example3 { }
// xdoc section -- end
// violation 14 lines above 'Header mismatch, expected line content was'
Comment thread
ZaheerAhmadDev marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

// violation 7 lines above 'Header mismatch, expected line content was'
10 changes: 10 additions & 0 deletions 10 ...esources/com/puppycrawl/tools/checkstyle/checks/header/multifileregexpheader/Example3.xml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?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">
<module name="MultiFileRegexpHeader">
<property name="headerFiles"
value="${config.folder}/java.header, ${config.folder}/apache.header"/>
</module>
</module>
7 changes: 0 additions & 7 deletions 7 ...sources/com/puppycrawl/tools/checkstyle/checks/header/multifileregexpheader/Example4.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/*xml
<module name="Checker">
<module name="MultiFileRegexpHeader">
<property
name="headerFiles"
value="${config.folder}/universal.header"/>
</module>
</module>
*/
// xdoc section -- start
package com.puppycrawl.tools.checkstyle.checks.header.multifileregexpheader;
Expand Down
11 changes: 11 additions & 0 deletions 11 ...esources/com/puppycrawl/tools/checkstyle/checks/header/multifileregexpheader/Example4.xml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="MultiFileRegexpHeader">
<property
name="headerFiles"
value="${config.folder}/universal.header"/>
</module>
</module>
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.