codeclimate 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cc/analyzer.rb +1 -0
- data/lib/cc/analyzer/engine.rb +15 -1
- data/lib/cc/analyzer/engine_output_filter.rb +40 -0
- data/lib/cc/analyzer/formatters/formatter.rb +7 -0
- data/lib/cc/analyzer/formatters/json_formatter.rb +3 -9
- data/lib/cc/analyzer/formatters/plain_text_formatter.rb +4 -8
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eade4e029db8e5fbeb3074af03ba35a571fa8b89
|
4
|
+
data.tar.gz: 9b10d656951c5f7411fe10fbf4e504d629810363
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66b2b0e15c242af37fb41cd88c62db72bbb6f60b32d16edd061bae32ffe051a624395c94a098ce0a466e4a8596c7bd5414b1b723b0cd95a418cb061fd739895b
|
7
|
+
data.tar.gz: 02d48721c2276f455e3480c5cabf7736cd65d8132f5f35ac2ad876d50efd3208f3b4e8137af585435dd5c3e6a78a07d06774a55404abba7fd9de9b49ee6b7746
|
data/lib/cc/analyzer.rb
CHANGED
@@ -4,6 +4,7 @@ module CC
|
|
4
4
|
autoload :Config, "cc/analyzer/config"
|
5
5
|
autoload :Engine, "cc/analyzer/engine"
|
6
6
|
autoload :EngineClient, "cc/analyzer/engine_client"
|
7
|
+
autoload :EngineOutputFilter, "cc/analyzer/engine_output_filter"
|
7
8
|
autoload :EngineProcess, "cc/analyzer/engine_process"
|
8
9
|
autoload :EngineRegistry, "cc/analyzer/engine_registry"
|
9
10
|
autoload :Filesystem, "cc/analyzer/filesystem"
|
data/lib/cc/analyzer/engine.rb
CHANGED
@@ -23,7 +23,11 @@ module CC
|
|
23
23
|
|
24
24
|
t_out = Thread.new do
|
25
25
|
out.each_line("\0") do |chunk|
|
26
|
-
|
26
|
+
output = chunk.chomp("\0")
|
27
|
+
|
28
|
+
unless output_filter.filter?(output)
|
29
|
+
stdout_io.write(output)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
@@ -110,6 +114,16 @@ module CC
|
|
110
114
|
end
|
111
115
|
end
|
112
116
|
|
117
|
+
def output_filter
|
118
|
+
@output_filter ||= EngineOutputFilter.new(config)
|
119
|
+
end
|
120
|
+
|
121
|
+
def config
|
122
|
+
# N.B. there is no expected scenario where this would fail so a
|
123
|
+
# parser-error rescue has been omitted intentionally
|
124
|
+
JSON.parse(@config_json)
|
125
|
+
end
|
126
|
+
|
113
127
|
CommandFailure = Class.new(StandardError)
|
114
128
|
EngineFailure = Class.new(StandardError)
|
115
129
|
EngineTimeout = Class.new(StandardError)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
class EngineOutputFilter
|
4
|
+
ISSUE_TYPE = "issue".freeze
|
5
|
+
|
6
|
+
def initialize(config = {})
|
7
|
+
@config = config
|
8
|
+
end
|
9
|
+
|
10
|
+
def filter?(output)
|
11
|
+
if (json = parse_as_json(output))
|
12
|
+
issue?(json) && ignore_issue?(json)
|
13
|
+
else
|
14
|
+
false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def parse_as_json(output)
|
21
|
+
JSON.parse(output)
|
22
|
+
rescue JSON::ParserError
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def issue?(json)
|
27
|
+
json["type"] == ISSUE_TYPE
|
28
|
+
end
|
29
|
+
|
30
|
+
def ignore_issue?(json)
|
31
|
+
!check_config(json["check"]).fetch("enabled", true)
|
32
|
+
end
|
33
|
+
|
34
|
+
def check_config(check_name)
|
35
|
+
@checks ||= @config.fetch("checks", {})
|
36
|
+
@checks.fetch(check_name, {})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -13,7 +13,10 @@ module CC
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def engine_running(engine)
|
16
|
+
@current_engine = engine
|
16
17
|
yield
|
18
|
+
ensure
|
19
|
+
@current_engine = nil
|
17
20
|
end
|
18
21
|
|
19
22
|
def finished
|
@@ -23,6 +26,10 @@ module CC
|
|
23
26
|
end
|
24
27
|
|
25
28
|
InvalidFormatterError = Class.new(StandardError)
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :current_engine
|
26
33
|
end
|
27
34
|
end
|
28
35
|
end
|
@@ -7,25 +7,19 @@ module CC
|
|
7
7
|
@has_begun = false
|
8
8
|
end
|
9
9
|
|
10
|
-
def engine_running(engine)
|
11
|
-
@active_engine = engine
|
12
|
-
yield
|
13
|
-
@active_engine = nil
|
14
|
-
end
|
15
|
-
|
16
10
|
def started
|
17
|
-
print "[
|
11
|
+
print "["
|
18
12
|
end
|
19
13
|
|
20
14
|
def finished
|
21
|
-
print "
|
15
|
+
print "]\n"
|
22
16
|
end
|
23
17
|
|
24
18
|
def write(data)
|
25
19
|
return unless data.present?
|
26
20
|
|
27
21
|
document = JSON.parse(data)
|
28
|
-
document["engine_name"] =
|
22
|
+
document["engine_name"] = current_engine.name
|
29
23
|
|
30
24
|
if @has_begun
|
31
25
|
print ",\n"
|
@@ -14,9 +14,7 @@ module CC
|
|
14
14
|
def write(data)
|
15
15
|
if data.present?
|
16
16
|
json = JSON.parse(data)
|
17
|
-
|
18
|
-
json["engine_name"] = @active_engine.name
|
19
|
-
end
|
17
|
+
json["engine_name"] = current_engine.name
|
20
18
|
|
21
19
|
case json["type"].downcase
|
22
20
|
when "issue"
|
@@ -54,12 +52,10 @@ module CC
|
|
54
52
|
puts(colorize(".", :green))
|
55
53
|
end
|
56
54
|
|
57
|
-
def engine_running(engine)
|
58
|
-
|
59
|
-
|
60
|
-
yield
|
55
|
+
def engine_running(engine, &block)
|
56
|
+
super(engine) do
|
57
|
+
with_spinner("Running #{current_engine.name}: ", &block)
|
61
58
|
end
|
62
|
-
@active_engine = nil
|
63
59
|
end
|
64
60
|
|
65
61
|
def failed(output)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeclimate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code Climate
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- lib/cc/analyzer.rb
|
199
199
|
- lib/cc/analyzer/config.rb
|
200
200
|
- lib/cc/analyzer/engine.rb
|
201
|
+
- lib/cc/analyzer/engine_output_filter.rb
|
201
202
|
- lib/cc/analyzer/engine_registry.rb
|
202
203
|
- lib/cc/analyzer/filesystem.rb
|
203
204
|
- lib/cc/analyzer/formatters.rb
|