codeclimate 0.15.2 → 0.16.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/analyzer.rb +2 -0
- data/lib/cc/analyzer/engine.rb +4 -2
- data/lib/cc/analyzer/engine_output.rb +32 -0
- data/lib/cc/analyzer/engine_output_filter.rb +7 -27
- data/lib/cc/analyzer/issue.rb +58 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c76b70967c771d965edd6504b4668dece09abf13
|
4
|
+
data.tar.gz: 287482f7b12f57a51bbeace56e80484b2d0760b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ebe59fd88a28aaa4c97faeae185b36047b4e6d226be314994ad93f07eda1c568182ca70e6bce9922d46ac3367b84d65a81f1f2b7a7b48a1dee1a43ccbebabda
|
7
|
+
data.tar.gz: 9c7340ec09a4c869153f5d41f3d185287dee5ce388c9154e1f28070d0ff155bbc973c8671714474333d7ee744f3581b72ec78d0e726a9e582be308dece89400e
|
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 :EngineOutput, "cc/analyzer/engine_output"
|
8
9
|
autoload :EngineOutputFilter, "cc/analyzer/engine_output_filter"
|
9
10
|
autoload :EngineRegistry, "cc/analyzer/engine_registry"
|
10
11
|
autoload :EnginesConfigBuilder, "cc/analyzer/engines_config_builder"
|
@@ -12,6 +13,7 @@ module CC
|
|
12
13
|
autoload :Filesystem, "cc/analyzer/filesystem"
|
13
14
|
autoload :Formatters, "cc/analyzer/formatters"
|
14
15
|
autoload :IncludePathsBuilder, "cc/analyzer/include_paths_builder"
|
16
|
+
autoload :Issue, "cc/analyzer/issue"
|
15
17
|
autoload :IssueSorter, "cc/analyzer/issue_sorter"
|
16
18
|
autoload :LocationDescription, "cc/analyzer/location_description"
|
17
19
|
autoload :LoggingContainerListener, "cc/analyzer/logging_container_listener"
|
data/lib/cc/analyzer/engine.rb
CHANGED
@@ -33,9 +33,11 @@ module CC
|
|
33
33
|
listener: composite_listener,
|
34
34
|
)
|
35
35
|
|
36
|
-
container.on_output("\0") do |
|
36
|
+
container.on_output("\0") do |raw_output|
|
37
|
+
output = EngineOutput.new(raw_output)
|
38
|
+
|
37
39
|
unless output_filter.filter?(output)
|
38
|
-
stdout_io.write(output) || container.stop
|
40
|
+
stdout_io.write(output.to_json) || container.stop
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
class EngineOutput
|
4
|
+
delegate :blank?, to: :raw_output
|
5
|
+
delegate :to_json, to: :as_issue
|
6
|
+
|
7
|
+
def initialize(raw_output)
|
8
|
+
@raw_output = raw_output
|
9
|
+
end
|
10
|
+
|
11
|
+
def issue?
|
12
|
+
parsed_output &&
|
13
|
+
parsed_output["type"].present? &&
|
14
|
+
parsed_output["type"].downcase == "issue"
|
15
|
+
end
|
16
|
+
|
17
|
+
def as_issue
|
18
|
+
Issue.new(raw_output)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_accessor :raw_output
|
24
|
+
|
25
|
+
def parsed_output
|
26
|
+
JSON.parse(raw_output)
|
27
|
+
rescue JSON::ParserError
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -8,41 +8,21 @@ module CC
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def filter?(output)
|
11
|
-
|
12
|
-
|
13
|
-
if (json = parse_as_json(output))
|
14
|
-
issue?(json) && ignore_issue?(json)
|
15
|
-
else
|
16
|
-
false
|
17
|
-
end
|
11
|
+
output.blank? || (output.issue? && ignore_issue?(output.as_issue))
|
18
12
|
end
|
19
13
|
|
20
14
|
private
|
21
15
|
|
22
|
-
def
|
23
|
-
|
24
|
-
rescue JSON::ParserError
|
25
|
-
nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def issue?(json)
|
29
|
-
json["type"] && json["type"].downcase == ISSUE_TYPE
|
30
|
-
end
|
31
|
-
|
32
|
-
def ignore_issue?(json)
|
33
|
-
check_disabled?(json) || ignore_fingerprint?(json)
|
16
|
+
def ignore_issue?(issue)
|
17
|
+
check_disabled?(issue) || ignore_fingerprint?(issue)
|
34
18
|
end
|
35
19
|
|
36
|
-
def check_disabled?(
|
37
|
-
!check_config(
|
20
|
+
def check_disabled?(issue)
|
21
|
+
!check_config(issue.check_name).fetch("enabled", true)
|
38
22
|
end
|
39
23
|
|
40
|
-
def ignore_fingerprint?(
|
41
|
-
|
42
|
-
@config.fetch("exclude_fingerprints", []).include?(fingerprint)
|
43
|
-
else
|
44
|
-
false
|
45
|
-
end
|
24
|
+
def ignore_fingerprint?(issue)
|
25
|
+
@config.fetch("exclude_fingerprints", []).include?(issue.fingerprint)
|
46
26
|
end
|
47
27
|
|
48
28
|
def check_config(check_name)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
class Issue
|
4
|
+
SPEC_ISSUE_ATTRIBUTES = %w[
|
5
|
+
categories
|
6
|
+
check_name
|
7
|
+
content
|
8
|
+
description
|
9
|
+
location
|
10
|
+
other_locations
|
11
|
+
remediation_points
|
12
|
+
severity
|
13
|
+
type
|
14
|
+
]
|
15
|
+
|
16
|
+
def initialize(output)
|
17
|
+
@output = output
|
18
|
+
end
|
19
|
+
|
20
|
+
def as_json(*)
|
21
|
+
parsed_output.reverse_merge!(
|
22
|
+
"fingerprint" => fingerprint,
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def fingerprint
|
27
|
+
parsed_output.fetch("fingerprint", default_fingerprint)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Allow access to hash keys as methods
|
31
|
+
SPEC_ISSUE_ATTRIBUTES.each do |key|
|
32
|
+
define_method(key) do
|
33
|
+
parsed_output[key]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
attr_reader :output
|
40
|
+
|
41
|
+
def default_fingerprint
|
42
|
+
digest = Digest::MD5.new
|
43
|
+
digest << path
|
44
|
+
digest << "|"
|
45
|
+
digest << check_name.to_s
|
46
|
+
digest.to_s
|
47
|
+
end
|
48
|
+
|
49
|
+
def parsed_output
|
50
|
+
@parsed_output ||= JSON.parse(output)
|
51
|
+
end
|
52
|
+
|
53
|
+
def path
|
54
|
+
parsed_output.fetch("location", {}).fetch("path", "")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
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
|
+
version: 0.16.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-12-
|
11
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- lib/cc/analyzer/container.rb
|
205
205
|
- lib/cc/analyzer/container_listener.rb
|
206
206
|
- lib/cc/analyzer/engine.rb
|
207
|
+
- lib/cc/analyzer/engine_output.rb
|
207
208
|
- lib/cc/analyzer/engine_output_filter.rb
|
208
209
|
- lib/cc/analyzer/engine_registry.rb
|
209
210
|
- lib/cc/analyzer/engines_config_builder.rb
|
@@ -215,6 +216,7 @@ files:
|
|
215
216
|
- lib/cc/analyzer/formatters/plain_text_formatter.rb
|
216
217
|
- lib/cc/analyzer/formatters/spinner.rb
|
217
218
|
- lib/cc/analyzer/include_paths_builder.rb
|
219
|
+
- lib/cc/analyzer/issue.rb
|
218
220
|
- lib/cc/analyzer/issue_sorter.rb
|
219
221
|
- lib/cc/analyzer/location_description.rb
|
220
222
|
- lib/cc/analyzer/logging_container_listener.rb
|