From 5a6b6eee35f07615f5d496781ee37f8ffe56b7d3 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 27 Feb 2020 20:27:31 +0900 Subject: [PATCH] Move array designators from the variable to the type As reported by Sonar Lint: Array designators should always be located on the type for better code readability. Otherwise, developers must look both at the type and the variable name to know whether or not a variable is an array. Change-Id: If6b41fed3483d0992d402d8680552ab4bef89ffb Signed-off-by: David Pursehouse --- .../src/org/eclipse/jgit/http/server/glue/RegexPipeline.java | 2 +- .../jgit/internal/transport/sshd/CachingKeyPairProvider.java | 2 +- .../jgit/internal/transport/sshd/proxy/HttpParser.java | 2 +- org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java | 2 +- .../eclipse/jgit/internal/storage/file/FileReftableStack.java | 4 ++-- .../org/eclipse/jgit/internal/storage/pack/PackWriter.java | 4 ++-- .../src/org/eclipse/jgit/merge/ResolveMerger.java | 2 +- .../src/org/eclipse/jgit/transport/UploadPack.java | 4 ++-- org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 2 +- org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java | 2 +- org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java | 2 +- 11 files changed, 14 insertions(+), 14 deletions(-) diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java index 010810508..06b31a547 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java @@ -138,7 +138,7 @@ class RegexPipeline extends UrlPipeline { // build a request for them so RegexGroupFilter can pick // a different capture group later. Continue using the // first capture group as the path info. - WrappedRequest groups[] = new WrappedRequest[cur.groupCount()]; + WrappedRequest[] groups = new WrappedRequest[cur.groupCount()]; for (int groupId = 1; groupId <= cur.groupCount(); groupId++) { final int s = cur.start(groupId); final String path, info; diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/CachingKeyPairProvider.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/CachingKeyPairProvider.java index a1ec31883..9673ff0fb 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/CachingKeyPairProvider.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/CachingKeyPairProvider.java @@ -121,7 +121,7 @@ public class CachingKeyPairProvider extends FileKeyPairProvider if (cache == null) { return loadKey(session, resource, path, getPasswordFinder()); } - Throwable t[] = { null }; + Throwable[] t = { null }; KeyPair key = cache.get(path, p -> { try { return loadKey(session, resource, p, getPasswordFinder()); diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpParser.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpParser.java index 02771b501..af8bf4700 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpParser.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpParser.java @@ -249,7 +249,7 @@ public final class HttpParser { start = nextStart + 1; } else { if (header.charAt(nextStart) == '"') { - int nextEnd[] = { nextStart + 1 }; + int[] nextEnd = { nextStart + 1 }; String value = scanQuotedString(header, nextStart + 1, nextEnd); challenge.addArgument(header.substring(start, end), value); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java index 219da0e9b..4e79fc938 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java @@ -448,7 +448,7 @@ public class RawText extends Sequence { } } - byte data[]; + byte[] data; try { data = new byte[(int)sz]; } catch (OutOfMemoryError e) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableStack.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableStack.java index 7abd1fb28..68d82c20d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableStack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableStack.java @@ -674,7 +674,7 @@ public class FileReftableStack implements AutoCloseable { } } - static List segmentSizes(long sizes[]) { + static List segmentSizes(long[] sizes) { List segments = new ArrayList<>(); Segment cur = new Segment(); for (int i = 0; i < sizes.length; i++) { @@ -694,7 +694,7 @@ public class FileReftableStack implements AutoCloseable { return segments; } - private static Optional autoCompactCandidate(long sizes[]) { + private static Optional autoCompactCandidate(long[] sizes) { if (sizes.length == 0) { return Optional.empty(); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java index 11e6c803e..fcf9ca579 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java @@ -225,7 +225,7 @@ public class PackWriter implements AutoCloseable { } @SuppressWarnings("unchecked") - BlockList objectsLists[] = new BlockList[OBJ_TAG + 1]; + BlockList[] objectsLists = new BlockList[OBJ_TAG + 1]; { objectsLists[OBJ_COMMIT] = new BlockList<>(); objectsLists[OBJ_TREE] = new BlockList<>(); @@ -270,7 +270,7 @@ public class PackWriter implements AutoCloseable { private List sortedByName; - private byte packcsum[]; + private byte[] packcsum; private boolean deltaBaseAsOffset; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java index e0b00c0bd..34b521e85 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java @@ -143,7 +143,7 @@ public class ResolveMerger extends ThreeWayMerger { * * @since 3.0 */ - protected String commitNames[]; + protected String[] commitNames; /** * Index of the base tree within the {@link #tw tree walk}. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java index 8eac06388..8a88e175f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -2411,12 +2411,12 @@ public class UploadPack { } @Override - public void write(byte b[]) throws IOException { + public void write(byte[] b) throws IOException { out.write(b); } @Override - public void write(byte b[], int off, int len) throws IOException { + public void write(byte[] b, int off, int len) throws IOException { out.write(b, off, len); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index a2b53a253..265950261 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -2270,7 +2270,7 @@ public abstract class FS { void copy() throws IOException { boolean writeFailure = false; - byte buffer[] = new byte[4096]; + byte[] buffer = new byte[4096]; int readBytes; while ((readBytes = in.read(buffer)) != -1) { // Do not try to write again after a failure, but keep diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java index 85ee09501..0f6620e81 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java @@ -313,7 +313,7 @@ public class LfsFactory { } @Override - public int read(byte b[], int off, int len) throws IOException { + public int read(byte[] b, int off, int len) throws IOException { return stream.read(b, off, len); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java index cd2a8e672..500c23673 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java @@ -49,7 +49,7 @@ public class Monitoring { String metricName) { boolean register = false; try { - Class interfaces[] = mbean.getClass().getInterfaces(); + Class[] interfaces = mbean.getClass().getInterfaces(); for (Class i : interfaces) { register = SystemReader.getInstance().getUserConfig() .getBoolean(