Fix a bunch of IDE warnings

Fix spelling typos, remove old Java 7 syntax, use new lambda syntax, and
more.

Change-Id: I8602636e3ad5cec7134c31d45a0fe24046f3b51a
diff --git a/src/main/java/com/google/gerrit/common/Container.java b/src/main/java/com/google/gerrit/common/Container.java
index 6e11534..0b64d5b 100644
--- a/src/main/java/com/google/gerrit/common/Container.java
+++ b/src/main/java/com/google/gerrit/common/Container.java
@@ -51,7 +51,7 @@
         field.setAccessible(true);
         values.add(field.get(this));
       }
-    } catch (IllegalArgumentException | IllegalAccessException e) {
+    } catch (IllegalArgumentException | IllegalAccessException ignored) {
     }
     return Objects.hash(values);
   }
@@ -62,14 +62,14 @@
     try {
       for (Field field : getClass().getDeclaredFields()) {
         field.setAccessible(true);
-        fieldStrings.add(field.getName() + ": " + Objects.toString(field.get(this)));
+        fieldStrings.add(field.getName() + ": " + field.get(this));
       }
-    } catch (IllegalArgumentException | IllegalAccessException e) {
+    } catch (IllegalArgumentException | IllegalAccessException ignored) {
     }
     String fields = String.join(", ", fieldStrings);
-    if (!"".equals(fields)) {
+    if (!fields.isEmpty()) {
       fields = "{" + fields + "}";
     }
-    return getClass().toString() + fields;
+    return getClass() + fields;
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/IsTrueOperator.java b/src/main/java/com/googlesource/gerrit/plugins/task/IsTrueOperator.java
index 472b1e7..79110d6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/IsTrueOperator.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/IsTrueOperator.java
@@ -37,7 +37,7 @@
     }
   }
 
-  public class TruePredicate extends SubmitRequirementPredicate {
+  public static class TruePredicate extends SubmitRequirementPredicate {
 
     public TruePredicate() {
       super("is", TRUE);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/MatchCache.java b/src/main/java/com/googlesource/gerrit/plugins/task/MatchCache.java
index 60dff17..679be00 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/MatchCache.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/MatchCache.java
@@ -48,7 +48,7 @@
   public Boolean matchOrNull(ChangeData changeData, String query, boolean isVisible) {
     try {
       return match(changeData, query, isVisible);
-    } catch (StorageException | QueryParseException e) {
+    } catch (StorageException | QueryParseException ignored) {
     }
     return null;
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/PredicateCache.java b/src/main/java/com/googlesource/gerrit/plugins/task/PredicateCache.java
index ba87fd8..777780a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/PredicateCache.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/PredicateCache.java
@@ -22,7 +22,6 @@
 import com.google.gerrit.index.query.QueryParseException;
 import com.google.gerrit.server.CurrentUser;
 import com.google.gerrit.server.index.change.ChangeField;
-import com.google.gerrit.server.query.change.BranchSetIndexPredicate;
 import com.google.gerrit.server.query.change.ChangeData;
 import com.google.gerrit.server.query.change.ChangeIndexPredicate;
 import com.google.gerrit.server.query.change.RegexProjectPredicate;
@@ -75,7 +74,7 @@
       return predProvider.get();
     }
     // never seen 'query' before
-    try (StopWatch stopWatch = predicatesByQuery.createLoadingStopWatch(query, isVisible)) {
+    try (StopWatch ignored = predicatesByQuery.createLoadingStopWatch(query, isVisible)) {
       Predicate<ChangeData> pred = srcqb.parse(query);
       predicatesByQuery.put(query, new ThrowingProvider.Entry<>(pred));
       return pred;
@@ -91,7 +90,7 @@
    */
   public boolean isCacheableByBranch(String query, boolean isVisible) throws QueryParseException {
     if (query == null
-        || "".equals(query)
+        || query.isEmpty()
         || "false".equalsIgnoreCase(query)
         || "true".equalsIgnoreCase(query)) {
       return true;
@@ -110,9 +109,7 @@
       }
       return true;
     }
-    if (predicate instanceof BranchSetIndexPredicate
-        || predicate instanceof RegexProjectPredicate
-        || predicate instanceof RegexRefPredicate) {
+    if (predicate instanceof RegexProjectPredicate || predicate instanceof RegexRefPredicate) {
       return true;
     }
     if (predicate instanceof ChangeIndexPredicate) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/Preloader.java b/src/main/java/com/googlesource/gerrit/plugins/task/Preloader.java
index 7b325cf..bc0f99d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/Preloader.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/Preloader.java
@@ -29,7 +29,7 @@
 import java.util.Optional;
 import org.eclipse.jgit.errors.ConfigInvalidException;
 
-/** Use to pre-load a task definition with values from its preload-task definition. */
+/** Use to preload a task definition with values from its preload-task definition. */
 public class Preloader {
   public interface Factory {
     Preloader create(@Assisted TaskConfigCache taskConfigCache);
@@ -139,7 +139,7 @@
     } catch (RuntimeConfigInvalidException e) {
       throw e.checkedException;
     } catch (NoSuchElementException e) {
-      // expression was not optional but we ran out of names to try
+      // expression was not optional, but we ran out of names to try
       throw new ConfigInvalidException("task not defined");
     }
     return Optional.empty();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/RuntimeConfigInvalidException.java b/src/main/java/com/googlesource/gerrit/plugins/task/RuntimeConfigInvalidException.java
index cc0ed94..fabc0fa 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/RuntimeConfigInvalidException.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/RuntimeConfigInvalidException.java
@@ -17,7 +17,7 @@
 import org.eclipse.jgit.errors.ConfigInvalidException;
 
 public class RuntimeConfigInvalidException extends RuntimeException {
-  protected static final long serialVersionUID = 1L;
+  private static final long serialVersionUID = 1L;
   protected ConfigInvalidException checkedException;
 
   public RuntimeConfigInvalidException(ConfigInvalidException e) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/TaskConfig.java b/src/main/java/com/googlesource/gerrit/plugins/task/TaskConfig.java
index 69b6fc1..102b675 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/TaskConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/TaskConfig.java
@@ -33,13 +33,14 @@
   public enum NamesFactoryType {
     CHANGE,
     STATIC,
-    PLUGIN;
+    PLUGIN,
+    INVALID;
 
     public static NamesFactoryType getNamesFactoryType(String str) {
       for (NamesFactoryType type : NamesFactoryType.values()) {
         if (type.name().equalsIgnoreCase(str)) return type;
       }
-      return null;
+      return INVALID;
     }
   }
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/TaskConfigCache.java b/src/main/java/com/googlesource/gerrit/plugins/task/TaskConfigCache.java
index 8f7d1f6..f3a654b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/TaskConfigCache.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/TaskConfigCache.java
@@ -17,7 +17,6 @@
 import com.google.common.flogger.FluentLogger;
 import com.google.gerrit.entities.BranchNameKey;
 import com.google.gerrit.entities.Project;
-import com.google.gerrit.extensions.restapi.AuthException;
 import com.google.gerrit.server.CurrentUser;
 import com.google.gerrit.server.config.AllProjectsName;
 import com.google.gerrit.server.config.AllProjectsNameProvider;
@@ -99,8 +98,6 @@
     } catch (IOException e) {
       log.atWarning().withCause(e).log("Failed to load %s for %s", file.file(), project);
       throw e;
-    } catch (ConfigInvalidException e) {
-      throw e;
     }
     return cfg;
   }
@@ -109,9 +106,8 @@
     try {
       PermissionBackend.ForProject permissions =
           permissionBackend.user(user).project(branch.project());
-      permissions.ref(branch.branch()).check(RefPermission.READ);
-      return true;
-    } catch (AuthException | PermissionBackendException e) {
+      return permissions.ref(branch.branch()).test(RefPermission.READ);
+    } catch (PermissionBackendException e) {
       return false;
     }
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/TaskExpression.java b/src/main/java/com/googlesource/gerrit/plugins/task/TaskExpression.java
index 5b9bef0..c0d8704 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/TaskExpression.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/TaskExpression.java
@@ -24,8 +24,8 @@
 
 /**
  * A TaskExpression represents a config string pointing to an expression which includes zero or more
- * task references separated by a '|', and potentially termintated by a '|'. If the expression is
- * not terminated by a '|' it indicates that task resolution of at least one task is required. Task
+ * task references separated by a '|', and potentially terminated by a '|'. If the expression is not
+ * terminated by a '|' it indicates that task resolution of at least one task is required. Task
  * selection priority is from left to right. This can be expressed as:
  *
  * <pre>
@@ -68,7 +68,7 @@
 
   @Override
   public Iterator<TaskKey> iterator() {
-    return new Iterator<TaskKey>() {
+    return new Iterator<>() {
       Matcher m = EXPRESSION_PATTERN.matcher(key.expression());
       Boolean hasNext;
       boolean optional;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/TaskKey.java b/src/main/java/com/googlesource/gerrit/plugins/task/TaskKey.java
index 609160e..8a95130 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/TaskKey.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/TaskKey.java
@@ -33,17 +33,17 @@
   protected static final String CONFIG_SECTION = "task";
   protected static final String CONFIG_TASKS_FACTORY = "tasks-factory";
 
-  /** Creates a TaskKey with task name as the name of sub section. */
+  /** Creates a TaskKey with task name as the name of subsection. */
   public static TaskKey create(SubSectionKey section) {
     return create(section, section.subSection());
   }
 
-  /** Creates a TaskKey with given FileKey and task name and sub section's name as 'task'. */
+  /** Creates a TaskKey with given FileKey and task name and subsection's name as 'task'. */
   public static TaskKey create(FileKey file, String task) {
     return create(SubSectionKey.create(file, CONFIG_SECTION, task));
   }
 
-  /** Creates a TaskKey from a sub section and task name, generally used by TasksFactory. */
+  /** Creates a TaskKey from a subsection and task name, generally used by TasksFactory. */
   public static TaskKey create(SubSectionKey section, String task) {
     return new AutoValue_TaskKey(section, task);
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/TaskPath.java b/src/main/java/com/googlesource/gerrit/plugins/task/TaskPath.java
index c0c5d8c..a9394b0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/TaskPath.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/TaskPath.java
@@ -69,7 +69,7 @@
           }
         }
       }
-    } catch (ConfigInvalidException | IOException e) {
+    } catch (ConfigInvalidException | IOException ignored) {
     }
     return null;
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/TaskPluginDefinedInfoFactory.java b/src/main/java/com/googlesource/gerrit/plugins/task/TaskPluginDefinedInfoFactory.java
index 0791bda..86c30be 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/TaskPluginDefinedInfoFactory.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/TaskPluginDefinedInfoFactory.java
@@ -34,6 +34,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
 import org.eclipse.jgit.errors.ConfigInvalidException;
@@ -52,7 +53,7 @@
     WAITING,
     READY,
     PASS,
-    FAIL;
+    FAIL
   }
 
   public static class Statistics {
@@ -314,14 +315,14 @@
                 && task.subTasksExternals.isEmpty()
                 && task.subTasksFactories.isEmpty());
         if (hasDefinedSubtasks) {
-          // Remove 'Grouping" tasks (tasks with subtasks but no PASS
+          // Remove "Grouping" tasks (tasks with subtasks but no PASS
           // or FAIL criteria) from the output if none of their subtasks
           // are applicable.  i.e. grouping tasks only really apply if at
           // least one of their subtasks apply.
           return null;
         }
         // A leaf configuration without a PASS or FAIL criteria is a
-        // missconfiguration.  Either someone forgot to add subtasks, or
+        // misconfiguration.  Either someone forgot to add subtasks, or
         // they forgot to add a PASS or FAIL criteria.
         return Status.INVALID;
       }
@@ -332,9 +333,9 @@
           // (like a CodeReview -2).  Thus, if hard blocked, it is
           // irrelevant what the subtask states, or the PASS criteria are.
           //
-          // It is also important that FAIL be useable to indicate that
-          // the task has actually executed.  Thus subtask status,
-          // including a subtask FAIL should not appear as a FAIL on the
+          // It is also important that FAIL be usable to indicate that
+          // the task has actually executed.  Thus, subtask status,
+          // including a subtask FAIL, should not appear as a FAIL on the
           // parent task.  This means that this is should be the only path
           // to make a task have a FAIL status.
           return Status.FAIL;
@@ -384,7 +385,7 @@
         if (subNode instanceof Node.Invalid) {
           subTasks.add(TaskPluginDefinedInfoFactory.invalid());
         } else {
-          new AttributeFactory(subNode).create().ifPresent(t -> subTasks.add(t));
+          new AttributeFactory(subNode).create().ifPresent(subTasks::add);
         }
       }
       if (subTasks.isEmpty()) {
@@ -429,7 +430,7 @@
     if (statistics != null) {
       statistics.numberOfChanges = pluginInfosByChange.size();
       statistics.numberOfTaskPluginAttributes =
-          pluginInfosByChange.values().stream().filter(tpa -> tpa != null).count();
+          pluginInfosByChange.values().stream().filter(Objects::nonNull).count();
       statistics.predicateCache = definitions.predicateCache.getStatistics();
       statistics.matchCache = definitions.matchCache.getStatistics();
       statistics.preloader = definitions.preloader.getStatistics();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/TaskReference.java b/src/main/java/com/googlesource/gerrit/plugins/task/TaskReference.java
index 1ccf673..ba27378 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/TaskReference.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/TaskReference.java
@@ -21,6 +21,7 @@
 import com.google.gerrit.server.config.AllUsersNameProvider;
 import com.google.inject.Inject;
 import com.google.inject.assistedinject.Assisted;
+import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.NoSuchElementException;
 import org.antlr.v4.runtime.BaseErrorListener;
@@ -38,7 +39,7 @@
   protected final String reference;
   protected final TaskKey.Builder taskKeyBuilder;
 
-  interface Factory {
+  public interface Factory {
     TaskReference create(FileKey relativeTo, String reference);
   }
 
@@ -103,7 +104,7 @@
     }
   }
 
-  protected class TaskReferenceListener extends TaskReferenceBaseListener {
+  protected static class TaskReferenceListener extends TaskReferenceBaseListener {
     TaskKey.Builder builder;
 
     TaskReferenceListener(TaskKey.Builder builder) {
@@ -121,7 +122,7 @@
         builder.setPath(
             ctx.dir().stream()
                 .map(dir -> Paths.get(dir.NAME().getText()))
-                .reduce(Paths.get(""), (a, b) -> a.resolve(b))
+                .reduce(Paths.get(""), Path::resolve)
                 .resolve(ctx.NAME().getText()));
       } catch (ConfigInvalidException e) {
         throw new RuntimeConfigInvalidException(e);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/TaskTree.java b/src/main/java/com/googlesource/gerrit/plugins/task/TaskTree.java
index 453fff1..baf40f9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/TaskTree.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/TaskTree.java
@@ -280,7 +280,7 @@
               }
               return node;
             }
-          } catch (Exception e) {
+          } catch (Exception ignored) {
           }
         }
         return createInvalid();
@@ -324,7 +324,7 @@
     }
 
     public String key() {
-      return String.valueOf(getChangeData().getId().get()) + TaskConfig.SEP + taskKey;
+      return getChangeData().getId().get() + TaskConfig.SEP + taskKey;
     }
 
     public List<Node> getSubNodes() throws IOException, StorageException, ConfigInvalidException {
@@ -338,7 +338,7 @@
         }
         definitionsBySubSection.computeIfAbsentTimed(
             task.key().subSection(),
-            k -> nodes.stream().map(n -> n.getDefinition()).collect(toList()),
+            k -> nodes.stream().map(Node::getDefinition).collect(toList()),
             task.isVisible);
       } else {
         hasUnfilterableSubNodes = true;
@@ -459,9 +459,7 @@
                 preloader.getOptionalTask(
                     taskExpressionFactory.create(
                         configSourcedValue.sourceFile(), configSourcedValue.value()));
-            if (def.isPresent()) {
-              addPreloaded(def.get());
-            }
+            def.ifPresent(this::addPreloaded);
           } catch (ConfigInvalidException e) {
             addInvalidNode();
           }
@@ -524,6 +522,8 @@
                 case PLUGIN:
                   addPluginTypeTasks(tasksFactory, namesFactory);
                   continue;
+                case INVALID:
+                  log.atWarning().log("Unrecognized names factory type: %s", namesFactory.type);
               }
             }
           }
@@ -566,7 +566,7 @@
         } catch (StorageException e) {
           log.atSevere().withCause(e).log(
               "Running changes query '%s' failed", namesFactory.changes);
-        } catch (QueryParseException | ConfigInvalidException e) {
+        } catch (QueryParseException | ConfigInvalidException ignored) {
         }
         addInvalidNode();
       }
@@ -666,8 +666,7 @@
                 definitionsByBranchBySubSection.put(subSection, definitionsByBranch);
               }
               definitionsByBranch.put(
-                  branch,
-                  filterable.get().stream().map(node -> node.getDefinition()).collect(toList()));
+                  branch, filterable.get().stream().map(Node::getDefinition).collect(toList()));
             }
             return filterable.get();
           }
@@ -697,7 +696,7 @@
                 // altered.
                 continue;
               }
-            } catch (QueryParseException e) {
+            } catch (QueryParseException ignored) {
             }
           }
           applicableNodes.add(node);
@@ -751,7 +750,7 @@
       throws StorageException, QueryParseException {
     List<ChangeData> changeDataList = changesByNamesFactoryQuery.get(query);
     if (changeDataList == null) {
-      try (StopWatch stopWatch =
+      try (StopWatch ignored =
           changesByNamesFactoryQuery.createLoadingStopWatch(query, isVisible)) {
         changeDataList =
             changeQueryProcessorProvider
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/cli/PatchSetArgument.java b/src/main/java/com/googlesource/gerrit/plugins/task/cli/PatchSetArgument.java
index 6fb4e69..93bec5f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/cli/PatchSetArgument.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/cli/PatchSetArgument.java
@@ -52,7 +52,7 @@
         permissionBackend.user(user).change(changeNotes).check(ChangePermission.READ);
         return new PatchSetArgument(changeNotes.getChange(), psUtil.get(changeNotes, patchSetId));
       } catch (PermissionBackendException | AuthException e) {
-        throw new IllegalArgumentException("database error", e);
+        throw new IllegalArgumentException(noSuchPatchSet(token), e);
       } catch (UnloggedFailure e) {
         throw new IllegalArgumentException(e.getMessage(), e);
       } catch (StorageException e) {
@@ -88,10 +88,4 @@
     this.patchSet = patchSet;
     this.change = change;
   }
-
-  public void ensureLatest() {
-    if (!change.currentPatchSetId().equals(patchSet.id())) {
-      throw new IllegalArgumentException(patchSet + " is not the latest patch set");
-    }
-  }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/properties/AbstractExpander.java b/src/main/java/com/googlesource/gerrit/plugins/task/properties/AbstractExpander.java
index a3ea8a6..e8b3bba 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/properties/AbstractExpander.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/properties/AbstractExpander.java
@@ -38,7 +38,7 @@
  * <p>a String like: <code>"The brown ${animal} jumped over the ${obstacle}."</code>
  *
  * <p>will expand to: <code>"The brown fox jumped over the fence."</code> This class is meant to be
- * used as a building block for other full featured expanders and thus must be overriden to provide
+ * used as a building block for other full-featured expanders and thus must be overridden to provide
  * the name/value associations via the getValueForName() method.
  */
 public abstract class AbstractExpander {
@@ -178,9 +178,9 @@
    * Get the replacement value for the property identified by name
    *
    * @param name of the property to get the replacement value for
-   * @return the replacement value. Since the expandText() method alwyas needs a String to replace
-   *     '${property-name}' reference with, even when the property does not exist, this will never
-   *     return null, instead it will returns the empty string if the property is not found.
+   * @return the replacement value. Since the expandText() method always needs a String to replace
+   *     the '${property-name}' reference with, even when the property does not exist, this will
+   *     never return null, instead it will return an empty string if the property is not found.
    */
   protected abstract String getValueForName(String name);
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/properties/CopyOnWrite.java b/src/main/java/com/googlesource/gerrit/plugins/task/properties/CopyOnWrite.java
index d1510fa..ddb2119 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/properties/CopyOnWrite.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/properties/CopyOnWrite.java
@@ -25,12 +25,12 @@
 public class CopyOnWrite<T> {
   public static class CloneOnWrite<C extends Cloneable> extends CopyOnWrite<C> {
     public CloneOnWrite(C cloneable) {
-      super(cloneable, copier(cloneable));
+      super(cloneable, copier());
     }
   }
 
-  public static <C extends Cloneable> Function<C, C> copier(C cloneable) {
-    return c -> clone(c);
+  public static <C extends Cloneable> Function<C, C> copier() {
+    return CopyOnWrite::clone;
   }
 
   @SuppressWarnings("unchecked")
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/properties/Expander.java b/src/main/java/com/googlesource/gerrit/plugins/task/properties/Expander.java
index df817a1..dd27264 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/properties/Expander.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/properties/Expander.java
@@ -27,7 +27,7 @@
  * <p>Using a recursive expansion approach makes order of evaluation unimportant as long as there
  * are no looping definitions.
  *
- * <p>Given some property name/value asssociations defined like this:
+ * <p>Given some property name/value associations defined like this:
  *
  * <p><code>
  * valueByName.put("obstacle", "fence");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/properties/Loader.java b/src/main/java/com/googlesource/gerrit/plugins/task/properties/Loader.java
index 05120b3..19206c4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/properties/Loader.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/properties/Loader.java
@@ -59,29 +59,22 @@
       return task.name();
     }
     String changeProp = name.replace("_change_", "");
-    if (changeProp != name) {
+    if (!changeProp.equals(name)) {
       return change(changeProp);
     }
     return "";
   }
 
   protected String change(String changeProp) throws StorageException {
-    switch (changeProp) {
-      case "number":
-        return String.valueOf(change().getId().get());
-      case "id":
-        return change().getKey().get();
-      case "project":
-        return change().getProject().get();
-      case "branch":
-        return change().getDest().branch();
-      case "status":
-        return change().getStatus().toString();
-      case "topic":
-        return change().getTopic();
-      default:
-        return "";
-    }
+    return switch (changeProp) {
+      case "number" -> String.valueOf(change().getId().get());
+      case "id" -> change().getKey().get();
+      case "project" -> change().getProject().get();
+      case "branch" -> change().getDest().branch();
+      case "status" -> change().getStatus().toString();
+      case "topic" -> change().getTopic();
+      default -> "";
+    };
   }
 
   protected Change change() {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/properties/Matcher.java b/src/main/java/com/googlesource/gerrit/plugins/task/properties/Matcher.java
index 68151fb..d5de9da 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/properties/Matcher.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/properties/Matcher.java
@@ -60,7 +60,7 @@
   }
 
   public boolean find() {
-    return findNanoseconds.get(() -> findUntimed());
+    return findNanoseconds.get(this::findUntimed);
   }
 
   protected boolean findUntimed() {
@@ -70,8 +70,7 @@
       return false;
     }
     end = text.indexOf('}', nameStart);
-    boolean found = end >= 0;
-    return found;
+    return end >= 0;
   }
 
   public String getName() {
@@ -79,19 +78,19 @@
   }
 
   public void appendValue(StringBuffer buffer, String value) {
-    appendNanoseconds.accept((b, v) -> appendValueUntimed(b, v), buffer, value);
+    appendNanoseconds.accept(this::appendValueUntimed, buffer, value);
   }
 
   protected void appendValueUntimed(StringBuffer buffer, String value) {
     if (start > cursor) {
-      buffer.append(text.substring(cursor, start));
+      buffer.append(text, cursor, start);
     }
     buffer.append(value);
     cursor = end + 1;
   }
 
   public void appendTail(StringBuffer buffer) {
-    appendNanoseconds.accept(b -> appendTailUntimed(b), buffer);
+    appendNanoseconds.accept(this::appendTailUntimed, buffer);
   }
 
   protected void appendTailUntimed(StringBuffer buffer) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/statistics/HitBooleanTable.java b/src/main/java/com/googlesource/gerrit/plugins/task/statistics/HitBooleanTable.java
index 2f35084..bc6cae2 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/statistics/HitBooleanTable.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/statistics/HitBooleanTable.java
@@ -54,6 +54,7 @@
     if (statistics.sumNanosecondsLoading == null) {
       statistics.sumNanosecondsLoading = 0L;
     }
+
     return new StopWatch.Enabled()
         .setNanosConsumer(
             ns ->
@@ -63,7 +64,7 @@
 
   public long updateTopLoadingTimes(long nanos, R row, C column, boolean isVisible) {
     statistics.topNanosecondsLoadingKeys.addIfTop(
-        nanos, isVisible ? new TopKeyMap.TableKeyValue<R, C>(row, column) : null);
+        nanos, isVisible ? new TopKeyMap.TableKeyValue<>(row, column) : null);
     return nanos;
   }
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/statistics/HitHashMap.java b/src/main/java/com/googlesource/gerrit/plugins/task/statistics/HitHashMap.java
index b080967..8b370b5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/statistics/HitHashMap.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/statistics/HitHashMap.java
@@ -32,7 +32,7 @@
     public List<Object> elements;
   }
 
-  public static final long serialVersionUID = 1;
+  private static final long serialVersionUID = 1;
 
   @SuppressWarnings("serial")
   protected Statistics<K> statistics;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/statistics/HitHashMapOfCollection.java b/src/main/java/com/googlesource/gerrit/plugins/task/statistics/HitHashMapOfCollection.java
index af68a0c..2b90d2c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/statistics/HitHashMapOfCollection.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/statistics/HitHashMapOfCollection.java
@@ -14,8 +14,6 @@
 
 package com.googlesource.gerrit.plugins.task.statistics;
 
-import static java.util.stream.Collectors.toList;
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Comparator;
@@ -27,9 +25,8 @@
     public List<Integer> bottom5CollectionSizes;
   }
 
-  public static final long serialVersionUID = 1;
+  private static final long serialVersionUID = 1;
 
-  @SuppressWarnings("serial")
   protected Statistics<K> statistics;
 
   public HitHashMapOfCollection() {}
@@ -47,7 +44,7 @@
     statistics.size = super.statistics.size;
 
     List<Integer> collectionSizes =
-        values().stream().map(l -> l.size()).sorted(Comparator.reverseOrder()).collect(toList());
+        values().stream().map(l -> l.size()).sorted(Comparator.reverseOrder()).toList();
     statistics.top5CollectionSizes = new ArrayList<>(5);
     statistics.bottom5CollectionSizes = new ArrayList<>(5);
     for (int i = 0; i < 5 && i < collectionSizes.size(); i++) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/statistics/StopWatch.java b/src/main/java/com/googlesource/gerrit/plugins/task/statistics/StopWatch.java
index 05f942b..661093c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/statistics/StopWatch.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/statistics/StopWatch.java
@@ -26,7 +26,7 @@
  * <p>The Stopwatch class from google commons is used by placing start() and stop() calls around
  * code sections which need to be timed. This approach can be problematic since the code being timed
  * could throw an exception and if the stop() is not in a finally clause, then it will likely never
- * get called, potentially causing bad timings, or worse programatic issues elsewhere due to double
+ * get called, potentially causing bad timings, or worse programmatic issues elsewhere due to double
  * calls to start(). The need for a finally clause to make things safe is an obvious hint that using
  * an AutoCloseable approach is likely going to be safer. With that in mind, the two API approaches
  * provided by these StopWatch classes are:
@@ -43,7 +43,7 @@
  */
 public interface StopWatch extends AutoCloseable {
   /** Designed for the greatest simplicity to time SAM executions. */
-  public abstract static class Runner extends SamTryWrapper<AutoCloseable> {
+  abstract class Runner extends SamTryWrapper<AutoCloseable> {
     public static class Enabled extends Runner {
       protected LongConsumer nanosConsumer = EMPTY_LONG_CONSUMER;
 
@@ -74,7 +74,7 @@
   }
 
   /** Should be created and used only within a try-with-resource */
-  public static class Enabled implements StopWatch {
+  class Enabled implements StopWatch {
     protected LongConsumer nanosConsumer = EMPTY_LONG_CONSUMER;
     protected Stopwatch stopwatch = Stopwatch.createStarted();
 
@@ -92,7 +92,7 @@
   }
 
   /**
-   * A easy way to build a timer which needes to be enabled/disabled based on a runtime boolean.
+   * An easy way to build a timer which needs to be enabled/disabled based on a runtime boolean.
    *
    * <p>Example Usage:
    *
@@ -103,7 +103,7 @@
    * }
    * </code>
    */
-  public static class Builder {
+  class Builder {
     protected static class Enabled extends Builder {
       @Override
       public StopWatch build() {
@@ -124,11 +124,11 @@
   }
 
   /** May be used anywhere that Enabled can be used */
-  public static final StopWatch DISABLED = new StopWatch() {};
+  StopWatch DISABLED = new StopWatch() {};
 
-  public static final LongConsumer EMPTY_LONG_CONSUMER = l -> {};
+  LongConsumer EMPTY_LONG_CONSUMER = l -> {};
 
-  public static Builder builder() {
+  static Builder builder() {
     return Builder.DISABLED;
   }
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/util/SamTryWrapper.java b/src/main/java/com/googlesource/gerrit/plugins/task/util/SamTryWrapper.java
index ef42e5a..a3c29e1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/util/SamTryWrapper.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/util/SamTryWrapper.java
@@ -21,7 +21,7 @@
 import java.util.function.Supplier;
 
 /**
- * Class designed to make SAM calls wrapped by an AutoCloseable. This is usefull with AutoCloseables
+ * Class designed to make SAM calls wrapped by an AutoCloseable. This is useful with AutoCloseables
  * which do not provide resources which are directly needed during the SAM call, but rather with
  * AutoCloseables which likely manage external resources or state such as a locks or timers.
  */
@@ -30,7 +30,7 @@
 
   @SuppressWarnings("try")
   public void run(Runnable runnable) {
-    try (A autoCloseable = getAutoCloseable()) {
+    try (A ignored = getAutoCloseable()) {
       runnable.run();
     } catch (Exception e) {
       throw new RuntimeException(e);
@@ -39,7 +39,7 @@
 
   @SuppressWarnings("try")
   public <T> T get(Supplier<T> supplier) {
-    try (A autoCloseable = getAutoCloseable()) {
+    try (A ignored = getAutoCloseable()) {
       return supplier.get();
     } catch (Exception e) {
       throw new RuntimeException(e);
@@ -48,7 +48,7 @@
 
   @SuppressWarnings("try")
   public <T> void accept(Consumer<T> consumer, T t) {
-    try (A autoCloseable = getAutoCloseable()) {
+    try (A ignored = getAutoCloseable()) {
       consumer.accept(t);
     } catch (Exception e) {
       throw new RuntimeException(e);
@@ -57,7 +57,7 @@
 
   @SuppressWarnings("try")
   public <T, U> void accept(BiConsumer<T, U> consumer, T t, U u) {
-    try (A autoCloseable = getAutoCloseable()) {
+    try (A ignored = getAutoCloseable()) {
       consumer.accept(t, u);
     } catch (Exception e) {
       throw new RuntimeException(e);
@@ -66,7 +66,7 @@
 
   @SuppressWarnings("try")
   public <T, R> R apply(Function<T, R> func, T t) {
-    try (A autoCloseable = getAutoCloseable()) {
+    try (A ignored = getAutoCloseable()) {
       return func.apply(t);
     } catch (Exception e) {
       throw new RuntimeException(e);
@@ -75,7 +75,7 @@
 
   @SuppressWarnings("try")
   public <T, U, R> R apply(BiFunction<T, U, R> func, T t, U u) {
-    try (A autoCloseable = getAutoCloseable()) {
+    try (A ignored = getAutoCloseable()) {
       return func.apply(t, u);
     } catch (Exception e) {
       throw new RuntimeException(e);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/util/ThrowingProvider.java b/src/main/java/com/googlesource/gerrit/plugins/task/util/ThrowingProvider.java
index 3d5197e..ae42bee 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/util/ThrowingProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/util/ThrowingProvider.java
@@ -15,9 +15,9 @@
 package com.googlesource.gerrit.plugins.task.util;
 
 public interface ThrowingProvider<V, E extends Exception> {
-  public V get() throws E;
+  V get() throws E;
 
-  public static class Entry<V, E extends Exception> implements ThrowingProvider<V, E> {
+  class Entry<V, E extends Exception> implements ThrowingProvider<V, E> {
     protected V entry;
 
     public Entry(V entry) {
@@ -30,7 +30,7 @@
     }
   }
 
-  public static class Thrown<V, E extends Exception> implements ThrowingProvider<V, E> {
+  class Thrown<V, E extends Exception> implements ThrowingProvider<V, E> {
     protected E exception;
 
     public Thrown(E exception) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/util/TopKeyMap.java b/src/main/java/com/googlesource/gerrit/plugins/task/util/TopKeyMap.java
index 8603ce0..0be84a6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/util/TopKeyMap.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/util/TopKeyMap.java
@@ -21,10 +21,10 @@
  * <p>A TopKeyMap is array based and has O(n) insertion time. Despite not having O(1) insertion
  * times, it should likely be much faster than a hash based map for small n sizes. It also is more
  * memory efficient than a hash based map, although both are likely O(n) in space usage. The
- * TopKeyMap allocates all of its entries up front so it does not change its memory utilization at
- * all, and it does not have to create or free any Objects during its post constructor lifespan.
+ * TopKeyMap allocates all of its entries up front so that it does not change its memory utilization
+ * at all, and it does not have to create or free any Objects during its post constructor lifespan.
  *
- * <p>While a TopKeyMap currently only uses 'long's as keys, it is possible to easiy upgrade this
+ * <p>While a TopKeyMap currently only uses 'long's as keys, it is possible to easily upgrade this
  * collection to use any type of Comparable key.
  *
  * <p>Although not currently thread safe, due to the simplicity of the data structures used, and the
@@ -32,8 +32,8 @@
  */
 public class TopKeyMap<V> {
   /**
-   * A TableKeyValue is a helper class for TopKeyMap use cases, such as a table with with row and
-   * column keys, which involve two values.
+   * A TableKeyValue is a helper class for TopKeyMap use cases, such as a table with row and column
+   * keys, which involve two values.
    */
   public static class TableKeyValue<R, C> {
     public final R row;