From eac2b817247f0675da09496e5497931f583f9513 Mon Sep 17 00:00:00 2001 From: Mohit Attry Date: Wed, 11 Sep 2024 09:34:33 +0530 Subject: [PATCH] Issue #15555: modified Example4.py to Example4.cpp --- .../checks/NewlineAtEndOfFileCheckExamplesTest.java | 2 +- .../newlineatendoffile/{Example4.py => Example4.cpp} | 7 ++++--- src/xdocs/checks/misc/newlineatendoffile.xml | 11 ++++++----- src/xdocs/checks/misc/newlineatendoffile.xml.template | 8 ++++---- 4 files changed, 15 insertions(+), 13 deletions(-) rename src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/newlineatendoffile/{Example4.py => Example4.cpp} (59%) diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/NewlineAtEndOfFileCheckExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/NewlineAtEndOfFileCheckExamplesTest.java index dcefb67345d..c010bdb5349 100644 --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/NewlineAtEndOfFileCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/NewlineAtEndOfFileCheckExamplesTest.java @@ -64,7 +64,7 @@ public void testExample4() throws Exception { "1: " + getCheckMessage(MSG_KEY_NO_NEWLINE_EOF), }; - verifyWithInlineConfigParser(getPath("Example4.py"), expected); + verifyWithInlineConfigParser(getPath("Example4.cpp"), expected); } @Test diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/newlineatendoffile/Example4.py b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/newlineatendoffile/Example4.cpp similarity index 59% rename from src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/newlineatendoffile/Example4.py rename to src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/newlineatendoffile/Example4.cpp index f99d1dca7fd..29b34acaf8c 100644 --- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/newlineatendoffile/Example4.py +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/newlineatendoffile/Example4.cpp @@ -1,12 +1,13 @@ /*xml - + */ // violation 7 lines above 'File does not end with a newline.' // xdoc section -- start -print("Hello world!") -# no ⤶ below it is violation +int main() { // ⤶ + return 0;// ⤶ +} // no ⤶ below it is violation // xdoc section -- end \ No newline at end of file diff --git a/src/xdocs/checks/misc/newlineatendoffile.xml b/src/xdocs/checks/misc/newlineatendoffile.xml index 8dd4f71a775..50180b7509a 100644 --- a/src/xdocs/checks/misc/newlineatendoffile.xml +++ b/src/xdocs/checks/misc/newlineatendoffile.xml @@ -128,19 +128,20 @@ public class Example3 { // ⤶

- To configure the check to work only on Java, XML and Python files: + To configure the check to work only on Java, XML and Cpp files:

<module name="Checker"> <module name="NewlineAtEndOfFile"> - <property name="fileExtensions" value="java, xml, py"/> + <property name="fileExtensions" value="java, xml, cpp"/> </module> </module> -

Python file Example4.py:

+

Cpp file Example4.cpp:

-print("Hello world!") -# no ⤶ below it is violation +int main() { // ⤶ + return 0;// ⤶ +} // no ⤶ below it is violation

Java file Example5.java:

diff --git a/src/xdocs/checks/misc/newlineatendoffile.xml.template b/src/xdocs/checks/misc/newlineatendoffile.xml.template index 12ec0678d43..03263046a52 100644 --- a/src/xdocs/checks/misc/newlineatendoffile.xml.template +++ b/src/xdocs/checks/misc/newlineatendoffile.xml.template @@ -108,17 +108,17 @@ StaticMethodCandidateCheck.name = Static Method Candidate

- To configure the check to work only on Java, XML and Python files: + To configure the check to work only on Java, XML and Cpp files:

+ value="resources/com/puppycrawl/tools/checkstyle/checks/newlineatendoffile/Example4.cpp"/> -

Python file Example4.py:

+

Cpp file Example4.cpp:

+ value="resources/com/puppycrawl/tools/checkstyle/checks/newlineatendoffile/Example4.cpp"/>