File tree 5 files changed +20
-11
lines changed
5 files changed +20
-11
lines changed Original file line number Diff line number Diff line change 1
1
PATH
2
2
remote: .
3
3
specs:
4
- codeclimate_diff (0.1.4 )
4
+ codeclimate_diff (0.1.5 )
5
5
colorize
6
6
json
7
7
optparse
Original file line number Diff line number Diff line change @@ -9,11 +9,7 @@ NOTE: similar code will only work correctly if you run a diff on all the files i
9
9
10
10
## Installation
11
11
12
- 1 . Install the codeclimate cli:
13
- ``` bash
14
- brew tap codeclimate/formulae
15
- brew install codeclimate
16
- ```
12
+ 1 . Make sure docker is installed and running
17
13
18
14
2 . Add a ` .codeclimate.yml ` config file eg:
19
15
``` yml
@@ -90,7 +86,7 @@ NOTE: similar code will only work correctly if you run a diff on all the files i
90
86
91
87
4. Add a `.codecimate_diff.yml` configuration file
92
88
```
93
- main_branch_name: main # defaults to main
89
+ main_branch_name : master # defaults to main
94
90
` ` `
95
91
96
92
5. Install the gem
Original file line number Diff line number Diff line change 6
6
module CodeclimateDiff
7
7
class CodeclimateWrapper
8
8
def run_codeclimate ( filename = "" )
9
- `codeclimate analyze -f json #{ filename } `
9
+ `docker run \
10
+ --interactive --tty --rm \
11
+ --env CODECLIMATE_CODE="$PWD" \
12
+ --volume "$PWD":/code \
13
+ --volume /var/run/docker.sock:/var/run/docker.sock \
14
+ --volume /tmp/cc:/tmp/cc \
15
+ codeclimate/codeclimate analyze -f json #{ filename } `
16
+ end
17
+
18
+ def pull_latest_image
19
+ puts "Downloading latest codeclimate docker image..."
20
+ `docker pull codeclimate/codeclimate`
10
21
end
11
22
end
12
23
end
Original file line number Diff line number Diff line change @@ -13,8 +13,6 @@ def self.calculate_changed_filenames(pattern)
13
13
extra_grep_filter = pattern ? " | grep '#{ pattern } '" : ""
14
14
branch_name = CodeclimateDiff . configuration [ "main_branch_name" ] || "main"
15
15
files_changed_str = `git diff --name-only #{ branch_name } | grep --invert-match spec/ | grep --extended-regexp '.js$|.rb$'#{ extra_grep_filter } `
16
- puts "Files changed on branch: #{ files_changed_str } "
17
-
18
16
files_changed_str . split ( "\n " )
19
17
end
20
18
@@ -46,13 +44,17 @@ def self.calculate_preexisting_issues_in_changed_files(changed_filenames)
46
44
end
47
45
48
46
def self . generate_baseline
47
+ CodeclimateWrapper . new . pull_latest_image
48
+
49
49
puts "Generating the baseline. Should take about 5 minutes..."
50
50
result = CodeclimateWrapper . new . run_codeclimate
51
51
File . write ( "codeclimate_diff_baseline.json" , result )
52
52
puts "Done!"
53
53
end
54
54
55
55
def self . run_diff_on_branch ( pattern , show_preexisting : true )
56
+ CodeclimateWrapper . new . pull_latest_image
57
+
56
58
changed_filenames = calculate_changed_filenames ( pattern )
57
59
58
60
changed_file_issues = calculate_issues_in_changed_files ( changed_filenames )
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
module CodeclimateDiff
4
- VERSION = "0.1.4 "
4
+ VERSION = "0.1.5 "
5
5
end
You can’t perform that action at this time.
0 commit comments