Sha256: f849741f7172737166f8b551e0a93f71dd93f310cb744327da0370d1f2ada692
Contents?: true
Size: 1.77 KB
Versions: 7
Compression:
Stored size: 1.77 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true # # Wrapper for the CodeClimate integration. require_relative '../lib/reek' require_relative '../lib/reek/cli/application' require_relative '../lib/reek/report/code_climate' # Map input coming from CodeClimate to Reek. class CodeClimateToReek # Following the spec (https://github.com/codeclimate/spec/blob/master/SPEC.md) # we have to exit with a zero for both failure and success. ENGINE_CONFIGURATION = [ '--failure-exit-code', '0', '--success-exit-code', '0' ].freeze attr_reader :configuration_file_path, :include_paths_key, :include_paths_default def initialize(configuration_file_path: '/config.json', include_paths_key: 'include_paths', include_paths_default: ['.']) @configuration_file_path = configuration_file_path @include_paths_key = include_paths_key @include_paths_default = include_paths_default end def cli_arguments include_paths + ENGINE_CONFIGURATION end private def configuration_file_exists? Pathname.new(configuration_file_path).exist? end # The config.json file we try to read below might look like this: # { # "include_paths":[ # "lib", # "spec" # ] # } def include_paths if configuration_file_exists? config = JSON.parse File.read(configuration_file_path) config.fetch include_paths_key, include_paths_default else include_paths_default end end end # Override for ReportCommand to force the use of CodeClimateReport. module ReportClassOverride def report_class Reek::Report::CodeClimateReport end end Reek::CLI::Command::ReportCommand.prepend ReportClassOverride application = Reek::CLI::Application.new(CodeClimateToReek.new.cli_arguments) exit application.execute
Version data entries
7 entries across 7 versions & 1 rubygems