Skip to content

Commit

Permalink
Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
rickie committed Sep 20, 2022
1 parent b477ec3 commit 3b28086
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions error-prone-contrib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The following is a list of checks we'd like to see implemented:
`java.util.stream.Collectors` and the various Guava collector factory
methods.
- A check which replaces `new Random().someMethod()` calls with
`ThreadLocalRandom.current().someMethod()` calls, so as to avoid unnecessary
`ThreadLocalRandom.current().someMethod()` calls, to avoid unnecessary
synchronization.
- A check which drops `this.` from `this.someMethod()` calls and which
optionally does the same for fields, if no ambiguity arises.
Expand Down Expand Up @@ -214,7 +214,7 @@ Refaster's expressiveness:
pure expression. Introduce a way to express such a constraint. For example,
rewriting `optional1.map(Optional::of).orElse(optional2)` to
`optional1.or(() -> optional2)` is not behavior preserving if evaluation of
`optional2` has side-effects.
`optional2` has side effects.
- Similarly, certain refactoring operations are only valid if one of the
matched expressions is not `@Nullable`. It'd be nice to be able to express
this.
Expand All @@ -241,36 +241,33 @@ Refaster's expressiveness:
example would be to rewrite `BigDecimal.valueOf("<some-long-value>")` to
`BigDecimal.valueOf(theParsedLongValue)`.
- More generally, investigate ways to plug in fully dynamic behavior, e.g.
by providing hooks which enable plugging in arbitrary predicates/transformations.
The result would be a Refaster/`BugChecker` hybrid. A feature such as this
could form the basis for many other features listed here. (As a
concrete example, consider the ability to reference
`com.google.errorprone.matchers.Matcher` implementations.)
- Provide a way to match lambda expressions and method references which match a
specified functional interface. This would allow rewrites such as
`Mono.fromCallable(this::doesNotThrowCheckException)` ->
`Mono.fromSupplier(this::doesNotThrowCheckException)`.
- Provide an extension API which enables defining methods or expressions based on
functional properties. A motivating example is the Java Collections
by providing hooks which enable plugging in arbitrary predicates/
transformations.
The result would be a Refaster/`BugChecker` hybrid. A feature like this could
form the basis for many other features listed here. (As a concrete example,
consider the ability to reference `com.google.errorprone.matchers.Matcher`
implementations.)
- Provide an extension API that enables defining methods or expressions based
on functional properties. A motivating example is the Java Collections
framework, which allows many ways to define (im)mutable (un)ordered
collections with(out) duplicates. One could then express things like "match
any method call which collects its inputs into an immutable ordered list". An
any method call that collects its inputs into an immutable ordered list". An
enum analogous to `java.util.stream.Collector.Characteristics` could be used.
Out of the box JDK and Guava collection factory methods could be classified,
with the user having the option to extend the classification.
- Refaster currently unconditionally ignores expressions containing comments.
Provide two additional modes: (a) match and drop the comments or (b)
transport the comments to before/after the replaced expression.
- Extend Refaster to drop imports that become unnecessary as a result of a
refactoring. This e.g. allows one to replace a statically import TestNG
refactoring. This e.g. allows one to replace a statically imported TestNG
`fail(...)` invocation with a statically imported equivalent AssertJ
`fail(...)` invocation. (Observe that without an import cleanup this
replacement would cause a compilation error.)
- Extend the `@Repeated` match semantics such that it also covers non-varargs
methods. For a motivating example see google/error-prone#568.
- When matching explicit type references, also match super types. For a
motivating example, see the two subtly different loop definitions in
`CollectionRemoveAllFromCollectionBlock`.
`CollectionRemoveAllFromCollectionExpression`.
- Figure out why Refaster sometimes doesn't match the correct generic overload.
See the `AssertThatIterableHasOneComparableElementEqualTo` template for an
example.
Expand Down

0 comments on commit 3b28086

Please sign in to comment.