Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #13100: Create tests from InnerTypeLast xdoc examples
- Loading branch information
Showing
6 changed files
with
155 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...es/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheckExamplesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/////////////////////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code and other text files for adherence to a set of rules. | ||
// Copyright (C) 2001-2023 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 com.puppycrawl.tools.checkstyle.checks.design; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; | ||
|
||
@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") | ||
public class InnerTypeLastCheckExamplesTest extends AbstractModuleTestSupport { | ||
@Override | ||
protected String getResourceLocation() { | ||
return "xdocs-examples"; | ||
} | ||
|
||
@Override | ||
protected String getPackageLocation() { | ||
return "com/puppycrawl/tools/checkstyle/checks/design/innertypelast"; | ||
} | ||
|
||
@Test | ||
public void testExample1() throws Exception { | ||
final String[] expected = { | ||
|
||
}; | ||
|
||
verifyWithInlineConfigParser(getPath("Example1.txt"), expected); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...amples/resources/com/puppycrawl/tools/checkstyle/checks/design/innertypelast/Example1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*xml | ||
<module name="Checker"> | ||
<module name="TreeWalker"> | ||
<module name="InnerTypeLast"/> | ||
</module> | ||
</module> | ||
*/ | ||
|
||
// xdoc section -- start | ||
class Test { | ||
private String s; // OK | ||
class InnerTest1 {} | ||
public void test() {} // violation, method should be declared before inner types. | ||
} | ||
|
||
class Test2 { | ||
static {}; // OK | ||
class InnerTest1 {} | ||
public Test2() {} // violation, constructor should be declared before inner types. | ||
} | ||
|
||
class Test3 { | ||
private String s; // OK | ||
public void test() {} // OK | ||
class InnerTest1 {} | ||
} | ||
// xdoc section -- end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document xmlns="http://maven.apache.org/XDOC/2.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd"> | ||
<head> | ||
<title>InnerTypeLast</title> | ||
</head> | ||
<body> | ||
<section name="InnerTypeLast"> | ||
<p>Since Checkstyle 5.2</p> | ||
<subsection name="Description" id="Description"> | ||
<p> | ||
Checks nested (internal) classes/interfaces are declared at the bottom of the | ||
primary (top-level) class after all init and static init blocks, | ||
method, constructor and field declarations. | ||
</p> | ||
</subsection> | ||
|
||
<subsection name="Examples" id="Examples"> | ||
<p id="Example1-config"> | ||
To configure the check: | ||
</p> | ||
<macro name="example"> | ||
<param name="path" | ||
value="resources/com/puppycrawl/tools/checkstyle/checks/design/innertypelast/Example1.txt"/> | ||
<param name="type" value="config"/> | ||
</macro> | ||
<p id="Example1-code">Example:</p> | ||
<macro name="example"> | ||
<param name="path" | ||
value="resources/com/puppycrawl/tools/checkstyle/checks/design/innertypelast/Example1.txt"/> | ||
<param name="type" value="code"/> | ||
</macro> | ||
</subsection> | ||
|
||
<subsection name="Example of Usage" id="Example_of_Usage"> | ||
<ul> | ||
<li> | ||
<a href="https://github.com/search?q=path%3Aconfig%20path%3A**%2Fcheckstyle-checks.xml+repo%3Acheckstyle%2Fcheckstyle+InnerTypeLast"> | ||
Checkstyle Style</a> | ||
</li> | ||
</ul> | ||
</subsection> | ||
|
||
<subsection name="Violation Messages" id="Violation_Messages"> | ||
<ul> | ||
<li> | ||
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fdesign%20path%3A**%2Fmessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22arrangement.members.before.inner%22"> | ||
arrangement.members.before.inner</a> | ||
</li> | ||
</ul> | ||
<p> | ||
All messages can be customized if the default message doesn't suit you. | ||
Please <a href="../../config.html#Custom_messages">see the documentation</a> | ||
to learn how to. | ||
</p> | ||
</subsection> | ||
|
||
<subsection name="Package" id="Package"> | ||
<p> | ||
com.puppycrawl.tools.checkstyle.checks.design | ||
</p> | ||
</subsection> | ||
|
||
<subsection name="Parent Module" id="Parent_Module"> | ||
<p> | ||
<a href="../../config.html#TreeWalker">TreeWalker</a> | ||
</p> | ||
</subsection> | ||
</section> | ||
</body> | ||
</document> |