From c292708b184d671dc8bcd34ad5faa6a3c9ba67a6 Mon Sep 17 00:00:00 2001 From: Jakub Judiny <judiny@cesnet.cz> Date: Wed, 10 May 2023 17:23:17 +0200 Subject: [PATCH] Fix unnecessary pass / else warnings (Redmine issue: #7652) --- lib/mentat/daemon/component/inspector.py | 8 ++++---- lib/mentat/dirq.py | 1 - lib/mentat/plugin/enricher/passivedns.py | 1 - lib/mentat/reports/event.py | 14 ++++++++------ lib/mentat/services/nerd.py | 1 - lib/mentat/services/pdnsr.py | 1 - 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/mentat/daemon/component/inspector.py b/lib/mentat/daemon/component/inspector.py index d74f8681..53139405 100644 --- a/lib/mentat/daemon/component/inspector.py +++ b/lib/mentat/daemon/component/inspector.py @@ -317,10 +317,10 @@ class InspectorDaemonComponent(pyzenkit.zendaemon.ZenDaemonComponent): # pylint raise pyzenkit.zendaemon.ZenDaemonComponentException( "Unknown inspection rule action '{}':'{}'".format(rule, action['action']) ) - else: - raise pyzenkit.zendaemon.ZenDaemonComponentException( - "Unknown fallback action '{}'".format(action['action']) - ) + + raise pyzenkit.zendaemon.ZenDaemonComponentException( + "Unknown fallback action '{}'".format(action['action']) + ) act = {} act['action'] = action.get('action') diff --git a/lib/mentat/dirq.py b/lib/mentat/dirq.py index 436d4330..9102876d 100644 --- a/lib/mentat/dirq.py +++ b/lib/mentat/dirq.py @@ -262,7 +262,6 @@ class DirectoryQueue: return (None, None) except FileNotFoundError: self.stats[self.STAT_CNT_SKIPS] += 1 - pass return (None, None) def _commit_move(self, itemid): diff --git a/lib/mentat/plugin/enricher/passivedns.py b/lib/mentat/plugin/enricher/passivedns.py index 0a8d0f34..d13c2d67 100644 --- a/lib/mentat/plugin/enricher/passivedns.py +++ b/lib/mentat/plugin/enricher/passivedns.py @@ -52,7 +52,6 @@ class PassiveDNSConnectorError(RuntimeError): """ Custom error of the PassiveDNSConnector """ - pass class PassiveDNSConnectorBase: diff --git a/lib/mentat/reports/event.py b/lib/mentat/reports/event.py index addd7c30..39617581 100644 --- a/lib/mentat/reports/event.py +++ b/lib/mentat/reports/event.py @@ -268,26 +268,28 @@ class EventReporter(BaseReporter): if not events: result['result'] = 'skipped-no-events' - for groups in events: + for groups, groups_events in events.items(): (group_chain, fallback_groups) = groups # Check, that there is anything to report (regular and/or relapsed events). - if 'regular' not in events[groups] and 'relapsed' not in events[groups]: + if 'regular' not in groups_events and 'relapsed' not in groups_events: result[str(group_chain)]['evcount_rep'] = 0 result[str(group_chain)]['result'] = 'skipped-no-events' continue - result[str(group_chain)]['evcount_rep'] = len(events[groups].get('regular', [])) + len(events[groups].get('relapsed', [])) + result[str(group_chain)]['evcount_rep'] = len(groups_events.get('regular', [])) + len(groups_events.get('relapsed', [])) main_group_settings = self.settings_dict[group_chain[0]] original_group_only = len(group_chain) == 1 and group_chain[0] == abuse_group.name # Generate summary report. - report_summary = self.report_summary(result, events[groups], group_chain, fallback_groups, main_group_settings, severity, time_l, time_h, original_group_only, template_vars, testdata) + report_summary = self.report_summary(result, groups_events, group_chain, fallback_groups, main_group_settings, + severity, time_l, time_h, original_group_only, template_vars, testdata) # Generate extra reports. - self.report_extra(report_summary, result, events[groups], group_chain, fallback_groups, main_group_settings, severity, time_l, time_h, template_vars, testdata) + self.report_extra(report_summary, result, groups_events, group_chain, fallback_groups, main_group_settings, + severity, time_l, time_h, template_vars, testdata) # Update thresholding cache. - self.update_thresholding_cache(events[groups], main_group_settings, severity, time_h) + self.update_thresholding_cache(groups_events, main_group_settings, severity, time_h) result['result'] = 'reported' result[str(group_chain)]['result'] = 'reported' diff --git a/lib/mentat/services/nerd.py b/lib/mentat/services/nerd.py index c5761db4..50a32ac7 100644 --- a/lib/mentat/services/nerd.py +++ b/lib/mentat/services/nerd.py @@ -81,7 +81,6 @@ class NerdService: """ Additional internal setup currently not necessary. """ - pass def status(self): """ diff --git a/lib/mentat/services/pdnsr.py b/lib/mentat/services/pdnsr.py index 6773dca1..c12abf57 100644 --- a/lib/mentat/services/pdnsr.py +++ b/lib/mentat/services/pdnsr.py @@ -78,7 +78,6 @@ class PDNSRService: """ Additional internal setup currently not necessary. """ - pass def status(self): """ -- GitLab