aboutsummaryrefslogtreecommitdiff
path: root/src/xdocs/config_regexp.xml
blob: 410362e97eebbead2c7600898a6fb0abc162da90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
<?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 http://maven.apache.org/xsd/xdoc-2.0.xsd">

  <head>
    <title>Regexp</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"/>
    <script type="text/javascript" src="js/anchors.js"/>
    <script type="text/javascript" src="js/google-analytics.js"/>
    <link rel="icon" href="images/favicon.png" type="image/x-icon" />
    <link rel="shortcut icon" href="images/favicon.ico" type="image/ico" />
  </head>

  <body>
    <section name="Content">
      <macro name="toc">
        <param name="fromDepth" value="1"/>
        <param name="toDepth" value="1"/>
      </macro>
    </section>

    <section name="Regexp">
      <subsection name="Description">
        <p>
          A check that makes sure that a specified pattern exists, exists less
          than a set number of times, or does not exist in the file.
        </p>
        <p>
          This check combines all the functionality provided by
          <a href="config_header.html#RegexpHeader">RegexpHeader</a>
          except supplying the regular expression from a file.
        </p>
        <p>
          It differs from them in that it works in multiline mode.
          Its regular expression can span multiple lines and it checks this
          against the whole file at once.
          The others work in singleline mode.
          Their single or multiple regular expressions can only span one line.
          They check each of these against each line in the file in turn.
        </p>
        <p>
          <b>Note:</b> Because of the different mode of operation there may be
          some changes in the regular expressions used to achieve a particular end.
        </p>
        <p>In multiline mode...</p>
        <ul>
          <li> <code>^</code> means the beginning of a line, as opposed to beginning of the input.</li>
          <li> For beginning of the input use <code>\A</code>.</li>
          <li> <code>$</code> means the end of a line, as opposed to the end of the input.</li>
          <li> For end of input use <code>\Z</code>.</li>
          <li> Each line in the file is terminated with a line feed character.</li>
        </ul>
        <p>
          <b>Note:</b> Not all regular expression engines are created equal. Some provide extra
          functions that others do not and some elements of the syntax may vary.
          This check makes use of the <a
                href="https://docs.oracle.com/javase/7/docs/api/java/util/regex/package-summary.html">
          java.util.regex package</a>; please check its documentation for
          details of how to construct a regular expression to achieve a particular
          goal.
        </p>
        <p>
          <b>Note:</b> When entering a regular expression as a parameter in the
          XML config file you must also take into account the XML rules. e.g. if
          you want to match a &lt; symbol you need to enter &amp;lt;. The regular
          expression should be entered on one line.
        </p>
      </subsection>

      <subsection name="Properties">
        <table>
          <tr>
            <th>name</th>
            <th>description</th>
            <th>type</th>
            <th>default value</th>
          </tr>
          <tr>
            <td>format</td>
            <td>pattern</td>
            <td><a href="property_types.html#regexp">Regular Expression</a></td>
            <td><code>"$^"</code> (empty)</td>
          </tr>
          <tr>
            <td>message</td>
            <td>message which is used to notify about violations,
              if empty then the default (hard-coded) message is used.</td>
            <td><a href="property_types.html#string">String</a></td>
            <td><code>&quot;&quot;</code>(empty)</td>
          </tr>
          <tr>
            <td>illegalPattern</td>
            <td>Controls whether the pattern is required or illegal.</td>
            <td><a href="property_types.html#boolean">Boolean</a></td>
            <td><code>false</code></td>
          </tr>
          <tr>
            <td>duplicateLimit</td>
            <td>Controls whether to check for duplicates of a required pattern,
              any negative value means no checking for duplicates, any positive
              value is used as the maximum number of allowed duplicates, if the
              limit is exceeded errors will be logged.</td>
            <td><a href="property_types.html#integer">Integer</a></td>
            <td><code>0</code></td>
          </tr>
          <tr>
            <td>errorLimit</td>
            <td>Controls the maximum number of errors before the check will abort.</td>
            <td><a href="property_types.html#integer">Integer</a></td>
            <td><code>100</code></td>
          </tr>
          <tr>
            <td>ignoreComments</td>
            <td>Controls whether to ignore matches found within comments.</td>
            <td><a href="property_types.html#boolean">Boolean</a></td>
            <td><code>false</code></td>
          </tr>
        </table>
      </subsection>

      <subsection name="Examples">
        <p>
          The following examples are mainly copied from the other 3 checks
          mentioned above, to show how the same results can be achieved using
          this check in place of them.
        </p>
        <p>
          <b>To use like Required Regexp check:</b>
        </p>
        <p>
          An example of how to configure the check to make sure a copyright
          statement is included in the file:
        </p>
        <p> The statement. </p>
        <source>
          // This code is copyrighted
        </source>
        <p> The check. </p>
        <source>
          &lt;module name="Regexp"&gt;
          &lt;property name="format" value="// This code is copyrighted"/&gt;
          &lt;/module&gt;
        </source>
        <p> Your statement may be multiline. </p>
        <source>
          // This code is copyrighted
          // (c) MyCompany
        </source>
        <p> Then the check would be. </p>
        <source>
          &lt;module name="Regexp"&gt;
          &lt;property name="format" value="// This code is copyrighted\n// \(c\) MyCompany"/&gt;
          &lt;/module&gt;
        </source>
        <p><b>Note:</b> To search for parentheses () in a regular expression
          you must escape them like \(\). This is required by the regexp engine,
          otherwise it will think they are special instruction characters.
        </p>
        <p>
          And to make sure it appears only once:
        </p>
        <source>
          &lt;module name="Regexp"&gt;
          &lt;property name="format" value="// This code is copyrighted\n// \(c\) MyCompany"/&gt;
          &lt;property name=&quot;duplicateLimit&quot; value=&quot;0&quot;/&gt;
          &lt;/module&gt;
        </source>
        <p>
          It can also be useful to attach a meaningful message to the check:
        </p>
        <source>
          &lt;module name="Regexp"&gt;
          &lt;property name="format" value="// This code is copyrighted\n// \(c\) MyCompany"/&gt;
          &lt;property name=&quot;message&quot; value=&quot;Copyright&quot;/&gt;
          &lt;/module&gt;
        </source>
        <p>
          <b>To use like illegal regexp check:</b>
        </p>
        <p>
          An example of how to configure the check to make sure there are no
          calls to <code>System.out.println</code>:
        </p>
        <source>
          &lt;module name=&quot;Regexp&quot;&gt;
          &lt;!-- . matches any character, so we need to escape it and use \. to match dots. --&gt;
          &lt;property name="format" value="System\.out\.println"/&gt;
          &lt;property name="illegalPattern" value="true"/&gt;
          &lt;/module&gt;
        </source>
        <p>
          You may want to make the above check ignore comments, like this:
        </p>
        <source>
          &lt;module name=&quot;Regexp&quot;&gt;
          &lt;property name="format" value="System\.out\.println"/&gt;
          &lt;property name="illegalPattern" value="true"/&gt;
          &lt;property name="ignoreComments" value="true"/&gt;
          &lt;/module&gt;
        </source>
        <p>
          An example of how to configure the check to find trailing whitespace
          at the end of a line:
        </p>
        <source>
          &lt;module name=&quot;Regexp&quot;&gt;
          &lt;property name="format" value="[ \t]+$"/&gt;
          &lt;property name="illegalPattern" value="true"/&gt;
          &lt;property name=&quot;message&quot; value=&quot;Trailing whitespace&quot;/&gt;
          &lt;/module&gt;
        </source>
        <p>
          An example of how to configure the check to find case-insensitive
          occurrences of &quot;debug&quot;:
        </p>
        <source>
          &lt;module name=&quot;Regexp&quot;&gt;
          &lt;property name="format" value="(?i)debug"/&gt;
          &lt;property name="illegalPattern" value="true"/&gt;
          &lt;/module&gt;
        </source>
        <p>
          <b>Note:</b> The (?i) at the beginning of the regular expression
          tells the regexp engine to ignore the case.
        </p>
        <p>
          There is also a feature to limit the number of errors reported.
          When the limit is reached the check aborts with a message
          reporting that the limit has been reached.
          The default limit setting is 100, but this can be change as shown in
          the following example.
        </p>
        <source>
          &lt;module name=&quot;Regexp&quot;&gt;
          &lt;property name="format" value="(?i)debug"/&gt;
          &lt;property name="illegalPattern" value="true"/&gt;
          &lt;property name="errorLimit" value="1000"/&gt;
          &lt;/module&gt;
        </source>
        <p>
          <b>To use like <a
                  href="config_header.html#RegexpHeader">RegexpHeader
          </a>:</b>
        </p>
        <p>
          To configure the check to verify that each file starts with the
          following multiline header.
        </p>
        <p>Note the following:</p>
        <ul>
          <li>\A means the start of the file.</li>
          <li>The date can be any 4 digit number.</li>
        </ul>

        <source>
          // Copyright (C) 2004 MyCompany
          // All rights reserved
        </source>
        <source>
          &lt;module name=&quot;Regexp&quot;&gt;
          &lt;property
          name=&quot;format&quot;
          value=&quot;\A// Copyright \(C\) \d\d\d\d MyCompany\n// All rights reserved&quot;/&gt;
          &lt;/module&gt;
        </source>
        <p>
          A more complex example. Note how the import and javadoc multilines are
          handled, there can be any number of them.
        </p>
        <source>
          ///////////////////////////////////////////////////////////////////////
          // checkstyle:
          // Checks Java source code for adherence to a set of rules.
          // Copyright (C) 2004  Oliver Burn
          // Last modification by $Author A.N.Other$
          ///////////////////////////////////////////////////////////////////////

          package com.puppycrawl.checkstyle;

          import java.util.thing1;
          import java.util.thing2;
          import java.util.thing3;

          /**
          * javadoc line 1
          * javadoc line 2
          * javadoc line 3
          */
        </source>
        <source>
          &lt;module name=&quot;Regexp&quot;&gt;
          &lt;property
          name=&quot;format&quot;
          value=&quot;\A/{71}\n// checkstyle:\n// Checks Java source code for
          adherence to a set of rules\.\n// Copyright \(C\) \d\d\d\d  Oliver Burn\n
          // Last modification by \$Author.*\$\n/{71}\n\npackage [\w\.]*;\n\n
          (import [\w\.]*;\n)*\n/\*\*\n( \*[^/]*\n)* \*/&quot;/&gt;
          &lt;/module&gt;
        </source>
        <p>
          <b>More examples:</b>
        </p>
        <p>
          The next 2 examples deal with the following example Java source file:
        </p>
        <source>
          /*
          * PID.java
          *
          * Copyright (c) 2001 ACME
          * 123 Some St.
          * Somewhere.
          *
          * This software is the confidential and proprietary information of ACME.
          * ("Confidential Information"). You shall not disclose such
          * Confidential Information and shall use it only in accordance with
          * the terms of the license agreement you entered into with ACME.
          *
          * $Log: config_misc.xml,v $
          * Revision 1.7  2007/01/16 12:16:35  oburn
          * Removing all reference to mailing lists
          *
          * Revision 1.6  2005/12/25 16:13:10  o_sukhodolsky
          * Fix for rfe 1248106 (TYPECAST is now accepted by NoWhitespaceAfter)
          *
          * Fix for rfe 953266 (thanks to Paul Guyot (pguyot) for submitting patch)
          * IllegalType can be configured to accept some abstract classes which
          * matches to regexp of illegal type names (property legalAbstractClassNames)
          *
          * TrailingComment now can be configured to accept some trailing comments
          * (such as NOI18N) (property legalComment, rfe 1385344).
          *
          * Revision 1.5  2005/11/06 11:54:12  oburn
          * Incorporate excellent patch [ 1344344 ] Consolidation of regexp checks.
          *
          * Revision 1.3.8.1  2005/10/11 14:26:32  someone
          * Fix for bug 251.  The broken bit is fixed
          */

          package com.acme.tools;

          import com.acme.thing1;
          import com.acme.thing2;
          import com.acme.thing3;

          /**
          *
          * &lt;P&gt;
          *   &lt;I&gt;This software is the confidential and proprietary information of
          *   ACME (&lt;B&gt;"Confidential Information"&lt;/B&gt;). You shall not
          *   disclose such Confidential Information and shall use it only in
          *   accordance with the terms of the license agreement you entered into
          *   with ACME.&lt;/I&gt;
          * &lt;/P&gt;
          *
          * &amp;#169; copyright 2002 ACME
          *
          * @author   Some Body
          */
          public class PID extends StateMachine implements WebObject.Constants {

          /** javadoc. */
          public static final int A_SETPOINT = 1;
          .
          .
          .
          } // class PID
        </source>
        <p>
          This checks for the presence of the header, the first 16 lines.
        </p>
        <p>Note the following:</p>
        <ul>
          <li>Line 2 and 13 contain the file name. These are checked to
            make sure they are the same, and that they match the class name.</li>
          <li>The date can be any 4 digit number.</li>
        </ul>

        <source>
          &lt;module name=&quot;Regexp&quot;&gt;
          &lt;property
          name=&quot;format&quot;
          value=&quot;\A/\*\n \* (\w*)\.java\n \*\n \* Copyright \(c\)
          \d\d\d\d ACME\n \* 123 Some St\.\n \* Somewhere\.\n \*\n
          \* This software is the confidential and proprietary information
          of ACME\.\n \* \(&amp;quot;Confidential Information&amp;quot;\)\. You
          shall not disclose such\n \* Confidential Information and shall
          use it only in accordance with\n \* the terms of the license
          agreement you entered into with ACME\.\n \*\n
          \* \$Log: config_misc\.xml,v $
          \* Revision 1\.7  2007/01/16 12:16:35  oburn
          \* Removing all reference to mailing lists
          \* \
          \* Revision 1.6  2005/12/25 16:13:10  o_sukhodolsky
          \* Fix for rfe 1248106 \(TYPECAST is now accepted by NoWhitespaceAfter\)
          \* \
          \* Fix for rfe 953266 \(thanks to Paul Guyot \(pguyot\) for submitting patch\)
          \* IllegalType can be configured to accept some abstract classes which
          \* matches to regexp of illegal type names \(property legalAbstractClassNames\)
          \*
          \* TrailingComment now can be configured to accept some trailing comments
          \* \(such as NOI18N\) \(property legalComment, rfe 1385344\).
          \*
          \* Revision 1.5  2005/11/06 11:54:12  oburn
          \* Incorporate excellent patch \[ 1344344 \] Consolidation of regexp checks.
          \* \\n(.*\n)*([\w|\s]*( class | interface )\1)&quot;/&gt;
          &lt;property name=&quot;message&quot; value=&quot;Correct header not found&quot;/&gt;
          &lt;/module&gt;
        </source>
        <p>
          This checks for the presence of a copyright notice within the class
          javadoc, lines 24 to 37.
        </p>
        <source>
          &lt;module name=&quot;Regexp&quot;&gt;
          &lt;property
          name=&quot;format&quot;
          value=&quot;(/\*\*\n)( \*.*\n)*( \* &amp;lt;P&amp;gt;\n \*   &amp;lt;I&amp;gt;
          This software is the confidential and proprietary information of\n
          \*   ACME \(&amp;lt;B&amp;gt;&amp;quot;Confidential Information&amp;quot;&amp;lt;/B&amp;gt;
          \)\. You shall not\n \*   disclose such Confidential Information
          and shall use it only in\n \*   accordance with the terms of the
          license agreement you entered into\n \*   with ACME\.&amp;lt;/I&amp;gt;\n
          \* &amp;lt;/P&amp;gt;\n \*\n \* &amp;#169; copyright \d\d\d\d ACME\n
          \*\n \* @author .*)(\n\s\*.*)*/\n[\w|\s]*( class | interface )&quot;/&gt;
          &lt;property name=&quot;message&quot; value=&quot;Copyright in class/interface Javadoc&quot;/&gt;
          &lt;property name=&quot;duplicateLimit&quot; value=&quot;0&quot;/&gt;
          &lt;/module&gt;
        </source>
        <p>
          <b>Note:</b> To search for things that mean something in XML, like
          &lt; you need to escape them like &amp;lt;. This is required so the
          XML parser does not act on them, but instead passes the correct
          character to the regexp engine.
        </p>
      </subsection>

      <subsection name="Example of Usage">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+Regexp">
            Checkstyle Style</a>
          </li>
        </ul>
      </subsection>

      <subsection name="Error Messages">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22duplicate.regexp%22">
            duplicate.regexp</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22illegal.regexp%22">
            illegal.regexp</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22required.regexp%22">
            required.regexp</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">
        <p>
          com.puppycrawl.tools.checkstyle.checks.regexp
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#TreeWalker">TreeWalker</a>
        </p>
      </subsection>
    </section>

    <section name="RegexpMultiline">
      <subsection name="Description">
        <p>
          A check for detecting that matches across multiple lines.
          Works with any file type.
        </p>

        <p>
          Rationale: This check can be used to when the regular
          expression can be span multiple lines.
        </p>
      </subsection>

      <subsection name="Properties">
        <table>
          <tr>
            <th>name</th>
            <th>description</th>
            <th>type</th>
            <th>default value</th>
          </tr>
          <tr>
            <td>format</td>
            <td>illegal pattern</td>
            <td><a href="property_types.html#regexp">Regular Expression</a></td>
            <td><code>&quot;$.&quot;</code></td>
          </tr>
          <tr>
            <td>message</td>
            <td>message which is used to notify about violations,
            if empty then default(hard-coded) message is used.</td>
            <td><a href="property_types.html#string">String</a></td>
            <td><code>&quot;&quot;</code>(empty)</td>
          </tr>
          <tr>
            <td>ignoreCase</td>
            <td>Controls whether to ignore case when searching.</td>
            <td><a href="property_types.html#boolean">Boolean</a></td>
            <td><code>false</code></td>
          </tr>
          <tr>
            <td>minimum</td>
            <td>The minimum number of matches required in each file.</td>
            <td><a href="property_types.html#integer">Integer</a></td>
            <td><code>0</code></td>
          </tr>
          <tr>
            <td>maximum</td>
            <td>The maximum number of matches required in each file.</td>
            <td><a href="property_types.html#integer">Integer</a></td>
            <td><code>0</code></td>
          </tr>
          <tr>
            <td>fileExtensions</td>
            <td>file type extension of files to process</td>
            <td><a href="property_types.html#stringSet">String Set</a></td>
            <td><code>{}</code></td>
          </tr>
        </table>
      </subsection>

      <subsection name="Examples">
        <p>
          To configure the check to find calls to print to the console:
        </p>
        <source>
&lt;module name=&quot;RegexpMultiline&quot;&gt;
  &lt;property name=&quot;format&quot;
   value=&quot;System\.(out)|(err)\.print(ln)?\(&quot;/&gt;
&lt;/module&gt;
        </source>
      </subsection>

      <subsection name="Example of Usage">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+RegexpMultiline">
            Checkstyle Style</a>
          </li>
        </ul>
      </subsection>

      <subsection name="Error Messages">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22regexp.StackOverflowError%22">
            regexp.StackOverflowError</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22regexp.empty%22">
            regexp.empty</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22regexp.exceeded%22">
            regexp.exceeded</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22regexp.minimum%22">
            regexp.minimum</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">
        <p>
          com.puppycrawl.tools.checkstyle.checks.regexp
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#Checker">Checker</a>
        </p>
      </subsection>
    </section>

    <section name="RegexpOnFilename">
      <subsection name="Description">
        <p>
          Implementation of a check that looks for a file name and/or path match (or mis-match)
          against specified patterns. It can also be used to verify files match specific naming
          patterns not covered by other checks (Ex: properties, xml, etc.).
        </p>
        <p>
          When customizing the check, the properties are applied in a specific order.
          The fileExtensions property first picks only files that match any of the
          specific extensions supplied.
          Once files are matched against the fileExtensions, the match property is then
          used in conjunction with the patterns to determine if the check is looking
          for a match or mis-match on those files. If the fileNamePattern is
          supplied, the matching is only applied to the fileNamePattern and not the
          folderPattern. If no fileNamePattern is supplied, then matching is applied
          to the folderPattern only and will result in all files in a folder to be
          reported on violations. If no folderPattern is supplied, then all folders
          that checkstyle finds are examined for violations.
          The ignoreFileNameExtensions property drops the file extension and applies
          the fileNamePattern only to the rest of file name. For example, if the file is
          named 'test.java' and this property is turned on, the pattern is only applied
          to 'test'.
        </p>
        <p>
          If this check is configured with no properties, then the default behavior
          of this check is to report file names with spaces in them.
          When at least one pattern property is supplied, the entire check is under
          the user's control to allow them to fully customize the behavior.
        </p>
        <p>
          It is recommended that if you create your own pattern, to also
          specify a custom error message. This allows the error message printed
          to be clear what the violation is, especially if multiple RegexpOnFilename
          checks are used.
          Argument 0 for the message populates the check's folderPattern.
          Argument 1 for the message populates the check's fileNamePattern.
          The file name is not passed as an argument since it is part of CheckStyle's
          default error messages.
        </p>
      </subsection>

      <subsection name="Properties">
        <table>
          <tr>
            <th>name</th>
            <th>description</th>
            <th>type</th>
            <th>default value</th>
          </tr>
          <tr>
            <td>folderPattern</td>
            <td>Regular expression to match the folder path against.</td>
            <td><a href="property_types.html#regexp">Regular Expression</a></td>
            <td><code>null</code></td>
          </tr>
          <tr>
            <td>fileNamePattern</td>
            <td>Regular expression to match the file name against.</td>
            <td><a href="property_types.html#regexp">Regular Expression</a></td>
            <td><code>null</code></td>
          </tr>
          <tr>
            <td>match</td>
            <td>Whether to look for a match or mis-match on the file name, if the
            fileNamePattern is supplied, otherwise it is applied on the folderPattern.</td>
            <td><a href="property_types.html#boolean">Boolean</a></td>
            <td><code>true</code></td>
          </tr>
          <tr>
            <td>ignoreFileNameExtensions</td>
            <td>Whether to ignore the file extension for the file name match.</td>
            <td><a href="property_types.html#boolean">Boolean</a></td>
            <td><code>false</code></td>
          </tr>
          <tr>
            <td>fileExtensions</td>
            <td>File type extension of files to process. If this is specified, then
            only files that match these types are examined with the other patterns.</td>
            <td><a href="property_types.html#stringSet">String Set</a></td>
            <td><code>{}</code></td>
          </tr>
        </table>
      </subsection>

      <subsection name="Examples">
        <p>
          To configure the check to report file names that contain a space:
        </p>
        <source>
&lt;module name=&quot;RegexpOnFilename&quot;/&gt;
        </source>
        <p>
          To configure the check to force picture files to not be 'gif':
        </p>
        <source>
&lt;module name=&quot;RegexpOnFilename&quot;&gt;
  &lt;property name=&quot;fileNamePattern&quot; value=&quot;\.gif$&quot;/&gt;
&lt;/module&gt;
        </source>
        <p>
          OR:
        </p>
        <source>
&lt;module name=&quot;RegexpOnFilename&quot;&gt;
  &lt;property name=&quot;fileNamePattern&quot; value=&quot;.&quot;/&gt;
  &lt;property name=&quot;fileExtensions&quot; value=&quot;gif&quot;/&gt;
&lt;/module&gt;
        </source>
        <p>
          To configure the check to only allow property and xml files to be located in the resource folder:
        </p>
        <source>
&lt;module name=&quot;RegexpOnFilename&quot;&gt;
  &lt;property name=&quot;folderPattern&quot; value=&quot;[\\/]src[\\/]\w+[\\/]resources[\\/]&quot;/&gt;
  &lt;property name=&quot;match&quot; value=&quot;false&quot;/&gt;
  &lt;property name=&quot;fileExtensions&quot; value=&quot;properties, xml&quot;/&gt;
&lt;/module&gt;
        </source>
        <p>
          To configure the check to only allow Java and XML files in your folders use the below.
        </p>
        <source>
&lt;module name=&quot;RegexpOnFilename&quot;&gt;
  &lt;property name=&quot;fileNamePattern&quot; value=&quot;\.(java|xml)$&quot;/&gt;
  &lt;property name=&quot;match&quot; value=&quot;false&quot;/&gt;
&lt;/module&gt;
        </source>
        <p>
          To configure the check to only allow Java and XML files only in your source folder
          and ignore any other folders:<br />
          <b>Note:</b> 'folderPattern' must be specified if checkstyle is analyzing more than
          the normal source folder, like the 'bin' folder where class files can be located.
        </p>
        <source>
&lt;module name=&quot;RegexpOnFilename&quot;&gt;
  &lt;property name=&quot;folderPattern&quot; value=&quot;[\\/]src[\\/]&quot;/&gt;
  &lt;property name=&quot;fileNamePattern&quot; value=&quot;\.(java|xml)$&quot;/&gt;
  &lt;property name=&quot;match&quot; value=&quot;false&quot;/&gt;
&lt;/module&gt;
        </source>
        <p>
          To configure the check to only allow file names to be camel case:
        </p>
        <source>
&lt;module name=&quot;RegexpOnFilename&quot;&gt;
  &lt;property name=&quot;fileNamePattern&quot; value=&quot;^([A-Z][a-z0-9]+\.?)+$&quot;/&gt;
  &lt;property name=&quot;match&quot; value=&quot;false&quot;/&gt;
  &lt;property name=&quot;ignoreFileNameExtensions&quot; value=&quot;true&quot;/&gt;
&lt;/module&gt;
        </source>
      </subsection>

      <subsection name="Example of Usage">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+RegexpOnFilename">
            Checkstyle Style</a>
          </li>
        </ul>
      </subsection>

      <subsection name="Error Messages">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22regexp.filename.match%22">
            regexp.filename.match</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22regexp.filename.mismatch%22">
            regexp.filename.mismatch</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">
        <p>
          com.puppycrawl.tools.checkstyle.checks.regexp
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#Checker">Checker</a>
        </p>
      </subsection>
    </section>

    <section name="RegexpSingleline">
      <subsection name="Description">
        <p>
          A check for detecting single lines that match a supplied
          regular expression. Works with any file type.
        </p>

        <p>
          Rationale: This check can be used to prototype checks and to
          find common bad practice such as calling <code>ex.printStacktrace()</code>, <code>
          System.out.println()</code>, <code>System.exit()</code>, etc.
        </p>
      </subsection>

      <subsection name="Properties">
        <table>
          <tr>
            <th>name</th>
            <th>description</th>
            <th>type</th>
            <th>default value</th>
          </tr>
          <tr>
            <td>format</td>
            <td>illegal pattern</td>
            <td><a href="property_types.html#regexp">Regular Expression</a></td>
            <td><code>&quot;$.&quot;</code></td>
          </tr>
          <tr>
            <td>message</td>
            <td>message which is used to notify about violations,
            if empty then default(hard-coded) message is used.</td>
            <td><a href="property_types.html#string">String</a></td>
            <td><code>&quot;&quot;</code>(empty)</td>
          </tr>
          <tr>
            <td>ignoreCase</td>
            <td>Controls whether to ignore case when searching.</td>
            <td><a href="property_types.html#boolean">Boolean</a></td>
            <td><code>false</code></td>
          </tr>
          <tr>
            <td>minimum</td>
            <td>The minimum number of matches required in each file.</td>
            <td><a href="property_types.html#integer">Integer</a></td>
            <td><code>0</code></td>
          </tr>
          <tr>
            <td>maximum</td>
            <td>The maximum number of matches required in each file.</td>
            <td><a href="property_types.html#integer">Integer</a></td>
            <td><code>0</code></td>
          </tr>
          <tr>
            <td>fileExtensions</td>
            <td>file type extension of files to process</td>
            <td><a href="property_types.html#stringSet">String Set</a></td>
            <td><code>{}</code></td>
          </tr>
        </table>
      </subsection>

      <subsection name="Examples">
        <p>
          To configure the check to find trailing whitespace at the end
          of a line:
        </p>
        <source>
&lt;module name=&quot;RegexpSingleline&quot;&gt;
  &lt;!-- \s matches whitespace character, $ matches end of line. --&gt;
  &lt;property name=&quot;format&quot; value=&quot;\s+$&quot;/&gt;
&lt;/module&gt;
        </source>

        <p>
          To configure the check to find trailing whitespace at the end
          of a line, with some <i>slack</i> of allowing two occurrences
          per file:
        </p>
        <source>
&lt;module name=&quot;RegexpSingleline&quot;&gt;
  &lt;property name=&quot;format&quot; value=&quot;\s+$&quot;/&gt;
  &lt;!-- next line not required as 0 is the default --&gt;
  &lt;property name=&quot;minimum&quot; value=&quot;0&quot;/&gt;
  &lt;property name=&quot;maximum&quot; value=&quot;2&quot;/&gt;
&lt;/module&gt;
        </source>

        <p>
          An example of how to configure the check to make sure a copyright
          statement is included in the file:
        </p>
        <source>
&lt;module name=&quot;RegexpSingleline&quot;&gt;
  &lt;property name="format" value="This file is copyrighted"/&gt;
  &lt;property name=&quot;minimum&quot; value=&quot;1&quot;/&gt;
  &lt;!--  Need to specify a maximum, so 10 times is more than enough. --&gt;
  &lt;property name=&quot;maximum&quot; value=&quot;10&quot;/&gt;
&lt;/module&gt;
        </source>
      </subsection>

      <subsection name="Example of Usage">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+RegexpSingleline">
            Checkstyle Style</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Asun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+RegexpSingleline">
            Sun Style</a>
          </li>
        </ul>
      </subsection>

      <subsection name="Error Messages">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22regexp.exceeded%22">
            regexp.exceeded</a>
          </li>
        </ul>
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22regexp.minimum%22">
            regexp.minimum</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">
        <p>
          com.puppycrawl.tools.checkstyle.checks.regexp
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#Checker">Checker</a>
        </p>
      </subsection>
    </section>

    <section name="RegexpSinglelineJava">
      <subsection name="Description">
        <p>
          This class is variation on <a
          href="#RegexpSingleline">RegexpSingleline</a> for detecting
          single lines that match a supplied regular expression in Java files. It supports suppressing matches in Java comments.
        </p>
      </subsection>

      <subsection name="Properties">
        <table>
          <tr>
            <th>name</th>
            <th>description</th>
            <th>type</th>
            <th>default value</th>
          </tr>
          <tr>
            <td>format</td>
            <td>illegal pattern</td>
            <td><a href="property_types.html#regexp">Regular Expression</a></td>
            <td><code>&quot;$.&quot;</code></td>
          </tr>
          <tr>
            <td>message</td>
            <td>message which is used to notify about violations,
            if empty then default(hard-coded) message is used.</td>
            <td><a href="property_types.html#string">String</a></td>
            <td><code>&quot;&quot;</code>(empty)</td>
          </tr>
          <tr>
            <td>ignoreCase</td>
            <td>Controls whether to ignore case when searching.</td>
            <td><a href="property_types.html#boolean">Boolean</a></td>
            <td><code>false</code></td>
          </tr>
          <tr>
            <td>minimum</td>
            <td>The minimum number of matches required in each file.</td>
            <td><a href="property_types.html#integer">Integer</a></td>
            <td><code>0</code></td>
          </tr>
          <tr>
            <td>maximum</td>
            <td>The maximum number of matches required in each file.</td>
            <td><a href="property_types.html#integer">Integer</a></td>
            <td><code>0</code></td>
          </tr>
          <tr>
            <td>ignoreComments</td>
            <td>Controls whether to ignore text in comments when searching.</td>
            <td><a href="property_types.html#boolean">Boolean</a></td>
            <td><code>false</code></td>
          </tr>
        </table>
      </subsection>

      <subsection name="Examples">
        <p>
          To configure the check for calls to <code>System.out.println</code>, except in comments:
        </p>
        <source>
&lt;module name=&quot;RegexpSinglelineJava&quot;&gt;
    &lt;!-- . matches any character, so we need to
         escape it and use \. to match dots. --&gt;
  &lt;property name=&quot;format&quot; value=&quot;System\.out\.println&quot;/&gt;
  &lt;property name=&quot;ignoreComments&quot; value=&quot;true&quot;/&gt;
&lt;/module&gt;
        </source>

        <p>
          To configure the check to find case-insensitive occurrences of
          &quot;debug&quot;:
        </p>
        <source>
&lt;module name=&quot;RegexpSinglelineJava&quot;&gt;
    &lt;property name=&quot;format&quot; value=&quot;debug&quot;/&gt;
    &lt;property name=&quot;ignoreCase&quot; value=&quot;true&quot;/&gt;
&lt;/module&gt;
        </source>
      </subsection>

      <subsection name="Example of Usage">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+RegexpSinglelineJava">
            Checkstyle Style</a>
          </li>
        </ul>
      </subsection>

      <subsection name="Error Messages">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22regexp.exceeded%22">
            regexp.exceeded</a>
          </li>
        </ul>
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fregexp+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22regexp.minimum%22">
            regexp.minimum</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">
        <p>
          com.puppycrawl.tools.checkstyle.checks.regexp
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#TreeWalker">TreeWalker</a>
        </p>
      </subsection>
    </section>
  </body>
</document>