codeclimate 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc6ca1d893dcb67f0b02f559ceba2d3f23a82559
4
- data.tar.gz: c5c70423501554cf8afe0b6e9703c19c8b88d571
3
+ metadata.gz: 7300c9980cfc0656f7d9f8db4bfdbca3072557e8
4
+ data.tar.gz: 538ebb98fdd24c8936f39616c30885bbf2cefcb5
5
5
  SHA512:
6
- metadata.gz: d9c89e8532d8a50ece6c96e75f42fc870016d5a5cd2aa2b0540a931e4e580337f6900bb0264dc01b4748114f4b110e196dd522982b88a7afefa4096d03746d4e
7
- data.tar.gz: 2035afdfe59e893be959e1e2668d848a02982fd5606b4403360bf1f509af9cc7fff467b824ddb35a593c12792bdabde2b2909c0bfcd7ce2bf4e7eb8dae7f2753
6
+ metadata.gz: 6b0283c0100f8165089aa96b6247beca715ede60c72175f43e8801b1abd80084eca7526865bbfd60a2c3fb37f0de995583a78f6a9e91e73ef2417c5d47fe9f2c
7
+ data.tar.gz: f8ed6d3cad1a68b3d8a6284d1cffb7094e6906776c997ce8f51a2f8990568862a01e5cb567a859f675cfd6705a085bcd09ac017e19a885695dc66d0f18919735
data/bin/check CHANGED
@@ -10,7 +10,11 @@ docker version | grep -q "Server version\|Server:" || {
10
10
  if command -v boot2docker > /dev/null 2>&1; then
11
11
  echo "Please ensure \`boot2docker up\` succeeds and you've run \`eval \$(boot2docker shellinit)\` in this shell" >&2
12
12
  else
13
- echo "Please ensure \`docker version' succeeds and try again"
13
+ if [ $UID -eq 0 ]; then
14
+ echo "Please ensure \`sudo docker version' succeeds and try again" >&2
15
+ else
16
+ echo "Please ensure \`docker version' succeeds and try again" >&2
17
+ fi
14
18
  fi
15
19
 
16
20
  exit 1
@@ -6,11 +6,12 @@ module CC
6
6
  InvalidEngineName = Class.new(StandardError)
7
7
  NoEnabledEngines = Class.new(StandardError)
8
8
 
9
- def initialize(registry, formatter, source_dir, config, container_label = nil)
9
+ def initialize(registry, formatter, source_dir, config, requested_paths = [], container_label = nil)
10
10
  @registry = registry
11
11
  @formatter = formatter
12
12
  @source_dir = source_dir
13
13
  @config = config
14
+ @requested_paths = requested_paths
14
15
  @container_label = container_label
15
16
  end
16
17
 
@@ -28,6 +29,8 @@ module CC
28
29
 
29
30
  private
30
31
 
32
+ attr_reader :requested_paths
33
+
31
34
  def run_engine(engine, container_listener)
32
35
  @formatter.engine_running(engine) do
33
36
  engine.run(@formatter, container_listener)
@@ -72,12 +75,12 @@ module CC
72
75
  @registry[engine_name]
73
76
  end
74
77
 
75
- def exclude_paths
76
- PathPatterns.new(@config.exclude_paths || []).expanded + gitignore_paths
78
+ def include_paths
79
+ IncludePathsBuilder.new(@config.exclude_paths || [], requested_paths).build
77
80
  end
78
81
 
79
- def include_paths
80
- IncludePathsBuilder.new(@config.exclude_paths || []).build
82
+ def exclude_paths
83
+ PathPatterns.new(@config.exclude_paths || []).expanded + gitignore_paths
81
84
  end
82
85
 
83
86
  def gitignore_paths
@@ -9,13 +9,21 @@ module CC
9
9
  end
10
10
  end
11
11
 
12
- def initialize(cc_exclude_paths)
12
+ attr_reader :cc_include_paths
13
+
14
+ def initialize(cc_exclude_paths, cc_include_paths = [])
13
15
  @cc_exclude_paths = cc_exclude_paths
16
+ @cc_include_paths = cc_include_paths
14
17
  end
15
18
 
16
19
  def build
17
- root = Directory.new('.', ignored_files)
18
- paths = root.included_paths
20
+ if cc_include_paths.any?
21
+ paths = filter_by_cc_includes
22
+ else
23
+ root = Directory.new(".", ignored_files)
24
+ paths = root.included_paths
25
+ end
26
+
19
27
  paths.each do |path|
20
28
  raise_on_unreadable_files(path)
21
29
  end
@@ -23,6 +31,19 @@ module CC
23
31
 
24
32
  protected
25
33
 
34
+ def filter_by_cc_includes
35
+ paths = []
36
+ cc_include_paths.each do |path|
37
+ if File.directory?(path)
38
+ root = Directory.new(path, ignored_files)
39
+ paths += root.included_paths
40
+ elsif !ignored_files.include?(path)
41
+ paths << path
42
+ end
43
+ end
44
+ paths.uniq
45
+ end
46
+
26
47
  def ignored_files
27
48
  Tempfile.open(".cc_gitignore") do |tmp|
28
49
  tmp.write(File.read(".gitignore")) if File.exist?(".gitignore")
@@ -5,15 +5,18 @@ module CC
5
5
 
6
6
  def initialize(_args = [])
7
7
  super
8
+ @engine_options = []
9
+ @path_options = []
8
10
 
9
11
  process_args
12
+ apply_config_options
10
13
  end
11
14
 
12
15
  def run
13
16
  require_codeclimate_yml
14
17
 
15
18
  Dir.chdir(ENV['FILESYSTEM_DIR']) do
16
- runner = EnginesRunner.new(registry, formatter, source_dir, config)
19
+ runner = EnginesRunner.new(registry, formatter, source_dir, config, path_options)
17
20
  runner.run
18
21
  end
19
22
 
@@ -25,13 +28,20 @@ module CC
25
28
 
26
29
  private
27
30
 
31
+ attr_accessor :config
32
+ attr_reader :engine_options, :path_options
33
+
28
34
  def process_args
29
35
  while arg = @args.shift
30
36
  case arg
31
37
  when '-f'
32
38
  @formatter = Formatters.resolve(@args.shift)
39
+ when '-e', '--engine'
40
+ @engine_options << @args.shift
33
41
  when '--dev'
34
42
  @dev_mode = true
43
+ else
44
+ @path_options << arg
35
45
  end
36
46
  end
37
47
  rescue Formatters::Formatter::InvalidFormatterError => e
@@ -51,7 +61,34 @@ module CC
51
61
  end
52
62
 
53
63
  def config
54
- CC::Yaml.parse(filesystem.read_path(CODECLIMATE_YAML))
64
+ @config ||= CC::Yaml.parse(filesystem.read_path(CODECLIMATE_YAML))
65
+ end
66
+
67
+ def apply_config_options
68
+ if engine_options.any? && config.engines?
69
+ filter_by_engine_options
70
+ elsif engine_options.any?
71
+ config["engines"] = CC::Yaml::Nodes::EngineList.new(config).with_value({})
72
+ end
73
+ add_engine_options
74
+ end
75
+
76
+ def filter_by_engine_options
77
+ config.engines.keys.each do |engine|
78
+ unless engine_options.include?(engine)
79
+ config.engines.delete(engine)
80
+ end
81
+ end
82
+ end
83
+
84
+ def add_engine_options
85
+ engine_options.each do |engine|
86
+ if config.engines.include?(engine)
87
+ config.engines[engine].enabled = true
88
+ else
89
+ config.engines[engine] = CC::Yaml::Nodes::Engine.new(config.engines).with_value({ "enabled" => true })
90
+ end
91
+ end
55
92
  end
56
93
  end
57
94
  end
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.4
4
+ version: 0.5.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: 2015-09-18 00:00:00.000000000 Z
11
+ date: 2015-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -250,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
250
  version: '0'
251
251
  requirements: []
252
252
  rubyforge_project:
253
- rubygems_version: 2.4.8
253
+ rubygems_version: 2.4.5
254
254
  signing_key:
255
255
  specification_version: 4
256
256
  summary: Code Climate CLI