Skip to content

Commit 766b07b

Browse files
committed
Java: Adjust comment style.
1 parent dd5a8f0 commit 766b07b

File tree

8 files changed

+41
-71
lines changed

8 files changed

+41
-71
lines changed

java/ql/src/Architecture/Dependencies/UnusedMavenDependencyBinary.ql

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,31 @@
99

1010
import UnusedMavenDependencies
1111

12-
/*
12+
/**
1313
* A whitelist of binary dependencies that should never be highlighted as unusued.
1414
*/
1515
predicate whitelist(Dependency d) {
16-
/*
17-
* jsr305 contains package annotations. If a project uses those exclusively, we will
18-
* consider it "unused".
19-
*/
16+
// jsr305 contains package annotations. If a project uses those exclusively, we will
17+
// consider it "unused".
2018
d.getShortCoordinate() = "com.google.code.findbugs:jsr305"
2119
}
2220

2321
from PomDependency d, Pom source
2422
where
2523
source.getADependency() = d and
26-
/*
27-
* There is not a Pom file for the target of this dependency, so we assume that it was resolved by
28-
* a binary file in the local maven repository.
29-
*/
24+
// There is not a Pom file for the target of this dependency, so we assume that it was resolved by
25+
// a binary file in the local maven repository.
3026
not exists(Pom target | target = d.getPom()) and
31-
/*
32-
* In order to accurately identify whether this binary dependency is required, we must have identified
33-
* a Maven repository. If we have not found a repository, it's likely that it has a custom path of
34-
* which we are unaware, so do not report any problems.
35-
*/
27+
// In order to accurately identify whether this binary dependency is required, we must have identified
28+
// a Maven repository. If we have not found a repository, it's likely that it has a custom path of
29+
// which we are unaware, so do not report any problems.
3630
exists(MavenRepo mr) and
37-
/*
38-
* We either haven't indexed a relevant jar file, which suggests that nothing statically depended upon
39-
* it, or we have indexed the relevant jar file, but no source code in the project defined by the pom
40-
* depends on any code within the detected jar.
41-
*/
31+
// We either haven't indexed a relevant jar file, which suggests that nothing statically depended upon
32+
// it, or we have indexed the relevant jar file, but no source code in the project defined by the pom
33+
// depends on any code within the detected jar.
4234
not pomDependsOnContainer(source, d.getJar()) and
43-
/*
44-
* If something that depends on us depends on the jar represented by this dependency, and it doesn't
45-
* depend directly on the jar itself, we don't consider it to be "unused".
46-
*/
35+
// If something that depends on us depends on the jar represented by this dependency, and it doesn't
36+
// depend directly on the jar itself, we don't consider it to be "unused".
4737
not exists(Pom pomThatDependsOnSource |
4838
pomThatDependsOnSource.getAnExportedPom+() = source
4939
|

java/ql/src/Architecture/Dependencies/UnusedMavenDependencySource.ql

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@ import UnusedMavenDependencies
1414
from PomDependency d, Pom source, Pom target
1515
where
1616
source.getADependency() = d and
17-
/*
18-
* We have a targetPom file, so this is a "source" dependency, rather than a binary dependency
19-
* from the Maven repository. Note, although .pom files exist in the local maven repository, they
20-
* are usually not indexed because they are outside the source directory. We assume that they have
21-
* not been indexed.
22-
*/
17+
// We have a targetPom file, so this is a "source" dependency, rather than a binary dependency
18+
// from the Maven repository. Note, although .pom files exist in the local maven repository, they
19+
// are usually not indexed because they are outside the source directory. We assume that they have
20+
// not been indexed.
2321
target = d.getPom() and
24-
/*
25-
* If we have a pom for the target of this dependency, then it is unused iff neither it, nor any
26-
* of its transitive dependencies are required.
27-
*/
22+
// If we have a pom for the target of this dependency, then it is unused iff neither it, nor any
23+
// of its transitive dependencies are required.
2824
not exists(Pom exported |
2925
exported = target.getAnExportedPom*()
3026
|

java/ql/src/DeadCode/DeadClass.ql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ where
2626
// Never accessed outside this class, so it's entirely unused.
2727
reason = " is entirely unused."
2828
else
29-
/*
30-
* There are no dead roots outside the class, but the class has a possible liveness cause
31-
* external to the class, so it must be accessed from at least one dead-code cycle.
32-
*/
29+
// There are no dead roots outside the class, but the class has a possible liveness cause
30+
// external to the class, so it must be accessed from at least one dead-code cycle.
3331
reason = " is only used from or in a dead-code cycle."
3432
)
3533
select c, "The class " + c.getName() + reason, origin, origin.getName()

java/ql/src/DeadCode/FLinesOfDeadCode.ql

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,18 @@ where
1818
// Lines of code contributed by dead classes.
1919
sum(DeadClass deadClass | deadClass.getFile() = f |
2020
deadClass.getNumberOfLinesOfCode() -
21-
/*
22-
* Remove inner and local classes, as they are reported as separate dead classes. Do not
23-
* remove anonymous classes, because they aren't reported separately.
24-
*/
21+
// Remove inner and local classes, as they are reported as separate dead classes. Do not
22+
// remove anonymous classes, because they aren't reported separately.
2523
sum(NestedClass innerClass | innerClass.getEnclosingType() = deadClass and not innerClass.isAnonymous() |
2624
innerClass.getNumberOfLinesOfCode()
2725
)
2826
) +
2927
// Lines of code contributed by dead methods, not in dead classes.
3028
sum(DeadMethod deadMethod | deadMethod.getFile() = f and not deadMethod.isInDeadScope() |
3129
deadMethod.getNumberOfLinesOfCode() -
32-
/*
33-
* Remove local classes defined in the dead method - they are reported separately as a dead
34-
* class. We keep anonymous class counts, because anonymous classes are not reported
35-
* separately.
36-
*/
30+
// Remove local classes defined in the dead method - they are reported separately as a dead
31+
// class. We keep anonymous class counts, because anonymous classes are not reported
32+
// separately.
3733
sum(LocalClass localClass | localClass.getLocalClassDeclStmt().getEnclosingCallable() = deadMethod |
3834
localClass.getNumberOfLinesOfCode()
3935
)

java/ql/src/Frameworks/Spring/Architecture/Refactoring Opportunities/UnusedBean.ql

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ class ImpureStmt extends Stmt {
4040
exists(Expr e |
4141
e.getEnclosingStmt() = this
4242
|
43-
/*
44-
* Only permit calls to set of whitelisted targets.
45-
*/
43+
// Only permit calls to set of whitelisted targets.
4644
(
4745
e instanceof Call and
4846
not e.(Call).getCallee().getDeclaringType().hasQualifiedName("java.util", "Collections")
@@ -73,10 +71,8 @@ private Stmt getANestedStmt(Block block) {
7371
class SpringPureClass extends Class {
7472
SpringPureClass() {
7573
(
76-
/*
77-
* The only permitted statement in static initializers is the initialization of a static
78-
* final or effectively final logger fields, or effectively immutable types.
79-
*/
74+
// The only permitted statement in static initializers is the initialization of a static
75+
// final or effectively final logger fields, or effectively immutable types.
8076
forall(Stmt s |
8177
s = getANestedStmt(getAMember().(StaticInitializer).getBody())
8278
|
@@ -164,11 +160,9 @@ class LiveSpringBean extends SpringBean {
164160
not getClass() instanceof SpringPureClass
165161
) or
166162
(
167-
/*
168-
* If the class does not exist for this bean, or the class is not a source bean, then this is
169-
* likely to be a definition using a library class, in which case we should consider it to be
170-
* live.
171-
*/
163+
// If the class does not exist for this bean, or the class is not a source bean, then this is
164+
// likely to be a definition using a library class, in which case we should consider it to be
165+
// live.
172166
not exists(getClass()) or
173167
not getClass().fromSource() or
174168
// In alfresco, "webscript" beans should be considered live

java/ql/src/Likely Bugs/Collections/ReadOnlyContainer.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ where
2727
forall(VarAccess va | va = v.getAnAccess() |
2828
// ...an assignment storing a fresh container into `v`,
2929
exists(AssignExpr assgn | va = assgn.getDest() | assgn.getSource() instanceof FreshContainer) or
30-
/// ...a return (but only if `v` is a local variable)
30+
// ...a return (but only if `v` is a local variable)
3131
(v instanceof LocalVariableDecl and exists(ReturnStmt ret | ret.getResult() = va)) or
3232
// ...or a call to a query method on `v`.
3333
exists(MethodAccess ma | va = ma.getQualifier() | ma.getMethod() instanceof ContainerQueryMethod)

java/ql/src/Likely Bugs/Concurrency/UnreleasedLock.ql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,8 @@ predicate blockIsLocked(LockType t, BasicBlock src, BasicBlock b, int locks) {
125125
exists(BasicBlock pred, int predlocks, int curlocks, int failedlock | pred = b.getABBPredecessor() |
126126
// The number of net locks from the `src` block to the predecessor block `pred` is `predlocks`.
127127
blockIsLocked(t, src, pred, predlocks) and
128-
/*
129-
* The recursive call ensures that at least one lock is held, so do not consider the false
130-
* successor of the `isHeldByCurrentThread()` check.
131-
*/
128+
// The recursive call ensures that at least one lock is held, so do not consider the false
129+
// successor of the `isHeldByCurrentThread()` check.
132130
not heldByCurrentThreadCheck(t, pred, b) and
133131
// Count a failed lock as an unlock so the net is zero.
134132
( if failedLock(t, pred, b) then failedlock = 1 else failedlock = 0 ) and

java/ql/src/Likely Bugs/Statements/ImpossibleCast.ql

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,12 @@ where
7979
target.getName() + "[] will always fail with a ClassCastException."
8080
)
8181
or
82-
/*
83-
* For unchecked operations, the crash would not occur at the cast site,
84-
* but only if/when the value is assigned to a variable of different array type.
85-
* This would require tracking the flow of values, but we focus on finding problematic
86-
* APIs. We keep two cases:
87-
* - An array that is actually returned from the (non-private) method, or
88-
* - an array that is assigned to a field returned from another (non-private) method.
89-
*/
82+
// For unchecked operations, the crash would not occur at the cast site,
83+
// but only if/when the value is assigned to a variable of different array type.
84+
// This would require tracking the flow of values, but we focus on finding problematic
85+
// APIs. We keep two cases:
86+
// - An array that is actually returned from the (non-private) method, or
87+
// - an array that is assigned to a field returned from another (non-private) method.
9088
(
9189
uncheckedCastType(target) and
9290
returnedFrom(ce, ce.getEnclosingCallable()) and

0 commit comments

Comments
 (0)