Skip to content

Commit dd86802

Browse files
author
Ashley Baldwin-Hunter
authored
Merge pull request qltysh#491 from codeclimate/abh-enable-duplication
Enable duplication
2 parents becc31c + 57d97e4 commit dd86802

11 files changed

+31
-63
lines changed

.codeclimate.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
engines:
33
rubocop:
44
enabled: true
5+
duplication:
6+
enabled: true
7+
config:
8+
languages:
9+
- "ruby"
510
fixme:
611
enabled: true
712
exclude_paths:

lib/cc/analyzer/formatters/formatter.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,18 @@ def initialize(filesystem, output = $stdout)
77
@output = output
88
end
99

10-
def write(_data)
10+
def write(data)
11+
json = JSON.parse(data)
12+
json["engine_name"] = current_engine.name
13+
14+
case json["type"].downcase
15+
when "issue"
16+
issues << json
17+
when "warning"
18+
warnings << json
19+
else
20+
raise "Invalid type found: #{json["type"]}"
21+
end
1122
end
1223

1324
def started

lib/cc/analyzer/formatters/html_formatter.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ def pluralize(number, noun)
2626
end
2727
end
2828

29-
def write(data)
30-
json = JSON.parse(data)
31-
json["engine_name"] = current_engine.name
32-
33-
case json["type"].downcase
34-
when "issue"
35-
issues << json
36-
when "warning"
37-
warnings << json
38-
else
39-
raise "Invalid type found: #{json["type"]}"
40-
end
41-
end
42-
4329
def finished
4430
template = ReportTemplate.new(issues.length, issues_by_path)
4531
puts template.render

lib/cc/analyzer/formatters/plain_text_formatter.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,6 @@ def started
1010
puts colorize("Starting analysis", :green)
1111
end
1212

13-
def write(data)
14-
json = JSON.parse(data)
15-
json["engine_name"] = current_engine.name
16-
17-
case json["type"].downcase
18-
when "issue"
19-
issues << json
20-
when "warning"
21-
warnings << json
22-
else
23-
raise "Invalid type found: #{json["type"]}"
24-
end
25-
end
26-
2713
def finished
2814
puts
2915

lib/cc/analyzer/issue_validations/content_validation.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ def message
1515
def has_content?
1616
object.key?("content")
1717
end
18-
19-
def content
20-
object["content"]
21-
end
2218
end
2319
end
2420
end

lib/cc/analyzer/issue_validations/path_existence_validation.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@ module Analyzer
33
module IssueValidations
44
class PathExistenceValidation < Validation
55
def valid?
6-
File.exist?(path)
6+
path && File.exist?(path)
77
end
88

99
def message
1010
"File does not exist: '#{path}'"
1111
end
12-
13-
private
14-
15-
def path
16-
object.fetch("location", {}).fetch("path", "")
17-
end
1812
end
1913
end
2014
end

lib/cc/analyzer/issue_validations/path_is_file_validation.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@ module Analyzer
33
module IssueValidations
44
class PathIsFileValidation < Validation
55
def valid?
6-
File.file?(path)
6+
path && File.file?(path)
77
end
88

99
def message
1010
"Path is not a file: '#{path}'"
1111
end
12-
13-
private
14-
15-
def path
16-
object.fetch("location", {}).fetch("path", "")
17-
end
1812
end
1913
end
2014
end

lib/cc/analyzer/issue_validations/path_presence_validation.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ def valid?
99
def message
1010
"Path must be present"
1111
end
12-
13-
private
14-
15-
def path
16-
object.fetch("location", {})["path"]
17-
end
1812
end
1913
end
2014
end

lib/cc/analyzer/issue_validations/relative_path_validation.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ def relative_to?(directory)
2222

2323
expanded_path.start_with?(expanded_base)
2424
end
25-
26-
def path
27-
object.fetch("location", {})["path"]
28-
end
2925
end
3026
end
3127
end

lib/cc/analyzer/issue_validations/type_validation.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ def valid?
99
def message
1010
"Type must be 'issue' but was '#{type}'"
1111
end
12-
13-
private
14-
15-
def type
16-
object["type"]
17-
end
1812
end
1913
end
2014
end

0 commit comments

Comments
 (0)