-
Notifications
You must be signed in to change notification settings - Fork 365
sonar.cxx.gcc.regex
Günter Wirth edited this page Nov 15, 2024
·
6 revisions
To read sonar.cxx.gcc.reportPaths a default sonar.cxx.gcc.regex
is already set, this can be customized if required. A regular expression can be defined to read the text. The regular expressions follow the Java convention.
Samples:
option | sonar.cxx.gcc.regex |
---|---|
with column number | (?<file>.*):(?<line>[0-9]+):[0-9]+:\x20warning:\x20(?<message>.*)\x20\[(?<id>.*)\] |
without column number | (?<file>.*):(?<line>[0-9]+):\x20warning:\x20(?<message>.*)\x20\[(?<id>.*)\] |
default | (?<file>[^:]*+):(?<line>\d{1,5}):\d{1,5}:\x20warning:\x20(?<message>.*?)(\x20\[(?<id>[^\[]*)\])?\s*$ |
Hint: You have to escape the backslash (
\
->\\
) for the regex parameter in the configuration file!
For the assignment of the individual parameters named-capturing groups are used. A capturing group (...)
can also be assigned a "name", a named-capturing group e.g. (?<file>.*):
The following named-capturing groups are defined:
named-capturing group | description |
---|---|
<file> |
filename part of the issue |
<line> |
line number of the issue |
<column> |
column number of the issue |
<id> |
rule id of the issue |
<message> |
message text of the issue |
Sample:
If the following regular expression is defined
sonar.cxx.gcc.regex=(?<file>.*):(?<line>[0-9]+):[0-9]+:\\x20warning:\\x20(?<message>.*)\\x20\\[(?<id>.*)\\]
and the sensor reads this text
src/zipmanager.cpp:141:10: warning: conversion to 'unsigned char' from 'unsigned int' may alter its value [-Wconversion]
then the text is split up as follows:
pattern | description | match |
---|---|---|
(?<file>.*): |
filename part of the issue | src/zipmanager.cpp |
(?<line>[0-9]+): |
line number of the issue | 141 |
[0-9]+:\x20warning:\x20 |
ignoring column and warning text | |
(?<message>.*)\x20 |
message text of the issue | conversion to 'unsigned char' from 'unsigned int' may alter its value |
\[(?<id>.*)\] |
rule id of the issue | -Wconversion |