@@ -8,6 +8,7 @@ import cpp
8
8
import semmle.code.cpp.XML
9
9
import codingstandards.cpp.exclusions.RuleMetadata
10
10
import codingstandards.cpp.Config
11
+ import CodeIdentifierDeviation
11
12
12
13
predicate applyDeviationsAtQueryLevel ( ) {
13
14
not exists ( CodingStandardsReportDeviatedAlerts reportDeviatedResults |
@@ -219,32 +220,8 @@ class DeviationRecord extends XmlElement {
219
220
else result = getADeviationPermit ( ) .getCodeIdentifier ( )
220
221
}
221
222
222
- /** Gets a comment which starts or ends with the code identifier comment. */
223
- Comment getACodeIdentifierComment ( ) {
224
- exists ( string text |
225
- (
226
- result instanceof CppStyleComment and
227
- // strip the beginning slashes
228
- text = result .getContents ( ) .suffix ( 2 ) .trim ( )
229
- or
230
- result instanceof CStyleComment and
231
- // strip both the beginning /* and the end */ the comment
232
- exists ( string text0 |
233
- text0 = result .getContents ( ) .suffix ( 2 ) and
234
- text = text0 .prefix ( text0 .length ( ) - 2 ) .trim ( )
235
- ) and
236
- // The /* */ comment must be a single-line comment
237
- not text .matches ( "%\n%" )
238
- ) and
239
- (
240
- // Code identifier appears at the start of the comment (modulo whitespace)
241
- text .prefix ( getCodeIdentifier ( ) .length ( ) ) = getCodeIdentifier ( )
242
- or
243
- // Code identifier appears at the end of the comment (modulo whitespace)
244
- text .suffix ( text .length ( ) - getCodeIdentifier ( ) .length ( ) ) = getCodeIdentifier ( )
245
- )
246
- )
247
- }
223
+ /** Gets a code identifier deviation in code which starts or ends with the code identifier comment. */
224
+ CodeIdentifierDeviation getACodeIdentifierDeviation ( ) { this = result .getDeviationRecord ( ) }
248
225
249
226
/** Gets the `rule-id` specified for this record, if any. */
250
227
private string getRawRuleId ( ) { result = getAChild ( "rule-id" ) .getTextValue ( ) }
0 commit comments