mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
C#: Autoformat QL queries
This commit is contained in:
@@ -11,14 +11,17 @@
|
||||
* testability
|
||||
* complexity
|
||||
*/
|
||||
|
||||
import csharp
|
||||
|
||||
class ComplexStmt extends Stmt {
|
||||
ComplexStmt() {
|
||||
(this instanceof ForStmt or
|
||||
this instanceof WhileStmt or
|
||||
this instanceof DoStmt or
|
||||
this instanceof SwitchStmt)
|
||||
(
|
||||
this instanceof ForStmt or
|
||||
this instanceof WhileStmt or
|
||||
this instanceof DoStmt or
|
||||
this instanceof SwitchStmt
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* @tags testability
|
||||
* readability
|
||||
*/
|
||||
|
||||
import csharp
|
||||
|
||||
predicate nontrivialLogicalOperator(BinaryLogicalOperation e) {
|
||||
@@ -17,13 +18,13 @@ predicate nontrivialLogicalOperator(BinaryLogicalOperation e) {
|
||||
)
|
||||
}
|
||||
|
||||
predicate logicalParent(LogicalOperation op, LogicalOperation parent)
|
||||
{
|
||||
parent = op.getParent()
|
||||
}
|
||||
predicate logicalParent(LogicalOperation op, LogicalOperation parent) { parent = op.getParent() }
|
||||
|
||||
from Expr e, int operators
|
||||
where not (e.getParent() instanceof LogicalOperation)
|
||||
and operators = count(BinaryLogicalOperation op | logicalParent*(op, e) and nontrivialLogicalOperator(op))
|
||||
and operators > 3
|
||||
where
|
||||
not (e.getParent() instanceof LogicalOperation) and
|
||||
operators = count(BinaryLogicalOperation op |
|
||||
logicalParent*(op, e) and nontrivialLogicalOperator(op)
|
||||
) and
|
||||
operators > 3
|
||||
select e.getLocation(), "Complex condition: too many logical operations in this expression."
|
||||
|
||||
Reference in New Issue
Block a user