Sha256: 6f2213e82c53631a578a9f4d02897b91663a942a98a1b050fc5f0452e7ce02fe

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

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

      def initialize(_args = [])
        super

        process_args
      end

      def run
        require_codeclimate_yml

        runner = EnginesRunner.new(registry, formatter, source_dir, config)
        runner.run

      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
      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

5 entries across 5 versions & 1 rubygems

Version Path
codeclimate-0.2.4 lib/cc/cli/analyze.rb
codeclimate-0.2.2 lib/cc/cli/analyze.rb
codeclimate-0.2.1 lib/cc/cli/analyze.rb
codeclimate-0.2 lib/cc/cli/analyze.rb
codeclimate-0.1.5 lib/cc/cli/analyze.rb