@@ -44,7 +44,7 @@ public class CxxClangTidySensor extends CxxIssuesReportSensor {
4444 private static final Logger LOG = Loggers .get (CxxClangTidySensor .class );
4545
4646 private static final String REGEX
47- = "(.+|[a-zA-Z]:\\ \\ .+):([0-9]+):([0-9]+): ([^:]+): ([^]]+)( \\ [([^]]+) \\ ])? " ;
47+ = "(.+|[a-zA-Z]:\\ \\ .+):([0-9]+):([0-9]+): ([^:]+): (.+) " ;
4848 private static final Pattern PATTERN = Pattern .compile (REGEX );
4949
5050 /**
@@ -59,10 +59,10 @@ public CxxClangTidySensor(CxxLanguage language) {
5959 @ Override
6060 public void describe (SensorDescriptor descriptor ) {
6161 descriptor
62- .name (getLanguage ().getName () + " ClangTidySensor" )
63- .onlyOnLanguage (getLanguage ().getKey ())
64- .createIssuesForRuleRepository (getRuleRepositoryKey ())
65- .onlyWhenConfiguration (conf -> conf .hasKey (getReportPathKey ()));
62+ .name (getLanguage ().getName () + " ClangTidySensor" )
63+ .onlyOnLanguage (getLanguage ().getKey ())
64+ .createIssuesForRuleRepository (getRuleRepositoryKey ())
65+ .onlyWhenConfiguration (conf -> conf .hasKey (getReportPathKey ()));
6666 }
6767
6868 @ Override
@@ -82,15 +82,33 @@ protected void processReport(final SensorContext context, File report) {
8282 String nextLine = scanner .nextLine ();
8383 final Matcher matcher = PATTERN .matcher (nextLine );
8484 if (matcher .matches ()) {
85- // group: 1 2 3 4 5 7
86- // <path>:<line>:<column>: <level>: <info> [<ruleId>]
85+ // group: 1 2 3 4 5
86+ // <path>:<line>:<column>: <level>: <txt>
8787 MatchResult m = matcher .toMatchResult ();
8888 String path = m .group (1 ); // relative paths
8989 String line = m .group (2 );
9090 //String column = m.group(3);
91- String level = m .group (4 ); // error, warning, note, ...
92- String info = m .group (5 );
93- String ruleId = m .group (7 ); // optional
91+ String level = m .group (4 ); // error, warning, note, ...
92+ String txt = m .group (5 ); // info( [ruleId])?
93+ String info = null ;
94+ String ruleId = null ;
95+
96+ if (txt .endsWith ("]" )) { // [ruleId]
97+ for (int i = txt .length () - 2 ; i >= 0 ; i --) {
98+ char c = txt .charAt (i );
99+ if (c == '[' ) {
100+ info = txt .substring (0 , i - 1 );
101+ ruleId = txt .substring (i + 1 , txt .length () - 1 );
102+ break ;
103+ }
104+ if (!(Character .isLetterOrDigit (c ) || c == '-' || c == '.' )) {
105+ break ;
106+ }
107+ }
108+ }
109+ if (info == null ) {
110+ info = txt ;
111+ }
94112
95113 if (ruleId != null ) {
96114 if (issue != null ) {
0 commit comments