Skip to content

Commit 1fddfbd

Browse files
committed
Suggestions
1 parent 06fd77c commit 1fddfbd

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/RandomGeneratorRules.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ static final class RandomGeneratorNextDouble {
3232
}
3333

3434
/**
35-
* Prefer {@link RandomGenerator#nextDouble(double origin, double bound)} over more contrived
36-
* alternatives.
35+
* Prefer {@link RandomGenerator#nextDouble(double origin, double bound)} over alternatives that
36+
* may silently yield an ununiform domain of values.
3737
*/
38+
// XXX: This rule assumes that `a` is not an expensive or side-effectful expression.
39+
// XXX: The replacement code throws an `IllegalArgumentException` in more cases than the original
40+
// code, but only in situations that are likely unintended.
3841
static final class RandomGeneratorNextDoubleWithOrigin {
3942
@BeforeTemplate
4043
double before(RandomGenerator random, double a, double b) {
@@ -63,8 +66,12 @@ int after(RandomGenerator random, int bound) {
6366
}
6467

6568
/**
66-
* Prefer {@link RandomGenerator#nextInt(int origin, int bound)} over more contrived alternatives.
69+
* Prefer {@link RandomGenerator#nextInt(int origin, int bound)} over alternatives that may
70+
* silently yield values outside the intended domain.
6771
*/
72+
// XXX: This rule assumes that `a` is not an expensive or side-effectful expression.
73+
// XXX: The replacement code throws an `IllegalArgumentException` in more cases than the original
74+
// code, but only in situations that are likely unintended.
6875
static final class RandomGeneratorNextIntWithOrigin {
6976
@BeforeTemplate
7077
int before(RandomGenerator random, int a, int b) {
@@ -111,6 +118,9 @@ long after(RandomGenerator random, long bound) {
111118
* Prefer {@link RandomGenerator#nextLong(long origin, long bound)} over more contrived
112119
* alternatives.
113120
*/
121+
// XXX: This rule assumes that `a` is not an expensive or side-effectful expression.
122+
// XXX: The replacement code throws an `IllegalArgumentException` in more cases than the original
123+
// code, but only in situations that are likely unintended.
114124
static final class RandomGeneratorNextLongWithOrigin {
115125
@BeforeTemplate
116126
long before(RandomGenerator random, long a, long b) {

refaster-support/src/main/java/tech/picnic/errorprone/refaster/matchers/RequiresComputation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import com.sun.source.tree.TypeCastTree;
1515
import com.sun.source.tree.UnaryTree;
1616

17-
/** A matcher of expressions that may a non-trivial amount of computation. */
17+
/** A matcher of expressions that may require a non-trivial amount of computation. */
1818
public final class RequiresComputation implements Matcher<ExpressionTree> {
1919
private static final long serialVersionUID = 1L;
2020

0 commit comments

Comments
 (0)