Skip to content

Commit f187e74

Browse files
committed
C#: Autoformat follow-up changes
1 parent daa4532 commit f187e74

File tree

10 files changed

+29
-36
lines changed

10 files changed

+29
-36
lines changed

csharp/ql/src/Bad Practices/Naming Conventions/ConfusingOverridesNames.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ predicate hasSubtypeStar(RefType t, RefType u) {
1919
}
2020

2121
/**
22-
* for each class, get all methods from this class or its
23-
* superclasses, with their names in lowercase
22+
* For each class, get all methods from this class or its
23+
* superclasses, with their names in lowercase
2424
*/
2525
predicate methodNames(RefType t, Method m, string lowercase) {
2626
exists(RefType t2 |
@@ -33,7 +33,7 @@ predicate methodNames(RefType t, Method m, string lowercase) {
3333

3434
/**
3535
* For each class, find the pairs of methods that
36-
* are candidates for being confusing in this class
36+
* are candidates for being confusing in this class
3737
*/
3838
predicate confusing(Method m1, Method m2) {
3939
exists(RefType t, string lower |

csharp/ql/src/Bad Practices/Naming Conventions/DefaultControlNames.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @name Windows controls with generated names
33
* @description Replacing the generated names in windows forms with meaningful names
4-
* makes it easier for other developers to understand the code.
4+
* makes it easier for other developers to understand the code.
55
* @kind problem
66
* @problem.severity recommendation
77
* @precision medium

csharp/ql/src/Complexity/BlockWithTooManyStatements.ql

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ import csharp
1616

1717
class ComplexStmt extends Stmt {
1818
ComplexStmt() {
19-
(
20-
this instanceof ForStmt or
21-
this instanceof WhileStmt or
22-
this instanceof DoStmt or
23-
this instanceof SwitchStmt
24-
)
19+
this instanceof ForStmt or
20+
this instanceof WhileStmt or
21+
this instanceof DoStmt or
22+
this instanceof SwitchStmt
2523
}
2624
}
2725

csharp/ql/src/Likely Bugs/BadCheckOdd.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ where
2525
not isDefinitelyPositive(lhs.getLeftOperand().stripCasts()) and
2626
lhs.getRightOperand().(IntegerLiteral).getValue() = "2" and
2727
(
28-
(t instanceof EQExpr and rhs.getValue() = "1" and parity = "oddness")
28+
t instanceof EQExpr and rhs.getValue() = "1" and parity = "oddness"
2929
or
30-
(t instanceof NEExpr and rhs.getValue() = "1" and parity = "evenness")
30+
t instanceof NEExpr and rhs.getValue() = "1" and parity = "evenness"
3131
or
32-
(t instanceof GTExpr and rhs.getValue() = "0" and parity = "oddness")
32+
t instanceof GTExpr and rhs.getValue() = "0" and parity = "oddness"
3333
)
3434
select t, "Possibly invalid test for " + parity + ". This will fail for negative numbers."

csharp/ql/src/Likely Bugs/IncomparableEquals.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import semmle.code.csharp.frameworks.System
1818
*/
1919
predicate whitelist(MethodCall mc) {
2020
// Allow tests to verify that equals methods return false
21-
(mc.getParent*().(MethodCall)).getTarget().hasName("IsFalse")
21+
mc.getParent*().(MethodCall).getTarget().hasName("IsFalse")
2222
}
2323

2424
from EqualsMethod equals, MethodCall ma, Type i, Type j

csharp/ql/src/Metrics/Callables/CNumberOfStatements.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ where
1616
c.isSourceDeclaration() and
1717
n = count(Stmt s |
1818
s.getEnclosingCallable() = c and
19-
s != c.getAChild()
20-
) // we do not count the top-level block
19+
s != c.getAChild() // we do not count the top-level block
20+
)
2121
select c, n order by n desc

csharp/ql/src/Metrics/Callables/StatementNestingDepth.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ import csharp
1414

1515
/**
1616
* The parent of a statement, excluding some common cases that don't really make
17-
* sense for nesting depth. An example is: "if (...) { } else if (...) { }: we don't
18-
* consider the second if nested. Blocks are also skipped
17+
* sense for nesting depth. An example is: "if (...) { } else if (...) { }: we don't
18+
* consider the second if nested. Blocks are also skipped
1919
*/
2020
predicate realParent(Stmt inner, Stmt outer) {
2121
if skipParent(inner) then realParent(inner.getParent(), outer) else outer = inner.getParent()
2222
}
2323

2424
predicate skipParent(Stmt s) {
2525
exists(Stmt parent | parent = s.getParent() |
26-
(s instanceof IfStmt and (parent.(IfStmt)).getElse() = s)
26+
s instanceof IfStmt and parent.(IfStmt).getElse() = s
2727
or
2828
parent instanceof BlockStmt
2929
)

csharp/ql/src/Performance/StringConcatenationInLoop.ql

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ import csharp
1414
// any use of + that has string type
1515
class StringCat extends AddExpr { StringCat() { this.getType() instanceof StringType } }
1616

17-
/*
18-
* an assignment of the form
19-
* v = ... + ... v ...
20-
* where v is a simple variable (and not, for example, a property)
17+
/**
18+
* Holds if `e` is an assignment of the form
19+
* `v = ... + ... v ...`
20+
* where `v` is a simple variable (and not, for example, a property).
2121
*/
22-
2322
predicate isSelfConcatAssignExpr(AssignExpr e, Variable v) {
2423
not e = any(AssignAddExpr a).getExpandedAssignment() and
2524
exists(VariableAccess use |
@@ -34,12 +33,11 @@ predicate stringCatContains(StringCat expr, Expr child) {
3433
stringCatContains(expr, child.getParent())
3534
}
3635

37-
/*
38-
* an assignment of the form
39-
* v += ...
40-
* where v is a simple variable (and not, for example, a property)
36+
/**
37+
* Holds if `e` is an assignment of the form
38+
* `v += ...`
39+
* where `v` is a simple variable (and not, for example, a property).
4140
*/
42-
4341
predicate isConcatExpr(AssignAddExpr e, Variable v) {
4442
e.getLValue().getType() instanceof StringType and
4543
v = e.getTargetVariable()

csharp/ql/src/Security Features/CWE-248/MissingASPNETGlobalErrorHandler.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class Application_Error extends Method {
2424
}
2525

2626
from CustomErrorsXMLElement customError
27-
// `<customErrors>` must be set to "off" to be dangerous
2827
where
28+
// `<customErrors>` must be set to "off" to be dangerous
2929
customError.getAttributeValue("mode").toLowerCase() = "off" and
3030
// There must not be an error handler in global.asax
3131
not exists(Application_Error ae)

csharp/ql/src/Security Features/CWE-352/MissingAntiForgeryTokenValidation.ql

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,9 @@ where
4848
// The method is not protected by a validate anti forgery token attribute
4949
not postMethod.getAnAttribute() instanceof ValidateAntiForgeryTokenAttribute and
5050
not c.getAnAttribute() instanceof ValidateAntiForgeryTokenAttribute and
51-
/*
52-
* Verify that validate anti forgery token attributes are used somewhere within this project, to
53-
* avoid reporting false positives on projects that use an alternative approach to mitigate CSRF
54-
* issues.
55-
*/
56-
51+
// Verify that validate anti forgery token attributes are used somewhere within this project, to
52+
// avoid reporting false positives on projects that use an alternative approach to mitigate CSRF
53+
// issues.
5754
exists(ValidateAntiForgeryTokenAttribute a, Element e | e = a.getTarget()) and
5855
// Also ignore cases where a global anti forgery filter is in use.
5956
not hasGlobalAntiForgeryFilter()

0 commit comments

Comments
 (0)