From 993321c7d4378f0d33291e47604d447f6d58a6ba Mon Sep 17 00:00:00 2001 From: Michael Scovetta Date: Sat, 8 Jul 2017 19:53:14 -0700 Subject: [PATCH] Added support for periodic scanning (new default). --- DevSkim.py | 18 +++++++++++++++++- DevSkim.sublime-settings | 5 ++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/DevSkim.py b/DevSkim.py index 1e96acc..a23ddc2 100644 --- a/DevSkim.py +++ b/DevSkim.py @@ -98,6 +98,7 @@ suppress_days = [] # Conditional Functions conditional_func_map = {} + class DevSkimEventListener(sublime_plugin.EventListener): """Handles events from Sublime Text.""" @@ -1132,11 +1133,26 @@ class DevSkimReloadRulesCommand(sublime_plugin.TextCommand): rules = [] stylesheet_content = "" +def periodic_analysis_callback(): + try: + view = sublime.active_window().active_view() + view.run_command("dev_skim_analyze", args={'show_popup': False}) + frequency = sublime.load_settings('DevSkim.sublime-settings').get('show_highlights_on_time', 0) + # Re-evaluate this so changes are picked up if the user changes their config. + if frequency > 0: + sublime.set_timeout_async(periodic_analysis_callback, frequency) + + except Exception as msg: + print("Error: {0}".format(msg)) + def plugin_loaded(): """Handle the plugin_loaded event from ST3.""" logger.info('DevSkim plugin_loaded(), Sublime Text v%s' % sublime.version()) - + # Schedule analysis based on configuration + frequency = sublime.load_settings('DevSkim.sublime-settings').get('show_highlights_on_time', 0) + if frequency > 0: + sublime.set_timeout_async(periodic_analysis_callback, frequency) def plugin_unloaded(): """Handle the plugin_unloaded event from ST3.""" diff --git a/DevSkim.sublime-settings b/DevSkim.sublime-settings index 60bf039..03a5ea6 100644 --- a/DevSkim.sublime-settings +++ b/DevSkim.sublime-settings @@ -38,7 +38,10 @@ "show_findings_on_save": true, /* Run analysis whenever a file is changed. */ - "show_highlights_on_modified": true, + "show_highlights_on_modified": false, + + /* Run analysis on a specific timer, in milliseconds, 0=disabled */ + "show_highlights_on_time": 10000, /* Enable per-rule suppressions */ "allow_suppress_specific_rules": true,