From 40f2cec0def204fa801c5ca73123887a6b55672a Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Fri, 2 Aug 2019 15:30:32 +0200 Subject: [PATCH] C#: Autoformat cookbook examples. --- csharp/ql/examples/snippets/cast_expr.ql | 5 +++-- csharp/ql/examples/snippets/catch_exception.ql | 2 +- csharp/ql/examples/snippets/constructor_call.ql | 2 +- csharp/ql/examples/snippets/eq_true.ql | 2 +- csharp/ql/examples/snippets/extend_class.ql | 2 +- csharp/ql/examples/snippets/field_read.ql | 9 +++++---- csharp/ql/examples/snippets/integer_literal.ql | 2 +- csharp/ql/examples/snippets/method_call.ql | 9 +++++---- csharp/ql/examples/snippets/mutual_recursion.ql | 8 ++++---- csharp/ql/examples/snippets/null_argument.ql | 14 +++++++++----- csharp/ql/examples/snippets/override_method.ql | 9 +++++---- csharp/ql/examples/snippets/switch_case.ql | 9 +++++---- csharp/ql/examples/snippets/ternary_conditional.ql | 7 ++++--- csharp/ql/examples/snippets/throw_exception.ql | 2 +- csharp/ql/examples/snippets/try_finally.ql | 5 +++-- 15 files changed, 49 insertions(+), 38 deletions(-) diff --git a/csharp/ql/examples/snippets/cast_expr.ql b/csharp/ql/examples/snippets/cast_expr.ql index b95b1155af8..9228d886584 100644 --- a/csharp/ql/examples/snippets/cast_expr.ql +++ b/csharp/ql/examples/snippets/cast_expr.ql @@ -11,6 +11,7 @@ import csharp from CastExpr c -where c.getExpr().getType() instanceof FloatingPointType - and c.getType() instanceof IntegralType +where + c.getExpr().getType() instanceof FloatingPointType and + c.getType() instanceof IntegralType select c diff --git a/csharp/ql/examples/snippets/catch_exception.ql b/csharp/ql/examples/snippets/catch_exception.ql index a8863497604..eff10ed9ba1 100644 --- a/csharp/ql/examples/snippets/catch_exception.ql +++ b/csharp/ql/examples/snippets/catch_exception.ql @@ -6,7 +6,7 @@ * try * exception */ - + import csharp from CatchClause catch diff --git a/csharp/ql/examples/snippets/constructor_call.ql b/csharp/ql/examples/snippets/constructor_call.ql index 6c1d17d8e38..0329b13169e 100644 --- a/csharp/ql/examples/snippets/constructor_call.ql +++ b/csharp/ql/examples/snippets/constructor_call.ql @@ -6,7 +6,7 @@ * constructor * new */ - + import csharp from ObjectCreation new diff --git a/csharp/ql/examples/snippets/eq_true.ql b/csharp/ql/examples/snippets/eq_true.ql index 26a3a005bf7..01b36af3cdc 100644 --- a/csharp/ql/examples/snippets/eq_true.ql +++ b/csharp/ql/examples/snippets/eq_true.ql @@ -6,7 +6,7 @@ * test * boolean */ - + import csharp from EqualityOperation eq diff --git a/csharp/ql/examples/snippets/extend_class.ql b/csharp/ql/examples/snippets/extend_class.ql index 310c78d1cd7..40a2eeb20d3 100644 --- a/csharp/ql/examples/snippets/extend_class.ql +++ b/csharp/ql/examples/snippets/extend_class.ql @@ -9,7 +9,7 @@ * subtype * supertype */ - + import csharp from RefType type diff --git a/csharp/ql/examples/snippets/field_read.ql b/csharp/ql/examples/snippets/field_read.ql index 2a8dd9916b1..e36c92aadf9 100644 --- a/csharp/ql/examples/snippets/field_read.ql +++ b/csharp/ql/examples/snippets/field_read.ql @@ -5,11 +5,12 @@ * @tags field * read */ - + import csharp from Field f, FieldRead read -where f.hasName("VirtualAddress") - and f.getDeclaringType().hasQualifiedName("Mono.Cecil.PE.Section") - and f = read.getTarget() +where + f.hasName("VirtualAddress") and + f.getDeclaringType().hasQualifiedName("Mono.Cecil.PE.Section") and + f = read.getTarget() select read diff --git a/csharp/ql/examples/snippets/integer_literal.ql b/csharp/ql/examples/snippets/integer_literal.ql index 26bd72f4994..4546c1d174b 100644 --- a/csharp/ql/examples/snippets/integer_literal.ql +++ b/csharp/ql/examples/snippets/integer_literal.ql @@ -5,7 +5,7 @@ * @tags integer * literal */ - + import csharp from IntegerLiteral literal diff --git a/csharp/ql/examples/snippets/method_call.ql b/csharp/ql/examples/snippets/method_call.ql index 3419f9abeab..8ae3c8d3fb0 100644 --- a/csharp/ql/examples/snippets/method_call.ql +++ b/csharp/ql/examples/snippets/method_call.ql @@ -5,11 +5,12 @@ * @tags call * method */ - + import csharp from MethodCall call, Method method -where call.getTarget() = method - and method.hasName("MethodName") - and method.getDeclaringType().hasQualifiedName("Company.Class") +where + call.getTarget() = method and + method.hasName("MethodName") and + method.getDeclaringType().hasQualifiedName("Company.Class") select call diff --git a/csharp/ql/examples/snippets/mutual_recursion.ql b/csharp/ql/examples/snippets/mutual_recursion.ql index 5c55cd95ade..8663527337c 100644 --- a/csharp/ql/examples/snippets/mutual_recursion.ql +++ b/csharp/ql/examples/snippets/mutual_recursion.ql @@ -9,8 +9,8 @@ import csharp from Method m, Method n -where m.calls(n) - and n.calls(m) - and m != n +where + m.calls(n) and + n.calls(m) and + m != n select m, n - diff --git a/csharp/ql/examples/snippets/null_argument.ql b/csharp/ql/examples/snippets/null_argument.ql index fb5c29d2301..85848e8a5a3 100644 --- a/csharp/ql/examples/snippets/null_argument.ql +++ b/csharp/ql/examples/snippets/null_argument.ql @@ -8,12 +8,16 @@ * collection * add */ - + import csharp from MethodCall call, Method add -where call.getTarget() = add.getAnUltimateImplementor*() - and add.hasName("Add") - and add.getDeclaringType().getSourceDeclaration().hasQualifiedName("System.Collections.Generic.ICollection<>") - and call.getAnArgument() instanceof NullLiteral +where + call.getTarget() = add.getAnUltimateImplementor*() and + add.hasName("Add") and + add + .getDeclaringType() + .getSourceDeclaration() + .hasQualifiedName("System.Collections.Generic.ICollection<>") and + call.getAnArgument() instanceof NullLiteral select call diff --git a/csharp/ql/examples/snippets/override_method.ql b/csharp/ql/examples/snippets/override_method.ql index 0e022864604..ea5c2126f6a 100644 --- a/csharp/ql/examples/snippets/override_method.ql +++ b/csharp/ql/examples/snippets/override_method.ql @@ -5,11 +5,12 @@ * @tags method * override */ - + import csharp from Method override, Method base -where base.hasName("ToString") - and base.getDeclaringType().hasQualifiedName("System.Object") - and base.getAnOverrider() = override +where + base.hasName("ToString") and + base.getDeclaringType().hasQualifiedName("System.Object") and + base.getAnOverrider() = override select override diff --git a/csharp/ql/examples/snippets/switch_case.ql b/csharp/ql/examples/snippets/switch_case.ql index 0fd378dae03..e993a35ebc3 100644 --- a/csharp/ql/examples/snippets/switch_case.ql +++ b/csharp/ql/examples/snippets/switch_case.ql @@ -10,8 +10,9 @@ import csharp from SwitchStmt switch, Enum enum, EnumConstant missing -where switch.getCondition().getType() = enum - and missing.getDeclaringType() = enum - and not switch.getAConstCase().getExpr() = missing.getAnAccess() - and not exists(switch.getDefaultCase()) +where + switch.getCondition().getType() = enum and + missing.getDeclaringType() = enum and + not switch.getAConstCase().getExpr() = missing.getAnAccess() and + not exists(switch.getDefaultCase()) select switch diff --git a/csharp/ql/examples/snippets/ternary_conditional.ql b/csharp/ql/examples/snippets/ternary_conditional.ql index 669db8d327e..22e26e71ea8 100644 --- a/csharp/ql/examples/snippets/ternary_conditional.ql +++ b/csharp/ql/examples/snippets/ternary_conditional.ql @@ -10,7 +10,8 @@ import csharp from ConditionalExpr e -where e.getThen().stripImplicitCasts() != e.getElse().stripImplicitCasts() - and not e.getThen().getType() instanceof NullType - and not e.getElse().getType() instanceof NullType +where + e.getThen().stripImplicitCasts() != e.getElse().stripImplicitCasts() and + not e.getThen().getType() instanceof NullType and + not e.getElse().getType() instanceof NullType select e diff --git a/csharp/ql/examples/snippets/throw_exception.ql b/csharp/ql/examples/snippets/throw_exception.ql index d363b6fde22..94c1615fd21 100644 --- a/csharp/ql/examples/snippets/throw_exception.ql +++ b/csharp/ql/examples/snippets/throw_exception.ql @@ -5,7 +5,7 @@ * @tags throw * exception */ - + import csharp from ThrowStmt throw diff --git a/csharp/ql/examples/snippets/try_finally.ql b/csharp/ql/examples/snippets/try_finally.ql index 5c119b91335..1a95454b2d3 100644 --- a/csharp/ql/examples/snippets/try_finally.ql +++ b/csharp/ql/examples/snippets/try_finally.ql @@ -11,6 +11,7 @@ import csharp from TryStmt t -where exists(t.getFinally()) - and not exists(t.getACatchClause()) +where + exists(t.getFinally()) and + not exists(t.getACatchClause()) select t