codeclimate 0.45.0 → 0.46.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cc/cli.rb +12 -12
- data/lib/cc/cli/analyze.rb +11 -0
- data/lib/cc/cli/command.rb +47 -1
- data/lib/cc/cli/console.rb +2 -0
- data/lib/cc/cli/engines.rb +6 -12
- data/lib/cc/cli/engines/disable.rb +7 -0
- data/lib/cc/cli/engines/enable.rb +6 -0
- data/lib/cc/cli/engines/engine_command.rb +2 -0
- data/lib/cc/cli/engines/install.rb +2 -0
- data/lib/cc/cli/engines/list.rb +2 -0
- data/lib/cc/cli/engines/remove.rb +6 -0
- data/lib/cc/cli/help.rb +31 -20
- data/lib/cc/cli/init.rb +6 -0
- data/lib/cc/cli/prepare.rb +6 -0
- data/lib/cc/cli/runner.rb +15 -10
- data/lib/cc/cli/test.rb +7 -0
- data/lib/cc/cli/validate_config.rb +2 -0
- data/lib/cc/cli/version.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a022d2dd262f4b69810a0039df68c2c35cbce1b1
|
4
|
+
data.tar.gz: c91433584f2f30204f7e91ff73eee620acf238de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8647501044a5a159e06b1c3b708a0fbb33c6c1aa6b18a6743923ebb5516406e229042b252a52f611239c34bad8c4bbf5a77c6d3b3e3ad2c17d5c967fa8279184
|
7
|
+
data.tar.gz: 4a60df0d24f319050ddef3610bd12071cd318db1508f34e2593c09ba9ab9ac3d5d73aabacd909b8ebe6297729581e5f21c0bc54c93308b7ca51a634536b66024
|
data/lib/cc/cli.rb
CHANGED
@@ -5,20 +5,20 @@ require "cc/analyzer"
|
|
5
5
|
require "cc/workspace"
|
6
6
|
require "cc/yaml"
|
7
7
|
|
8
|
+
require "cc/cli/analyze"
|
9
|
+
require "cc/cli/command"
|
10
|
+
require "cc/cli/console"
|
11
|
+
require "cc/cli/engines"
|
12
|
+
require "cc/cli/help"
|
13
|
+
require "cc/cli/init"
|
14
|
+
require "cc/cli/prepare"
|
15
|
+
require "cc/cli/runner"
|
16
|
+
require "cc/cli/test"
|
17
|
+
require "cc/cli/validate_config"
|
18
|
+
require "cc/cli/version"
|
19
|
+
|
8
20
|
module CC
|
9
21
|
module CLI
|
10
|
-
autoload :Analyze, "cc/cli/analyze"
|
11
|
-
autoload :Command, "cc/cli/command"
|
12
|
-
autoload :Console, "cc/cli/console"
|
13
|
-
autoload :Engines, "cc/cli/engines"
|
14
|
-
autoload :Help, "cc/cli/help"
|
15
|
-
autoload :Init, "cc/cli/init"
|
16
|
-
autoload :Prepare, "cc/cli/prepare"
|
17
|
-
autoload :Runner, "cc/cli/runner"
|
18
|
-
autoload :Test, "cc/cli/test"
|
19
|
-
autoload :ValidateConfig, "cc/cli/validate_config"
|
20
|
-
autoload :Version, "cc/cli/version"
|
21
|
-
|
22
22
|
def self.debug?
|
23
23
|
ENV["CODECLIMATE_DEBUG"]
|
24
24
|
end
|
data/lib/cc/cli/analyze.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
|
+
require "cc/cli/command"
|
2
|
+
|
1
3
|
module CC
|
2
4
|
module CLI
|
3
5
|
class Analyze < Command
|
6
|
+
ARGUMENT_LIST = "[-f format] [-e engine[:channel]] [path]".freeze
|
7
|
+
SHORT_HELP = "Run analysis with the given arguments".freeze
|
8
|
+
HELP = "#{SHORT_HELP}\n" \
|
9
|
+
"\n" \
|
10
|
+
" -f <format>, --format <format> Format of output. Possible values: #{CC::Analyzer::Formatters::FORMATTERS.keys.join ", "}\n" \
|
11
|
+
" -e <engine[:channel]> Engine to run. Can be specified multiple times.\n" \
|
12
|
+
" --dev Run in development mode. Engines installed locally that are not in the manifest will be run.\n" \
|
13
|
+
" path Path to check. Can be specified multiple times.".freeze
|
14
|
+
|
4
15
|
include CC::Analyzer
|
5
16
|
|
6
17
|
def initialize(_args = [])
|
data/lib/cc/cli/command.rb
CHANGED
@@ -7,6 +7,50 @@ module CC
|
|
7
7
|
module CLI
|
8
8
|
class Command
|
9
9
|
CODECLIMATE_YAML = ".codeclimate.yml".freeze
|
10
|
+
NAMESPACE = name.split("::")[0..-2].join("::").freeze
|
11
|
+
|
12
|
+
def self.abstract!
|
13
|
+
@abstract = true
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.abstract?
|
17
|
+
@abstract == true
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.all
|
21
|
+
@@subclasses.reject(&:abstract?)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.[](name)
|
25
|
+
all.find { |command| command.name == "#{NAMESPACE}::#{name}" || command.command_name == name }
|
26
|
+
end
|
27
|
+
|
28
|
+
# rubocop: disable Style/ClassVars
|
29
|
+
def self.inherited(subclass)
|
30
|
+
@@subclasses ||= []
|
31
|
+
@@subclasses << subclass
|
32
|
+
end
|
33
|
+
# rubocop: enable Style/ClassVars
|
34
|
+
|
35
|
+
def self.synopsis
|
36
|
+
"#{command_name} #{self::ARGUMENT_LIST if const_defined?(:ARGUMENT_LIST)}".strip
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.short_help
|
40
|
+
if const_defined? :SHORT_HELP
|
41
|
+
self::SHORT_HELP
|
42
|
+
else
|
43
|
+
""
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.help
|
48
|
+
if const_defined? :HELP
|
49
|
+
self::HELP
|
50
|
+
else
|
51
|
+
short_help
|
52
|
+
end
|
53
|
+
end
|
10
54
|
|
11
55
|
def initialize(args = [])
|
12
56
|
@args = args
|
@@ -17,7 +61,9 @@ module CC
|
|
17
61
|
end
|
18
62
|
|
19
63
|
def self.command_name
|
20
|
-
name
|
64
|
+
name.gsub(/^#{NAMESPACE}::/, "").split("::").map do |part|
|
65
|
+
part.split(/(?=[A-Z])/).map(&:downcase).join("-")
|
66
|
+
end.join(":")
|
21
67
|
end
|
22
68
|
|
23
69
|
def execute
|
data/lib/cc/cli/console.rb
CHANGED
data/lib/cc/cli/engines.rb
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
require "cc/analyzer"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
autoload :Install, "cc/cli/engines/install"
|
10
|
-
autoload :List, "cc/cli/engines/list"
|
11
|
-
autoload :Remove, "cc/cli/engines/remove"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
3
|
+
require "cc/cli/engines/disable"
|
4
|
+
require "cc/cli/engines/enable"
|
5
|
+
require "cc/cli/engines/engine_command"
|
6
|
+
require "cc/cli/engines/install"
|
7
|
+
require "cc/cli/engines/list"
|
8
|
+
require "cc/cli/engines/remove"
|
@@ -1,9 +1,16 @@
|
|
1
1
|
require "cc/analyzer"
|
2
|
+
require "cc/cli/engines/engine_command"
|
2
3
|
|
3
4
|
module CC
|
4
5
|
module CLI
|
5
6
|
module Engines
|
6
7
|
class Disable < EngineCommand
|
8
|
+
ARGUMENT_LIST = "<engine_name>".freeze
|
9
|
+
SHORT_HELP = "Disable an engine in your codeclimate.yml.".freeze
|
10
|
+
HELP = "#{SHORT_HELP}\n" \
|
11
|
+
"\n"\
|
12
|
+
" <engine_name> Engine to disable in your codeclimate.yml".freeze
|
13
|
+
|
7
14
|
def run
|
8
15
|
require_codeclimate_yml
|
9
16
|
|
@@ -4,6 +4,12 @@ module CC
|
|
4
4
|
module CLI
|
5
5
|
module Engines
|
6
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
|
+
|
7
13
|
def run
|
8
14
|
require_codeclimate_yml
|
9
15
|
|
data/lib/cc/cli/engines/list.rb
CHANGED
@@ -4,6 +4,12 @@ module CC
|
|
4
4
|
module CLI
|
5
5
|
module Engines
|
6
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
|
+
|
7
13
|
def run
|
8
14
|
require_codeclimate_yml
|
9
15
|
|
data/lib/cc/cli/help.rb
CHANGED
@@ -3,34 +3,45 @@ require "rainbow"
|
|
3
3
|
module CC
|
4
4
|
module CLI
|
5
5
|
class Help < Command
|
6
|
+
ARGUMENT_LIST = "[command]".freeze
|
7
|
+
SHORT_HELP = "Display help information.".freeze
|
8
|
+
HELP = "#{SHORT_HELP}\n" \
|
9
|
+
"\n" \
|
10
|
+
" no arguments Show help summary for all commands.\n" \
|
11
|
+
" [command] Show help for specific commands. Can be specified multiple times.".freeze
|
12
|
+
|
6
13
|
def run
|
7
|
-
|
8
|
-
|
9
|
-
|
14
|
+
if @args.any?
|
15
|
+
@args.each do |command|
|
16
|
+
show_help(command)
|
17
|
+
end
|
18
|
+
else
|
19
|
+
show_help_summary
|
10
20
|
end
|
11
21
|
end
|
12
22
|
|
13
23
|
private
|
14
24
|
|
15
|
-
def
|
16
|
-
[
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
"engines:install",
|
22
|
-
"engines:list",
|
23
|
-
"engines:remove #{underline("engine_name")}",
|
24
|
-
"prepare",
|
25
|
-
"help",
|
26
|
-
"init",
|
27
|
-
"validate-config",
|
28
|
-
"version",
|
29
|
-
].freeze
|
25
|
+
def show_help(command_name)
|
26
|
+
command = Command[command_name]
|
27
|
+
say "Usage: codeclimate #{command.synopsis}\n"
|
28
|
+
say "\n"
|
29
|
+
say "#{command.help}\n"
|
30
|
+
say "\n\n"
|
30
31
|
end
|
31
32
|
|
32
|
-
def
|
33
|
-
|
33
|
+
def show_help_summary
|
34
|
+
short_helps =
|
35
|
+
Command.all.sort_by(&:command_name).map do |command|
|
36
|
+
[command.synopsis, command.short_help]
|
37
|
+
end.compact.to_h
|
38
|
+
|
39
|
+
longest_command_length = short_helps.keys.map(&:length).max
|
40
|
+
|
41
|
+
say "Usage: codeclimate COMMAND ...\n\nAvailable commands:\n"
|
42
|
+
short_helps.each do |command, help|
|
43
|
+
say format(" %-#{longest_command_length}s %s\n", command, help)
|
44
|
+
end
|
34
45
|
end
|
35
46
|
end
|
36
47
|
end
|
data/lib/cc/cli/init.rb
CHANGED
@@ -7,6 +7,12 @@ module CC
|
|
7
7
|
class Init < Command
|
8
8
|
include CC::Analyzer
|
9
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
|
+
|
10
16
|
def run
|
11
17
|
if !upgrade? && filesystem.exist?(CODECLIMATE_YAML)
|
12
18
|
warn "Config file .codeclimate.yml already present.\nTry running 'validate-config' to check configuration."
|
data/lib/cc/cli/prepare.rb
CHANGED
@@ -10,6 +10,12 @@ require "uri"
|
|
10
10
|
module CC
|
11
11
|
module CLI
|
12
12
|
class Prepare < Command
|
13
|
+
ARGUMENT_LIST = "[--allow-internal-ips]".freeze
|
14
|
+
SHORT_HELP = "Run the commands in your prepare step.".freeze
|
15
|
+
HELP = "#{SHORT_HELP}\n" \
|
16
|
+
"\n" \
|
17
|
+
" --allow-internal-ips Allow fetching from internal IPs.".freeze
|
18
|
+
|
13
19
|
InternalHostError = Class.new(StandardError)
|
14
20
|
FetchError = Class.new(StandardError)
|
15
21
|
|
data/lib/cc/cli/runner.rb
CHANGED
@@ -31,25 +31,30 @@ module CC
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def command_class
|
34
|
-
|
34
|
+
command_const = Command[command]
|
35
|
+
if command_const.abstract?
|
36
|
+
nil
|
37
|
+
else
|
38
|
+
command_const
|
39
|
+
end
|
35
40
|
rescue NameError
|
36
41
|
nil
|
37
42
|
end
|
38
43
|
|
39
|
-
def command_name
|
40
|
-
case command
|
41
|
-
when nil, "-h", "-?", "--help" then "Help"
|
42
|
-
when "-v", "--version" then "Version"
|
43
|
-
else command.sub(":", "::").underscore.camelize
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
44
|
def command_arguments
|
48
45
|
@args[1..-1]
|
49
46
|
end
|
50
47
|
|
51
48
|
def command
|
52
|
-
@args.first
|
49
|
+
command_name = @args.first
|
50
|
+
case command_name
|
51
|
+
when nil, "-h", "-?", "--help"
|
52
|
+
"help"
|
53
|
+
when "-v", "--version"
|
54
|
+
"version"
|
55
|
+
else
|
56
|
+
command_name
|
57
|
+
end
|
53
58
|
end
|
54
59
|
end
|
55
60
|
end
|
data/lib/cc/cli/test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "cc/yaml"
|
2
|
+
require "tmpdir"
|
2
3
|
|
3
4
|
module CC
|
4
5
|
module CLI
|
@@ -68,6 +69,12 @@ module CC
|
|
68
69
|
end
|
69
70
|
|
70
71
|
class Test < Command
|
72
|
+
ARGUMENT_LIST = "<engine_name>".freeze
|
73
|
+
SHORT_HELP = "Test an engine.".freeze
|
74
|
+
HELP = "Validate that an engine is behaving correctly.\n" \
|
75
|
+
"\n"\
|
76
|
+
" <engine_name> Engine to test".freeze
|
77
|
+
|
71
78
|
def run
|
72
79
|
@engine_name = @args.first
|
73
80
|
|
data/lib/cc/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeclimate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.46.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code Climate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
253
|
version: '0'
|
254
254
|
requirements: []
|
255
255
|
rubyforge_project:
|
256
|
-
rubygems_version: 2.5
|
256
|
+
rubygems_version: 2.4.5
|
257
257
|
signing_key:
|
258
258
|
specification_version: 4
|
259
259
|
summary: Code Climate CLI
|