Skip to content

Commit

Permalink
Merge pull request #33 from malice00/fix/PMD
Browse files Browse the repository at this point in the history
Fixed PMD issues
  • Loading branch information
malice00 authored Oct 20, 2024
2 parents cc0bbd6 + 3882349 commit 3ab2152
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ private abstract class CalendarEventImpl implements CalendarEvent {
protected long duration;
private transient List<StartedCalendarEvent> lastEvents;

protected String initId(final String url, final long startTimeInMillis) {
/* default */ final String initId(final String url, final long startTimeInMillis) {
return StringUtils.defaultString(url, "")
.replace("/", "-")
.toLowerCase(Locale.ENGLISH) + startTimeInMillis;
}

protected Moment initEnd(final long timeInMillis, final long duration) {
/* default */ final Moment initEnd(final long timeInMillis, final long duration) {
// duration needs to be at least 1sec otherwise
// fullcalendar will not properly display the event
final long dur = (duration < 1000) ? 1000 : duration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import hudson.model.Result;
import hudson.model.Run;
import hudson.scheduler.CronTab;
import hudson.util.RunList;
import io.jenkins.plugins.view.calendar.CalendarView.CalendarViewEventsType;
import io.jenkins.plugins.view.calendar.event.CalendarEvent;
import io.jenkins.plugins.view.calendar.event.CalendarEventComparator;
Expand Down Expand Up @@ -222,7 +221,7 @@ public List<StartedCalendarEvent> getStartedEvents(final List<? extends Job> job
if (state == CalendarEventState.RUNNING && !job.isBuilding()) {
continue;
}
final RunList<Run> builds = job.getBuilds();
final List<Run> builds = job.getBuilds();
for (final Run build : builds) {
if (state == CalendarEventState.RUNNING && !build.isBuilding()) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public List<CronTab> getCronTabs(final Trigger trigger, final Hash hash) {

@SuppressWarnings("PMD.CyclomaticComplexity")
public List<Trigger> getCronTriggers(final Job job, final CalendarViewEventsType eventsType) {
Collection<Trigger<?>> jobTriggers;
final Collection<Trigger<?>> jobTriggers;
if (job instanceof AbstractProject) {
jobTriggers = ((AbstractProject)job).getTriggers().values();
} else if (PluginUtil.hasWorkflowJobPluginInstalled() && job instanceof WorkflowJob) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ public int hashCode() {

@Override
public boolean equals(final Object o) {
if (!(o instanceof Moment)) {
return false;
}
return calendar.equals(((Moment)o).calendar);
return (o instanceof Moment) && calendar.equals(((Moment)o).calendar);
}

@Override
Expand Down

0 comments on commit 3ab2152

Please sign in to comment.