Class: CC::CLI::Analyze

Inherits:
Command show all
Includes:
Analyzer
Defined in:
lib/cc/cli/analyze.rb

Constant Summary collapse

ARGUMENT_LIST =
"[-f format] [-e engine[:channel]] [path]".freeze
SHORT_HELP =
"Run analysis with the given arguments".freeze
HELP =
"#{SHORT_HELP}\n" \
"\n" \
"    -f <format>, --format <format>   Format of output. Possible values: #{CC::Analyzer::Formatters::FORMATTERS.keys.join ", "}\n" \
"    -e <engine[:channel]>            Engine to run. Can be specified multiple times.\n" \
"    --dev                            Run in development mode. Engines installed locally that are not in the manifest will be run.\n" \
"    path                             Path to check. Can be specified multiple times.".freeze

Constants included from Analyzer

Analyzer::UnreadableFileError

Constants inherited from Command

Command::CODECLIMATE_YAML, Command::NAMESPACE

Instance Method Summary collapse

Methods inherited from Command

[], abstract!, abstract?, all, command_name, #execute, help, inherited, #require_codeclimate_yml, short_help, synopsis

Methods included from Output

#colorize, #fatal, #rainbow, #say, #success, #terminal, #warn

Constructor Details

#initialize(_args = []) ⇒ Analyze

Returns a new instance of Analyze.



17
18
19
20
21
22
23
24
# File 'lib/cc/cli/analyze.rb', line 17

def initialize(_args = [])
  super
  @engine_options = []
  @path_options = []

  process_args
  apply_config_options
end

Instance Method Details

#runObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cc/cli/analyze.rb', line 26

def run
  require_codeclimate_yml

  Dir.chdir(MountedPath.code.container_path) do
    runner = EnginesRunner.new(registry, formatter, source_dir, config, path_options)
    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