Automatic code cleanup.

PiperOrigin-RevId: 448915648
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Attribute.java b/src/main/java/com/google/devtools/build/lib/packages/Attribute.java
index 7b48285..b055181 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Attribute.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Attribute.java
@@ -776,15 +776,6 @@
     }
 
     /**
-     * Allow all files for legacy compatibility. All uses of this method should be audited and then
-     * removed. In some cases, it's correct to allow any file, but mostly the set of files should be
-     * restricted to a reasonable set.
-     */
-    public Builder<TYPE> legacyAllowAnyFileType() {
-      return allowedFileTypes(FileTypeSet.ANY_FILE);
-    }
-
-    /**
      * If this is a label or label-list attribute, then this sets the allowed file types for file
      * labels occurring in the attribute. If the attribute contains labels that correspond to files
      * of any other type, then an error is produced during the analysis phase.
@@ -797,6 +788,15 @@
     }
 
     /**
+     * Allow all files for legacy compatibility. All uses of this method should be audited and then
+     * removed. In some cases, it's correct to allow any file, but mostly the set of files should be
+     * restricted to a reasonable set.
+     */
+    public Builder<TYPE> legacyAllowAnyFileType() {
+      return allowedFileTypes(FileTypeSet.ANY_FILE);
+    }
+
+    /**
      * If this is a label or label-list attribute, then this sets the allowed rule types with
      * warning for the labels occurring in the attribute. This must be a disjoint set from {@link
      * #allowedRuleClasses}.
@@ -1753,7 +1753,7 @@
       RequiredProviders requiredProviders,
       ImmutableList<AspectDetails<?>> aspects) {
     Preconditions.checkArgument(
-        (NoTransition.isInstance(transitionFactory))
+        NoTransition.isInstance(transitionFactory)
             || type.getLabelClass() == LabelClass.DEPENDENCY
             || type.getLabelClass() == LabelClass.NONDEP_REFERENCE,
         "Configuration transitions can only be specified for label or label list attributes");
diff --git a/src/main/java/com/google/devtools/build/lib/packages/BuildType.java b/src/main/java/com/google/devtools/build/lib/packages/BuildType.java
index d9e73bb..7914350 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/BuildType.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/BuildType.java
@@ -492,7 +492,7 @@
       try {
         printer.repr(com.google.devtools.build.lib.packages.SelectorList.of(selectorValueList));
       } catch (EvalException e) {
-        throw new IllegalStateException("this list should have been validated on creation");
+        throw new IllegalStateException("this list should have been validated on creation", e);
       }
     }
   }
diff --git a/src/main/java/com/google/devtools/build/lib/packages/GlobCache.java b/src/main/java/com/google/devtools/build/lib/packages/GlobCache.java
index c8ffbfe..a3acefe 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/GlobCache.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/GlobCache.java
@@ -289,10 +289,6 @@
     finishBackgroundTasks(globCache.values());
   }
 
-  public void cancelBackgroundTasks() {
-    cancelBackgroundTasks(globCache.values());
-  }
-
   private static void finishBackgroundTasks(Collection<Future<List<Path>>> tasks) {
     for (Future<List<Path>> task : tasks) {
       try {
@@ -304,6 +300,10 @@
     }
   }
 
+  public void cancelBackgroundTasks() {
+    cancelBackgroundTasks(globCache.values());
+  }
+
   private static void cancelBackgroundTasks(Collection<Future<List<Path>>> tasks) {
     for (Future<List<Path>> task : tasks) {
       task.cancel(true);
diff --git a/src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java b/src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java
index 1fa265c..8e36abe 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java
@@ -304,6 +304,20 @@
     return fromFunctions(Arrays.asList(functions));
   }
 
+  /**
+   * The implicit output function that generates files based on a set of template substitutions
+   * using rule attribute values.
+   *
+   * @param functions The functions used to construct the name of the implicit output file target.
+   *     The substring "%{name}" will be replaced by the actual name of the rule, the substring
+   *     "%{srcs}" will be replaced by the name of each source file without its extension. If
+   *     multiple %{} substrings exist, the cross-product of them is generated.
+   */
+  public static SafeImplicitOutputsFunction fromFunctions(
+      final Iterable<SafeImplicitOutputsFunction> functions) {
+    return new FunctionCombinationImplicitOutputsFunction(functions);
+  }
+
   private static class FunctionCombinationImplicitOutputsFunction
       extends SafeImplicitOutputsFunction {
 
@@ -329,21 +343,6 @@
   }
 
   /**
-   * The implicit output function that generates files based on a set of
-   * template substitutions using rule attribute values.
-   *
-   * @param functions The functions used to construct the name of the implicit
-   *   output file target.  The substring "%{name}" will be replaced by the
-   *   actual name of the rule, the substring "%{srcs}" will be replaced by the
-   *   name of each source file without its extension.  If multiple %{}
-   *   substrings exist, the cross-product of them is generated.
-   */
-  public static SafeImplicitOutputsFunction fromFunctions(
-      final Iterable<SafeImplicitOutputsFunction> functions) {
-    return new FunctionCombinationImplicitOutputsFunction(functions);
-  }
-
-  /**
    * Coerces attribute "attrName" of the specified rule into a sequence of strings. Helper function
    * for {@link #fromTemplates(Iterable)}.
    */
@@ -427,16 +426,35 @@
   }
 
   /**
-   * Given a template string, replaces all placeholders of the form %{...} with
-   * the values from attributeSource.  If there are multiple placeholders, then
-   * the output is the cross product of substitutions.
+   * Given a template string, replaces all placeholders of the form %{...} with the values from
+   * attributeSource. If there are multiple placeholders, then the output is the cross product of
+   * substitutions.
    */
-  public static ImmutableList<String> substitutePlaceholderIntoTemplate(String template,
-      AttributeMap rule) {
+  public static ImmutableList<String> substitutePlaceholderIntoTemplate(
+      String template, AttributeMap rule) {
     return substitutePlaceholderIntoTemplate(
         template, rule, ImplicitOutputsFunction::attributeValues);
   }
 
+  /**
+   * Substitutes attribute-placeholders in a template string, producing all possible combinations.
+   *
+   * @param template the template string, may contain named placeholders for rule attributes, like
+   *     <code>%{name}</code> or <code>%{deps}</code>
+   * @param rule the rule whose attributes the placeholders correspond to
+   * @param attributeGetter a helper for fetching attribute values
+   * @return all possible combinations of the attributes referenced by the placeholders, substituted
+   *     into the template; empty if any of the placeholders expands to no values
+   */
+  public static ImmutableList<String> substitutePlaceholderIntoTemplate(
+      String template, AttributeMap rule, AttributeValueGetter attributeGetter) {
+    // Parse the template to get the attribute names and format string.
+    ParsedTemplate parsedTemplate = ParsedTemplate.parse(template);
+
+    // Return the substituted strings.
+    return parsedTemplate.substituteAttributes(rule, attributeGetter);
+  }
+
   @AutoValue
   abstract static class ParsedTemplate {
     abstract String template();
@@ -477,25 +495,6 @@
     }
   }
 
-  /**
-   * Substitutes attribute-placeholders in a template string, producing all possible combinations.
-   *
-   * @param template the template string, may contain named placeholders for rule attributes, like
-   *     <code>%{name}</code> or <code>%{deps}</code>
-   * @param rule the rule whose attributes the placeholders correspond to
-   * @param attributeGetter a helper for fetching attribute values
-   * @return all possible combinations of the attributes referenced by the placeholders, substituted
-   *     into the template; empty if any of the placeholders expands to no values
-   */
-  public static ImmutableList<String> substitutePlaceholderIntoTemplate(
-      String template, AttributeMap rule, AttributeValueGetter attributeGetter) {
-    // Parse the template to get the attribute names and format string.
-    ParsedTemplate parsedTemplate = ParsedTemplate.parse(template);
-
-    // Return the substituted strings.
-    return parsedTemplate.substituteAttributes(rule, attributeGetter);
-  }
-
   private static ImmutableList<String> substitutePlaceholderIntoUnsafeTemplate(
       String unsafeTemplate, AttributeMap rule, AttributeValueGetter attributeGetter)
       throws EvalException {
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Package.java b/src/main/java/com/google/devtools/build/lib/packages/Package.java
index 908756f..cfb0214 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Package.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Package.java
@@ -668,7 +668,7 @@
     try {
       label = Label.create(packageIdentifier, targetName);
     } catch (LabelSyntaxException e) {
-      throw new IllegalArgumentException(targetName);
+      throw new IllegalArgumentException(targetName, e);
     }
 
     if (succinctTargetNotFoundErrors) {
@@ -1577,8 +1577,8 @@
         try {
           return addInputFile(createLabel(targetName), location);
         } catch (LabelSyntaxException e) {
-          throw new IllegalArgumentException("FileTarget in package " + pkg.getName()
-                                             + " has illegal name: " + targetName);
+          throw new IllegalArgumentException(
+              "FileTarget in package " + pkg.getName() + " has illegal name: " + targetName, e);
         }
       } else if (existing instanceof InputFile) {
         return (InputFile) existing; // idempotent
diff --git a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
index 2e0d6b2..a1a9746 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
@@ -761,7 +761,8 @@
                 return;
               }
 
-              Expression excludeDirectories = null, include = null;
+              Expression excludeDirectories = null;
+              Expression include = null;
               List<Argument> arguments = call.getArguments();
               for (int i = 0; i < arguments.size(); i++) {
                 Argument arg = arguments.get(i);
diff --git a/src/main/java/com/google/devtools/build/lib/packages/SelectorList.java b/src/main/java/com/google/devtools/build/lib/packages/SelectorList.java
index 4746d85..9ff57a2 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/SelectorList.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/SelectorList.java
@@ -99,24 +99,6 @@
   }
 
   /**
-   * Creates a list that concatenates two values, where each value may be a native type, a select
-   * over that type, or a selector list over that type.
-   *
-   * @throws EvalException if the values don't have the same underlying type
-   */
-  static SelectorList concat(Object x, Object y) throws EvalException {
-    return of(Arrays.asList(x, y));
-  }
-
-  @Override
-  public SelectorList binaryOp(TokenKind op, Object that, boolean thisLeft) throws EvalException {
-    if (op == TokenKind.PLUS) {
-      return thisLeft ? concat(this, that) : concat(that, this);
-    }
-    return null;
-  }
-
-  /**
    * Creates a list from the given sequence of values, which must be non-empty. Each value may be a
    * native type, a select over that type, or a selector list over that type.
    *
@@ -146,6 +128,24 @@
     return new SelectorList(getNativeType(firstValue), elements.build());
   }
 
+  /**
+   * Creates a list that concatenates two values, where each value may be a native type, a select
+   * over that type, or a selector list over that type.
+   *
+   * @throws EvalException if the values don't have the same underlying type
+   */
+  static SelectorList concat(Object x, Object y) throws EvalException {
+    return of(Arrays.asList(x, y));
+  }
+
+  @Override
+  public SelectorList binaryOp(TokenKind op, Object that, boolean thisLeft) throws EvalException {
+    if (op == TokenKind.PLUS) {
+      return thisLeft ? concat(this, that) : concat(that, this);
+    }
+    return null;
+  }
+
   private static final Class<?> NATIVE_LIST_TYPE = List.class;
 
   private static String getTypeName(Object x) {
diff --git a/src/main/java/com/google/devtools/build/lib/packages/TestSize.java b/src/main/java/com/google/devtools/build/lib/packages/TestSize.java
index d4d3494..e58e4f4 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/TestSize.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/TestSize.java
@@ -65,17 +65,15 @@
    */
   public int getDefaultShards() { return defaultShards; }
 
-  /**
-   * Returns test size of the given test target, or null if the size attribute is unrecognized.
-   */
+  /** Returns test size of the given test target, or null if the size attribute is unrecognized. */
   public static TestSize getTestSize(Rule testTarget) {
     String attr = NonconfigurableAttributeMapper.of(testTarget).get("size", Type.STRING);
     return getTestSize(attr);
   }
 
   /**
-   * Returns {@link TestSize} matching the given timeout or null if the
-   * given timeout doesn't match any {@link TestSize}.
+   * Returns {@link TestSize} matching the given timeout or null if the given timeout doesn't match
+   * any {@link TestSize}.
    *
    * @param timeout The timeout associated with the desired TestSize.
    */
@@ -89,16 +87,8 @@
   }
 
   /**
-   * Normal practice is to always use size tags as lower case strings.
-   */
-  @Override
-  public String toString() {
-    return super.toString().toLowerCase();
-  }
-
-  /**
-   * Returns the enum associated with a test's size or null if the tag is
-   * not lower case or an unknown size.
+   * Returns the enum associated with a test's size or null if the tag is not lower case or an
+   * unknown size.
    */
   public static TestSize getTestSize(String attr) {
     if (!attr.equals(attr.toLowerCase())) {
@@ -111,6 +101,12 @@
     }
   }
 
+  /** Normal practice is to always use size tags as lower case strings. */
+  @Override
+  public String toString() {
+    return super.toString().toLowerCase();
+  }
+
   /**
    * Converter for the --test_size_filters option.
    */