Skip to content

Commit e58094c

Browse files
committed
Javascript: Autoformat.
1 parent 28261d6 commit e58094c

File tree

472 files changed

+1723
-1834
lines changed

Some content is hidden

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

472 files changed

+1723
-1834
lines changed

javascript/ql/src/AngularJS/IncompatibleService.ql

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,25 @@ predicate isCompatibleRequestedService(InjectableFunctionServiceRequest request,
6767
isWildcardKind(kind)
6868
or
6969
(
70-
(
71-
isServiceDirectiveOrFilterFunction(request) or
72-
isRunMethod(request) or
73-
isControllerFunction(request)
74-
) and
75-
(
76-
kind = "value" or
77-
kind = "service" or
78-
kind = "factory" or
79-
kind = "constant" or
80-
kind = "provider-value"
81-
)
82-
)
83-
or
70+
isServiceDirectiveOrFilterFunction(request) or
71+
isRunMethod(request) or
72+
isControllerFunction(request)
73+
) and
8474
(
85-
isControllerFunction(request) and
86-
kind = "controller-only"
75+
kind = "value" or
76+
kind = "service" or
77+
kind = "factory" or
78+
kind = "constant" or
79+
kind = "provider-value"
8780
)
8881
or
82+
isControllerFunction(request) and
83+
kind = "controller-only"
84+
or
85+
isConfigMethod(request) and
8986
(
90-
isConfigMethod(request) and
91-
(
92-
kind = "constant" or
93-
kind = "provider"
94-
)
87+
kind = "constant" or
88+
kind = "provider"
9589
)
9690
}
9791

@@ -105,19 +99,19 @@ string getServiceKind(InjectableFunctionServiceRequest request, string serviceNa
10599
exists(CustomServiceDefinition custom |
106100
id = custom.getServiceReference() and
107101
(
108-
(custom instanceof ValueRecipeDefinition and result = "value")
102+
custom instanceof ValueRecipeDefinition and result = "value"
109103
or
110-
(custom instanceof ServiceRecipeDefinition and result = "service")
104+
custom instanceof ServiceRecipeDefinition and result = "service"
111105
or
112-
(custom instanceof FactoryRecipeDefinition and result = "factory")
106+
custom instanceof FactoryRecipeDefinition and result = "factory"
113107
or
114-
(custom instanceof DecoratorRecipeDefinition and result = "decorator")
108+
custom instanceof DecoratorRecipeDefinition and result = "decorator"
115109
or
116-
(custom instanceof ConstantRecipeDefinition and result = "constant")
110+
custom instanceof ConstantRecipeDefinition and result = "constant"
117111
or
118112
(
119113
custom instanceof ProviderRecipeDefinition and
120-
if (serviceName.matches("%Provider"))
114+
if serviceName.matches("%Provider")
121115
then result = "provider"
122116
else result = "provider-value"
123117
)
@@ -145,25 +139,17 @@ where
145139
compatibleKind
146140
).regexpReplaceAll(",(?=[^,]+$)", " or") and
147141
(
148-
(
149-
isServiceDirectiveOrFilterFunction(request) and
150-
componentDescriptionString = "Components such as services, directives, filters, and animations"
151-
)
142+
isServiceDirectiveOrFilterFunction(request) and
143+
componentDescriptionString = "Components such as services, directives, filters, and animations"
152144
or
153-
(
154-
isControllerFunction(request) and
155-
componentDescriptionString = "Controllers"
156-
)
145+
isControllerFunction(request) and
146+
componentDescriptionString = "Controllers"
157147
or
158-
(
159-
isRunMethod(request) and
160-
componentDescriptionString = "Run methods"
161-
)
148+
isRunMethod(request) and
149+
componentDescriptionString = "Run methods"
162150
or
163-
(
164-
isConfigMethod(request) and
165-
componentDescriptionString = "Config methods"
166-
)
151+
isConfigMethod(request) and
152+
componentDescriptionString = "Config methods"
167153
)
168154
select request,
169155
"'" + name + "' is a dependency of kind '" + kind + "', and cannot be injected here. " +

javascript/ql/src/Comments/CommentedOut.qll

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,34 @@ import semmle.javascript.Comments
66
private string getALineOfCommentedOutCode(Comment c) {
77
result = c.getLine(_) and
88
// line ends with ';', '{', or '}', optionally followed by a comma,
9-
((result.regexpMatch(".*[;{}],?\\s*") and
9+
(
10+
result.regexpMatch(".*[;{}],?\\s*") and
1011
// but it doesn't look like a JSDoc-like annotation
1112
not result.regexpMatch(".*@\\w+\\s*\\{.*\\}\\s*") and
1213
// and it does not contain three consecutive words (which is uncommon in code)
13-
not result.regexpMatch("[^'\\\"]*\\w\\s++\\w++\\s++\\w[^'\\\"]*")) or
14-
// line is part of a block comment and ends with something that looks
15-
// like a line comment; character before '//' must not be ':' to
16-
// avoid matching URLs
17-
(not c instanceof SlashSlashComment and
18-
result.regexpMatch("(.*[^:]|^)//.*[^/].*")) or
19-
// similar, but don't be fooled by '//// this kind of comment' and
20-
// '//// this kind of comment ////'
21-
(c instanceof SlashSlashComment and
22-
result.regexpMatch("/*([^/].*[^:]|[^:/])//.*[^/].*") and
23-
// exclude externalization comments
24-
not result.regexpMatch(".*\\$NON-NLS-\\d+\\$.*")))
14+
not result.regexpMatch("[^'\\\"]*\\w\\s++\\w++\\s++\\w[^'\\\"]*")
15+
or
16+
// line is part of a block comment and ends with something that looks
17+
// like a line comment; character before '//' must not be ':' to
18+
// avoid matching URLs
19+
not c instanceof SlashSlashComment and
20+
result.regexpMatch("(.*[^:]|^)//.*[^/].*")
21+
or
22+
// similar, but don't be fooled by '//// this kind of comment' and
23+
// '//// this kind of comment ////'
24+
c instanceof SlashSlashComment and
25+
result.regexpMatch("/*([^/].*[^:]|[^:/])//.*[^/].*") and
26+
// exclude externalization comments
27+
not result.regexpMatch(".*\\$NON-NLS-\\d+\\$.*")
28+
)
2529
}
2630

2731
/**
2832
* Holds if `c` is a comment containing code examples, and hence should be
2933
* disregarded when looking for commented-out code.
3034
*/
3135
private predicate containsCodeExample(Comment c) {
32-
exists (string text | text = c.getText() |
36+
exists(string text | text = c.getText() |
3337
text.matches("%<pre>%</pre>%") or
3438
text.matches("%<code>%</code>%") or
3539
text.matches("%@example%") or
@@ -43,19 +47,19 @@ private predicate containsCodeExample(Comment c) {
4347
* preceding it, if any, does not.
4448
*/
4549
private Comment getCommentInRun(File f, Comment c) {
46-
exists (int n |
50+
exists(int n |
4751
c.onLines(f, n, _) and
4852
countCommentedOutLines(c) > 0 and
49-
not exists (Comment d | d.onLines(f, _, n-1) |
50-
countCommentedOutLines(d) > 0
51-
)
53+
not exists(Comment d | d.onLines(f, _, n - 1) | countCommentedOutLines(d) > 0)
5254
) and
53-
(result = c or
54-
exists (Comment prev, int n |
55-
prev = getCommentInRun(f, c) and
56-
prev.onLines(f, _, n) and
57-
result.onLines(f, n+1, _)
58-
)
55+
(
56+
result = c
57+
or
58+
exists(Comment prev, int n |
59+
prev = getCommentInRun(f, c) and
60+
prev.onLines(f, _, n) and
61+
result.onLines(f, n + 1, _)
62+
)
5963
)
6064
}
6165

@@ -68,9 +72,7 @@ private Comment getRelevantCommentInRun(Comment c) {
6872
}
6973

7074
/** Gets the number of lines in comment `c` that look like commented-out code. */
71-
private int countCommentedOutLines(Comment c) {
72-
result = count(getALineOfCommentedOutCode(c))
73-
}
75+
private int countCommentedOutLines(Comment c) { result = count(getALineOfCommentedOutCode(c)) }
7476

7577
/** Gets the number of non-blank lines in comment `c`. */
7678
private int countNonBlankLines(Comment c) {
@@ -98,31 +100,27 @@ private int countNonBlankLinesInRun(Comment c) {
98100
* `hasLocationInfo` implementation that assigns it the entire run as its location.
99101
*/
100102
class CommentedOutCode extends Comment {
101-
CommentedOutCode(){
103+
CommentedOutCode() {
102104
exists(int codeLines, int nonBlankLines |
103105
countCommentedOutLines(this) > 0 and
104106
not exists(Comment prev | this = getCommentInRun(_, prev) and this != prev) and
105107
nonBlankLines = countNonBlankLinesInRun(this) and
106108
codeLines = countCommentedOutLinesInRun(this) and
107109
nonBlankLines > 0 and
108-
2*codeLines > nonBlankLines
110+
2 * codeLines > nonBlankLines
109111
)
110112
}
111113

112114
/**
113115
* Gets the number of lines in this run of comments
114116
* that look like they contain commented-out code.
115117
*/
116-
int getNumCodeLines() {
117-
result = countCommentedOutLinesInRun(this)
118-
}
118+
int getNumCodeLines() { result = countCommentedOutLinesInRun(this) }
119119

120120
/**
121121
* Gets the number of non-blank lines in this run of comments.
122122
*/
123-
int getNumNonBlankLines() {
124-
result = countNonBlankLinesInRun(this)
125-
}
123+
int getNumNonBlankLines() { result = countNonBlankLinesInRun(this) }
126124

127125
/**
128126
* Holds if this element is at the specified location.
@@ -131,18 +129,20 @@ class CommentedOutCode extends Comment {
131129
* For more information, see
132130
* [LGTM locations](https://lgtm.com/help/ql/locations).
133131
*/
134-
predicate hasLocationInfo(string filepath, int startline, int startcolumn, int endline, int endcolumn) {
135-
exists (Location loc, File f | loc = getLocation() and f = loc.getFile() |
132+
predicate hasLocationInfo(
133+
string filepath, int startline, int startcolumn, int endline, int endcolumn
134+
) {
135+
exists(Location loc, File f | loc = getLocation() and f = loc.getFile() |
136136
filepath = f.getAbsolutePath() and
137137
startline = loc.getStartLine() and
138138
startcolumn = loc.getStartColumn() and
139139
exists(Location last |
140140
last = getCommentInRun(f, this).getLocation() and
141-
last.getEndLine() = max(getCommentInRun(f, this).getLocation().getEndLine()) |
141+
last.getEndLine() = max(getCommentInRun(f, this).getLocation().getEndLine())
142+
|
142143
endline = last.getEndLine() and
143144
endcolumn = last.getEndColumn()
144145
)
145146
)
146147
}
147148
}
148-

javascript/ql/src/Comments/CommentedOutCode.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ predicate isFlowAnnotation(SlashStarComment c) {
2323

2424
from CommentedOutCode c
2525
where not isFlowAnnotation(c)
26-
select c, "This comment appears to contain commented-out code."
26+
select c, "This comment appears to contain commented-out code."

javascript/ql/src/Comments/FCommentedOutCode.ql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@
1313
import CommentedOut
1414

1515
from File f
16-
select f, sum(CommentedOutCode comment |
17-
comment.getFile() = f |
18-
comment.getNumCodeLines())
16+
select f, sum(CommentedOutCode comment | comment.getFile() = f | comment.getNumCodeLines())

javascript/ql/src/Comments/TodoComments.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ import javascript
1414

1515
from Comment c
1616
where c.getText().regexpMatch("(?s).*FIXME.*|.*TODO.*|.*(?<!=)\\s*XXX.*")
17-
select c, "TODO comments should be addressed."
17+
select c, "TODO comments should be addressed."

javascript/ql/src/Declarations/DeadStoreOfProperty.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ predicate postDominatedPropWrite(
5757
*/
5858
bindingset[name]
5959
predicate maybeAccessesProperty(Expr e, string name) {
60-
(e.(PropAccess).getPropertyName() = name and e instanceof RValue)
60+
e.(PropAccess).getPropertyName() = name and e instanceof RValue
6161
or
6262
// conservatively reject all side-effects
6363
e.isImpure()

javascript/ql/src/Expressions/BadParityCheck.ql

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,14 @@ where
9292
me.getRightOperand().getIntValue() = 2 and
9393
maybeNegative(me.getLeftOperand()) and
9494
(
95-
(
96-
(cmp instanceof EqExpr or cmp instanceof StrictEqExpr) and
97-
num = 1 and
98-
parity = "oddness"
99-
)
95+
(cmp instanceof EqExpr or cmp instanceof StrictEqExpr) and
96+
num = 1 and
97+
parity = "oddness"
10098
or
101-
(
102-
(cmp instanceof NEqExpr or cmp instanceof StrictNEqExpr) and
103-
num = 1 and
104-
parity = "evenness"
105-
)
99+
(cmp instanceof NEqExpr or cmp instanceof StrictNEqExpr) and
100+
num = 1 and
101+
parity = "evenness"
106102
or
107-
(cmp instanceof GTExpr and num = 0 and parity = "oddness")
103+
cmp instanceof GTExpr and num = 0 and parity = "oddness"
108104
)
109105
select cmp, "Test for " + parity + " does not take negative numbers into account."

javascript/ql/src/Expressions/ComparisonWithNaN.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
import javascript
1616

1717
from Comparison cmp
18-
where (cmp.getAnOperand().(GlobalVarAccess)).getName() = "NaN"
18+
where cmp.getAnOperand().(GlobalVarAccess).getName() = "NaN"
1919
select cmp, "Useless comparison with NaN."

javascript/ql/src/Expressions/ExprHasNoEffect.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ predicate inVoidContext(Expr e) {
3030
or
3131
// if the toplevel in its entirety is of the form `({ ... })`,
3232
// it is probably a configuration object (e.g., a require.js build configuration)
33-
(tl.getNumChildStmt() = 1 and e.stripParens() instanceof ObjectExpr)
33+
tl.getNumChildStmt() = 1 and e.stripParens() instanceof ObjectExpr
3434
)
3535
)
3636
or

javascript/ql/src/Expressions/HapaxLegomenon.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract class Hapax extends @expr {
3636
abstract string getName();
3737

3838
/** Gets a textual representation of this element. */
39-
string toString() { result = (this.(Expr)).toString() }
39+
string toString() { result = this.(Expr).toString() }
4040
}
4141

4242
/**

0 commit comments

Comments
 (0)