Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bcaaebf

Browse files
committed
CSharp: Autoformat qlls
1 parent 1182fca commit bcaaebf

64 files changed

Lines changed: 356 additions & 145 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

csharp/ql/src/API Abuse/Dispose.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ class WebControl extends RefType {
1515
WebControl() { this.getBaseClass*() instanceof SystemWebUIControlClass }
1616
}
1717

18-
class WebPage extends RefType { WebPage() { this.getBaseClass*() instanceof SystemWebUIPageClass } }
18+
class WebPage extends RefType {
19+
WebPage() { this.getBaseClass*() instanceof SystemWebUIPageClass }
20+
}
1921

2022
/**
2123
* Holds if `f` is an auto-disposed web control.

csharp/ql/src/Concurrency/ThreadCreation.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ abstract class ConcurrentEntryPoint extends Callable { }
3131
/**
3232
* Methods annotated with the `async` keyword are concurrent entry points.
3333
*/
34-
class AsyncMethod extends ConcurrentEntryPoint { AsyncMethod() { this.(Modifiable).isAsync() } }
34+
class AsyncMethod extends ConcurrentEntryPoint {
35+
AsyncMethod() { this.(Modifiable).isAsync() }
36+
}
3537

3638
/**
3739
* Lambdas or methods passed into the thread or task creation library functions

csharp/ql/src/Documentation/Documentation.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import csharp
22

3-
class SourceDeclaration extends Declaration { SourceDeclaration() { this.isSourceDeclaration() } }
3+
class SourceDeclaration extends Declaration {
4+
SourceDeclaration() { this.isSourceDeclaration() }
5+
}
46

57
/** A parameter that has come from source code. */
68
class SourceParameter extends SourceDeclaration, Parameter { }

csharp/ql/src/Stubs/Stubs.qll

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ abstract private class GeneratedType extends ValueOrRefType, GeneratedElement {
110110
t = this.getAnInterestingBaseType() and
111111
(if t instanceof Class then i = 0 else i = 1)
112112
|
113-
stubClassName(t), ", "
114-
order by
115-
i
113+
stubClassName(t), ", " order by i
116114
)
117115
else result = ""
118116
}
@@ -265,7 +263,10 @@ private string stubAccessibility(Member m) {
265263
else
266264
if m.isPrivate()
267265
then result = "private "
268-
else if m.isInternal() then result = "internal " else result = "unknown-accessibility"
266+
else
267+
if m.isInternal()
268+
then result = "internal "
269+
else result = "unknown-accessibility"
269270
}
270271

271272
private string stubModifiers(Member m) {
@@ -285,7 +286,10 @@ private string stubOverride(Member m) {
285286
else
286287
if m.(Virtualizable).isAbstract()
287288
then result = "abstract "
288-
else if m.(Virtualizable).isOverride() then result = "override " else result = ""
289+
else
290+
if m.(Virtualizable).isOverride()
291+
then result = "override "
292+
else result = ""
289293
}
290294

291295
private string stubQualifiedNamePrefix(ValueOrRefType t) {
@@ -338,9 +342,7 @@ private string stubClassName(Type t) {
338342
concat(int i, Type element |
339343
element = t.(TupleType).getElementType(i)
340344
|
341-
stubClassName(element), ","
342-
order by
343-
i
345+
stubClassName(element), "," order by i
344346
) + ")"
345347
else
346348
if t instanceof ValueOrRefType
@@ -358,9 +360,7 @@ private string stubGenericArguments(ValueOrRefType t) {
358360
concat(int n |
359361
exists(t.(UnboundGenericType).getTypeParameter(n))
360362
|
361-
t.(UnboundGenericType).getTypeParameter(n).getName(), ","
362-
order by
363-
n
363+
t.(UnboundGenericType).getTypeParameter(n).getName(), "," order by n
364364
) + ">"
365365
else
366366
if t instanceof ConstructedType
@@ -369,9 +369,7 @@ private string stubGenericArguments(ValueOrRefType t) {
369369
concat(int n |
370370
exists(t.(ConstructedType).getTypeArgument(n))
371371
|
372-
stubClassName(t.(ConstructedType).getTypeArgument(n)), ","
373-
order by
374-
n
372+
stubClassName(t.(ConstructedType).getTypeArgument(n)), "," order by n
375373
) + ">"
376374
else result = ""
377375
}
@@ -383,9 +381,7 @@ private string stubGenericMethodParams(Method m) {
383381
concat(int n, TypeParameter param |
384382
param = m.(UnboundGenericMethod).getTypeParameter(n)
385383
|
386-
param.getName(), ","
387-
order by
388-
n
384+
param.getName(), "," order by n
389385
) + ">"
390386
else result = ""
391387
}
@@ -419,7 +415,10 @@ private string stubParameterModifiers(Parameter p) {
419415
else
420416
if p.isIn()
421417
then result = "" // Only C# 7.1 so ignore
422-
else if p.hasExtensionMethodModifier() then result = "this " else result = ""
418+
else
419+
if p.hasExtensionMethodModifier()
420+
then result = "this "
421+
else result = ""
423422
}
424423

425424
private string stubDefaultValue(Parameter p) {

csharp/ql/src/semmle/code/asp/AspNet.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ class AspQuotedString extends AspAttribute, @asp_quoted_string {
165165
}
166166

167167
/** Arbitrary text. It will be inserted into the document as is. */
168-
class AspText extends AspElement, @asp_text { override string toString() { result = getBody() } }
168+
class AspText extends AspElement, @asp_text {
169+
override string toString() { result = getBody() }
170+
}
169171

170172
/** An XML directive, such as a `DOCTYPE` declaration. */
171173
class AspXmlDirective extends AspElement, @asp_xml_directive {

csharp/ql/src/semmle/code/asp/WebConfig.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import csharp
77
/**
88
* A `Web.config` file.
99
*/
10-
class WebConfigXML extends XMLFile { WebConfigXML() { getName().matches("%Web.config") } }
10+
class WebConfigXML extends XMLFile {
11+
WebConfigXML() { getName().matches("%Web.config") }
12+
}
1113

1214
/** A `<configuration>` tag in an ASP.NET configuration file. */
1315
class ConfigurationXMLElement extends XMLElement {

csharp/ql/src/semmle/code/cil/Access.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ class ReadRef extends Expr, @cil_read_ref { }
3030
class ReadRefAccess extends ReadAccess, ReadRef { }
3131

3232
/** An instruction that writes a variable. */
33-
class WriteAccess extends VariableAccess, @cil_write_access { Expr getExpr() { none() } }
33+
class WriteAccess extends VariableAccess, @cil_write_access {
34+
Expr getExpr() { none() }
35+
}
3436

3537
/** An instruction that accesses a parameter. */
3638
class ParameterAccess extends StackVariableAccess, @cil_arg_access {

csharp/ql/src/semmle/code/cil/BasicBlock.qll

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ predicate bbIPostDominates(BasicBlock dom, BasicBlock bb) =
302302
* An entry basic block, that is, a basic block whose first node is
303303
* the entry node of a callable.
304304
*/
305-
class EntryBasicBlock extends BasicBlock { EntryBasicBlock() { entryBB(this) } }
305+
class EntryBasicBlock extends BasicBlock {
306+
EntryBasicBlock() { entryBB(this) }
307+
}
306308

307309
/** Holds if `bb` is an entry basic block. */
308310
private predicate entryBB(BasicBlock bb) { bb.getFirstNode() instanceof EntryPoint }
@@ -311,15 +313,19 @@ private predicate entryBB(BasicBlock bb) { bb.getFirstNode() instanceof EntryPoi
311313
* An exit basic block, that is, a basic block whose last node is
312314
* an exit node.
313315
*/
314-
class ExitBasicBlock extends BasicBlock { ExitBasicBlock() { exitBB(this) } }
316+
class ExitBasicBlock extends BasicBlock {
317+
ExitBasicBlock() { exitBB(this) }
318+
}
315319

316320
/** Holds if `bb` is an exit basic block. */
317321
private predicate exitBB(BasicBlock bb) { not exists(bb.getLastNode().getASuccessor()) }
318322

319323
/**
320324
* A basic block with more than one predecessor.
321325
*/
322-
class JoinBlock extends BasicBlock { JoinBlock() { getFirstNode().isJoin() } }
326+
class JoinBlock extends BasicBlock {
327+
JoinBlock() { getFirstNode().isJoin() }
328+
}
323329

324330
/** A basic block that terminates in a condition, splitting the subsequent control flow. */
325331
class ConditionBlock extends BasicBlock {

csharp/ql/src/semmle/code/cil/ControlFlow.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,21 @@ private newtype TFlowType =
122122
TFalseFlow()
123123

124124
/** A type of control flow. Either normal flow (`NormalFlow`), true flow (`TrueFlow`) or false flow (`FalseFlow`). */
125-
abstract class FlowType extends TFlowType { abstract string toString(); }
125+
abstract class FlowType extends TFlowType {
126+
abstract string toString();
127+
}
126128

127129
/** Normal control flow. */
128-
class NormalFlow extends FlowType, TNormalFlow { override string toString() { result = "" } }
130+
class NormalFlow extends FlowType, TNormalFlow {
131+
override string toString() { result = "" }
132+
}
129133

130134
/** True control flow. */
131-
class TrueFlow extends FlowType, TTrueFlow { override string toString() { result = "true" } }
135+
class TrueFlow extends FlowType, TTrueFlow {
136+
override string toString() { result = "true" }
137+
}
132138

133139
/** False control flow. */
134-
class FalseFlow extends FlowType, TTrueFlow { override string toString() { result = "false" } }
140+
class FalseFlow extends FlowType, TTrueFlow {
141+
override string toString() { result = "false" }
142+
}

csharp/ql/src/semmle/code/cil/InstructionGroups.qll

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class ConditionalBranch extends Branch, @cil_conditional_jump {
5252
}
5353

5454
/** An expression with two operands. */
55-
class BinaryExpr extends Expr, @cil_binary_expr { override int getPopCount() { result = 2 } }
55+
class BinaryExpr extends Expr, @cil_binary_expr {
56+
override int getPopCount() { result = 2 }
57+
}
5658

5759
/** An expression with one operand. */
5860
class UnaryExpr extends Expr, @cil_unary_expr {
@@ -200,10 +202,14 @@ class TailCall extends Call {
200202
}
201203

202204
/** A call to a static target. */
203-
class StaticCall extends Call { StaticCall() { not this.isVirtual() } }
205+
class StaticCall extends Call {
206+
StaticCall() { not this.isVirtual() }
207+
}
204208

205209
/** A call to a virtual target. */
206-
class VirtualCall extends Call { VirtualCall() { this.isVirtual() } }
210+
class VirtualCall extends Call {
211+
VirtualCall() { this.isVirtual() }
212+
}
207213

208214
/** A read of an array element. */
209215
class ReadArrayElement extends BinaryExpr, @cil_read_array {

0 commit comments

Comments
 (0)