Skip to content

Commit a31e047

Browse files
Format additional files
1 parent ea173e5 commit a31e047

File tree

3 files changed

+30
-43
lines changed

3 files changed

+30
-43
lines changed

cpp/common/src/codingstandards/cpp/util/CondensedList.qll

+9-11
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ signature module CondensedListSig {
2727
*
2828
* For instance, if connecting variables defined in a file, the index will be the line number of
2929
* the variable in the file.
30-
*
30+
*
3131
* The sparse index (which may have gaps) is used to determine the ordering of the items in the
3232
* condensed list. Once the condensed list is created, the items in the list will automatically be
3333
* assigned a dense index (which has no gaps).
34-
*
34+
*
3535
* There must be no duplicate indices for the same division for correctness.
3636
*/
3737
int getSparseIndex(Division d, Item l);
@@ -40,7 +40,7 @@ signature module CondensedListSig {
4040
/**
4141
* A module to take orderable data (which may not be continuous) and condense it into one or more
4242
* dense lists, with one such list per specified division.
43-
*
43+
*
4444
* To instantiate this module, you need to provide a `CondensedListSig` module that
4545
* specifies the spare index and division of the items to be connected.
4646
*
@@ -67,7 +67,9 @@ signature module CondensedListSig {
6767
module Condense<CondensedListSig Config> {
6868
newtype TList =
6969
THead(Config::Item l, Config::Division t) { denseRank(t, l) = 1 } or
70-
TCons(ListEntry prev, Config::Item l) { prev.getDenseIndex() = denseRank(prev.getDivision(), l) - 1 }
70+
TCons(ListEntry prev, Config::Item l) {
71+
prev.getDenseIndex() = denseRank(prev.getDivision(), l) - 1
72+
}
7173

7274
private module DenseRankConfig implements DenseRankInputSig2 {
7375
class Ranked = Config::Item;
@@ -86,22 +88,18 @@ module Condense<CondensedListSig Config> {
8688
exists(ListEntry prev | this = TCons(prev, _) and result = prev.getDivision())
8789
}
8890

89-
string toString() {
90-
result = getItem().toString() + " [index " + getDenseIndex() + "]"
91-
}
91+
string toString() { result = getItem().toString() + " [index " + getDenseIndex() + "]" }
9292

9393
Config::Item getItem() {
9494
this = THead(result, _)
9595
or
9696
this = TCons(_, result)
9797
}
9898

99-
int getDenseIndex() {
100-
result = denseRank(getDivision(), getItem())
101-
}
99+
int getDenseIndex() { result = denseRank(getDivision(), getItem()) }
102100

103101
ListEntry getPrev() { this = TCons(result, _) }
104102

105103
ListEntry getNext() { result.getPrev() = this }
106104
}
107-
}
105+
}
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
bindingset[this]
22
signature class ItemSig {
3-
bindingset[this]
4-
string toString();
3+
bindingset[this]
4+
string toString();
55
}
66

77
module Pair<ItemSig A, ItemSig B> {
88
signature predicate pred(A a, B b);
99

1010
module Where<pred/2 ctor> {
11-
private newtype TAll = TSome(A a, B b) {
12-
ctor(a, b)
13-
}
11+
private newtype TAll = TSome(A a, B b) { ctor(a, b) }
1412

1513
class Pair extends TAll {
16-
A getFirst() {
17-
this = TSome(result, _)
18-
}
14+
A getFirst() { this = TSome(result, _) }
1915

20-
B getSecond() {
21-
this = TSome(_, result)
22-
}
16+
B getSecond() { this = TSome(_, result) }
2317

24-
string toString() {
25-
result = getFirst().toString() + ", " + getSecond().toString()
26-
}
18+
string toString() { result = getFirst().toString() + ", " + getSecond().toString() }
2719
}
2820
}
29-
}
21+
}

cpp/misra/src/rules/RULE-19-1-1/InvalidTokenInDefinedOperator.ql

+14-17
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,26 @@
1717
import cpp
1818
import codingstandards.cpp.misra
1919

20-
string idRegex() {
21-
result = "[a-zA-Z_]([a-zA-Z_0-9]*)"
22-
}
20+
string idRegex() { result = "[a-zA-Z_]([a-zA-Z_0-9]*)" }
2321

2422
bindingset[body]
2523
predicate hasInvalidDefinedOperator(string body) {
26-
body.regexpMatch(
27-
// Contains text "defined" at a word break
28-
".*\\bdefined" +
29-
// Negative zero width lookahead:
30-
"(?!(" +
31-
// (group) optional whitespace followed by a valid identifier
32-
"(\\s*" + idRegex() + ")" +
33-
// or
34-
"|" +
35-
// (group) optional whitespace followed by parenthesis and valid identifier
36-
"(\\s*\\(\\s*" + idRegex() + "\\s*\\))" +
37-
// End negative zero width lookahead, match remaining text
38-
")).*")
24+
body.regexpMatch(".*\\bdefined" +
25+
// Contains text "defined" at a word break
26+
// Negative zero width lookahead:
27+
"(?!(" +
28+
// (group) optional whitespace followed by a valid identifier
29+
"(\\s*" + idRegex() + ")" +
30+
// or
31+
"|" +
32+
// (group) optional whitespace followed by parenthesis and valid identifier
33+
"(\\s*\\(\\s*" + idRegex() + "\\s*\\))" +
34+
// End negative zero width lookahead, match remaining text
35+
")).*")
3936
}
4037

4138
from PreprocessorIf ifDirective
4239
where
4340
not isExcluded(ifDirective, PreprocessorPackage::invalidTokenInDefinedOperatorQuery()) and
4441
hasInvalidDefinedOperator(ifDirective.getHead())
45-
select ifDirective, "Invalid use of defined operator in if directive."
42+
select ifDirective, "Invalid use of defined operator in if directive."

0 commit comments

Comments
 (0)