def setup_lizard_tool_plugin(): """Initialize and return an instance of the lizard plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument( "--show-tool-output", dest="show_tool_output", action="store_false", help="Show tool output", ) resources = Resources( [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")]) config = Config(resources.get_file("config.yaml")) plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) plugin_context.args.output_directory = os.path.dirname(__file__) ltp = LizardToolPlugin() ltp.set_plugin_context(plugin_context) return ltp
def setup_make_tool_plugin(): """Construct and return an instance of the Make plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument("--show-tool-output", dest="show_tool_output", action="store_false", help="Show tool output") arg_parser.add_argument('--mapping-file-suffix', dest="mapping_file_suffix", type=str) resources = Resources( [os.path.join(os.path.dirname(statick_tool.__file__), 'plugins')]) config = Config(resources.get_file("config.yaml")) plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) plugin_context.args.output_directory = os.path.dirname(__file__) mtp = MakeToolPlugin() mtp.set_plugin_context(plugin_context) return mtp
def setup_bandit_tool_plugin(): """Create an instance of the bandit plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument("--show-tool-output", dest="show_tool_output", action="store_true", help="Show tool output") arg_parser.add_argument("--bandit-bin", dest="bandit_bin") arg_parser.add_argument('--mapping-file-suffix', dest="mapping_file_suffix", type=str) resources = Resources( [os.path.join(os.path.dirname(statick_tool.__file__), 'plugins')]) config = Config(resources.get_file("config.yaml")) plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) btp = BanditToolPlugin() btp.set_plugin_context(plugin_context) return btp
def setup_rstcheck_tool_plugin(): """Initialize and return an instance of the rstcheck plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument( "--show-tool-output", dest="show_tool_output", action="store_false", help="Show tool output", ) resources = Resources([ os.path.join(os.path.dirname(statick_tool.__file__), "plugins"), os.path.join(os.path.dirname(__file__), "valid_package"), ]) config = Config(resources.get_file("config.yaml")) plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) plugin = RstcheckToolPlugin() plugin.set_plugin_context(plugin_context) return plugin
def setup_cccc_tool_plugin(use_plugin_context=True, binary=None, cccc_config=None): """Create an instance of the CCCC plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument("--cccc-bin", dest="cccc_bin") arg_parser.add_argument("--cccc-config", dest="cccc_config") resources = Resources( [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")] ) config = Config(resources.get_file("config.yaml")) ctp = CCCCToolPlugin() plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) plugin_context.args.output_directory = os.path.dirname(__file__) if binary: plugin_context.args.cccc_bin = binary if cccc_config: plugin_context.args.cccc_config = cccc_config if use_plugin_context: ctp.set_plugin_context(plugin_context) return ctp
def setup_clang_tidy_tool_plugin(use_plugin_context=True, binary=None): """Initialize and return an instance of the clang-tidy plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument("--clang-tidy-bin", dest="clang_tidy_bin") arg_parser.add_argument( "--mapping-file-suffix", dest="mapping_file_suffix", type=str ) resources = Resources( [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")] ) config = Config(resources.get_file("config.yaml")) plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) plugin_context.args.output_directory = os.path.dirname(__file__) cttp = ClangTidyToolPlugin() if binary is not None: plugin_context.args.clang_tidy_bin = binary if use_plugin_context: cttp.set_plugin_context(plugin_context) return cttp
def setup_cmake_discovery_plugin(add_plugin_context=True): """Create an instance of the CMake discovery plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument( "--show-tool-output", dest="show_tool_output", action="store_false", help="Show tool output", ) resources = Resources( [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")] ) config = Config(resources.get_file("config.yaml")) cmdp = CMakeDiscoveryPlugin() if add_plugin_context: plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) plugin_context.args.output_directory = os.path.dirname(__file__) cmdp.set_plugin_context(plugin_context) return cmdp
def setup_spotbugs_tool_plugin(use_plugin_context=True, custom_rsc_path=None): """Initialize and return a spotbugs plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument("--mapping-file-suffix", dest="mapping_file_suffix", type=str) if custom_rsc_path is not None: resources = Resources([custom_rsc_path]) else: resources = Resources( [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")]) config = Config(resources.get_file("config.yaml")) plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) plugin_context.args.output_directory = os.path.dirname(__file__) sbtp = SpotbugsToolPlugin() if use_plugin_context: sbtp.set_plugin_context(plugin_context) return sbtp
def setup_perlcritic_tool_plugin(): """Initialize and return a perlcritic plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument("--show-tool-output", dest="show_tool_output", action="store_true", help="Show tool output") arg_parser.add_argument("--perlcritic-bin", dest="perlcritic_bin") arg_parser.add_argument('--mapping-file-suffix', dest="mapping_file_suffix", type=str) resources = Resources( [os.path.join(os.path.dirname(statick_tool.__file__), 'plugins')]) config = Config(resources.get_file("config.yaml")) plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) pctp = PerlCriticToolPlugin() pctp.set_plugin_context(plugin_context) return pctp
def setup_clang_format_tool_plugin(): """Initialize and return an instance of the clang-format plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument("--show-tool-output", dest="show_tool_output", action="store_true", help="Show tool output") arg_parser.add_argument("--clang-format-bin", dest="clang_format_bin") arg_parser.add_argument("--clang-format-raise-exception", dest="clang_format_raise_exception", action="store_true", default=True) resources = Resources( [os.path.join(os.path.dirname(statick_tool.__file__), 'plugins')]) config = Config(resources.get_file("config.yaml")) plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) cftp = ClangFormatToolPlugin() cftp.set_plugin_context(plugin_context) return cftp
def setup_uncrustify_tool_plugin(extra_path=None): """Initialize and return an instance of the uncrustify plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument("--uncrustify-bin", dest="uncrustify_bin") arg_parser.add_argument("--show-tool-output", dest="show_tool_output", action="store_false", help="Show tool output") paths = [] if extra_path: paths.append(extra_path) paths.append( os.path.join(os.path.dirname(statick_tool.__file__), 'plugins')) resources = Resources(paths) config = Config(resources.get_file("config.yaml")) plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) plugin_context.args.output_directory = os.path.dirname(__file__) utp = UncrustifyToolPlugin() utp.set_plugin_context(plugin_context) return utp
def setup_spotbugs_tool_plugin(use_plugin_context=True): """Initialize and return a spotbugs plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument( "--show-tool-output", dest="show_tool_output", action="store_false", help="Show tool output", ) arg_parser.add_argument("--mapping-file-suffix", dest="mapping_file_suffix", type=str) resources = Resources( [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")]) config = Config(resources.get_file("config.yaml")) plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) plugin_context.args.output_directory = os.path.dirname(__file__) sbtp = SpotbugsToolPlugin() if use_plugin_context: sbtp.set_plugin_context(plugin_context) return sbtp
def setup_uncrustify_tool_plugin(extra_path=None, use_plugin_context=True, binary=None): """Initialize and return an instance of the uncrustify plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument("--uncrustify-bin", dest="uncrustify_bin") paths = [] if extra_path: paths.append(extra_path) paths.append( os.path.join(os.path.dirname(statick_tool.__file__), "plugins")) resources = Resources(paths) config = Config(resources.get_file("config.yaml")) plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) plugin_context.args.output_directory = os.path.dirname(__file__) utp = UncrustifyToolPlugin() if binary: plugin_context.args.uncrustify_bin = binary if use_plugin_context: utp.set_plugin_context(plugin_context) return utp
def setup_flawfinder_tool_plugin(): """Initialize and return an instance of the flawfinder plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument( "--show-tool-output", dest="show_tool_output", action="store_false", help="Show tool output", ) arg_parser.add_argument("--flawfinder-bin", dest="flawfinder_bin") arg_parser.add_argument("--mapping-file-suffix", dest="mapping_file_suffix", type=str) resources = Resources( [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")]) config = Config(resources.get_file("config.yaml")) plugin_context = PluginContext(arg_parser.parse_args([]), resources, config) plugin_context.args.output_directory = os.path.dirname(__file__) fftp = FlawfinderToolPlugin() fftp.set_plugin_context(plugin_context) return fftp
def test_config_extend_combine_base_level(): """Test that user level that inherits from a base level combines plugins.""" base_config_file = os.path.join(os.path.dirname(__file__), "rsc", "config.yaml") user_config_file = os.path.join(os.path.dirname(__file__), "rsc", "config-list.yaml") config = Config(base_config_file, user_config_file) plugins = config.get_enabled_plugins("extend_base", "discovery") assert "C" in plugins plugins = config.get_enabled_plugins("extend_base", "reporting") assert "print_to_console" in plugins assert "write_jenkins_warnings_ng" in plugins plugins = config.get_enabled_plugins("extend_base", "tool") assert "bandit" in plugins assert "catkin_lint" in plugins assert "clang-tidy" in plugins assert "cppcheck" in plugins assert "cpplint" in plugins assert "flawfinder" in plugins assert "perlcritic" in plugins assert "spotbugs" in plugins
def setup_write_jenkins_warnings_ng_reporting_plugin( file_path, use_plugin_context=True ): """Create an instance of the file writer plugin.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument("output_directory") arg_parser.add_argument( "--show-tool-output", dest="show_tool_output", action="store_false", help="Show tool output", ) resources = Resources( [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")] ) config = Config(resources.get_file("config.yaml")) wfrp = WriteJenkinsWarningsNGReportingPlugin() if use_plugin_context: plugin_context = PluginContext( arg_parser.parse_args([file_path]), resources, config ) wfrp.set_plugin_context(plugin_context) return wfrp
def get_config(self, args: argparse.Namespace) -> None: """Get Statick configuration.""" config_filename = "config.yaml" if args.config is not None: config_filename = args.config self.config = Config(self.resources.get_file(config_filename))