File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11PATH
22 remote: .
33 specs:
4- codeclimate_diff (0.1.4 )
4+ codeclimate_diff (0.1.5 )
55 colorize
66 json
77 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
99
1010## Installation
1111
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
1713
18142 . Add a ` .codeclimate.yml ` config file eg:
1915 ``` yml
@@ -90,7 +86,7 @@ NOTE: similar code will only work correctly if you run a diff on all the files i
9086
91874. Add a `.codecimate_diff.yml` configuration file
9288 ```
93- main_branch_name: main # defaults to main
89+ main_branch_name : master # defaults to main
9490 ` ` `
9591
96925. Install the gem
Original file line number Diff line number Diff line change 66module CodeclimateDiff
77 class CodeclimateWrapper
88 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`
1021 end
1122 end
1223end
Original file line number Diff line number Diff line change @@ -13,8 +13,6 @@ def self.calculate_changed_filenames(pattern)
1313 extra_grep_filter = pattern ? " | grep '#{ pattern } '" : ""
1414 branch_name = CodeclimateDiff . configuration [ "main_branch_name" ] || "main"
1515 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-
1816 files_changed_str . split ( "\n " )
1917 end
2018
@@ -46,13 +44,17 @@ def self.calculate_preexisting_issues_in_changed_files(changed_filenames)
4644 end
4745
4846 def self . generate_baseline
47+ CodeclimateWrapper . new . pull_latest_image
48+
4949 puts "Generating the baseline. Should take about 5 minutes..."
5050 result = CodeclimateWrapper . new . run_codeclimate
5151 File . write ( "codeclimate_diff_baseline.json" , result )
5252 puts "Done!"
5353 end
5454
5555 def self . run_diff_on_branch ( pattern , show_preexisting : true )
56+ CodeclimateWrapper . new . pull_latest_image
57+
5658 changed_filenames = calculate_changed_filenames ( pattern )
5759
5860 changed_file_issues = calculate_issues_in_changed_files ( changed_filenames )
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33module CodeclimateDiff
4- VERSION = "0.1.4 "
4+ VERSION = "0.1.5 "
55end
You can’t perform that action at this time.
0 commit comments