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

Skip to content

Commit 330a5b8

Browse files
committed
autoformat ql
1 parent 32416f0 commit 330a5b8

6 files changed

Lines changed: 25 additions & 26 deletions

File tree

java/ql/lib/semmle/code/java/ControlFlowGraph.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,17 @@ private module ControlFlowGraphImpl {
447447
* Gets the `i`th `PatternCase` defined on `switch`, if one exists.
448448
*/
449449
private PatternCase getPatternCase(StmtParent switch, int i) {
450-
result = rank[i + 1](PatternCase pc, int caseIdx | pc = getCase(switch, caseIdx) | pc order by caseIdx asc)
450+
result =
451+
rank[i + 1](PatternCase pc, int caseIdx | pc = getCase(switch, caseIdx) | pc order by caseIdx)
451452
}
452453

453454
/**
454455
* Gets the PatternCase after pc, if one exists.
455456
*/
456457
private PatternCase getNextPatternCase(PatternCase pc) {
457-
exists(int idx, StmtParent switch | pc = getPatternCase(switch, idx) and result = getPatternCase(switch, idx + 1))
458+
exists(int idx, StmtParent switch |
459+
pc = getPatternCase(switch, idx) and result = getPatternCase(switch, idx + 1)
460+
)
458461
}
459462

460463
/**

java/ql/lib/semmle/code/java/Expr.qll

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,9 +1558,7 @@ class SwitchExpr extends Expr, StmtParent, @switchexpr {
15581558
/** An `instanceof` expression. */
15591559
class InstanceOfExpr extends Expr, @instanceofexpr {
15601560
/** Gets the expression on the left-hand side of the `instanceof` operator. */
1561-
Expr getExpr() {
1562-
result.isNthChildOf(this, 0)
1563-
}
1561+
Expr getExpr() { result.isNthChildOf(this, 0) }
15641562

15651563
/**
15661564
* Gets the pattern of an `x instanceof T pattern` expression, if any.
@@ -2558,7 +2556,5 @@ class RecordPatternExpr extends Expr, @recordpatternexpr {
25582556

25592557
override string getAPrimaryQlClass() { result = "RecordPatternExpr" }
25602558

2561-
Pattern getSubPattern(int i) {
2562-
result.isNthChildOf(this, i)
2563-
}
2559+
Pattern getSubPattern(int i) { result.isNthChildOf(this, i) }
25642560
}

java/ql/lib/semmle/code/java/PrettyPrintAst.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,9 @@ private class PpSwitchCase extends PpAst, SwitchCase {
770770

771771
private int lastConstCaseValueIndex() {
772772
result =
773-
1 + 2 * (max(int j | j = 0 or exists(this.(ConstCase).getValue(j))) + this.getCaseDefaultOffset())
773+
1 +
774+
2 *
775+
(max(int j | j = 0 or exists(this.(ConstCase).getValue(j))) + this.getCaseDefaultOffset())
774776
}
775777

776778
override PpAst getChild(int i) {

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowUtil.qll

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,11 @@ predicate simpleAstFlowStep(Expr e1, Expr e2) {
191191
or
192192
e2.(WhenExpr).getBranch(_).getAResult() = e1
193193
or
194-
exists(SwitchExpr se |
195-
e1 = se.getExpr() and e2 = se.getACase().(PatternCase).getPattern()
196-
)
194+
exists(SwitchExpr se | e1 = se.getExpr() and e2 = se.getACase().(PatternCase).getPattern())
197195
or
198-
exists(SwitchStmt ss |
199-
e1 = ss.getExpr() and e2 = ss.getACase().(PatternCase).getPattern()
200-
)
196+
exists(SwitchStmt ss | e1 = ss.getExpr() and e2 = ss.getACase().(PatternCase).getPattern())
201197
or
202-
exists(InstanceOfExpr ioe |
203-
e1 = ioe.getExpr() and e2 = ioe.getPattern()
204-
)
198+
exists(InstanceOfExpr ioe | e1 = ioe.getExpr() and e2 = ioe.getPattern())
205199
}
206200

207201
private predicate simpleLocalFlowStep0(Node node1, Node node2) {

java/ql/test/library-tests/pattern-instanceof/dfg.ql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import java
2-
32
import semmle.code.java.controlflow.Guards
43
import semmle.code.java.dataflow.DataFlow
54

@@ -12,9 +11,13 @@ private predicate isSafe(Guard g, Expr checked, boolean branch) {
1211
}
1312

1413
module TestConfig implements DataFlow::ConfigSig {
15-
predicate isSource(DataFlow::Node source) { source.asExpr() = any(MethodCall mc | mc.getMethod().getName() = "source") }
14+
predicate isSource(DataFlow::Node source) {
15+
source.asExpr() = any(MethodCall mc | mc.getMethod().getName() = "source")
16+
}
1617

17-
predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(MethodCall mc | mc.getMethod().getName() = "sink").getAnArgument() }
18+
predicate isSink(DataFlow::Node sink) {
19+
sink.asExpr() = any(MethodCall mc | mc.getMethod().getName() = "sink").getAnArgument()
20+
}
1821

1922
predicate isBarrier(DataFlow::Node node) {
2023
node = DataFlow::BarrierGuard<isSafe/3>::getABarrierNode()
@@ -26,4 +29,3 @@ module Flow = DataFlow::Global<TestConfig>;
2629
from DataFlow::Node source, DataFlow::Node sink
2730
where Flow::flow(source, sink)
2831
select source, sink
29-

java/ql/test/library-tests/pattern-switch/dfg/test.ql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import java
2-
32
import semmle.code.java.controlflow.Guards
43
import semmle.code.java.dataflow.DataFlow
54

@@ -12,9 +11,13 @@ private predicate isSafe(Guard g, Expr checked, boolean branch) {
1211
}
1312

1413
module TestConfig implements DataFlow::ConfigSig {
15-
predicate isSource(DataFlow::Node source) { source.asExpr() instanceof StringLiteral or source.asParameter().getCallable().hasName("test") }
14+
predicate isSource(DataFlow::Node source) {
15+
source.asExpr() instanceof StringLiteral or source.asParameter().getCallable().hasName("test")
16+
}
1617

17-
predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(MethodCall mc | mc.getMethod().getName() = "sink").getAnArgument() }
18+
predicate isSink(DataFlow::Node sink) {
19+
sink.asExpr() = any(MethodCall mc | mc.getMethod().getName() = "sink").getAnArgument()
20+
}
1821

1922
predicate isBarrier(DataFlow::Node node) {
2023
node = DataFlow::BarrierGuard<isSafe/3>::getABarrierNode()
@@ -26,4 +29,3 @@ module Flow = DataFlow::Global<TestConfig>;
2629
from DataFlow::Node source, DataFlow::Node sink
2730
where Flow::flow(source, sink)
2831
select source, sink
29-

0 commit comments

Comments
 (0)