C#: Autoformat QL queries

This commit is contained in:
Tom Hvitved
2019-01-02 12:59:07 +01:00
parent 4348de3120
commit daa45322b1
277 changed files with 2462 additions and 2301 deletions

View File

@@ -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
)
}
}

View File

@@ -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."