Skip to content

Commit

Permalink
refactor: Refaster rules related to expressions dealing with time
Browse files Browse the repository at this point in the history
  • Loading branch information
2 people authored and app committed Feb 21, 2024
1 parent 3bd8271 commit 7c7b24f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,7 @@ private static List<Committer> getCommitters(Repository repository) {
PersonIdent who = commit.getAuthorIdent();
Committer committer = committers.computeIfAbsent(who.getEmailAddress(),
email -> new Committer(who.getName(), email, new TreeMap<>()));
committer.getCommitsByDay().compute(ZonedDateTime
.ofInstant(who.getWhen().toInstant(), who.getTimeZone().toZoneId())
committer.getCommitsByDay().compute(who.getWhen().toInstant().atZone(who.getTimeZone().toZoneId())
.toLocalDate(),
(day, count) -> count == null ? 1 : count + 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.openrewrite.xml.tree.Xml;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.List;

@Value
Expand Down Expand Up @@ -81,7 +80,7 @@ public Xml.Tag visitTag(Xml.Tag tag, ExecutionContext ctx) {
}
}
if (!hasUntil) {
String date = (untilDate != null && !untilDate.isEmpty()) ? untilDate : LocalDate.now().plus(30, ChronoUnit.DAYS).toString();
String date = (untilDate != null && !untilDate.isEmpty()) ? untilDate : LocalDate.now().plusDays(30).toString();
return t.withAttributes(ListUtils.concat(attributes, autoFormat(new Xml.Attribute(Tree.randomId(), "", Markers.EMPTY,
new Xml.Ident(Tree.randomId(), "", Markers.EMPTY, "until"),
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import java.time.LocalDate;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoUnit;

@Value
@EqualsAndHashCode(callSuper = false)
Expand Down Expand Up @@ -71,7 +70,7 @@ private boolean isPastDueSuppression(Content content) {
}
try {
LocalDate date = LocalDate.parse(maybeDate);
if (date.isBefore(LocalDate.now().minus(1, ChronoUnit.DAYS))) {
if (date.isBefore(LocalDate.now().minusDays(1))) {
return true;
}
} catch (DateTimeParseException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.openrewrite.xml.tree.Xml;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.List;

@Value
Expand Down Expand Up @@ -90,7 +89,7 @@ public Xml.Tag visitTag(Xml.Tag tag, ExecutionContext ctx) {
}
}
if (hasCve) {
String date = (untilDate != null && !untilDate.isEmpty()) ? untilDate : LocalDate.now().plus(30, ChronoUnit.DAYS).toString();
String date = (untilDate != null && !untilDate.isEmpty()) ? untilDate : LocalDate.now().plusDays(30).toString();
final String zuluDate = date + "Z";
t = t.withAttributes(ListUtils.map(t.getAttributes(), attr -> {
if ("until".equals(attr.getKeyAsString())) {
Expand Down

0 comments on commit 7c7b24f

Please sign in to comment.