Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
rickie authored and Stephan202 committed Oct 25, 2022
1 parent 5b547fd commit 827b70c
Showing 1 changed file with 28 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
package tech.picnic.errorprone.bugpatterns;

import static com.google.common.base.Predicates.containsPattern;

import com.google.errorprone.CompilationTestHelper;
import org.junit.jupiter.api.Test;

final class TimeZoneUsageTest {
private final CompilationTestHelper compilationHelper =
CompilationTestHelper.newInstance(TimeZoneUsage.class, getClass())
.expectErrorMessage(
"X",
containsPattern(
"Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone"));
CompilationTestHelper.newInstance(TimeZoneUsage.class, getClass());

@Test
void identification() {
Expand Down Expand Up @@ -39,68 +33,68 @@ void identification() {
" Clock.offset(clock, Duration.ZERO);",
" Clock.tick(clock, Duration.ZERO);",
"",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" Clock.systemUTC();",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" Clock.systemDefaultZone();",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" Clock.system(UTC);",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" Clock.tickMillis(UTC);",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" Clock.tickMinutes(UTC);",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" Clock.tickSeconds(UTC);",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" clock.getZone();",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" clock.withZone(UTC);",
"",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" Instant.now();",
" // This is equivalent to `clock.instant()`, which is fine.",
" Instant.now(clock);",
"",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" LocalDate.now();",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" LocalDate.now(clock);",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" LocalDate.now(UTC);",
"",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" LocalDateTime.now();",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" LocalDateTime.now(clock);",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" LocalDateTime.now(UTC);",
"",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" LocalTime.now();",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" LocalTime.now(clock);",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" LocalTime.now(UTC);",
"",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" OffsetDateTime.now();",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" OffsetDateTime.now(clock);",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" OffsetDateTime.now(UTC);",
"",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" OffsetTime.now();",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" OffsetTime.now(clock);",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" OffsetTime.now(UTC);",
"",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" ZonedDateTime.now();",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" ZonedDateTime.now(clock);",
" // BUG: Diagnostic matches: X",
" // BUG: Diagnostic contains:",
" ZonedDateTime.now(UTC);",
" }",
"",
Expand Down

0 comments on commit 827b70c

Please sign in to comment.