Remove unnecessary array creation for varargs parameters

SonarLint reports:

Arrays should not be created for varargs parameters (squid:S3878)

There's no point in creating an array solely for the purpose of
passing it as a varargs (...) argument; varargs is an array. Simply
pass the elements directly. They will be consolidated into an array
automatically.

Change-Id: Ib3b8795a0afa8849292da3c1bffad5c2d6e4ad49
This commit is contained in:
David Pursehouse
2020-02-19 17:45:17 +09:00
parent d77a118150
commit b715bb82a4
3 changed files with 4 additions and 5 deletions

View File

@@ -733,7 +733,7 @@ public abstract class AbstractDaemonTest {
} }
private static final List<Character> RANDOM = private static final List<Character> RANDOM =
Chars.asList(new char[] {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}); Chars.asList('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h');
protected PushOneCommit.Result amendChange(String changeId) throws Exception { protected PushOneCommit.Result amendChange(String changeId) throws Exception {
return amendChange(changeId, "refs/for/master", admin, testRepo); return amendChange(changeId, "refs/for/master", admin, testRepo);

View File

@@ -61,7 +61,7 @@ public class InitLabels implements InitStep {
KEY_LABEL, KEY_LABEL,
LABEL_VERIFIED, LABEL_VERIFIED,
KEY_VALUE, KEY_VALUE,
Arrays.asList(new String[] {"-1 Fails", "0 No score", "+1 Verified"})); Arrays.asList("-1 Fails", "0 No score", "+1 Verified"));
cfg.setBoolean(KEY_LABEL, LABEL_VERIFIED, KEY_COPY_ALL_SCORES_IF_NO_CODE_CHANGE, true); cfg.setBoolean(KEY_LABEL, LABEL_VERIFIED, KEY_COPY_ALL_SCORES_IF_NO_CODE_CHANGE, true);
allProjectsConfig.save("Configure 'Verified' label"); allProjectsConfig.save("Configure 'Verified' label");
} }

View File

@@ -86,7 +86,6 @@ import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.NoMergeBaseException; import org.eclipse.jgit.errors.NoMergeBaseException;
import org.eclipse.jgit.errors.NoMergeBaseException.MergeBaseFailureReason; import org.eclipse.jgit.errors.NoMergeBaseException.MergeBaseFailureReason;
import org.eclipse.jgit.errors.RevisionSyntaxException; import org.eclipse.jgit.errors.RevisionSyntaxException;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.CommitBuilder; import org.eclipse.jgit.lib.CommitBuilder;
import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
@@ -638,7 +637,7 @@ public class MergeUtil {
} }
try (ObjectInserter ins = new InMemoryInserter(repo)) { try (ObjectInserter ins = new InMemoryInserter(repo)) {
return newThreeWayMerger(ins, repo.getConfig()).merge(new AnyObjectId[] {mergeTip, toMerge}); return newThreeWayMerger(ins, repo.getConfig()).merge(mergeTip, toMerge);
} catch (LargeObjectException e) { } catch (LargeObjectException e) {
logger.atWarning().log("Cannot merge due to LargeObjectException: %s", toMerge.name()); logger.atWarning().log("Cannot merge due to LargeObjectException: %s", toMerge.name());
return false; return false;
@@ -736,7 +735,7 @@ public class MergeUtil {
throws IntegrationException { throws IntegrationException {
ThreeWayMerger m = newThreeWayMerger(inserter, repoConfig); ThreeWayMerger m = newThreeWayMerger(inserter, repoConfig);
try { try {
if (m.merge(new AnyObjectId[] {mergeTip, n})) { if (m.merge(mergeTip, n)) {
return writeMergeCommit( return writeMergeCommit(
author, committer, rw, inserter, destBranch, mergeTip, m.getResultTreeId(), n); author, committer, rw, inserter, destBranch, mergeTip, m.getResultTreeId(), n);
} }