Sha256: 2d0588b3a61ad217479ce9b32c8ec27755d71796670c3fbdcbc81f6b9ef73fcc

Contents?: true

Size: 1.53 KB

Versions: 24

Compression:

Stored size: 1.53 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'

# 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 = [
    '-f', 'code_climate',
    '--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

application = Reek::CLI::Application.new(CodeClimateToReek.new.cli_arguments)

exit application.execute

Version data entries

24 entries across 22 versions & 2 rubygems

Version Path
reek-5.6.0 bin/code_climate_reek
reek-5.5.0 bin/code_climate_reek
reek-5.4.1 bin/code_climate_reek
reek-5.4.0 bin/code_climate_reek
reek-5.3.2 bin/code_climate_reek
reek-5.3.1 bin/code_climate_reek
reek-5.3.0 bin/code_climate_reek
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/bin/code_climate_reek
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/bin/code_climate_reek
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/bin/code_climate_reek
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/bin/code_climate_reek
reek-5.2.0 bin/code_climate_reek
reek-5.1.0 bin/code_climate_reek
reek-5.0.2 bin/code_climate_reek
reek-5.0.1 bin/code_climate_reek
reek-5.0.0 bin/code_climate_reek
reek-4.8.2 bin/code_climate_reek
reek-4.8.1 bin/code_climate_reek
reek-4.8.0 bin/code_climate_reek
reek-4.7.3 bin/code_climate_reek