Skip to content
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

chore: use List.of where possible if only one argument is passed #2468

Merged
merged 4 commits into from
Nov 2, 2023

Conversation

SimonVerhoeven
Copy link
Contributor

Cleaned up some Arrays.asList that were never adapted/only one arguments, and removed them in case they weren't used at all.

Submitter checklist

  • Recommended: Join WireMock Slack to get any help in #help-contributing or a project-specific channel like #wiremock-java
  • Recommended: If you participate in Hacktoberfest 2023, make sure you're signed up there and in the WireMock form
  • The PR request is well described and justified, including the body and the references
  • The PR title represents the desired changelog entry
  • The repository's code style is followed (see the contributing guide)
  • Test coverage that demonstrates that the change works as expected
  • For new features, there's necessary documentation in this pull request or in a subsequent PR to wiremock.org

@SimonVerhoeven SimonVerhoeven requested a review from a team as a code owner October 29, 2023 13:08
Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

I am fine with a particular suggested refactoring, but many changes here are unrelated to it

@@ -26,20 +26,13 @@ public static String generate(String url, String prefix, String id) {

public static String generate(String url, String prefix, String id, String extension) {
String pathPart = Urls.urlToPathParts(URI.create(url));
pathPart = pathPart.equals("") ? "(root)" : sanitise(pathPart);
pathPart = pathPart.isEmpty() ? "(root)" : sanitise(pathPart);
Copy link
Member

Choose a reason for hiding this comment

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

Ideally should be isBlank() so that we handle more edge cases, but out of the scope for the PR title anyway

@@ -158,7 +158,7 @@ public boolean remove(Object o) {
}

public boolean containsAll(Collection<?> c) {
return data.containsAll(c);
return new HashSet<>(data).containsAll(c);
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

HashSet.containsAll tends to be faster.

Copy link
Member

Choose a reason for hiding this comment

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

Of course, but you would need to iterate through all the elements at least once to form the new collection. It defeats the purpose of this change for most of the cases

@tomakehurst tomakehurst merged commit ae1cc03 into wiremock:master Nov 2, 2023
7 checks passed
henrik242 pushed a commit to henrik242/wiremock that referenced this pull request Nov 10, 2023
…emock#2468)

* chore: use List.of where possible if only one argument is passed

* chore: use isBlank
Marvin9 pushed a commit to Marvin9/wiremock that referenced this pull request Nov 20, 2023
…emock#2468)

* chore: use List.of where possible if only one argument is passed

* chore: use isBlank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants