aboutsummaryrefslogtreecommitdiff
path: root/src/xdocs/property_types.xml
blob: 11a5a3a1e963289ffc331e1d0fa00aa56a146632 (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
<?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>Property Types</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="Overview">
    <p>
      Checkstyle is configured using properties, which are string
      representations. This document describes how these string
      representations are mapped to typed properties.
    </p>
    </section>

    <section name="integer">
      <p>
        This property represents an integer. The string representation is
        parsed using the <code>java.lang.Integer</code> class.
      </p>
    </section>

    <section name="string">
      <p>
        This property represents a string. The literal string representation
        is used.
      </p>
    </section>

    <section name="boolean">
      <p>
        This property represents a boolean. The default value is <code>false</code>. The following string representations will
        map to <code>true</code>:
      </p>

      <ul>
        <li><code>yes</code></li>
        <li><code>true</code></li>
        <li><code>on</code></li>
      </ul>

      <p>Anything else will map to <code>false</code>.</p>
    </section>

    <section name="stringSet">
      <p>
        This property represents a set of strings. The string representation
        is parsed as a set of comma (',') separated strings.
      </p>
      <p>
        Alternatively, this property can be supplied multiple times which
        is equivalent to a set of comma separated strings. For example, the
        following:
      </p>
      <source>
&lt;property name=&quot;tokens&quot; value=&quot;DIV_ASSIGN,PLUS_ASSIGN&quot;/&gt;
      </source>
      <p>can instead be expressed as:</p>
      <source>
&lt;property name=&quot;tokens&quot; value=&quot;DIV_ASSIGN&quot;/&gt;
&lt;property name=&quot;tokens&quot; value=&quot;PLUS_ASSIGN&quot;/&gt;
      </source>
    </section>

    <section name="intSet">
      <p>
        This property represents a set of integers. The string representation
        is parsed as a set of comma (',') separated integers that are parsed
        using the <code>java.lang.Integer</code> class.
      </p>
      <p>
        Alternatively, this property can be supplied multiple times which
        is equivalent to a set of comma separated integers. For example, the
        following:
      </p>
      <source>
&lt;property name=&quot;tokens&quot; value=&quot;42,666&quot;/&gt;
      </source>
      <p>can instead be expressed as:</p>
      <source>
&lt;property name=&quot;tokens&quot; value=&quot;42&quot;/&gt;
&lt;property name=&quot;tokens&quot; value=&quot;666&quot;/&gt;
      </source>
    </section>

    <section name="regexp">
      <p>
        This property represents a regular expression. The string
        representation is parsed using <a
        href="http://docs.oracle.com/javase/7/docs/api/index.html?java/util/regex/package-summary.html">java.util.regex
        package</a>.
      </p>
    </section>

    <section name="parenPad">
      <p>
        This property represents the policy for padding with white space. The
        following table describes the valid options:
      </p>

      <table summary="padding options">
        <tr>
          <td>Option</td>
          <td>Definition</td>
        </tr>
        <tr>
          <td><code>nospace</code></td>
          <td>
            Do not pad. For example, <code>method(a, b);</code>
          </td>
        </tr>
        <tr>
          <td><code>space</code></td>
          <td>
            Ensure padding. For example,
            <code>method( a, b );</code>
          </td>
        </tr>
      </table>
    </section>

    <section name="wrapOp">
      <p>
        This property represents the policy for wrapping lines.
        The following table describes the valid options:
      </p>

      <table summary="wrap options">
        <tr>
          <td>Option</td>
          <td>Definition</td>
        </tr>
        <tr>
          <td><code>nl</code></td>
          <td>
            The token must be on a new line. For example:
            <pre>
    someVariable = aBigVariableNameToMakeThings + "this may work"
                   + lookVeryInteresting;
            </pre>
          </td>
        </tr>
        <tr>
          <td><code>eol</code></td>
          <td>
            The token must be at the end of the line. For example:
            <pre>
    someVariable = aBigVariableNameToMakeThings + "this may work" +
                   lookVeryInteresting;
            </pre>
          </td>
        </tr>
      </table>
    </section>

    <section name="block">
      <p>
        This property represents the policy for checking block statements. The
        following table describes the valid options:
      </p>

      <table summary="block options">
        <tr>
          <td>Option</td>
          <td>Definition</td>
        </tr>
        <tr>
          <td><code>text</code></td>
          <td>
            Require that there is some text in the block. For example:
            <pre>
    catch (Exception ex) {
        // This is a bad coding practice
    }
            </pre>
          </td>
        </tr>
        <tr>
          <td><code>stmt</code></td>
          <td>
            Require that there is a statement in the block. For example:
            <pre>
    finally {
        lock.release();
    }
            </pre>
          </td>
        </tr>
      </table>
    </section>

    <section name="lcurly">
      <p>
        This property represents the policy for checking the placement of a
        left curly brace (<code>'{'</code>). The following table
        describes the valid options:
      </p>

      <table summary="left curly options">
        <tr>
          <td>Option</td>
          <td>Definition</td>
        </tr>

        <tr>
          <td><code>eol</code></td>
          <td>
            The brace must always be on the end of the line. For example:
            <pre>
    if (condition) {
        ...
            </pre>
          </td>
        </tr>

        <tr>
          <td><code>nl</code></td>
          <td>
            The brace must always be on a new line. For example:
            <pre>
    if (condition)
    {
        ...
            </pre>
          </td>
        </tr>

        <tr>
          <td><code>nlow</code></td>
          <td>
            If the brace will fit on the first line of the statement,
            then apply <code>eol</code> rule. Otherwise apply the
            <code>nl</code> rule. <code>nlow</code> is a
            mnemonic for "new line on wrap". For the example above Checkstyle
            will enforce:
            <pre>
    if (condition) {
        ...
            </pre>
            But for a statement spanning multiple lines, Checkstyle will
            enforce:
            <pre>
    if (condition1 &amp;&amp; condition2 &amp;&amp;
        condition3 &amp;&amp; condition4)
    {
        ...
            </pre>
          </td>
        </tr>
      </table>
    </section>

    <section name="rcurly">
      <p>
        This property represents the policy for checking the placement of a
        right curly brace (<code>'}'</code>). The following table
        describes the valid options:
      </p>

      <table summary="right curly options">
        <tr>
          <td>Option</td>
          <td>Definition</td>
        </tr>

        <tr>
          <td><code>same</code></td>
          <td>
            The brace should be on the same line as the next part of a multi-block statement
            (one that directly contains multiple blocks: if/else-if/else or try/catch/finally).

            <p>Examples:</p>

              <pre>
    // try-catch-finally blocks
    try {
        ...
    <b>}</b> catch (Exception ex) { // this is OK
        ...
    <b>}</b> finally { // this is OK
        ...
    }

    try {
        ...
    <b>}</b> // this is NOT OK, not on the same line as the next part of a multi-block statement
    catch (Exception ex) {
          ...
    <b>}</b> // this is NOT OK, not on the same line as the next part of a multi-block statement
    finally {
          ...
    }

    // if-else blocks
    if (a &#62; 0) {
       ...
    <b>}</b> else { // this is OK
       ...
    }

    if (a &#62; 0) {
       ...
    <b>}</b> // this is NOT OK, not on the same line as the next part of a multi-block statement
    else {
       ...
    }

    if (a > 0) {
       ...
    <b>}</b> int i = 5; // this is NOT OK, next part of a multi-block statement is absent

    // Single line blocks will rise violations, because right curly
    // brace is not on the same line as the next part of a multi-block
    // statement, it just ends the line.
    public long getId() {return id;<b>}</b> // this is NOT OK

    Thread t = new Thread(new Runnable() {
       @Override
       public void run() {
                  ...
       <b>}</b> // this is NOT OK, brace is not on the same line as the next part of a multi-block statement
    <b>}</b>); // this is OK, allowed for better code readability
              </pre>
          </td>
        </tr>

        <tr>
          <td><code>alone</code></td>
          <td>
            The brace must be alone on the line. For example:
            <pre>
    try {
        ...
    <b>}</b>
    finally {
        ...
    <b>}</b>
            </pre>
          </td>
        </tr>

          <tr>
              <td><code>alone_or_singleline</code></td>
              <td>
                  The brace must be alone on the line, yet
                  single-line format of block is allowed.
                  For example:
                  <pre>
    // Brace is alone on the line
    try {
        ...
    <b>}</b>
    finally {
        ...
    <b>}</b>

    // Single-line format of block
    public long getId() { return id; <b>}</b>
                  </pre>
              </td>
          </tr>
      </table>
    </section>

    <section name="scope">
      <p>This property represents a Java scope. The scope is treated
      inclusively (as javadoc does): 'package' means all 'package', 'protected'
      and 'public' methods/fields/classes. The valid options are:</p>

      <ul>
        <li><code>nothing</code></li>
        <li><code>public</code></li>
        <li><code>protected</code></li>
        <li><code>package</code></li>
        <li><code>private</code></li>
        <li><code>anoninner</code></li>
      </ul>
    </section>

    <section name="severity">
      <p>
        This property represents the severity level of a check violation. The
        valid options are:
      </p>

      <ul>
        <li><code>ignore</code></li>
        <li><code>info</code></li>
        <li><code>warning</code></li>
        <li><code>error</code></li>
      </ul>
    </section>

    <section name="importOrder">
      <p>
        This property represents the policy for checking imports order.
        The following table describes the valid options:
      </p>

      <table summary="import order options">
        <tr>
          <td>Option</td>
          <td>Definition</td>
        </tr>

        <tr>
          <td><code>top</code></td>
          <td>All static imports are at the top. For example:
              <pre>
    import static a.b.C.*;
    import static x.y.Z.*;

    import a.b.D;
    import x.y.Z;</pre>
          </td>
        </tr>

        <tr>
          <td><code>above</code></td>
          <td>All static imports are above the local group. For example:
            <pre>
    import static a.b.C.*;
    import a.b.D;

    import static x.y.Z.*;
    import x.y.Z;</pre>
          </td>
        </tr>

        <tr>
          <td><code>inflow</code></td>
          <td>All static imports are processed like non static
              imports. For example:
              <pre>
    import static a.b.C.*;
    import a.b.D;

    import x.y.Z;
    import static x.y.Z.*;</pre>
          </td>
        </tr>

        <tr>
          <td><code>under</code></td>
          <td>All static imports are under the local group. For example:
              <pre>
    import a.b.D;
    import static a.b.C.*;

    import x.y.Z;
    import static x.y.Z.*;</pre>
          </td>
        </tr>

        <tr>
          <td><code>bottom</code></td>
          <td>All static imports are at the bottom. For example:
              <pre>
    import a.b.D;
    import x.y.Z;

    import static a.b.C.*;
    import static x.y.Z.*;</pre>
          </td>
        </tr>
      </table>
    </section>

    <section name="elementStyle">
      <p>
        This property represents the policy for the styles for defining
        elements in an annotation. The following table
        describes the valid options:
      </p>

      <table summary="elementStyle options">
        <tr>
          <td>Option</td>
          <td>Definition</td>
        </tr>

        <tr>
          <td><code>expanded</code></td>
          <td>
            The expanded version is sometimes referred to as "named parameters"
            in other languages. Example:
            <pre>@SuppressWarnings(value={"unchecked","unused",})</pre>
          </td>
        </tr>

        <tr>
          <td><code>compact</code></td>
          <td>
            This style can only be used when there is an element called 'value'
            which is either the sole element or all other elements have default
            values. Examples:
            <pre>@SuppressWarnings({"unchecked","unused",})</pre>
            and:
            <pre>@SuppressWarnings("unchecked")</pre>
          </td>
        </tr>

        <tr>
          <td><code>compact_no_array</code></td>
          <td>
            It is similar to the <code>compact</code> style but
            single value arrays are flagged. With annotations a single value
            array does not need to be placed in an array initializer.
            This style can only be used when there is an element called 'value'
            which is either the sole element or all other elements have
            default values.
            Example: <pre>@SuppressWarnings("unchecked")</pre>
          </td>
        </tr>

        <tr>
          <td><code>ignore</code></td>
          <td>
            Anything goes.
          </td>
        </tr>
      </table>
    </section>

    <section name="closingParens">
      <p>
        This property represents the policy for the styles for the ending
        parenthesis. The following table describes the valid options:
      </p>

      <table summary="closingParens options">
        <tr>
          <td>Option</td>
          <td>Definition</td>
        </tr>

        <tr>
          <td><code>always</code></td>
          <td>
            Example:
            <pre>@Deprecated()</pre>
          </td>
        </tr>

        <tr>
          <td><code>never</code></td>
          <td>
            Example:
            <pre>@Deprecated</pre>
          </td>
        </tr>

        <tr>
          <td><code>ignore</code></td>
          <td>
            Anything goes.
          </td>
        </tr>
      </table>
    </section>

    <section name="trailingArrayComma">
      <p>
        This property represents the policy for the styles for the trailing
        array comma. The following table describes the valid options:
      </p>

      <table summary="trailingArrayComma options">
        <tr>
          <td>Option</td>
          <td>Definition</td>
        </tr>

        <tr>
          <td><code>always</code></td>
          <td>
            Example:
            <pre>@SuppressWarnings(value={"unchecked","unused",})</pre>
          </td>
        </tr>

        <tr>
          <td><code>never</code></td>
          <td>
            Example:
            <pre>@SuppressWarnings(value={"unchecked","unused"})</pre>
          </td>
        </tr>

        <tr>
          <td><code>ignore</code></td>
          <td>
            Anything goes.
          </td>
        </tr>
      </table>
    </section>
  </body>
</document>