Skip to content

Commit ca0bc98

Browse files
feat: if settings missing, will default to not downloading from pipeline. Plus updated docs
1 parent c7e26a7 commit ca0bc98

File tree

2 files changed

+57
-20
lines changed

2 files changed

+57
-20
lines changed

README.md

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,62 @@ NOTE: similar code will only work correctly if you run a diff on all the files i
4646
- "**/__tests__/"
4747
- "**/__mocks__/"
4848
- "/.gitlab/"
49-
- coverage/
49+
- coverage/ . # simple cov
5050
```
5151
52-
3. Install the gem
52+
3. Add a `.reek.yml` config file eg:
53+
54+
See https://github.com/troessner/reek#working-with-rails
55+
```
56+
detectors:
57+
IrresponsibleModule:
58+
enabled: false
59+
60+
LongParameterList:
61+
max_params: 4 # defaults to 3. You want this number realistic but stretchy so we can move it down
62+
63+
TooManyStatements:
64+
max_statements: 10 # defaults to 5. You want this number realistic but stretchy so we can move it down
65+
66+
directories:
67+
"app/controllers":
68+
IrresponsibleModule:
69+
enabled: false
70+
NestedIterators:
71+
max_allowed_nesting: 2
72+
UnusedPrivateMethod:
73+
enabled: false
74+
InstanceVariableAssumption:
75+
enabled: false
76+
"app/helpers":
77+
IrresponsibleModule:
78+
enabled: false
79+
UtilityFunction:
80+
enabled: false
81+
FeatureEnvy:
82+
enabled: false
83+
"app/mailers":
84+
InstanceVariableAssumption:
85+
enabled: false
86+
"app/models":
87+
InstanceVariableAssumption:
88+
enabled: false
89+
```
90+
91+
4. Add a `.codecimate_diff.yml` configuration file
92+
```
93+
main_branch_name: main
94+
95+
# settings to pull down the baseline from the pipeline in Gitlab before checking your branch
96+
gitlab:
97+
download_baseline_from_pipeline: true # If false or excluded, you will need to generate the baseline manually
98+
project_id: '85'
99+
host: https://gitlab.digitalnz.org/
100+
baseline_filename: 'gl-code-quality-report.json'
101+
```
102+
103+
104+
4. Install the gem
53105
54106
Add this line to your application's Gemfile:
55107
@@ -83,7 +135,7 @@ NOTE: similar code will only work correctly if you run a diff on all the files i
83135
84136
2. Do some work
85137
86-
3. Check if you've added any issues (about 10 secs per code file changed on your branch)
138+
3. Check if you've added any issues (about 10 secs per code file changed on your branch):
87139
88140
```
89141
# runs on all code files changed in your branch
@@ -101,21 +153,6 @@ NOTE: similar code will only work correctly if you run a diff on all the files i
101153
```
102154
4. Now you have time to fix the issues yay!
103155
104-
## Configuration
105-
106-
Example:
107-
108-
.codeclimate_diff.yml
109-
110-
```rb
111-
gitlab:
112-
main_branch_name: main
113-
download_baseline_for_pipeline: true
114-
project_id: '..'
115-
host: https://gitlab.digitalnz.org/
116-
personal_access_token: <LOAD FROM ENV VARIABLE>
117-
```
118-
119156
## Development
120157
121158
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

lib/codeclimate_diff/downloader.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
module CodeclimateDiff
66
class Downloader
77
def self.refresh_baseline_if_configured
8-
should_download = CodeclimateDiff.configuration["gitlab"]["download_baseline_for_pipeline"]
9-
return unless should_download
8+
return unless CodeclimateDiff.configuration["gitlab"]
9+
return unless CodeclimateDiff.configuration["gitlab"]["download_baseline_from_pipeline"]
1010

1111
puts "Downloading baseline file from gitlab"
1212
branch_name = CodeclimateDiff.configuration["main_branch_name"]

0 commit comments

Comments
 (0)