Skip to content

Commit 3d2a3a3

Browse files
committed
Improve query documentation
1 parent 92685e6 commit 3d2a3a3

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

java/ql/src/Violations of Best Practice/SpecialCharactersInLiterals/NonExplicitControlAndWhitespaceCharsInLiterals.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
## Overview
22

3-
This query detects non-explicit control and whitespace characters in java literals.
3+
This query detects non-explicit control and whitespace characters in Java literals.
44
Such characters are often introduced accidentally and can be invisible or hard to recognize, leading to bugs when the actual contents of the string contain control characters.
55

66
## Recommendation
77

8-
To avoid issues, use the encoded versions of control characters (e.g., ASCII `\n`, `\t`, or Unicode `U+000D`, `U+0009`).
9-
This makes the literals (e.g., string literals) more readable, and also helps to make the surrounding code less error-prone and more maintainable.
8+
To avoid issues, use the encoded versions of control characters (e.g. ASCII `\n`, `\t`, or Unicode `U+000D`, `U+0009`).
9+
This makes the literals (e.g. string literals) more readable, and also helps to make the surrounding code less error-prone and more maintainable.
1010

1111
## Example
1212

13-
The following examples illustrate `NON_COMPLIANT` and `COMPLIANT` code:
13+
The following examples illustrate good and bad code:
1414

15-
`NON_COMPLIANT`:
15+
Bad:
1616

1717
```java
18-
char tabulationChar = ' '; // NON_COMPLIANT
19-
String tabulationCharInsideString = "A B"; // NON_COMPLIANT
20-
String fooZeroWidthSpacebar = "foo​bar"; // NON_COMPLIANT
18+
char tabulationChar = ' '; // Non compliant
19+
String tabulationCharInsideString = "A B"; // Non compliant
20+
String fooZeroWidthSpacebar = "foo​bar"; // Non compliant
2121
```
2222

23-
`COMPLIANT`:
23+
Good:
2424

2525
```java
2626
char escapedTabulationChar = '\t';
27-
String escapedTabulationCharInsideString = "A\tB"; // COMPLIANT
28-
String fooUnicodeSpacebar = "foo\u0020bar"; // COMPLIANT
29-
String foo2Spacebar = "foo bar"; // COMPLIANT
30-
String foo3Spacebar = "foo bar"; // COMPLIANT
27+
String escapedTabulationCharInsideString = "A\tB"; // Compliant
28+
String fooUnicodeSpacebar = "foo\u0020bar"; // Compliant
29+
String foo2Spacebar = "foo bar"; // Compliant
30+
String foo3Spacebar = "foo bar"; // Compliant
3131
```
3232

33-
## Implementation Notes
33+
## Implementation notes
3434

35-
This query detects java literals that contain reserved control characters and/or non-printable whitespace characters, such as:
35+
This query detects Java literals that contain reserved control characters and/or non-printable whitespace characters, such as:
3636

3737
- Decimal and hexidecimal representations of ASCII control characters (code points 0-8, 11, 14-31, and 127).
38-
- Invisible characters (e.g., zero-width space, zero-width joiner).
38+
- Invisible characters (e.g. zero-width space, zero-width joiner).
3939
- Unicode C0 control codes, plus the delete character (U+007F), such as:
4040

4141
| Escaped Unicode | ASCII Decimal | Description |
@@ -70,7 +70,7 @@ This query detects java literals that contain reserved control characters and/or
7070
| `\u001F` | 31 | unit separator |
7171
| `\u007F` | 127 | delete |
7272

73-
- Zero-width Unicode characters (e.g., zero-width space, zero-width joiner), such as:
73+
- Zero-width Unicode characters (e.g. zero-width space, zero-width joiner), such as:
7474

7575
| Escaped Unicode | Description |
7676
| --------------- | ------------------------- |
@@ -85,7 +85,7 @@ This query detects java literals that contain reserved control characters and/or
8585
The following list outlines the _**explicit exclusions from query scope**_:
8686

8787
- any number of simple space characters (`U+0020`, ASCII 32).
88-
- an escape character sequence (e.g., `\t`), or the Unicode equivalent (e.g., `\u0009`), for printable whitespace characters:
88+
- an escape character sequence (e.g. `\t`), or the Unicode equivalent (e.g. `\u0009`), for printable whitespace characters:
8989

9090
| Character Sequence | Escaped Unicode | ASCII Decimal | Description |
9191
| ------------------ | --------------- | ------------- | --------------- |

0 commit comments

Comments
 (0)