@@ -12,80 +12,70 @@ import javascript
1212 */
1313class SuppressionComment extends Locatable {
1414 string text ;
15+
1516 string annotation ;
1617
1718 SuppressionComment ( ) {
1819 (
19- text = this .( LineComment ) .getText ( ) or
20- text = this .( HTML:: CommentNode ) .getText ( )
21- )
22- and
20+ text = this .( LineComment ) .getText ( ) or
21+ text = this .( HTML:: CommentNode ) .getText ( )
22+ ) and
2323 (
24- // match `lgtm[...]` anywhere in the comment
25- annotation = text .regexpFind ( "(?i)\\blgtm\\s*\\[[^\\]]*\\]" , _, _)
26- or
27- // match `lgtm` at the start of the comment and after semicolon
28- annotation = text .regexpFind ( "(?i)(?<=^|;)\\s*lgtm(?!\\B|\\s*\\[)" , _, _) .trim ( )
24+ // match `lgtm[...]` anywhere in the comment
25+ annotation = text .regexpFind ( "(?i)\\blgtm\\s*\\[[^\\]]*\\]" , _, _)
26+ or
27+ // match `lgtm` at the start of the comment and after semicolon
28+ annotation = text .regexpFind ( "(?i)(?<=^|;)\\s*lgtm(?!\\B|\\s*\\[)" , _, _) .trim ( )
2929 )
3030 }
3131
3232 /** Gets the text of this suppression comment, not including delimiters. */
33- string getText ( ) {
34- result = text
35- }
33+ string getText ( ) { result = text }
3634
3735 /** Gets the suppression annotation in this comment. */
38- string getAnnotation ( ) {
39- result = annotation
40- }
36+ string getAnnotation ( ) { result = annotation }
4137
4238 /**
43- * Holds if this comment applies to the range from column `startcolumn` of line `startline`
44- * to column `endcolumn` of line `endline` in file `filepath`.
45- */
39+ * Holds if this comment applies to the range from column `startcolumn` of line `startline`
40+ * to column `endcolumn` of line `endline` in file `filepath`.
41+ */
4642 predicate covers ( string filepath , int startline , int startcolumn , int endline , int endcolumn ) {
4743 this .getLocation ( ) .hasLocationInfo ( filepath , startline , _, endline , endcolumn ) and
4844 startcolumn = 1
4945 }
5046
5147 /** Gets the scope of this suppression. */
52- SuppressionScope getScope ( ) {
53- this = result .getSuppressionComment ( )
54- }
48+ SuppressionScope getScope ( ) { this = result .getSuppressionComment ( ) }
5549}
5650
5751/**
5852 * The scope of an alert suppression comment.
5953 */
6054class SuppressionScope extends @locatable {
61- SuppressionScope ( ) {
62- this instanceof SuppressionComment
63- }
55+ SuppressionScope ( ) { this instanceof SuppressionComment }
6456
6557 /** Gets a suppression comment with this scope. */
66- SuppressionComment getSuppressionComment ( ) {
67- result = this
68- }
58+ SuppressionComment getSuppressionComment ( ) { result = this }
6959
7060 /**
71- * Holds if this element is at the specified location.
72- * The location spans column `startcolumn` of line `startline` to
73- * column `endcolumn` of line `endline` in file `filepath`.
74- * For more information, see
75- * [LGTM locations](https://lgtm.com/help/ql/locations).
76- */
77- predicate hasLocationInfo ( string filepath , int startline , int startcolumn , int endline , int endcolumn ) {
61+ * Holds if this element is at the specified location.
62+ * The location spans column `startcolumn` of line `startline` to
63+ * column `endcolumn` of line `endline` in file `filepath`.
64+ * For more information, see
65+ * [LGTM locations](https://lgtm.com/help/ql/locations).
66+ */
67+ predicate hasLocationInfo (
68+ string filepath , int startline , int startcolumn , int endline , int endcolumn
69+ ) {
7870 this .( SuppressionComment ) .covers ( filepath , startline , startcolumn , endline , endcolumn )
7971 }
8072
8173 /** Gets a textual representation of this element. */
82- string toString ( ) {
83- result = "suppression range"
84- }
74+ string toString ( ) { result = "suppression range" }
8575}
8676
8777from SuppressionComment c
88- select c , // suppression comment
89- c .getText ( ) , // text of suppression comment (excluding delimiters)
90- c .getAnnotation ( ) , // text of suppression annotation
91- c .getScope ( ) // scope of suppression
78+ select c , // suppression comment
79+ c .getText ( ) , // text of suppression comment (excluding delimiters)
80+ c .getAnnotation ( ) , // text of suppression annotation
81+ c .getScope ( ) // scope of suppression
0 commit comments