Error Prone v2.3.3 Release Notes

Release Date: 2019-03-20 // about 5 years ago
  • ๐Ÿ†• New checks:

    • ๐Ÿคก AssignmentToMock: Fields annotated with @mock should not be manually assigned to.
    • AutoValueImmutableFields: AutoValue recommends using immutable collections
    • CompareToZero: The result of #compareTo or #compare should only be compared to 0. It is an implementation detail whether a given type returns strictly the values {-1, 0, +1} or others.
    • DeduplicateConstants: This expression was previously declared as a constant; consider replacing this occurrence.
    • DiscardedPostfixExpression: The result of this unary operation on a lambda parameter is discarded
    • DuplicateMapKeys: Map#ofEntries will throw an IllegalArgumentException if there are any duplicate keys
    • EscapedEntity: HTML entities in @code/@literal tags will appear literally in the rendered javadoc.
    • InheritDoc: Invalid use of @inheritdoc.
    • InterfaceWithOnlyStatics: This interface only contains static fields and methods; consider making it a final class instead to prevent subclassing.
    • InvalidBlockTag: This tag is invalid.
    • InvalidInlineTag: This tag is invalid.
    • MissingSummary: A summary line is required on public/protected Javadocs.
    • MixedDescriptors: The field number passed into #getFieldByNumber belongs to a different proto to the Descriptor.
    • MixedMutabilityReturnType: This method returns both mutable and immutable collections or maps from different paths. This may be confusing for users of the method.
    • ๐Ÿคก MockitoInternalUsage: org.mockito.internal.* is a private API and should not be used by clients
    • OptionalMapToOptional: Mapping to another Optional will yield a nested Optional. Did you mean flatMap?
    • ๐Ÿ’… OutlineNone: Setting CSS outline style to none or 0 (while not otherwise providing visual focus indicators) is inaccessible for users navigating a web page without a mouse.
    • PreconditionsCheckNotNullRepeated: Including the first argument of checkNotNull in the failure message is not useful, as it will always be null.
    • ๐Ÿšš RedundantOverride: This override is redundant, and can be removed.
    • RefersToDaggerCodegen: Don't refer to Dagger's internal or generated code
    • โฑ RxReturnValueIgnored: Returned Rx objects must be checked. Ignoring a returned Rx value means it is never scheduled for execution
    • TreeToString: Tree#toString shouldn't be used for Trees deriving from the code being compiled, as it discards whitespace and comments.
    • โœ… TypeEquals: com.sun.tools.javac.code.Type doesn't override Object.equals and instances are not interned by javac, so testing types for equality should be done with Types#isSameType instead
    • UnescapedEntity: Javadoc is interpreted as HTML, so HTML entities such as &, <, > must be escaped.
    • UnusedMethod: Unused.
    • ๐Ÿšš UnusedNestedClass: This nested class is unused, and can be removed.
    • UnusedVariable: Unused.

    ๐Ÿ†• New date and time related checks:

    • JavaDurationGetSecondsGetNano: duration.getNano() only accesses the underlying nanosecond adjustment from the whole second.
    • JavaDurationWithNanos: Use of java.time.Duration.withNanos(int) is not allowed.
    • JavaDurationWithSeconds: Use of java.time.Duration.withSeconds(long) is not allowed.
    • JavaInstantGetSecondsGetNano: instant.getNano() only accesses the underlying nanosecond adjustment from the whole second.
    • 0๏ธโƒฃ JavaTimeDefaultTimeZone: java.time APIs that silently use the default system time-zone are not allowed.
    • JodaDurationConstructor: Use of new Duration(long) is not allowed. Please use Duration.millis(long) instead.
    • JodaDurationWithMillis: Use of duration.withMillis(long) is not allowed. Please use Duration.millis(long) instead.
    • JodaInstantWithMillis: Use of instant.withMillis(long) is not allowed. Please use new Instant(long) instead.
    • ๐Ÿ“œ JodaNewPeriod: This may have surprising semantics, e.g. new Period(LocalDate.parse("1970-01-01"), LocalDate.parse("1970-02-02")).getDays() == 1, not 32.
    • JodaPlusMinusLong: Use of JodaTime's type.plus(long) or type.minus(long) is not allowed (where = {Duration,Instant,DateTime,DateMidnight}). Please use type.plus(Duration.millis(long)) or type.minus(Duration.millis(long)) instead.
    • JodaTimeConverterManager: Joda-Time's ConverterManager makes the semantics of DateTime/Instant/etc construction subject to global static state. If you need to define your own converters, use a helper.
    • JodaToSelf: Use of Joda-Time's DateTime.toDateTime(), Duration.toDuration(), Instant.toInstant(), Interval.toInterval(), and Period.toPeriod() are not allowed.
    • JodaWithDurationAddedLong: Use of JodaTime's type.withDurationAdded(long, int) (where = {Duration,Instant,DateTime}). Please use type.withDurationAdded(Duration.millis(long), int) instead.
    • TemporalAccessorGetChronoField: TemporalAccessor.get() only works for certain values of ChronoField.
    • TimeUnitConversionChecker: This TimeUnit conversion looks buggy: converting from a smaller unit to a larger unit (and passing a constant), converting to/from the same TimeUnit, or converting TimeUnits where the result is statically known to be 0 or 1 are all buggy patterns.
    • ๐Ÿ‘ป DurationFrom: Duration.from(Duration) returns itself; from(Period) throws a runtime exception.
    • DurationGetTemporalUnit: Duration.get() only works with SECONDS or NANOS.
    • DurationToLongTimeUnit: Unit mismatch when decomposing a Duration or Instant to call a <long, TimeUnit> API
    • ๐Ÿ‘ป InvalidZoneId: Invalid zone identifier. ZoneId.of(String) will throw exception at runtime.
    • ๐Ÿ‘ป PeriodFrom: Period.from(Period) returns itself; from(Duration) throws a runtime exception.
    • PeriodGetTemporalUnit: Period.get() only works with YEARS, MONTHS, or DAYS.
    • PeriodTimeMath: When adding or subtracting from a Period, Duration is incompatible.
    • ProtoDurationGetSecondsGetNano: getNanos() only accesses the underlying nanosecond-adjustment of the duration.
    • ProtoTimestampGetSecondsGetNano: getNanos() only accesses the underlying nanosecond-adjustment of the instant.
    • ProtoTruthMixedDescriptors: The arguments passed to ignoringFields are inconsistent with the proto which is the subject of the assertion.
    • TimeUnitMismatch: An value that appears to be represented in one unit is used where another appears to be required (e.g., seconds where nanos are needed)

    API changes:

    • ๐Ÿ‘ @BugPattern.category is no longer supported; prefer @BugPattern.tags as a means to apply general tags to checks.

    Other changes:

    • โš  Suppress checks thoroughly when -XepDisableWarningsInGeneratedCode is passed.
    • ๐Ÿ‘‰ Make UnusedVariable match unused assignments too.
    • ๐Ÿ– Handle static methods in InfiniteRecursion
    • โž• Add common java.time types to ReturnValueIgnored.
    • ๐Ÿ— ModifiedButNotUsed: match orphaned chains of proto/collection builders
    • ๐Ÿ‘Œ Improve NarrowingCompoundAssignment's fixes for ternary
    • ๐Ÿ‘ Allow suppressing AutoValueImmutableFields at the field level rather than just for the entire class.
    • ๐Ÿ– Handle DateTimeFormat and DateTimeFormatter in MisusedWeekYear
    • ๐Ÿ‘ Allow suppressing UnusedException on the CatchTree's VariableTree.
    • require constructors invoking a @MustBeClosed constructor to be marked @MustBeClosed too
    • ๐Ÿ‘Œ support Android's @RecentlyXxx annotations and @CheckForNull in nullness analysis.
    • Match methods instead of classes in AutoValueImmutableFields checker.
    • โž• Add a bunch more mutable types to the AutoValueImmutableFields matcher.
    • ๐Ÿ›  Fix bug in WellKnownMutability incorrectly identifying proto1 as proto2.
    • Don't flag java.lang.Object in EqualsHashCode check
    • ๐Ÿ‘Œ Improve AutoValueFinalMethods check by adding more specific diagnostic at first matched method.
    • The NoAllocationChecker now requires the @NoAllocation annotation to be propagated to all overrides of a method that has the annotation, to reflect the contractual nature of the annotation.
    • Catch unescaped entities in Javadocs.