codeclimate 0.69.0 → 0.70.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/prep-release +1 -1
- data/config/engines.yml +32 -323
- data/lib/cc/analyzer.rb +5 -4
- data/lib/cc/analyzer/bridge.rb +106 -0
- data/lib/cc/analyzer/composite_container_listener.rb +4 -8
- data/lib/cc/analyzer/container.rb +44 -41
- data/lib/cc/analyzer/container/result.rb +74 -0
- data/lib/cc/analyzer/container_listener.rb +2 -7
- data/lib/cc/analyzer/engine.rb +53 -45
- data/lib/cc/analyzer/engine_output.rb +40 -10
- data/lib/cc/analyzer/formatters/formatter.rb +2 -0
- data/lib/cc/analyzer/formatters/html_formatter.rb +4 -0
- data/lib/cc/analyzer/formatters/json_formatter.rb +1 -0
- data/lib/cc/analyzer/formatters/plain_text_formatter.rb +8 -1
- data/lib/cc/analyzer/issue.rb +4 -2
- data/lib/cc/analyzer/issue_validations/relative_path_validation.rb +6 -2
- data/lib/cc/analyzer/issue_validator.rb +3 -32
- data/lib/cc/analyzer/logging_container_listener.rb +9 -7
- data/lib/cc/analyzer/measurement.rb +22 -0
- data/lib/cc/analyzer/measurement_validations.rb +16 -0
- data/lib/cc/analyzer/measurement_validations/name_validation.rb +23 -0
- data/lib/cc/analyzer/measurement_validations/type_validation.rb +15 -0
- data/lib/cc/analyzer/measurement_validations/validation.rb +27 -0
- data/lib/cc/analyzer/measurement_validations/value_validation.rb +21 -0
- data/lib/cc/analyzer/measurement_validator.rb +11 -0
- data/lib/cc/analyzer/raising_container_listener.rb +18 -18
- data/lib/cc/analyzer/statsd_container_listener.rb +22 -22
- data/lib/cc/analyzer/validator.rb +38 -0
- data/lib/cc/cli.rb +12 -12
- data/lib/cc/cli/analyze.rb +42 -60
- data/lib/cc/cli/analyze/engine_failure.rb +11 -0
- data/lib/cc/cli/command.rb +0 -10
- data/lib/cc/cli/engines.rb +0 -3
- data/lib/cc/cli/engines/engine_command.rb +2 -34
- data/lib/cc/cli/engines/install.rb +11 -17
- data/lib/cc/cli/engines/list.rb +5 -3
- data/lib/cc/cli/prepare.rb +5 -11
- data/lib/cc/cli/runner.rb +1 -2
- data/lib/cc/cli/test.rb +0 -1
- data/lib/cc/cli/validate_config.rb +49 -63
- data/lib/cc/cli/version_checker.rb +3 -3
- data/lib/cc/config.rb +70 -0
- data/lib/cc/config/checks_adapter.rb +40 -0
- data/lib/cc/config/default_adapter.rb +52 -0
- data/lib/cc/config/engine.rb +41 -0
- data/lib/cc/config/engine_set.rb +47 -0
- data/lib/cc/config/json_adapter.rb +17 -0
- data/lib/cc/config/prepare.rb +92 -0
- data/lib/cc/config/validation/check_validator.rb +34 -0
- data/lib/cc/config/validation/engine_validator.rb +89 -0
- data/lib/cc/config/validation/fetch_validator.rb +78 -0
- data/lib/cc/config/validation/file_validator.rb +112 -0
- data/lib/cc/config/validation/hash_validations.rb +52 -0
- data/lib/cc/config/validation/json.rb +31 -0
- data/lib/cc/config/validation/prepare_validator.rb +40 -0
- data/lib/cc/config/validation/yaml.rb +66 -0
- data/lib/cc/config/yaml_adapter.rb +73 -0
- data/lib/cc/engine_registry.rb +74 -0
- data/lib/cc/workspace/path_tree/dir_node.rb +1 -1
- metadata +36 -55
- data/bin/codeclimate-init +0 -6
- data/config/coffeelint/coffeelint.json +0 -129
- data/config/csslint/.csslintrc +0 -2
- data/config/eslint/.eslintignore +0 -1
- data/config/eslint/.eslintrc.yml +0 -277
- data/config/rubocop/.rubocop.yml +0 -1156
- data/lib/cc/analyzer/config.rb +0 -86
- data/lib/cc/analyzer/engine_registry.rb +0 -36
- data/lib/cc/analyzer/engines_config_builder.rb +0 -97
- data/lib/cc/analyzer/engines_runner.rb +0 -64
- data/lib/cc/cli/config.rb +0 -44
- data/lib/cc/cli/config_generator.rb +0 -108
- data/lib/cc/cli/engines/disable.rb +0 -38
- data/lib/cc/cli/engines/enable.rb +0 -41
- data/lib/cc/cli/engines/remove.rb +0 -35
- data/lib/cc/cli/init.rb +0 -117
- data/lib/cc/cli/prepare/quality.rb +0 -64
- data/lib/cc/cli/upgrade_config_generator.rb +0 -42
@@ -1,41 +0,0 @@
|
|
1
|
-
require "cc/analyzer"
|
2
|
-
|
3
|
-
module CC
|
4
|
-
module CLI
|
5
|
-
module Engines
|
6
|
-
class Enable < EngineCommand
|
7
|
-
ARGUMENT_LIST = "<engine_name>".freeze
|
8
|
-
SHORT_HELP = "Enable an engine in your codeclimate.yml.".freeze
|
9
|
-
HELP = "#{SHORT_HELP}\n" \
|
10
|
-
"\n"\
|
11
|
-
" <engine_name> Engine to enable in your codeclimate.yml".freeze
|
12
|
-
|
13
|
-
def run
|
14
|
-
require_codeclimate_yml
|
15
|
-
|
16
|
-
if !engine_exists?
|
17
|
-
say "Engine not found. Run 'codeclimate engines:list' for a list of valid engines."
|
18
|
-
elsif engine_enabled?
|
19
|
-
say "Engine already enabled."
|
20
|
-
pull_docker_images
|
21
|
-
else
|
22
|
-
enable_engine
|
23
|
-
update_yaml
|
24
|
-
say "Engine added to .codeclimate.yml."
|
25
|
-
pull_docker_images
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def pull_docker_images
|
32
|
-
Engines::Install.new.run
|
33
|
-
end
|
34
|
-
|
35
|
-
def enable_engine
|
36
|
-
parsed_yaml.enable_engine(engine_name)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require "cc/analyzer"
|
2
|
-
|
3
|
-
module CC
|
4
|
-
module CLI
|
5
|
-
module Engines
|
6
|
-
class Remove < EngineCommand
|
7
|
-
ARGUMENT_LIST = "<engine_name>".freeze
|
8
|
-
SHORT_HELP = "Remove an engine from your codeclimate.yml.".freeze
|
9
|
-
HELP = "#{SHORT_HELP} This command deletes the config rather than setting it to disabled.\n" \
|
10
|
-
"\n"\
|
11
|
-
" <engine_name> Engine to remove from your codeclimate.yml".freeze
|
12
|
-
|
13
|
-
def run
|
14
|
-
require_codeclimate_yml
|
15
|
-
|
16
|
-
if !engine_exists?
|
17
|
-
say "Engine not found. Run 'codeclimate engines:list' for a list of valid engines."
|
18
|
-
elsif !engine_present_in_yaml?
|
19
|
-
say "Engine not found in .codeclimate.yml."
|
20
|
-
else
|
21
|
-
remove_engine
|
22
|
-
update_yaml
|
23
|
-
say "Engine removed from .codeclimate.yml."
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def remove_engine
|
30
|
-
parsed_yaml.remove_engine(engine_name)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/lib/cc/cli/init.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
require "cc/cli/config"
|
2
|
-
require "cc/cli/config_generator"
|
3
|
-
require "cc/cli/upgrade_config_generator"
|
4
|
-
|
5
|
-
module CC
|
6
|
-
module CLI
|
7
|
-
class Init < Command
|
8
|
-
include CC::Analyzer
|
9
|
-
|
10
|
-
ARGUMENT_LIST = "[--upgrade]".freeze
|
11
|
-
SHORT_HELP = "Generate a configuration based on the contents of your repo.".freeze
|
12
|
-
HELP = "#{SHORT_HELP}\n" \
|
13
|
-
"\n" \
|
14
|
-
" --upgrade Upgrade a Code Climate Classic configuration".freeze
|
15
|
-
|
16
|
-
def run
|
17
|
-
if !upgrade? && filesystem.exist?(CODECLIMATE_YAML)
|
18
|
-
warn "Config file .codeclimate.yml already present.\nTry running 'validate-config' to check configuration."
|
19
|
-
create_default_engine_configs if engines_enabled?
|
20
|
-
elsif upgrade? && engines_enabled?
|
21
|
-
warn "Config file .codeclimate.yml already configured for the Platform.\nTry running 'validate-config' to check configuration."
|
22
|
-
create_default_engine_configs
|
23
|
-
else
|
24
|
-
generate_all_config
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def upgrade?
|
31
|
-
@args.include?("--upgrade")
|
32
|
-
end
|
33
|
-
|
34
|
-
def generate_all_config
|
35
|
-
unless config_generator.can_generate?
|
36
|
-
config_generator.errors.each do |error|
|
37
|
-
$stderr.puts colorize("ERROR: #{error}", :red)
|
38
|
-
end
|
39
|
-
fatal "Cannot generate .codeclimate.yml: please address above errors."
|
40
|
-
end
|
41
|
-
|
42
|
-
create_codeclimate_yaml
|
43
|
-
success "Config file .codeclimate.yml successfully #{config_generator.post_generation_verb}.\nEdit and then try running 'validate-config' to check configuration."
|
44
|
-
create_default_engine_configs
|
45
|
-
end
|
46
|
-
|
47
|
-
def create_codeclimate_yaml
|
48
|
-
say "Generating .codeclimate.yml..."
|
49
|
-
config = CC::CLI::Config.new
|
50
|
-
|
51
|
-
config_generator.eligible_engines.each do |(engine_name, engine_config)|
|
52
|
-
config.add_engine(engine_name, engine_config)
|
53
|
-
end
|
54
|
-
|
55
|
-
config.add_exclude_paths(config_generator.exclude_paths)
|
56
|
-
filesystem.write_path(CODECLIMATE_YAML, config.to_yaml)
|
57
|
-
end
|
58
|
-
|
59
|
-
def create_default_engine_configs
|
60
|
-
say "Generating default configuration for engines..."
|
61
|
-
available_engine_configs.each do |(engine_name, config_paths)|
|
62
|
-
if (engine = engine_registry[engine_name])
|
63
|
-
config_mapping = Hash.new { |_, k| [k] }.merge(engine.fetch("config_files", {}))
|
64
|
-
|
65
|
-
config_paths.each do |config_path|
|
66
|
-
filename = File.basename(config_path)
|
67
|
-
possible_names = config_mapping[filename].concat([filename])
|
68
|
-
generate_config(config_path, possible_names)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def generate_config(config_path, possible_names)
|
75
|
-
file_name = File.basename(config_path)
|
76
|
-
existing_files = possible_names.select do |f|
|
77
|
-
filesystem.exist? f
|
78
|
-
end
|
79
|
-
if existing_files.any?
|
80
|
-
say "Skipping generating #{file_name}, existing file(s) found: #{existing_files.join(", ")}"
|
81
|
-
else
|
82
|
-
filesystem.write_path(file_name, File.read(config_path))
|
83
|
-
success "Config file #{file_name} successfully generated."
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def available_engine_configs
|
88
|
-
engines = existing_cc_config.engines || {}
|
89
|
-
engine_names = engines.select { |_, config| config.enabled? }.keys
|
90
|
-
|
91
|
-
engine_names.map do |engine_name|
|
92
|
-
engine_directory = File.expand_path("../../../config/#{engine_name}", __dir__)
|
93
|
-
[
|
94
|
-
engine_name,
|
95
|
-
Dir.glob("#{engine_directory}/*", File::FNM_DOTMATCH).
|
96
|
-
reject { |path| %w[. ..].include?(File.basename(path)) },
|
97
|
-
]
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def engines_enabled?
|
102
|
-
cc_config = existing_cc_config
|
103
|
-
cc_config.present? && cc_config.engines.present?
|
104
|
-
end
|
105
|
-
|
106
|
-
def config_generator
|
107
|
-
@config_generator ||= ConfigGenerator.for(filesystem, engine_registry, upgrade?)
|
108
|
-
end
|
109
|
-
|
110
|
-
def existing_cc_config
|
111
|
-
if filesystem.exist?(CODECLIMATE_YAML)
|
112
|
-
CC::Yaml.parse(filesystem.read_path(CODECLIMATE_YAML))
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require "safe_yaml/load"
|
2
|
-
|
3
|
-
module CC
|
4
|
-
module CLI
|
5
|
-
class Prepare
|
6
|
-
class Quality < Command
|
7
|
-
ENGINES_CONFIG = {
|
8
|
-
"complexity-ruby" => {
|
9
|
-
"enabled" => true,
|
10
|
-
"channel" => "beta",
|
11
|
-
},
|
12
|
-
"duplication" => {
|
13
|
-
"enabled" => true,
|
14
|
-
"channel" => "cronopio",
|
15
|
-
"config" => {
|
16
|
-
"languages" => [
|
17
|
-
"ruby",
|
18
|
-
],
|
19
|
-
},
|
20
|
-
},
|
21
|
-
}.freeze
|
22
|
-
|
23
|
-
def execute
|
24
|
-
Dir.chdir(CC::Analyzer::MountedPath.code.container_path) do
|
25
|
-
content =
|
26
|
-
if (existing_contents = read_codeclimate_yml)
|
27
|
-
modify(existing_contents)
|
28
|
-
else
|
29
|
-
{ "engines" => ENGINES_CONFIG }
|
30
|
-
end
|
31
|
-
|
32
|
-
write_codeclimate_yml(content)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def modify(content)
|
39
|
-
content.delete("ratings")
|
40
|
-
content["engines"] ||= {}
|
41
|
-
content["engines"].merge!(ENGINES_CONFIG)
|
42
|
-
content
|
43
|
-
end
|
44
|
-
|
45
|
-
def read_codeclimate_yml
|
46
|
-
SafeYAML.load_file(CODECLIMATE_YAML)
|
47
|
-
rescue Errno::ENOENT
|
48
|
-
CLI.debug("No .codeclimate.yml present")
|
49
|
-
rescue => ex
|
50
|
-
message = "Error reading existing #{CODECLIMATE_YAML}, overwriting."
|
51
|
-
$stderr.puts(colorize("WARNING: #{message}", :yellow))
|
52
|
-
CLI.debug("error: #{ex.class} - #{ex.message}")
|
53
|
-
end
|
54
|
-
|
55
|
-
def write_codeclimate_yml(content)
|
56
|
-
yaml = YAML.dump(content)
|
57
|
-
CLI.debug("Writing .codeclimate.yml")
|
58
|
-
CLI.debug(yaml)
|
59
|
-
File.write(CODECLIMATE_YAML, yaml)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require "cc/cli/config_generator"
|
2
|
-
|
3
|
-
module CC
|
4
|
-
module CLI
|
5
|
-
class UpgradeConfigGenerator < ConfigGenerator
|
6
|
-
def can_generate?
|
7
|
-
errors.blank?
|
8
|
-
end
|
9
|
-
|
10
|
-
def errors
|
11
|
-
existing_yaml.errors
|
12
|
-
end
|
13
|
-
|
14
|
-
def exclude_paths
|
15
|
-
(existing_yaml.exclude_paths || []).map(&:to_s)
|
16
|
-
end
|
17
|
-
|
18
|
-
def post_generation_verb
|
19
|
-
"upgraded"
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def engine_eligible?(engine)
|
25
|
-
base_eligible = super
|
26
|
-
if engine["upgrade_languages"].present?
|
27
|
-
base_eligible && (engine["upgrade_languages"] & classic_languages).any?
|
28
|
-
else
|
29
|
-
base_eligible
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def classic_languages
|
34
|
-
@classic_languages ||= existing_yaml.languages.reject { |_, v| !v }.map(&:first)
|
35
|
-
end
|
36
|
-
|
37
|
-
def existing_yaml
|
38
|
-
@existing_yaml ||= CC::Yaml.parse(File.read(CODECLIMATE_YAML))
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|