-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ArraysAsList
Refaster rule
#1275
Conversation
Looks good. No mutations were possible for these changes. |
42321e0
to
2c2d0df
Compare
Looks good. No mutations were possible for these changes. |
ArraysAsList
refaster ruleArraysAsList
Refaster rule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a commit and tweaked the suggested commit message. Tnx @mohamedsamehsalah!
@AfterTemplate | ||
List<T> after(T[] array) { | ||
return Arrays.asList(array); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This expression doesn't relate to streams, so it shouldn't be in this class.
static final class ArraysAsList<T> { | ||
@BeforeTemplate | ||
List<T> before(@NotMatches(IsRefasterAsVarargs.class) T[] array) { | ||
return Arrays.stream(array).toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add an XXX
to track that we're losing unmodifiability.
(We could also target ImmutableList#copyOf
. For now I'll just make a note about this.)
@@ -86,6 +87,10 @@ Stream<String> testStreamOfArray() { | |||
return Stream.of(new String[] {"foo", "bar"}); | |||
} | |||
|
|||
List<String> testArraysAsList() { | |||
return Arrays.stream(new String[] {"foo", "bar"}).toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smaller 😄
return Arrays.stream(new String[] {"foo", "bar"}).toList(); | |
return Arrays.stream(new String[0]).toList(); |
Looks good. No mutations were possible for these changes. |
Quality Gate passedIssues Measures |
Suggested commit message