C#: Auto format

This commit is contained in:
Tom Hvitved
2019-06-26 19:32:08 +02:00
parent 1a9f3624c2
commit bd03e7a590
8 changed files with 22 additions and 20 deletions

View File

@@ -63,9 +63,7 @@ private predicate localFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo)
private predicate reachesDisposeCall(DisposeCall disposeCall, DataFlow::Node node) {
localFlowStep(node, DataFlow::exprNode(disposeCall.getQualifier()))
or
exists(DataFlow::Node mid | reachesDisposeCall(disposeCall, mid) |
localFlowStep(node, mid)
)
exists(DataFlow::Node mid | reachesDisposeCall(disposeCall, mid) | localFlowStep(node, mid))
}
/**

View File

@@ -34,6 +34,10 @@ class UnsafeYearCreationFromArithmeticConfiguration extends TaintTracking::Confi
}
}
from UnsafeYearCreationFromArithmeticConfiguration config, DataFlow::PathNode source, DataFlow::PathNode sink
from
UnsafeYearCreationFromArithmeticConfiguration config, DataFlow::PathNode source,
DataFlow::PathNode sink
where config.hasFlowPath(source, sink)
select sink, source, sink, "This $@ based on a 'System.DateTime.Year' property is used in a construction of a new 'System.DateTime' object, flowing to the 'year' argument.", source, "arithmetic operation"
select sink, source, sink,
"This $@ based on a 'System.DateTime.Year' property is used in a construction of a new 'System.DateTime' object, flowing to the 'year' argument.",
source, "arithmetic operation"

View File

@@ -26,7 +26,8 @@ predicate isExactEraStartDateCreation(ObjectCreation cr) {
cr.getType().hasQualifiedName("System.DateTime") or
cr.getType().hasQualifiedName("System.DateTimeOffset")
) and
isEraStart(cr.getArgument(0).getValue().toInt(), cr.getArgument(1).getValue().toInt(), cr.getArgument(2).getValue().toInt())
isEraStart(cr.getArgument(0).getValue().toInt(), cr.getArgument(1).getValue().toInt(),
cr.getArgument(2).getValue().toInt())
}
predicate isDateFromJapaneseCalendarToDateTime(MethodCall mc) {
@@ -64,9 +65,12 @@ predicate isDateFromJapaneseCalendarCreation(ObjectCreation cr) {
from Expr expr, string message
where
isDateFromJapaneseCalendarToDateTime(expr) and message = "'DateTime' created from Japanese calendar with explicit or current era and hard-coded year."
isDateFromJapaneseCalendarToDateTime(expr) and
message = "'DateTime' created from Japanese calendar with explicit or current era and hard-coded year."
or
isDateFromJapaneseCalendarCreation(expr) and message = "'DateTime' constructed from Japanese calendar with explicit or current era and hard-coded year."
isDateFromJapaneseCalendarCreation(expr) and
message = "'DateTime' constructed from Japanese calendar with explicit or current era and hard-coded year."
or
isExactEraStartDateCreation(expr) and message = "Hard-coded the beginning of the Japanese Heisei era."
isExactEraStartDateCreation(expr) and
message = "Hard-coded the beginning of the Japanese Heisei era."
select expr, message

View File

@@ -41,9 +41,7 @@ private predicate alwaysNullExpr(Expr expr) {
or
alwaysNullMethod(expr.(StaticCall).getTarget())
or
forex(VariableUpdate vu | DefUse::variableUpdateUse(_, vu, expr) |
alwaysNullVariableUpdate(vu)
)
forex(VariableUpdate vu | DefUse::variableUpdateUse(_, vu, expr) | alwaysNullVariableUpdate(vu))
}
pragma[noinline]

View File

@@ -1303,9 +1303,7 @@ class UsingDeclStmt extends LocalVariableDeclStmt, UsingStmt, @using_decl_stmt {
result = LocalVariableDeclStmt.super.getVariableDeclExpr(n)
}
override Expr getAnExpr() {
result = this.getAVariableDeclExpr().getInitializer()
}
override Expr getAnExpr() { result = this.getAVariableDeclExpr().getInitializer() }
}
/**

View File

@@ -4,6 +4,6 @@ query predicate edges(ControlFlow::Node node1, ControlFlow::Node node2, string l
label = "semmle.label" and
exists(ControlFlow::SuccessorType t |
node2 = node1.getASuccessorByType(t) and value = t.toString()
)
and node1.getEnclosingCallable().hasName("NullCoalescing")
) and
node1.getEnclosingCallable().hasName("NullCoalescing")
}

View File

@@ -2,4 +2,4 @@ import csharp
from LocalFunction fn, string modifier
where fn.hasModifier(modifier)
select fn, modifier
select fn, modifier

View File

@@ -4,6 +4,6 @@ query predicate edges(ControlFlow::Node node1, ControlFlow::Node node2, string l
label = "semmle.label" and
exists(ControlFlow::SuccessorType t |
node2 = node1.getASuccessorByType(t) and value = t.toString()
)
and node1.getEnclosingCallable().hasName("TestUsingDeclarations")
) and
node1.getEnclosingCallable().hasName("TestUsingDeclarations")
}