Skip to content

Commit 8a17c63

Browse files
refactor: pulled out the code climate executing code into class
1 parent 8fdbab9 commit 8a17c63

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

lib/codeclimate_diff.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
require_relative "codeclimate_diff/version"
44

55
module CodeclimateDiff
6-
76
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
require "json"
4+
require "colorize"
5+
6+
module CodeclimateDiff
7+
class CodeclimateWrapper
8+
def run_codeclimate(filename = "")
9+
`codeclimate analyze -f json #{filename}`
10+
end
11+
end
12+
end

lib/codeclimate_diff/configuration.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ module CodeclimateDiff
44
class Configuration
55
attr_accessor :main_branch_name
66

7-
#using_gitlab: true
7+
# using_gitlab: true
88

99
# gitlab host
1010

1111
# project id
12-
1312
end
1413
end

lib/codeclimate_diff/runner.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
require "json"
44
require "colorize"
5+
require_relative "./codeclimate_wrapper"
56

67
module CodeclimateDiff
78
class Runner
89
def self.generate_baseline
910
puts "Generating the baseline. Should take about 5 minutes..."
10-
`codeclimate analyze -f json > codeclimate_diff_baseline.json`
11+
result = CodeclimateWrapper.new.run_codeclimate
12+
File.write("codeclimate_diff_baseline.json", result)
1113
puts "Done!"
1214
end
1315

@@ -24,7 +26,7 @@ def self.calculate_issues_in_changed_files(changed_filenames)
2426
next if filename == "codeclimate_diff.rb" # TODO: fix this file's code quality issues when we make a Gem!
2527

2628
puts "Analysing '#{filename}'..."
27-
result = `codeclimate analyze -f json #{filename}`
29+
result = CodeclimateWrapper.new.run_codeclimate(filename)
2830
JSON.parse(result).each do |issue|
2931
next if issue["type"] != "issue"
3032

0 commit comments

Comments
 (0)