Browse Source

Make inner classes static where possible

As reported by Error Prone:

An inner class should be static unless it references members of its
enclosing class. An inner class that is made non-static unnecessarily
uses more memory and does not make the intent of the class clear.

See https://errorprone.info/bugpattern/ClassCanBeStatic

Change-Id: Ib99d120532630dba63cf400cc1c61c318286fc41
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
(cherry picked from commit ee40efcea4)
tags/v5.1.9.201908210455-r
David Pursehouse 5 years ago
parent
commit
6d0168a414

+ 1
- 1
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/transport/http/apache/HttpClientConnectionTest.java View File

@@ -76,7 +76,7 @@ public class HttpClientConnectionTest {
assertTrue(headerValues.contains("NTLM"));
}

private class HttpResponseMock extends AbstractHttpMessage
private static class HttpResponseMock extends AbstractHttpMessage
implements HttpResponse {
@Override
public StatusLine getStatusLine() {

+ 1
- 1
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java View File

@@ -70,7 +70,7 @@ import org.eclipse.jgit.util.time.ProposedTimestamp;
* Mock {@link org.eclipse.jgit.util.SystemReader} for tests.
*/
public class MockSystemReader extends SystemReader {
private final class MockConfig extends FileBasedConfig {
private static final class MockConfig extends FileBasedConfig {
private MockConfig(File cfgLocation, FS fs) {
super(cfgLocation, fs);
}

+ 1
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java View File

@@ -474,7 +474,7 @@ class TextHashFunctions extends TextBuiltin {
}

/** Utility to help us identify unique lines in a file. */
private class Line {
private static class Line {
private final RawText txt;

private final int pos;

+ 3
- 2
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ArchiveCommandTest.java View File

@@ -190,7 +190,8 @@ public class ArchiveCommandTest extends RepositoryTestCase {
}
}

private class MockFormat implements ArchiveCommand.Format<MockOutputStream> {
private static class MockFormat
implements ArchiveCommand.Format<MockOutputStream> {

private Map<String, String> entries = new HashMap<>();

@@ -240,7 +241,7 @@ public class ArchiveCommandTest extends RepositoryTestCase {
}
}

public class MockOutputStream extends OutputStream {
public static class MockOutputStream extends OutputStream {

private int foo;


+ 1
- 1
org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java View File

@@ -139,7 +139,7 @@ public class RepoCommandTest extends RepositoryTestCase {
resolveRelativeUris();
}

class IndexedRepos implements RepoCommand.RemoteReader {
static class IndexedRepos implements RepoCommand.RemoteReader {
Map<String, Repository> uriRepoMap;
IndexedRepos() {
uriRepoMap = new HashMap<>();

+ 1
- 1
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java View File

@@ -141,7 +141,7 @@ public class WindowCacheGetTest extends SampleDataRepositoryTestCase {
}
}

private class TestObject {
private static class TestObject {
ObjectId id;

int type;

+ 2
- 2
org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java View File

@@ -839,7 +839,7 @@ public class MergerTest extends RepositoryTestCase {
/**
* Throws an exception if reading beyond limit.
*/
class BigReadForbiddenStream extends ObjectStream.Filter {
static class BigReadForbiddenStream extends ObjectStream.Filter {
int limit;

BigReadForbiddenStream(ObjectStream orig, int limit) {
@@ -878,7 +878,7 @@ public class MergerTest extends RepositoryTestCase {
}
}

class BigReadForbiddenReader extends ObjectReader.Filter {
static class BigReadForbiddenReader extends ObjectReader.Filter {
ObjectReader delegate;
int limit;


+ 1
- 1
org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/PlotCommitListTest.java View File

@@ -56,7 +56,7 @@ import org.junit.Test;

public class PlotCommitListTest extends RevWalkTestCase {

class CommitListAssert {
static class CommitListAssert {
private PlotCommitList<PlotLane> pcl;
private PlotCommit<PlotLane> current;
private int nextIndex = 0;

+ 1
- 1
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/AbstractTreeIteratorTest.java View File

@@ -66,7 +66,7 @@ public class AbstractTreeIteratorTest {
return s > 0 ? path.substring(0, s) : "";
}

public class FakeTreeIterator extends WorkingTreeIterator {
public static class FakeTreeIterator extends WorkingTreeIterator {
public FakeTreeIterator(String pathName, FileMode fileMode) {
super(prefix(pathName), new Config().get(WorkingTreeOptions.KEY));
mode = fileMode.getBits();

+ 1
- 1
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutOutputStreamTest.java View File

@@ -282,7 +282,7 @@ public class TimeoutOutputStreamTest {
return System.currentTimeMillis();
}

private final class FullPipeInputStream extends PipedInputStream {
private static final class FullPipeInputStream extends PipedInputStream {
FullPipeInputStream(PipedOutputStream src) throws IOException {
super(src);
src.write(new byte[PIPE_SIZE]);

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java View File

@@ -207,7 +207,7 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
}

/** An entry in the old PackBitmapIndex. */
public final class Entry extends ObjectId {
public static final class Entry extends ObjectId {
private final int flags;

Entry(AnyObjectId src, int flags) {

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java View File

@@ -823,7 +823,7 @@ public abstract class RefUpdate {
* Handle the abstraction of storing a ref update. This is because both
* updating and deleting of a ref have merge testing in common.
*/
private abstract class Store {
private static abstract class Store {
abstract Result execute(Result status) throws IOException;
}
}

Loading…
Cancel
Save