Skip to content

Commit dca13f5

Browse files
committed
C++: Initial cpp/comma-before-misleading-indentation
MRVA top 1000 run at: https://github.com/github/semmle-code/actions/runs/3106828111
1 parent f1efc76 commit dca13f5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
select 1
1+
/**
2+
* @name Comma before misleading indentation
3+
* @description The expressions before and after the comma operator can be misread because of an unusual difference in start columns.
4+
* @kind problem
5+
* @id cpp/comma-before-misleading-indentation
6+
* @problem.severity recommendation
7+
* @tags maintainability
8+
* readability
9+
*/
10+
11+
import cpp
12+
13+
from CommaExpr ce
14+
where
15+
ce.fromSource() and
16+
not exists(MacroInvocation me | ce = me.getAnAffectedElement()) and
17+
ce.getLeftOperand().getLocation().getStartColumn() >
18+
ce.getRightOperand().getLocation().getStartColumn()
19+
select ce, "Comma before misleading indentation."
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
| 1 |
1+
| test.cpp:9:3:10:8 | ... , ... | Comma before misleading indentation. |
2+
| test.cpp:17:7:18:4 | ... , ... | Comma before misleading indentation. |

0 commit comments

Comments
 (0)