Declare static methods and final members. * To suppress some Java coding style warnings. Change-Id: I3c663f3baf108bf693afa3cfd0570e4eeb1ec9c4
diff --git a/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java b/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java index c9b39fe..c7c4b7a 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java +++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java
@@ -97,7 +97,7 @@ return "?"; } - private List<OwnerInfo> getOwners(OwnersDb db, Collection<String> files) { + private static List<OwnerInfo> getOwners(OwnersDb db, Collection<String> files) { Map<String, OwnerWeights> weights = new HashMap<>(); db.findOwners(files, weights, new ArrayList<>()); List<OwnerInfo> result = new ArrayList<>();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/findowners/OwnerWeights.java b/src/main/java/com/googlesource/gerrit/plugins/findowners/OwnerWeights.java index 233f1d2..6755eb3 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/findowners/OwnerWeights.java +++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/OwnerWeights.java
@@ -38,7 +38,7 @@ */ class OwnerWeights { static class WeightComparator implements Comparator<String> { - private Map<String, OwnerWeights> map; + private final Map<String, OwnerWeights> map; WeightComparator(Map<String, OwnerWeights> weights) { map = weights;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/findowners/Parser.java b/src/main/java/com/googlesource/gerrit/plugins/findowners/Parser.java index c1cd591..c13213c 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/findowners/Parser.java +++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/Parser.java
@@ -104,12 +104,12 @@ // A parser keeps current permissionBackend, readFiles, repoManager, project, branch, // included file path, and debug/trace logs. private final PermissionBackend permissionBackend; - private Map<String, String> readFiles; - private GitRepositoryManager repoManager; - private String branch; // All owners files are read from the same branch. - private IncludeStack stack; // a stack of including files. - private List<String> logs; // Keeps debug/trace messages. - private Map<String, Result> savedResults; // projectName:filePath => Parser.Result + private final Map<String, String> readFiles; + private final GitRepositoryManager repoManager; + private final String branch; // All owners files are read from the same branch. + private final IncludeStack stack; // a stack of including files. + private final List<String> logs; // Keeps debug/trace messages. + private final Map<String, Result> savedResults; // projectName:filePath => Parser.Result static class IncludeStack { Deque<String> projectName; // project/repository name of included file
diff --git a/src/test/java/com/googlesource/gerrit/plugins/findowners/IncludeIT.java b/src/test/java/com/googlesource/gerrit/plugins/findowners/IncludeIT.java index 192fbf6..55cf6fb 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/findowners/IncludeIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/findowners/IncludeIT.java
@@ -29,15 +29,15 @@ private static final FluentLogger logger = FluentLogger.forEnclosingClass(); @Rule public Watcher watcher = new Watcher(logger); - private String getRepoFileLog(String msg1, String msg2) { + private static String getRepoFileLog(String msg1, String msg2) { return "getRepoFile:" + msg1 + ", getFile:" + msg2 + ", "; } - private String concat(String s1, String s2) { + private static String concat(String s1, String s2) { return s1 + s2; } - private String concat(String s1, String s2, String s3) { + private static String concat(String s1, String s2, String s3) { return s1 + s2 + s3; }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/findowners/ParserTest.java b/src/test/java/com/googlesource/gerrit/plugins/findowners/ParserTest.java index 8a0481b..a458249 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/findowners/ParserTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/findowners/ParserTest.java
@@ -245,7 +245,7 @@ } } - private void testOneIncludeOrFileLine( + private static void testOneIncludeOrFileLine( String project, String line, String keyword, String projectName, String filePath) { String[] results = Parser.parseInclude(project, line); assertThat(results).hasLength(3); @@ -254,11 +254,12 @@ assertThat(results[2]).isEqualTo(filePath); } - private void testOneFileLine(String project, String line, String projectName, String filePath) { + private static void testOneFileLine( + String project, String line, String projectName, String filePath) { testOneIncludeOrFileLine(project, line, "file", projectName, filePath); } - private void testOneIncludeLine( + private static void testOneIncludeLine( String project, String line, String projectName, String filePath) { testOneIncludeOrFileLine(project, line, "include", projectName, filePath); }