Formatting the Rule Violation String

By default, any rule violation specifiers (i.e. %G, %K, %M, %r, %v and %z) are output together with the diagnostic according to the ‑‑format output string. If there are multiple rule violations each field would be output, and a comma used to separate the output for each rule. This can lead to confusing output especially when there are multiple rule violations and multiple rule specifiers.

A new format string is available, ‑‑rule‑format. If specified then the diagnostic information is first output, then, for each rule violation, the rule specific fields in the ‑‑rule‑format option are then output. This allows all rule specific information to be output together for each violation.

Only the following specifiers should be used in the ‑‑rule‑format string:

Specifier Description

%G

Parent Rule Id

%K Rule Categories 1
%M Rule Group Name and last child Rule Id(s)

%r

Last child Rule Id excluding the Parent Rule Id

For Parent Rule Id, see %G

%v

Rule Id and text (must have ‑‑rules set)

%z

Rule help file (absolute path)

1 Fields for each rule are '|' (bar) separated.

These are the only supported specifiers that can be used. It is not recommended to use some rule specifiers in the ‑‑format option and some in the ‑‑rule‑format option as this will produce confusing output.

For example, to show basic diagnostic output, with the rule violations on a separate line a command such as this can be used:

qacli view -P . -t DIAGLST -m STDOUT --format "%f:%l:%c %N\n" --rule-format "-->%M Categories:%K\n"

This would give output such as:

inspect.c:2:1 2887
-->M3CM Rule-17.4 Categories:MISRA Mandatory Rules|Mandatory|Rules|Functions

inspect.c:9:3 3114
-->M3CM Rule-17.4 Categories:MISRA Mandatory Rules|Mandatory|Rules|Functions
-->M3CM Rule-1.3 Categories:MISRA Required Rules|Required|Rules|A standard C environment