You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user_manual.md
+47-2Lines changed: 47 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,8 @@
29
29
| 0.21.0 | 2024-05-01 | Luke Cartey | Add MISRA C++ 2023 as under development, and clarify MISRA C 2012 coverage. |
30
30
| 0.22.0 | 2024-10-02 | Luke Cartey | Add MISRA C 2023 as under development, and clarify MISRA C 2012 coverage. |
31
31
| 0.23.0 | 2024-10-21 | Luke Cartey | Add assembly as a hazard. |
32
-
| 0.24.0 | 2024-10-22 | Luke Cartey | Add CodeQL packs as a usable output, update release artifacts list. |
32
+
| 0.24.0 | 2024-10-22 | Luke Cartey | Add CodeQL packs as a usable output, update release artifacts list. |
33
+
| 0.25.0 | 2024-12-03 | Luke Cartey | Discuss support for new deviation code identifier formats |
33
34
34
35
## Release information
35
36
@@ -405,7 +406,7 @@ The example describes three ways of scoping a deviation:
405
406
406
407
1. The deviation for `A18-1-1` applies to any source file in the same or a child directory of the directory containing the example `coding-standards.yml`.
407
408
2. The deviation for `A18-5-1` applies to any source file in the directory `foo/bar` or a child directory of `foo/bar` relative to the directory containing the `coding-standards.yml`.
408
-
3. The deviation for `A0-4-2` applies to any source element that has a comment residing on **the same line** containing the identifier specified in `code-identifier`.
409
+
3. The deviation for `A0-4-2` applies to any source element that marked by a comment containing the identifier specified in `code-identifier`. The different acceptable formats are discussed in the next section.
409
410
410
411
The activation of the deviation mechanism requires an extra step in the database creation process.
411
412
This extra step is the invocation of the Python script `path/to/codeql-coding-standards/scripts/configuration/process_coding_standards_config.py` that is part of the coding standards code scanning pack.
@@ -420,6 +421,50 @@ The `process_coding_standards_config.py` has a dependency on the package `pyyaml
A code identifier specified in a deviation record can be applied to certain results in the code by adding a comment marker consisting of a `code-identifier` with some optional annotations. The supported marker annotation formats are:
427
+
428
+
- `<code-identifier>`- the deviation applies to results on the current line.
429
+
- `DEVIATION(<code-identifier>)`- the deviation applies to results on the current line.
430
+
- `DEVIATION_NEXT_LINE(<code-identifier>)`- this deviation applies to results on the next line.
431
+
- `DEVIATION_BEGIN(<code-identifier>)`- marks the beginning of a range of lines where the deviation applies.
432
+
- `DEVIATION_END(<code-identifier>)`- marks the end of a range of lines where the deviation applies.
433
+
434
+
Here are some examples, using the deviation record with the `a-0-4-2-deviation` code-identifier specified above:
435
+
```cpp
436
+
long double x1; // NON_COMPLIANT
437
+
438
+
long double x2; // a-0-4-2-deviation - COMPLIANT
439
+
long double x3; // COMPLIANT - a-0-4-2-deviation
440
+
441
+
long double x4; // DEVIATION(a-0-4-2-deviation) - COMPLIANT
442
+
long double x5; // COMPLIANT - DEVIATION(a-0-4-2-deviation)
443
+
444
+
// DEVIATION_NEXT_LINE(a-0-4-2-deviation)
445
+
long double x6; // COMPLIANT
446
+
447
+
// DEVIATION_BEGIN(a-0-4-2-deviation)
448
+
long double x7; // COMPLIANT
449
+
// DEVIATION_END(a-0-4-2-deviation)
450
+
```
451
+
452
+
`DEVIATION_END` markers will pair with the closest unmatched `DEVIATION_BEGIN` for the same `code-identifier`. Consider this example:
453
+
```cpp
454
+
1 | // DEVIATION_BEGIN(a-0-4-2-deviation)
455
+
2 |
456
+
3 | // DEVIATION_BEGIN(a-0-4-2-deviation)
457
+
4 |
458
+
5 | // DEVIATION_END(a-0-4-2-deviation)
459
+
6 |
460
+
7 | // DEVIATION_END(a-0-4-2-deviation)
461
+
```
462
+
Here, Line 1 will pair with Line 7, and Line 3 will pair with Line 8.
463
+
464
+
A `DEVIATION_END` without a matching `DEVIATION_BEGIN`, or `DEVIATION_BEGIN` without a matching `DEVIATION_END` is invalid and will be ignored.
465
+
466
+
`DEVIATION_BEGIN`and `DEVIATION_END` markers only apply within a single file. Markers cannot be paired across files, and deviations do not apply to included files.
467
+
423
468
##### Deviation permit
424
469
425
470
The current implementation supports _deviation permits_ as described in the [MISRA Compliance:2020](https://www.misra.org.uk/app/uploads/2021/06/MISRA-Compliance-2020.pdf) section _4.3 Deviation permits_.
0 commit comments