Skip to content

Commit 3d00a61

Browse files
authored
Merge pull request #10528 from erik-krogh/java-followMsg
Java: Update the alert messages to better follow the style guide
2 parents 47e5623 + 39ffa55 commit 3d00a61

File tree

137 files changed

+1596
-1588
lines changed

Some content is hidden

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

137 files changed

+1596
-1588
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ where
3434
bean1.getBeanIdentifier() < bean2.getBeanIdentifier() and
3535
bean1 != bean2
3636
select bean1,
37-
"Bean $@ has " + similarProps.toString() +
37+
"This bean has " + similarProps.toString() +
3838
" properties similar to $@. Consider introducing a common parent bean for these two beans.",
39-
bean1, bean1.getBeanIdentifier(), bean2, bean2.getBeanIdentifier()
39+
bean2, bean2.getBeanIdentifier()

java/ql/src/Frameworks/Spring/Violations of Best Practice/ParentShouldNotUseAbstractClass.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ class ParentBean extends SpringBean {
2626

2727
from ParentBean parent
2828
where parent.getDeclaredClass().isAbstract()
29-
select parent, "Parent bean $@ should not have an abstract class.", parent,
30-
parent.getBeanIdentifier()
29+
select parent, "This parent bean should not have an abstract class."

java/ql/src/Language Abuse/UselessNullCheck.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ where
2121
e = clearlyNotNullExpr(reason) and
2222
(
2323
if reason instanceof Guard
24-
then msg = "This check is useless, $@ cannot be null here, since it is guarded by $@."
24+
then msg = "This check is useless. $@ cannot be null at this check, since it is guarded by $@."
2525
else
2626
if reason != e
27-
then msg = "This check is useless, $@ cannot be null here, since $@ always is non-null."
27+
then
28+
msg = "This check is useless. $@ cannot be null at this check, since $@ always is non-null."
2829
else msg = "This check is useless, since $@ always is non-null."
2930
)
3031
select guard, msg, e, e.toString(), reason, reason.toString()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ where
7272
remove.getCallee().hasName("remove") and
7373
iterOfSpecialCollection(remove.getQualifier(), scc)
7474
select remove,
75-
"This call may fail when iterating over the collection created $@, since it does not support element removal.",
76-
scc, "here"
75+
"This call may fail when iterating over $@, since it does not support element removal.", scc,
76+
"the collection"

java/ql/src/Likely Bugs/Comparison/MissingInstanceofInEquals.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ where
7777
// Exclude `equals` methods that implement reference-equality.
7878
not m instanceof ReferenceEquals and
7979
not m instanceof UnimplementedEquals
80-
select m, "equals() method does not check argument type."
80+
select m, "This 'equals()' method does not check argument type."

java/ql/src/Likely Bugs/Comparison/WrongNanComparison.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ where
2121
eq.getAnOperand() = f.getAnAccess() and nanField(f) and f.getDeclaringType().hasName(classname)
2222
select eq,
2323
"This comparison will always yield the same result since 'NaN != NaN'. Consider using " +
24-
classname + ".isNaN instead"
24+
classname + ".isNaN instead."

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ where
2323
ma.getEnclosingStmt().getEnclosingStmt*() instanceof SynchronizedStmt or
2424
ma.getEnclosingCallable().isSynchronized()
2525
)
26-
select ma, "sleep() with lock held."
26+
select ma, "This calls 'Thread.sleep()' with a lock held."

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ where
2727
ma.getMethod().getDeclaringType().hasQualifiedName("java.lang", "Object") and
2828
ma.getEnclosingStmt().getEnclosingStmt*() = synch and
2929
synch.getEnclosingStmt+() instanceof Synched
30-
select ma, "wait() with two locks held."
30+
select ma, "This calls 'Object.wait()' with two locks held."

java/ql/src/Likely Bugs/Likely Typos/ContradictoryTypeChecks.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ predicate contradictoryTypeCheck(Expr e, Variable v, RefType t, RefType sup, Exp
4646

4747
from Expr e, Variable v, RefType t, RefType sup, Expr cond
4848
where contradictoryTypeCheck(e, v, t, sup, cond)
49-
select e, "Variable $@ cannot be of type $@ here, since $@ ensures that it is not of type $@.", v,
49+
select e, "This access of $@ cannot be of type $@, since $@ ensures that it is not of type $@.", v,
5050
v.getName(), t, t.getName(), cond, "this expression", sup, sup.getName()

java/ql/src/Likely Bugs/Likely Typos/SelfAssignment.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,4 @@ predicate sameVariable(VarAccess left, VarAccess right) {
4545
from AssignExpr assign
4646
where sameVariable(assign.getDest(), assign.getSource())
4747
select assign,
48-
"This assigns the variable " + assign.getDest().(VarAccess).getVariable().getName() +
49-
" to itself and has no effect."
48+
"This expression assigns " + assign.getDest().(VarAccess).getVariable().getName() + " to itself."

0 commit comments

Comments
 (0)