Skip to content

Commit

Permalink
Use List.of (#1852)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg authored Oct 9, 2023
2 parents 8cdfdd0 + 1ce91c7 commit d346ef8
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -53,17 +51,15 @@ public class KtLintCompat0Dot48Dot0Adapter implements KtLintCompatAdapter {
private static final List<EditorConfigProperty<?>> DEFAULT_EDITOR_CONFIG_PROPERTIES;

static {
List<EditorConfigProperty<?>> list = new ArrayList<>();
list.add(CodeStyleEditorConfigPropertyKt.getCODE_STYLE_PROPERTY());
//noinspection deprecation
list.add(DisabledRulesEditorConfigPropertyKt.getDISABLED_RULES_PROPERTY());
//noinspection KotlinInternalInJava,deprecation
list.add(DisabledRulesEditorConfigPropertyKt.getKTLINT_DISABLED_RULES_PROPERTY());
list.add(IndentStyleEditorConfigPropertyKt.getINDENT_STYLE_PROPERTY());
list.add(IndentSizeEditorConfigPropertyKt.getINDENT_SIZE_PROPERTY());
list.add(InsertFinalNewLineEditorConfigPropertyKt.getINSERT_FINAL_NEWLINE_PROPERTY());
list.add(MaxLineLengthEditorConfigPropertyKt.getMAX_LINE_LENGTH_PROPERTY());
DEFAULT_EDITOR_CONFIG_PROPERTIES = Collections.unmodifiableList(list);
DEFAULT_EDITOR_CONFIG_PROPERTIES = List.of(
CodeStyleEditorConfigPropertyKt.getCODE_STYLE_PROPERTY(),
DisabledRulesEditorConfigPropertyKt.getDISABLED_RULES_PROPERTY(),
DisabledRulesEditorConfigPropertyKt.getKTLINT_DISABLED_RULES_PROPERTY(),
IndentStyleEditorConfigPropertyKt.getINDENT_STYLE_PROPERTY(),
IndentSizeEditorConfigPropertyKt.getINDENT_SIZE_PROPERTY(),
InsertFinalNewLineEditorConfigPropertyKt.getINSERT_FINAL_NEWLINE_PROPERTY(),
MaxLineLengthEditorConfigPropertyKt.getMAX_LINE_LENGTH_PROPERTY());
}

static class FormatterCallback implements Function2<LintError, Boolean, Unit> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -61,15 +59,14 @@ public class KtLintCompat0Dot49Dot0Adapter implements KtLintCompatAdapter {
private static final List<EditorConfigProperty<?>> DEFAULT_EDITOR_CONFIG_PROPERTIES;

static {
List<EditorConfigProperty<?>> list = new ArrayList<>();
list.add(CodeStyleEditorConfigPropertyKt.getCODE_STYLE_PROPERTY());
list.add(EndOfLinePropertyKt.getEND_OF_LINE_PROPERTY());
list.add(IndentSizeEditorConfigPropertyKt.getINDENT_SIZE_PROPERTY());
list.add(IndentStyleEditorConfigPropertyKt.getINDENT_STYLE_PROPERTY());
list.add(InsertFinalNewLineEditorConfigPropertyKt.getINSERT_FINAL_NEWLINE_PROPERTY());
list.add(MaxLineLengthEditorConfigPropertyKt.getMAX_LINE_LENGTH_PROPERTY());
list.add(RuleExecutionEditorConfigPropertyKt.getEXPERIMENTAL_RULES_EXECUTION_PROPERTY());
DEFAULT_EDITOR_CONFIG_PROPERTIES = Collections.unmodifiableList(list);
DEFAULT_EDITOR_CONFIG_PROPERTIES = List.of(
CodeStyleEditorConfigPropertyKt.getCODE_STYLE_PROPERTY(),
EndOfLinePropertyKt.getEND_OF_LINE_PROPERTY(),
IndentSizeEditorConfigPropertyKt.getINDENT_SIZE_PROPERTY(),
IndentStyleEditorConfigPropertyKt.getINDENT_STYLE_PROPERTY(),
InsertFinalNewLineEditorConfigPropertyKt.getINSERT_FINAL_NEWLINE_PROPERTY(),
MaxLineLengthEditorConfigPropertyKt.getMAX_LINE_LENGTH_PROPERTY(),
RuleExecutionEditorConfigPropertyKt.getEXPERIMENTAL_RULES_EXECUTION_PROPERTY());
}

private static final Method RULEID_METHOD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -61,15 +60,14 @@ public class KtLintCompat0Dot50Dot0Adapter implements KtLintCompatAdapter {
private static final List<EditorConfigProperty<?>> DEFAULT_EDITOR_CONFIG_PROPERTIES;

static {
List<EditorConfigProperty<?>> list = new ArrayList<>();
list.add(CodeStyleEditorConfigPropertyKt.getCODE_STYLE_PROPERTY());
list.add(EndOfLinePropertyKt.getEND_OF_LINE_PROPERTY());
list.add(IndentSizeEditorConfigPropertyKt.getINDENT_SIZE_PROPERTY());
list.add(IndentStyleEditorConfigPropertyKt.getINDENT_STYLE_PROPERTY());
list.add(InsertFinalNewLineEditorConfigPropertyKt.getINSERT_FINAL_NEWLINE_PROPERTY());
list.add(MaxLineLengthEditorConfigPropertyKt.getMAX_LINE_LENGTH_PROPERTY());
list.add(RuleExecutionEditorConfigPropertyKt.getEXPERIMENTAL_RULES_EXECUTION_PROPERTY());
DEFAULT_EDITOR_CONFIG_PROPERTIES = Collections.unmodifiableList(list);
DEFAULT_EDITOR_CONFIG_PROPERTIES = List.of(
CodeStyleEditorConfigPropertyKt.getCODE_STYLE_PROPERTY(),
EndOfLinePropertyKt.getEND_OF_LINE_PROPERTY(),
IndentSizeEditorConfigPropertyKt.getINDENT_SIZE_PROPERTY(),
IndentStyleEditorConfigPropertyKt.getINDENT_STYLE_PROPERTY(),
InsertFinalNewLineEditorConfigPropertyKt.getINSERT_FINAL_NEWLINE_PROPERTY(),
MaxLineLengthEditorConfigPropertyKt.getMAX_LINE_LENGTH_PROPERTY(),
RuleExecutionEditorConfigPropertyKt.getEXPERIMENTAL_RULES_EXECUTION_PROPERTY());
}

static class FormatterCallback implements Function2<LintError, Boolean, Unit> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -61,15 +60,14 @@ public class KtLintCompat1Dot0Dot0Adapter implements KtLintCompatAdapter {
private static final List<EditorConfigProperty<?>> DEFAULT_EDITOR_CONFIG_PROPERTIES;

static {
List<EditorConfigProperty<?>> list = new ArrayList<>();
list.add(CodeStyleEditorConfigPropertyKt.getCODE_STYLE_PROPERTY());
list.add(EndOfLinePropertyKt.getEND_OF_LINE_PROPERTY());
list.add(IndentSizeEditorConfigPropertyKt.getINDENT_SIZE_PROPERTY());
list.add(IndentStyleEditorConfigPropertyKt.getINDENT_STYLE_PROPERTY());
list.add(InsertFinalNewLineEditorConfigPropertyKt.getINSERT_FINAL_NEWLINE_PROPERTY());
list.add(MaxLineLengthEditorConfigPropertyKt.getMAX_LINE_LENGTH_PROPERTY());
list.add(RuleExecutionEditorConfigPropertyKt.getEXPERIMENTAL_RULES_EXECUTION_PROPERTY());
DEFAULT_EDITOR_CONFIG_PROPERTIES = Collections.unmodifiableList(list);
DEFAULT_EDITOR_CONFIG_PROPERTIES = List.of(
CodeStyleEditorConfigPropertyKt.getCODE_STYLE_PROPERTY(),
EndOfLinePropertyKt.getEND_OF_LINE_PROPERTY(),
IndentSizeEditorConfigPropertyKt.getINDENT_SIZE_PROPERTY(),
IndentStyleEditorConfigPropertyKt.getINDENT_STYLE_PROPERTY(),
InsertFinalNewLineEditorConfigPropertyKt.getINSERT_FINAL_NEWLINE_PROPERTY(),
MaxLineLengthEditorConfigPropertyKt.getMAX_LINE_LENGTH_PROPERTY(),
RuleExecutionEditorConfigPropertyKt.getEXPERIMENTAL_RULES_EXECUTION_PROPERTY());
}

static class FormatterCallback implements Function2<LintError, Boolean, Unit> {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/main/java/com/diffplug/spotless/npm/FileFinder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 DiffPlug
* Copyright 2020-2023 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,7 @@ class FileFinder {
private final List<Supplier<Optional<File>>> fileCandidateFinders;

private FileFinder(Builder builder) {
this.fileCandidateFinders = Collections.unmodifiableList(new ArrayList<>(builder.candidateFinders));
this.fileCandidateFinders = List.copyOf(builder.candidateFinders);
}

static Builder finderForFilename(String fileName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
package com.diffplug.spotless.npm;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

Expand All @@ -35,7 +33,7 @@ public NpmPathResolver(File explicitNpmExecutable, File explicitNodeExecutable,
this.explicitNpmExecutable = explicitNpmExecutable;
this.explicitNodeExecutable = explicitNodeExecutable;
this.explicitNpmrcFile = explicitNpmrcFile;
this.additionalNpmrcLocations = Collections.unmodifiableList(new ArrayList<>(additionalNpmrcLocations));
this.additionalNpmrcLocations = List.copyOf(additionalNpmrcLocations);
}

/**
Expand Down

0 comments on commit d346ef8

Please sign in to comment.