Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 424225156
  • Loading branch information
graememorgan authored and Error Prone Team committed Jan 26, 2022
1 parent 0fdd3ee commit dd0ee50
Show file tree
Hide file tree
Showing 360 changed files with 44 additions and 486 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@
import org.checkerframework.checker.nullness.qual.Nullable;

/** Bugpattern to find conditions which are checked more than once. */
@BugPattern(
name = "AlreadyChecked",
severity = WARNING,
summary = "This condition has already been checked.")
@BugPattern(severity = WARNING, summary = "This condition has already been checked.")
public final class AlreadyChecked extends BugChecker implements CompilationUnitTreeMatcher {

private final ConstantExpressions constantExpressions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@
import java.util.function.Consumer;

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "AlwaysThrows",
summary = "Detects calls that will fail at runtime",
severity = ERROR)
@BugPattern(summary = "Detects calls that will fail at runtime", severity = ERROR)
public class AlwaysThrows extends BugChecker implements MethodInvocationTreeMatcher {

@SuppressWarnings("UnnecessarilyFullyQualified")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@
import java.util.Map;

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "AmbiguousMethodReference",
summary = "Method reference is ambiguous",
severity = WARNING)
@BugPattern(summary = "Method reference is ambiguous", severity = WARNING)
public class AmbiguousMethodReference extends BugChecker implements ClassTreeMatcher {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
* @author [email protected] (Graeme Morgan)
*/
@BugPattern(
name = "AnnotateFormatMethod",
summary =
"This method passes a pair of parameters through to String.format, but the enclosing"
+ " method wasn't annotated @FormatMethod. Doing so gives compile-time rather than"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "AnnotationMirrorToString",
summary =
"AnnotationMirror#toString doesn't use fully qualified type names, prefer auto-common's"
+ " AnnotationMirrors#toString",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
* @author [email protected] (Graeme Morgan)
*/
@BugPattern(
name = "AnnotationPosition",
summary = "Annotations should be positioned after Javadocs, but before modifiers.",
severity = WARNING,
tags = STYLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "AnnotationValueToString",
summary =
"AnnotationValue#toString doesn't use fully qualified type names, prefer auto-common's"
+ " AnnotationValues#toString",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* @author [email protected] (Eleanor Harris)
*/
@BugPattern(
name = "ArrayAsKeyOfSetOrMap",
summary =
"Arrays do not override equals() or hashCode, so comparisons will be done on"
+ " reference equality only. If neither deduplication nor lookup are needed, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
import com.sun.tools.javac.tree.JCTree.JCFieldAccess;

/** @author [email protected] (Eddie Aftandilian) */
@BugPattern(
name = "ArrayEquals",
summary = "Reference equality used to compare arrays",
severity = ERROR)
@BugPattern(summary = "Reference equality used to compare arrays", severity = ERROR)
public class ArrayEquals extends BugChecker implements MethodInvocationTreeMatcher {
/** Matches when the equals instance method is used to compare two arrays. */
private static final Matcher<MethodInvocationTree> instanceEqualsMatcher =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
* result in an ArrayStoreException.
*/
@BugPattern(
name = "ArrayFillIncompatibleType",
summary = "Arrays.fill(Object[], Object) called with incompatible types.",
severity = ERROR)
public class ArrayFillIncompatibleType extends BugChecker implements MethodInvocationTreeMatcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
import com.sun.tools.javac.tree.JCTree.JCFieldAccess;

/** @author [email protected] (Eddie Aftandilian) */
@BugPattern(
name = "ArrayHashCode",
summary = "hashcode method on array does not hash array contents",
severity = ERROR)
@BugPattern(summary = "hashcode method on array does not hash array contents", severity = ERROR)
public class ArrayHashCode extends BugChecker implements MethodInvocationTreeMatcher {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
* @author [email protected] (Liam Miller-Cushon)
*/
@BugPattern(
name = "ArrayToString",
summary = "Calling toString on an array does not provide useful information",
severity = ERROR)
public class ArrayToString extends AbstractToString {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import javax.lang.model.type.TypeKind;

@BugPattern(
name = "ArraysAsListPrimitiveArray",
summary = "Arrays.asList does not autobox primitive arrays, as one might expect.",
severity = ERROR)
public class ArraysAsListPrimitiveArray extends BugChecker implements MethodInvocationTreeMatcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

/** @author [email protected] (Sebastian Monte) */
@BugPattern(
name = "AssertFalse",
summary =
"Assertions may be disabled at runtime and do not guarantee that execution will "
+ "halt here; consider throwing an exception instead",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "AssertThrowsMultipleStatements",
summary = "The lambda passed to assertThrows should contain exactly one statement",
severity = SeverityLevel.WARNING)
public class AssertThrowsMultipleStatements extends BugChecker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "AssertionFailureIgnored",
summary =
"This assertion throws an AssertionError if it fails, which will be caught by an enclosing"
+ " try block.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

/** Checks that {@link AsyncCallable} implementations do not directly {@code return null}. */
@BugPattern(
name = "AsyncCallableReturnsNull",
summary = "AsyncCallable should not return a null Future, only a Future whose result is null.",
severity = ERROR)
public final class AsyncCallableReturnsNull extends AbstractAsyncTypeReturnsNull {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

/** Checks that {@link AsyncFunction} implementations do not directly {@code return null}. */
@BugPattern(
name = "AsyncFunctionReturnsNull",
summary = "AsyncFunction should not return a null Future, only a Future whose result is null.",
severity = ERROR)
public final class AsyncFunctionReturnsNull extends AbstractAsyncTypeReturnsNull {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

/** See summary for details. */
@BugPattern(
name = "AutoValueBuilderDefaultsInConstructor",
summary =
"Defaults for AutoValue Builders should be set in the factory method returning Builder"
+ " instances, not the constructor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
* @author [email protected] (Sumit Bhagwani)
*/
@BugPattern(
name = "AutoValueFinalMethods",
summary =
"Make toString(), hashCode() and equals() final in AutoValue classes"
+ ", so it is clear to readers that AutoValue is not overriding them",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
* @author [email protected] (Sumit Bhagwani)
*/
@BugPattern(
name = "AutoValueImmutableFields",
altNames = "mutable",
summary = "AutoValue recommends using immutable collections",
severity = WARNING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

/** Matches {@code AutoValue_} uses outside the containing file. */
@BugPattern(
name = "AutoValueSubclassLeaked",
severity = WARNING,
summary =
"Do not refer to the autogenerated AutoValue_ class outside the file containing the"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
* meet the contract specified by the {@link Annotation} interface.
*/
@BugPattern(
name = "BadAnnotationImplementation",
summary =
"Classes that implement Annotation must override equals and hashCode. Consider "
+ "using AutoAnnotation instead of implementing Annotation by hand.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@

/** @author [email protected] (Ian Rogers) */
@BugPattern(
name = "BadComparable",
summary = "Possible sign flip from narrowing conversion",
severity = WARNING,
tags = StandardTags.FRAGILE_CODE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@

/** @author [email protected] (Andy Turner) */
@BugPattern(
name = "BadImport",
summary =
"Importing nested classes/static methods/static fields with commonly-used names can make "
+ "code harder to read, because it may not be clear from the context exactly which "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
* @author [email protected] (Graeme Morgan)
*/
@BugPattern(
name = "BadInstanceof",
summary = "instanceof used in a way that is equivalent to a null check.",
severity = WARNING,
tags = SIMPLIFICATION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
* @author [email protected] (Bill Pugh)
* @author [email protected] (Eddie Aftandilian)
*/
@BugPattern(
name = "BadShiftAmount",
summary = "Shift by an amount that is out of range",
severity = ERROR)
@BugPattern(summary = "Shift by an amount that is out of range", severity = ERROR)
public class BadShiftAmount extends BugChecker implements BinaryTreeMatcher {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

/** A {@link BugChecker} that detects use of the unsafe {@link java.io.Serializable} API. */
@BugPattern(
name = "BanSerializableRead",
summary = "Deserializing user input via the `Serializable` API is extremely dangerous",
severity = SeverityLevel.ERROR)
public final class BanSerializableRead extends BugChecker implements MethodInvocationTreeMatcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

/** A BugChecker; see the associated BugPattern for details. */
@BugPattern(
name = "BareDotMetacharacter",
summary =
"\".\" is rarely useful as a regex, as it matches any character. To match a literal '.'"
+ " character, instead write \"\\\\.\".",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
* @author [email protected] (Graeme Morgan)
*/
@BugPattern(
name = "BigDecimalEquals",
summary = "BigDecimal#equals has surprising behavior: it also compares scale.",
severity = WARNING)
public final class BigDecimalEquals extends BugChecker implements MethodInvocationTreeMatcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
*
* @author [email protected] (Eric Dobson)
*/
@BugPattern(
name = "BigDecimalLiteralDouble",
summary = "new BigDecimal(double) loses precision in this case.",
severity = WARNING)
@BugPattern(summary = "new BigDecimal(double) loses precision in this case.", severity = WARNING)
public class BigDecimalLiteralDouble extends BugChecker implements NewClassTreeMatcher {

private static final BigInteger LONG_MAX = BigInteger.valueOf(Long.MAX_VALUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "BooleanParameter",
summary = "Use parameter comments to document ambiguous literals",
severity = SUGGESTION)
public class BooleanParameter extends BugChecker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "BoxedPrimitiveConstructor",
summary = "valueOf or autoboxing provides better time and space performance",
severity = SeverityLevel.WARNING,
tags = StandardTags.PERFORMANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "BoxedPrimitiveEquality",
summary =
"Comparison using reference equality instead of value equality. Reference equality of"
+ " boxed primitive types is usually not useful, as they are value objects, and it is"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

/** See the {@code summary}. */
@BugPattern(
name = "BugPatternNaming",
summary = "Giving BugPatterns a name different to the enclosing class can be confusing",
severity = WARNING)
public final class BugPatternNaming extends BugChecker implements ClassTreeMatcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
* array, or when the buffer wasn't initialized using ByteBuffer.wrap() or ByteBuffer.allocate().
*/
@BugPattern(
name = "ByteBufferBackingArray",
summary =
"ByteBuffer.array() shouldn't be called unless ByteBuffer.arrayOffset() is used or "
+ "if the ByteBuffer was initialized using ByteBuffer.wrap() or ByteBuffer.allocate().",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
import com.sun.tools.javac.code.Type;

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "CacheLoaderNull",
summary = "The result of CacheLoader#load must be non-null.",
severity = WARNING)
@BugPattern(summary = "The result of CacheLoader#load must be non-null.", severity = WARNING)
public class CacheLoaderNull extends BugChecker implements MethodTreeMatcher {

private static final Supplier<Type> CACHE_LOADER_TYPE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@
*
* @author Louis Wasserman
*/
@BugPattern(
name = "CannotMockFinalClass",
summary = "Mockito cannot mock final classes",
severity = SeverityLevel.WARNING)
@BugPattern(summary = "Mockito cannot mock final classes", severity = SeverityLevel.WARNING)
public class CannotMockFinalClass extends BugChecker
implements MethodInvocationTreeMatcher, VariableTreeMatcher {
// TODO(lowasser): consider stopping mocks of primitive types here or in its own checker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "CanonicalDuration",
summary = "Duration can be expressed more clearly with different units",
severity = WARNING)
public class CanonicalDuration extends BugChecker implements MethodInvocationTreeMatcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "CatchAndPrintStackTrace",
summary =
"Logging or rethrowing exceptions should usually be preferred to catching and calling"
+ " printStackTrace",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
name = "CatchFail",
summary =
"Ignoring exceptions and calling fail() is unnecessary, and makes test output less useful",
severity = WARNING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
* Flags code which catches {@link RuntimeException}s under the guise of catching {@link Exception}.
*/
@BugPattern(
name = "CatchingUnchecked",
summary =
"This catch block catches `Exception`, but can only catch unchecked exceptions. Consider"
+ " catching RuntimeException (or something more specific) instead so it is more"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
* }</pre>
*/
@BugPattern(
name = "ChainedAssertionLosesContext",
summary =
"Inside a Subject, use check(...) instead of assert*() to preserve user-supplied messages"
+ " and other settings.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
* @author [email protected] (Chris Povirk)
*/
@BugPattern(
name = "ChainingConstructorIgnoresParameter",
severity = ERROR,
summary =
"The called constructor accepts a parameter with the same name and type as one of "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* @author [email protected]
*/
@BugPattern(
name = "CharacterGetNumericValue",
summary =
"getNumericValue has unexpected behaviour: it interprets A-Z as base-36 digits with values"
+ " 10-35, but also supports non-arabic numerals and miscellaneous numeric unicode"
Expand Down
Loading

0 comments on commit dd0ee50

Please sign in to comment.