From 05fe1c16c41b6a799dec011244a162d868200bb5 Mon Sep 17 00:00:00 2001 From: millmanorama Date: Fri, 2 Nov 2018 10:00:48 +0100 Subject: [PATCH] fixes for codacy issues --- .../autopsy/timeline/FilteredEventsModel.java | 4 ++-- .../autopsy/timeline/TimeLineController.java | 8 +++----- .../timeline/ui/filtering/FilterSetPanel.java | 2 -- .../datamodel/CompoundFilterStateImpl.java | 8 ++++++++ .../ui/filtering/datamodel/RootFilterState.java | 13 +++++-------- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/timeline/FilteredEventsModel.java b/Core/src/org/sleuthkit/autopsy/timeline/FilteredEventsModel.java index de69ad585b..52cb0c51a6 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/FilteredEventsModel.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/FilteredEventsModel.java @@ -246,7 +246,7 @@ public final class FilteredEventsModel { //because there is no way to remove a datasource we only add to this map. for (Long id : dataSourceIDs) { try { - if (datasourcesMap.containsKey(id) == false) { + if (datasourcesMap.get(id) == null) { datasourcesMap.put(id, skCase.getDataSource(id)); } } catch (TskDataException ex) { @@ -663,7 +663,7 @@ public final class FilteredEventsModel { return updatedEventIDs; } - synchronized void invalidateAllCaches() throws TskCoreException { + synchronized protected void invalidateAllCaches() throws TskCoreException { minCache.invalidateAll(); maxCache.invalidateAll(); idToEventCache.invalidateAll(); diff --git a/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java b/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java index d0f1ac3fcd..ebb16cef85 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java @@ -40,7 +40,6 @@ import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.ReadOnlyStringProperty; import javafx.beans.property.ReadOnlyStringWrapper; -import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.collections.ObservableSet; @@ -56,7 +55,6 @@ import org.joda.time.Interval; import org.joda.time.ReadablePeriod; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; -import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import static org.sleuthkit.autopsy.casemodule.Case.Events.CURRENT_CASE; @@ -76,8 +74,10 @@ import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.ModuleDataEvent; import org.sleuthkit.autopsy.timeline.events.ViewInTimelineRequestedEvent; import org.sleuthkit.autopsy.timeline.ui.detailview.datamodel.DetailViewEvent; +import org.sleuthkit.autopsy.timeline.ui.filtering.datamodel.FilterState; import org.sleuthkit.autopsy.timeline.ui.filtering.datamodel.RootFilterState; import org.sleuthkit.autopsy.timeline.utils.IntervalUtils; +import org.sleuthkit.autopsy.timeline.zooming.TimeUnits; import org.sleuthkit.autopsy.timeline.zooming.ZoomState; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -85,8 +85,6 @@ import org.sleuthkit.datamodel.DescriptionLoD; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.timeline.EventType; import org.sleuthkit.datamodel.timeline.EventTypeZoomLevel; -import org.sleuthkit.autopsy.timeline.ui.filtering.datamodel.FilterState; -import org.sleuthkit.autopsy.timeline.zooming.TimeUnits; import org.sleuthkit.datamodel.timeline.TimelineFilter.DescriptionFilter; import org.sleuthkit.datamodel.timeline.TimelineFilter.EventTypeFilter; @@ -283,7 +281,7 @@ public class TimeLineController { * TimeLineController. Do we need to do this with datasource or hash hit * filters? */ - historyManager.currentState().addListener(( observable, oldState, newState) -> { + historyManager.currentState().addListener((observable, oldState, newState) -> { ZoomState historyManagerState = newState; filteredEvents.syncFilters(historyManagerState.getFilterState()); currentParams.set(historyManagerState); diff --git a/Core/src/org/sleuthkit/autopsy/timeline/ui/filtering/FilterSetPanel.java b/Core/src/org/sleuthkit/autopsy/timeline/ui/filtering/FilterSetPanel.java index 84bd48dbc2..0fe559d19a 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/ui/filtering/FilterSetPanel.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/ui/filtering/FilterSetPanel.java @@ -22,7 +22,6 @@ import java.util.Arrays; import javafx.application.Platform; import javafx.beans.InvalidationListener; import javafx.beans.binding.Bindings; -import javafx.beans.binding.BooleanBinding; import javafx.collections.FXCollections; import javafx.collections.ObservableMap; import javafx.fxml.FXML; @@ -44,7 +43,6 @@ import org.sleuthkit.autopsy.timeline.FXMLConstructor; import org.sleuthkit.autopsy.timeline.FilteredEventsModel; import org.sleuthkit.autopsy.timeline.TimeLineController; import org.sleuthkit.autopsy.timeline.actions.ResetFilters; -import org.sleuthkit.autopsy.timeline.ui.filtering.datamodel.CompoundFilterState; import org.sleuthkit.autopsy.timeline.ui.filtering.datamodel.FilterState; import org.sleuthkit.autopsy.timeline.ui.filtering.datamodel.RootFilterState; import org.sleuthkit.datamodel.timeline.TimelineFilter; diff --git a/Core/src/org/sleuthkit/autopsy/timeline/ui/filtering/datamodel/CompoundFilterStateImpl.java b/Core/src/org/sleuthkit/autopsy/timeline/ui/filtering/datamodel/CompoundFilterStateImpl.java index ebcc5b6426..26674d03a3 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/ui/filtering/datamodel/CompoundFilterStateImpl.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/ui/filtering/datamodel/CompoundFilterStateImpl.java @@ -28,6 +28,14 @@ import javafx.collections.ObservableList; import org.sleuthkit.datamodel.timeline.TimelineFilter; import org.sleuthkit.datamodel.timeline.TimelineFilter.CompoundFilter; +/** + * + * Defualt implementation of CompoundFilterState + * + * @param The type of the subfilters in the underlying + * CompoundFilter + * @param The type of the underlying CompoundFilter + */ class CompoundFilterStateImpl> extends DefaultFilterState implements CompoundFilterState { diff --git a/Core/src/org/sleuthkit/autopsy/timeline/ui/filtering/datamodel/RootFilterState.java b/Core/src/org/sleuthkit/autopsy/timeline/ui/filtering/datamodel/RootFilterState.java index 3f50a39615..06ddb935f9 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/ui/filtering/datamodel/RootFilterState.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/ui/filtering/datamodel/RootFilterState.java @@ -22,6 +22,8 @@ import javafx.beans.property.ReadOnlyBooleanProperty; import javafx.beans.property.ReadOnlyBooleanWrapper; import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import org.apache.commons.lang3.ObjectUtils; +import static org.apache.commons.lang3.ObjectUtils.notEqual; import org.sleuthkit.datamodel.timeline.TimelineFilter; import org.sleuthkit.datamodel.timeline.TimelineFilter.DataSourceFilter; import org.sleuthkit.datamodel.timeline.TimelineFilter.DataSourcesFilter; @@ -199,24 +201,19 @@ public class RootFilterState implements CompoundFilterState< TimelineFilter, Roo RootFilter activeFilter = getActiveFilter(); RootFilter activeFilter1 = otherFilterState.getActiveFilter(); - if (false == activeFilter.equals(activeFilter1)) { + if (notEqual(activeFilter, activeFilter1)) { return false; } RootFilter filter = getFilter(); RootFilter filter1 = otherFilterState.getFilter(); - if (false == filter.equals(filter1)) { - return false; - } - return true; + return filter.equals(filter1); } @Override public int hashCode() { - int hash = 7; - - return hash; + return 7; } @Override