@@ -57,11 +57,10 @@ public class CxxPCLintSensor extends CxxIssuesReportSensor {
5757
5858 private static final String SUPPLEMENTAL_TYPE_ISSUE = "supplemental" ;
5959
60- private static final String PREFIX_DURING_SPECIFIC_WALK_MSG = "during specific walk " ;
60+ private static final String PREFIX_DURING_SPECIFIC_WALK_MSG = "during specific walk" ;
6161
62- private static final int PREFIX_MSG_LENGTH = PREFIX_DURING_SPECIFIC_WALK_MSG .length ();
63-
64- private static final Pattern FILE_NAME_WITH_LINE_AND_COL_PATTERN = Pattern .compile ("(.+):(\\ d+):(\\ d+)" );
62+ private static final Pattern SUPPLEMENTAL_MSG_PATTERN =
63+ Pattern .compile (PREFIX_DURING_SPECIFIC_WALK_MSG + "\\ s+(.+):(\\ d+):(\\ d+)\\ s+.+" );
6564
6665 /**
6766 * CxxPCLintSensor for PC-lint Sensor
@@ -116,7 +115,7 @@ public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
116115 // handle the case when supplemental message has no file and line
117116 // eg, issue 894.
118117 if (SUPPLEMENTAL_TYPE_ISSUE .equals (type ) && currentIssue != null ) {
119- addMoreLocationsToCurrentIssue (currentIssue , file , line , msg );
118+ addSecondaryLocationsToCurrentIssue (currentIssue , file , line , msg );
120119 continue ;
121120 }
122121
@@ -132,13 +131,11 @@ public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
132131 }
133132 }
134133
135- CxxReportIssue issue = new CxxReportIssue (id , file , line , msg );
136-
137134 if (currentIssue != null ) {
138135 saveUniqueViolation (context , currentIssue );
139136 }
140137
141- currentIssue = issue ;
138+ currentIssue = new CxxReportIssue ( id , file , line , msg ) ;
142139 } else {
143140 LOG .warn ("PC-lint warning ignored: {}" , msg );
144141 if (LOG .isDebugEnabled ()) {
@@ -157,15 +154,12 @@ public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
157154 }
158155 }
159156
160- private void addMoreLocationsToCurrentIssue (@ Nonnull CxxReportIssue currentIssue ,
161- String file ,
162- String line ,
163- String msg ) {
164- if (file != null && file .isEmpty () && msg != null && msg .startsWith (PREFIX_DURING_SPECIFIC_WALK_MSG )) {
165- String walkedSrcFile =
166- msg .substring (PREFIX_MSG_LENGTH , msg .indexOf (" " , PREFIX_MSG_LENGTH ));
167-
168- Matcher matcher = FILE_NAME_WITH_LINE_AND_COL_PATTERN .matcher (walkedSrcFile );
157+ private void addSecondaryLocationsToCurrentIssue (@ Nonnull CxxReportIssue currentIssue ,
158+ String file ,
159+ String line ,
160+ String msg ) {
161+ if (file != null && file .isEmpty () && msg != null ) {
162+ Matcher matcher = SUPPLEMENTAL_MSG_PATTERN .matcher (msg );
169163
170164 if (matcher .matches ()) {
171165 file = matcher .group (1 );
@@ -183,12 +177,12 @@ private void addMoreLocationsToCurrentIssue(@Nonnull CxxReportIssue currentIssue
183177 return ;
184178 }
185179
186- // Due to SONAR-9929, even the API supports the extral /flow in different file,
180+ // Due to SONAR-9929, even the API supports the extra /flow in different file,
187181 // the UI is not ready. For this case, use the parent issue's file and line for now.
188182 CxxReportLocation primaryLocation = currentIssue .getLocations ().get (0 );
189183 if (!primaryLocation .getFile ().equals (file )) {
190184 if (!msg .startsWith (PREFIX_DURING_SPECIFIC_WALK_MSG )) {
191- msg = PREFIX_DURING_SPECIFIC_WALK_MSG + String .format (" %s:%s %s" , file , line , msg );
185+ msg = String .format ("%s %s:%s %s" , PREFIX_DURING_SPECIFIC_WALK_MSG , file , line , msg );
192186 }
193187
194188 file = primaryLocation .getFile ();
0 commit comments