C++: Initial cpp/comma-before-misleading-indentation

MRVA top 1000 run at: https://github.com/github/semmle-code/actions/runs/3106828111
This commit is contained in:
Nora Dimitrijević
2022-09-22 17:42:28 +02:00
parent f1efc76e8c
commit dca13f5c89
2 changed files with 21 additions and 2 deletions

View File

@@ -1 +1,19 @@
select 1
/**
* @name Comma before misleading indentation
* @description The expressions before and after the comma operator can be misread because of an unusual difference in start columns.
* @kind problem
* @id cpp/comma-before-misleading-indentation
* @problem.severity recommendation
* @tags maintainability
* readability
*/
import cpp
from CommaExpr ce
where
ce.fromSource() and
not exists(MacroInvocation me | ce = me.getAnAffectedElement()) and
ce.getLeftOperand().getLocation().getStartColumn() >
ce.getRightOperand().getLocation().getStartColumn()
select ce, "Comma before misleading indentation."

View File

@@ -1 +1,2 @@
| 1 |
| test.cpp:9:3:10:8 | ... , ... | Comma before misleading indentation. |
| test.cpp:17:7:18:4 | ... , ... | Comma before misleading indentation. |