Sha256: ba780c73658df2197795690c430082d3eb598af58c22597c194117e5fe6318da

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

module CC
  module CLI
    class Analyze < Command
      include CC::Analyzer

      def initialize(_args = [])
        super

        process_args
      end

      def run
        require_codeclimate_yml

        Dir.chdir(ENV['FILESYSTEM_DIR']) do
          runner = EnginesRunner.new(registry, formatter, source_dir, config)
          runner.run
        end

      rescue EnginesRunner::InvalidEngineName => ex
        fatal(ex.message)
      rescue EnginesRunner::NoEnabledEngines
        fatal("No enabled engines. Add some to your .codeclimate.yml file!")
      end

      private

      def process_args
        while arg = @args.shift
          case arg
          when '-f'
            @formatter = Formatters.resolve(@args.shift)
          when '--dev'
            @dev_mode = true
          end
        end
      rescue Formatters::Formatter::InvalidFormatterError => e
        fatal(e.message)
      end

      def registry
        EngineRegistry.new(@dev_mode)
      end

      def formatter
        @formatter ||= Formatters::PlainTextFormatter.new(filesystem)
      end

      def source_dir
        ENV["CODE_PATH"]
      end

      def config
        CC::Yaml.parse(filesystem.read_path(CODECLIMATE_YAML))
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
codeclimate-0.4.4 lib/cc/cli/analyze.rb
codeclimate-0.4.3 lib/cc/cli/analyze.rb
codeclimate-0.4.1 lib/cc/cli/analyze.rb
codeclimate-0.4.0 lib/cc/cli/analyze.rb
codeclimate-0.3.2 lib/cc/cli/analyze.rb
codeclimate-0.3.1 lib/cc/cli/analyze.rb
codeclimate-0.3.0 lib/cc/cli/analyze.rb