codeclimate 0.9.1 → 0.9.2

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: d81ae107229801a3f5752e7ef948a3b0b56db80d
4
- data.tar.gz: 789f4ed9e51c32f62be863c5403bf8ef09b325b7
3
+ metadata.gz: dacbb140292d61911f693eddf47566cca79a8971
4
+ data.tar.gz: e3a2d03b2f9114d6e68a199461492ed5e1bcf380
5
5
  SHA512:
6
- metadata.gz: bf48b0890ed9325ac0ab5d73c5c8b3642f6b7b39bb90d5f576d0e0f367d6cdc20d29a567f21bbad394e97070b676164f1c18f0477b095950b5fa0c857e0e195d
7
- data.tar.gz: dfbf3f35fbbbae9f4bc7d6fa84cfa011b4b94d85e4ffeaed171dd901c8df12257d05b57c2a7ca91f2a008e85d0a0e3ef8ca9b5c515d7aa267d040efb69471ed7
6
+ metadata.gz: 22f87e0b1980085a4b5a7db3471aa73bad2b7db36f88216ea33f79e15eeb32d33db8a743ed916213cf68bcd235955806a0be34a197033a5d8de7ee580ed91474
7
+ data.tar.gz: b1605896bb70d332f30da3c503ec0d57977ce7dd0d5565133368dc3596067c92833288a75f24c142957476c049550244170a50f0206484aa75f00b8b7e369012
data/lib/cc/analyzer.rb CHANGED
@@ -5,6 +5,7 @@ module CC
5
5
  autoload :Container, "cc/analyzer/container"
6
6
  autoload :ContainerListener, "cc/analyzer/container_listener"
7
7
  autoload :Engine, "cc/analyzer/engine"
8
+ autoload :Engines, "cc/analyzer/engines"
8
9
  autoload :EngineOutputFilter, "cc/analyzer/engine_output_filter"
9
10
  autoload :EngineRegistry, "cc/analyzer/engine_registry"
10
11
  autoload :EnginesRunner, "cc/analyzer/engines_runner"
@@ -0,0 +1,73 @@
1
+ require "securerandom"
2
+
3
+ module CC
4
+ module Analyzer
5
+ class Engines < Array
6
+ def initialize(registry:, config:, container_label:, source_dir:, requested_paths:)
7
+ super()
8
+ @registry = registry
9
+ @config = config
10
+ @container_label = container_label
11
+ @requested_paths = requested_paths
12
+ @source_dir = source_dir
13
+ names_and_raw_engine_configs.each do |name, raw_engine_config|
14
+ self << build_engine(name, raw_engine_config)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def build_engine(name, raw_engine_config)
21
+ label = @container_label || SecureRandom.uuid
22
+ engine_config = engine_config(raw_engine_config)
23
+ Engine.new(
24
+ name, @registry[name], @source_dir, engine_config, label
25
+ )
26
+ end
27
+
28
+ def engine_config(raw_engine_config)
29
+ config = raw_engine_config.merge(
30
+ exclude_paths: exclude_paths,
31
+ include_paths: include_paths
32
+ )
33
+ # The yaml gem turns a config file string into a hash, but engines
34
+ # expect the string. So we (for now) need to turn it into a string in
35
+ # that one scenario.
36
+ # TODO: update the engines to expect the hash and then remove this.
37
+ if config.fetch("config", {}).keys.size == 1 && config["config"].key?("file")
38
+ config["config"] = config["config"]["file"]
39
+ end
40
+ config
41
+ end
42
+
43
+ def names_and_raw_engine_configs
44
+ {}.tap do |ret|
45
+ @config.engines.each do |name, raw_engine_config|
46
+ if raw_engine_config.enabled? && @registry.key?(name)
47
+ ret[name] = raw_engine_config
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ def include_paths
54
+ IncludePathsBuilder.new(
55
+ @config.exclude_paths || [], @requested_paths
56
+ ).build
57
+ end
58
+
59
+ def exclude_paths
60
+ PathPatterns.new(@config.exclude_paths || []).expanded +
61
+ gitignore_paths
62
+ end
63
+
64
+ def gitignore_paths
65
+ if File.exist?(".gitignore")
66
+ `git ls-files --others -i -z --exclude-from .gitignore`.split("\0")
67
+ else
68
+ []
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -31,63 +31,19 @@ module CC
31
31
 
32
32
  attr_reader :requested_paths
33
33
 
34
- def run_engine(engine, container_listener)
35
- @formatter.engine_running(engine) do
36
- engine.run(@formatter, container_listener)
37
- end
38
- end
39
-
40
34
  def engines
41
- @engines ||= enabled_engines.map do |name, config|
42
- label = @container_label || SecureRandom.uuid
43
-
44
- Engine.new(name, metadata(name), @source_dir, engine_config(config), label)
45
- end
46
- end
47
-
48
- def engine_config(config)
49
- config = config.merge(
50
- exclude_paths: exclude_paths,
51
- include_paths: include_paths
35
+ @engines ||= Engines.new(
36
+ registry: @registry,
37
+ config: @config,
38
+ container_label: @container_label,
39
+ source_dir: @source_dir,
40
+ requested_paths: @requested_paths
52
41
  )
53
-
54
- # The yaml gem turns a config file string into a hash, but engines expect the string
55
- # So we (for now) need to turn it into a string in that one scenario.
56
- # TODO: update the engines to expect the hash and then remove this.
57
- if config.fetch("config", {}).keys.size == 1 && config["config"].key?("file")
58
- config["config"] = config["config"]["file"]
59
- end
60
-
61
- config
62
42
  end
63
43
 
64
- def enabled_engines
65
- {}.tap do |ret|
66
- @config.engines.each do |name, config|
67
- if config.enabled? && @registry.key?(name)
68
- ret[name] = config
69
- end
70
- end
71
- end
72
- end
73
-
74
- def metadata(engine_name)
75
- @registry[engine_name]
76
- end
77
-
78
- def include_paths
79
- IncludePathsBuilder.new(@config.exclude_paths || [], requested_paths).build
80
- end
81
-
82
- def exclude_paths
83
- PathPatterns.new(@config.exclude_paths || []).expanded + gitignore_paths
84
- end
85
-
86
- def gitignore_paths
87
- if File.exist?(".gitignore")
88
- `git ls-files --others -i -z --exclude-from .gitignore`.split("\0")
89
- else
90
- []
44
+ def run_engine(engine, container_listener)
45
+ @formatter.engine_running(engine) do
46
+ engine.run(@formatter, container_listener)
91
47
  end
92
48
  end
93
49
  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.9.1
4
+ version: 0.9.2
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-10-14 00:00:00.000000000 Z
11
+ date: 2015-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -201,6 +201,7 @@ files:
201
201
  - lib/cc/analyzer/engine.rb
202
202
  - lib/cc/analyzer/engine_output_filter.rb
203
203
  - lib/cc/analyzer/engine_registry.rb
204
+ - lib/cc/analyzer/engines.rb
204
205
  - lib/cc/analyzer/engines_runner.rb
205
206
  - lib/cc/analyzer/filesystem.rb
206
207
  - lib/cc/analyzer/formatters.rb
@@ -256,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
257
  version: '0'
257
258
  requirements: []
258
259
  rubyforge_project:
259
- rubygems_version: 2.4.5
260
+ rubygems_version: 2.4.8
260
261
  signing_key:
261
262
  specification_version: 4
262
263
  summary: Code Climate CLI