Skip to content

Commit 17c6e37

Browse files
mohitsatrromani
authored andcommitted
supplemental: Documentation to disable LineLength Check on Text-blocks
1 parent 1e22276 commit 17c6e37

3 files changed

Lines changed: 78 additions & 0 deletions

File tree

src/site/xdoc/checks/sizes/linelength.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,40 @@ class Example5 {
246246
System.out.println("This line is long and exceeds the default limit of 80 characters.");
247247
}
248248
}
249+
</code></pre></div><hr class="example-separator"/>
250+
<p id="Example6-config">
251+
To prevent this check from flagging lines in text-blocks, with
252+
<a href="https://github.com/checkstyle/checkstyle/issues/17707">side effects</a>:
253+
</p>
254+
<div class="wrapper"><pre class="prettyprint"><code class="language-xml">
255+
&lt;module name="Checker"&gt;
256+
&lt;module name="LineLength"&gt;
257+
&lt;property name="max" value="70"/&gt;
258+
&lt;/module&gt;
259+
&lt;module name="SuppressWithPlainTextCommentFilter"&gt;
260+
&lt;property name="checkFormat" value="LineLength"/&gt;
261+
&lt;property name="offCommentFormat" value='^.*"""$'/&gt;
262+
&lt;property name="onCommentFormat" value='^\s*"""\s*(?:[,;]|.+)$'/&gt;
263+
&lt;/module&gt;
264+
&lt;/module&gt;
265+
</code></pre></div>
266+
<p id="Example6-code">
267+
Example:
268+
</p>
269+
<div class="wrapper"><pre class="prettyprint"><code class="language-java">
270+
package com.puppycrawl.tools.checkstyle.checks.sizes.linelength;
271+
272+
public class Example6 {
273+
void testMethod() {
274+
String str1 = """
275+
This is a very really long string that exceeds the limit but no error....
276+
""";
277+
String str2 =
278+
"""
279+
This is a very really long string that exceeds the limit but no error.....
280+
""";
281+
}
282+
}
249283
</code></pre></div>
250284
</subsection>
251285

src/site/xdoc/checks/sizes/linelength.xml.template

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,23 @@
117117
<param name="path"
118118
value="resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/Example5.java"/>
119119
<param name="type" value="code"/>
120+
</macro><hr class="example-separator"/>
121+
<p id="Example6-config">
122+
To prevent this check from flagging lines in text-blocks, with
123+
<a href="https://github.com/checkstyle/checkstyle/issues/17707">side effects</a>:
124+
</p>
125+
<macro name="example">
126+
<param name="path"
127+
value="resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/Example6.java"/>
128+
<param name="type" value="config"/>
129+
</macro>
130+
<p id="Example6-code">
131+
Example:
132+
</p>
133+
<macro name="example">
134+
<param name="path"
135+
value="resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/Example6.java"/>
136+
<param name="type" value="code"/>
120137
</macro>
121138
</subsection>
122139

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="LineLength">
4+
<property name="max" value="70"/>
5+
</module>
6+
<module name="SuppressWithPlainTextCommentFilter">
7+
<property name="checkFormat" value="LineLength"/>
8+
<property name="offCommentFormat" value='^.*"""$'/>
9+
<property name="onCommentFormat" value='^\s*"""\s*(?:[,;]|.+)$'/>
10+
</module>
11+
</module>
12+
*/
13+
// xdoc section -- start
14+
package com.puppycrawl.tools.checkstyle.checks.sizes.linelength;
15+
16+
public class Example6 {
17+
void testMethod() {
18+
String str1 = """
19+
This is a very really long string that exceeds the limit but no error....
20+
""";
21+
String str2 =
22+
"""
23+
This is a very really long string that exceeds the limit but no error.....
24+
""";
25+
}
26+
}
27+
// xdoc section -- end

0 commit comments

Comments
 (0)