@@ -8,6 +8,7 @@ import cpp
88import semmle.code.cpp.XML
99import codingstandards.cpp.exclusions.RuleMetadata
1010import codingstandards.cpp.Config
11+ import CodeIdentifierDeviation
1112
1213predicate applyDeviationsAtQueryLevel ( ) {
1314 not exists ( CodingStandardsReportDeviatedAlerts reportDeviatedResults |
@@ -219,32 +220,8 @@ class DeviationRecord extends XmlElement {
219220 else result = getADeviationPermit ( ) .getCodeIdentifier ( )
220221 }
221222
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 ( ) }
248225
249226 /** Gets the `rule-id` specified for this record, if any. */
250227 private string getRawRuleId ( ) { result = getAChild ( "rule-id" ) .getTextValue ( ) }
0 commit comments