Skip to content

Conversation

mohamedsamehsalah
Copy link
Contributor

@mohamedsamehsalah mohamedsamehsalah commented Aug 10, 2024

Suggested commit message

Introduce `ArraysAsList` Refaster rule (#1275)

@mohamedsamehsalah mohamedsamehsalah added this to the 0.18.0 milestone Aug 10, 2024
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@mohamedsamehsalah mohamedsamehsalah force-pushed the mohamedsamehsalah/arrays-as-list branch from 42321e0 to 2c2d0df Compare August 10, 2024 13:10
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202 Stephan202 changed the title Introduce ArraysAsList refaster rule Introduce ArraysAsList Refaster rule Aug 10, 2024
Copy link
Member

@Stephan202 Stephan202 left a 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!

Comment on lines 135 to 138
@AfterTemplate
List<T> after(T[] array) {
return Arrays.asList(array);
}
Copy link
Member

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();
Copy link
Member

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.)

}

List<String> testArraysAsList() {
return Arrays.stream(new String[] {"foo", "bar"}).toList();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smaller 😄

Suggested change
return Arrays.stream(new String[] {"foo", "bar"}).toList();
return Arrays.stream(new String[0]).toList();

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

@rickie rickie merged commit 363b0c2 into master Aug 10, 2024
@rickie rickie deleted the mohamedsamehsalah/arrays-as-list branch August 10, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants