Skip to content

Commit 126ed55

Browse files
committed
Add getLastColumnNumber to shared library
1 parent 184e5d3 commit 126ed55

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

cpp/common/src/codingstandards/cpp/Locations.qll

+6
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ int getLastColumnNumber(File f) {
2222
l.getEndColumn()
2323
)
2424
}
25+
26+
/** Gets the last column number on the given line of `filepath`. */
27+
bindingset[filepath, lineNumber]
28+
int getLastColumnNumber(string filepath, int lineNumber) {
29+
result = max(Location l | l.hasLocationInfo(filepath, _, _, lineNumber, _) | l.getEndColumn())
30+
}

cpp/common/src/codingstandards/cpp/deviations/CodeIdentifierDeviation.qll

+2-7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
import cpp
3434
import Deviations
35+
import codingstandards.cpp.Locations
3536

3637
string supportedStandard() { result = ["misra", "autosar", "cert"] }
3738

@@ -358,13 +359,7 @@ class CodeIdentifierDeviation extends TCodeIndentifierDeviation {
358359
then endcolumn = commentMarker.(DeviationEndOfLineMarker).getLocation().getEndColumn()
359360
else
360361
// Find the last column for a location on the next line
361-
endcolumn =
362-
max(Location l |
363-
l.hasLocationInfo(filepath, _, _, _, _) and
364-
l.getEndLine() = suppressedLine
365-
|
366-
l.getEndColumn()
367-
)
362+
endcolumn = getLastColumnNumber(filepath, suppressedLine)
368363
)
369364
or
370365
this = TMultiLineDeviation(_, _, _, filepath, suppressedLine, endline) and

0 commit comments

Comments
 (0)