danger-rubocop_disable_checker 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/gem-push.yml +46 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +148 -0
- data/.ruby-version +1 -0
- data/.travis.yml +11 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +170 -0
- data/Guardfile +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +20 -0
- data/Rakefile +25 -0
- data/danger-rubocop_disable_checker.gemspec +51 -0
- data/lib/danger_plugin.rb +3 -0
- data/lib/danger_rubocop_disable_checker.rb +3 -0
- data/lib/rubocop_disable_checker/gem_version.rb +5 -0
- data/lib/rubocop_disable_checker/plugin.rb +148 -0
- data/spec/rubocop_disable_checker_spec.rb +47 -0
- data/spec/spec_helper.rb +67 -0
- metadata +204 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 92bd39a41e8bde6becc9a2adb3b3e8bfcf658084329369da8e2c2ec36c7a6029
|
4
|
+
data.tar.gz: 32995e7d4c7614431b65a893bf8e2aa2ca0fb685fefeff9fcb3dac4fb46132e1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9331f0eb46bafa665bbc444c8c7aef2ce4961cacda756178c59c9e1b73a6dc3b7f71353b9ad27b5997431088b6176375ada1bdaba46737d083c10fdd2e08b061
|
7
|
+
data.tar.gz: a43957cc2d1293cb7d0e9b009aa95d9dffa30e2cfc2ffd8672d2179e525515dfa0350fdd7445a527ed76d34149a046b2cf667b485cb69d18c259eadd6b79ac70
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "main" ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ "main" ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
name: Build + Publish
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
permissions:
|
14
|
+
contents: read
|
15
|
+
packages: write
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v3
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: .ruby-version
|
23
|
+
bundler-cache: true
|
24
|
+
|
25
|
+
- name: Publish to GPR
|
26
|
+
run: |
|
27
|
+
mkdir -p $HOME/.gem
|
28
|
+
touch $HOME/.gem/credentials
|
29
|
+
chmod 0600 $HOME/.gem/credentials
|
30
|
+
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
31
|
+
gem build *.gemspec
|
32
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
33
|
+
env:
|
34
|
+
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
35
|
+
OWNER: ${{ github.repository_owner }}
|
36
|
+
|
37
|
+
- name: Publish to RubyGems
|
38
|
+
run: |
|
39
|
+
mkdir -p $HOME/.gem
|
40
|
+
touch $HOME/.gem/credentials
|
41
|
+
chmod 0600 $HOME/.gem/credentials
|
42
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
43
|
+
gem build *.gemspec
|
44
|
+
gem push *.gem
|
45
|
+
env:
|
46
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
# Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
2
|
+
|
3
|
+
# If you don't like these settings, just delete this file :)
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 2.6
|
7
|
+
|
8
|
+
Style/StringLiterals:
|
9
|
+
EnforcedStyle: double_quotes
|
10
|
+
Enabled: true
|
11
|
+
|
12
|
+
# kind_of? is a good way to check a type
|
13
|
+
Style/ClassCheck:
|
14
|
+
EnforcedStyle: kind_of?
|
15
|
+
|
16
|
+
# specs sometimes have useless assignments, which is fine
|
17
|
+
Lint/UselessAssignment:
|
18
|
+
Exclude:
|
19
|
+
- '**/spec/**/*'
|
20
|
+
|
21
|
+
# We could potentially enable the 2 below:
|
22
|
+
Layout/FirstHashElementIndentation:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Layout/HashAlignment:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
# HoundCI doesn't like this rule
|
29
|
+
Layout/DotPosition:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
# We allow !! as it's an easy way to convert ot boolean
|
33
|
+
Style/DoubleNegation:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
# Cop supports --auto-correct.
|
37
|
+
Lint/UnusedBlockArgument:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
# We want to allow class Fastlane::Class
|
41
|
+
Style/ClassAndModuleChildren:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Metrics/AbcSize:
|
45
|
+
Max: 60
|
46
|
+
|
47
|
+
# The %w might be confusing for new users
|
48
|
+
Style/WordArray:
|
49
|
+
MinSize: 19
|
50
|
+
|
51
|
+
# raise and fail are both okay
|
52
|
+
Style/SignalException:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
# Better too much 'return' than one missing
|
56
|
+
Style/RedundantReturn:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
# Having if in the same line might not always be good
|
60
|
+
Style/IfUnlessModifier:
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
# and and or is okay
|
64
|
+
Style/AndOr:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
# Configuration parameters: CountComments.
|
68
|
+
Metrics/ClassLength:
|
69
|
+
Max: 350
|
70
|
+
|
71
|
+
Metrics/CyclomaticComplexity:
|
72
|
+
Max: 17
|
73
|
+
|
74
|
+
# Configuration parameters: AllowURI, URISchemes.
|
75
|
+
Layout/LineLength:
|
76
|
+
Max: 370
|
77
|
+
|
78
|
+
# Configuration parameters: CountKeywordArgs.
|
79
|
+
Metrics/ParameterLists:
|
80
|
+
Max: 10
|
81
|
+
|
82
|
+
Metrics/PerceivedComplexity:
|
83
|
+
Max: 18
|
84
|
+
|
85
|
+
# Sometimes it's easier to read without guards
|
86
|
+
Style/GuardClause:
|
87
|
+
Enabled: false
|
88
|
+
|
89
|
+
# something = if something_else
|
90
|
+
# that's confusing
|
91
|
+
Style/ConditionalAssignment:
|
92
|
+
Enabled: false
|
93
|
+
|
94
|
+
# Better to have too much self than missing a self
|
95
|
+
Style/RedundantSelf:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
Metrics/MethodLength:
|
99
|
+
Max: 60
|
100
|
+
|
101
|
+
# We're not there yet
|
102
|
+
Style/Documentation:
|
103
|
+
Enabled: false
|
104
|
+
|
105
|
+
# Adds complexity
|
106
|
+
Style/IfInsideElse:
|
107
|
+
Enabled: false
|
108
|
+
|
109
|
+
# danger specific
|
110
|
+
|
111
|
+
Style/BlockComments:
|
112
|
+
Enabled: false
|
113
|
+
|
114
|
+
Layout/MultilineMethodCallIndentation:
|
115
|
+
EnforcedStyle: indented
|
116
|
+
|
117
|
+
# FIXME: 25
|
118
|
+
Metrics/BlockLength:
|
119
|
+
Max: 345
|
120
|
+
Exclude:
|
121
|
+
- "**/*_spec.rb"
|
122
|
+
|
123
|
+
Style/MixinGrouping:
|
124
|
+
Enabled: false
|
125
|
+
|
126
|
+
Naming/FileName:
|
127
|
+
Enabled: false
|
128
|
+
|
129
|
+
Layout/HeredocIndentation:
|
130
|
+
Enabled: false
|
131
|
+
|
132
|
+
Style/SpecialGlobalVars:
|
133
|
+
Enabled: false
|
134
|
+
|
135
|
+
Style/PercentLiteralDelimiters:
|
136
|
+
PreferredDelimiters:
|
137
|
+
"%": ()
|
138
|
+
"%i": ()
|
139
|
+
"%q": ()
|
140
|
+
"%Q": ()
|
141
|
+
"%r": "{}"
|
142
|
+
"%s": ()
|
143
|
+
"%w": ()
|
144
|
+
"%W": ()
|
145
|
+
"%x": ()
|
146
|
+
|
147
|
+
Security/YAMLLoad:
|
148
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.4
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
danger-rubocop_disable_checker (0.0.1)
|
5
|
+
danger-plugin-api (~> 1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.8.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
ast (2.4.2)
|
13
|
+
claide (1.1.0)
|
14
|
+
claide-plugins (0.9.2)
|
15
|
+
cork
|
16
|
+
nap
|
17
|
+
open4 (~> 1.3)
|
18
|
+
coderay (1.1.3)
|
19
|
+
colored2 (3.1.2)
|
20
|
+
cork (0.3.0)
|
21
|
+
colored2 (~> 3.1)
|
22
|
+
danger (8.6.1)
|
23
|
+
claide (~> 1.0)
|
24
|
+
claide-plugins (>= 0.9.2)
|
25
|
+
colored2 (~> 3.1)
|
26
|
+
cork (~> 0.1)
|
27
|
+
faraday (>= 0.9.0, < 2.0)
|
28
|
+
faraday-http-cache (~> 2.0)
|
29
|
+
git (~> 1.7)
|
30
|
+
kramdown (~> 2.3)
|
31
|
+
kramdown-parser-gfm (~> 1.0)
|
32
|
+
no_proxy_fix
|
33
|
+
octokit (~> 4.7)
|
34
|
+
terminal-table (>= 1, < 4)
|
35
|
+
danger-plugin-api (1.0.0)
|
36
|
+
danger (> 2.0)
|
37
|
+
diff-lcs (1.5.0)
|
38
|
+
faraday (1.10.0)
|
39
|
+
faraday-em_http (~> 1.0)
|
40
|
+
faraday-em_synchrony (~> 1.0)
|
41
|
+
faraday-excon (~> 1.1)
|
42
|
+
faraday-httpclient (~> 1.0)
|
43
|
+
faraday-multipart (~> 1.0)
|
44
|
+
faraday-net_http (~> 1.0)
|
45
|
+
faraday-net_http_persistent (~> 1.0)
|
46
|
+
faraday-patron (~> 1.0)
|
47
|
+
faraday-rack (~> 1.0)
|
48
|
+
faraday-retry (~> 1.0)
|
49
|
+
ruby2_keywords (>= 0.0.4)
|
50
|
+
faraday-em_http (1.0.0)
|
51
|
+
faraday-em_synchrony (1.0.0)
|
52
|
+
faraday-excon (1.1.0)
|
53
|
+
faraday-http-cache (2.2.0)
|
54
|
+
faraday (>= 0.8)
|
55
|
+
faraday-httpclient (1.0.1)
|
56
|
+
faraday-multipart (1.0.3)
|
57
|
+
multipart-post (>= 1.2, < 3)
|
58
|
+
faraday-net_http (1.0.1)
|
59
|
+
faraday-net_http_persistent (1.2.0)
|
60
|
+
faraday-patron (1.0.0)
|
61
|
+
faraday-rack (1.0.0)
|
62
|
+
faraday-retry (1.0.3)
|
63
|
+
ffi (1.15.5)
|
64
|
+
formatador (1.1.0)
|
65
|
+
git (1.11.0)
|
66
|
+
rchardet (~> 1.8)
|
67
|
+
guard (2.18.0)
|
68
|
+
formatador (>= 0.2.4)
|
69
|
+
listen (>= 2.7, < 4.0)
|
70
|
+
lumberjack (>= 1.0.12, < 2.0)
|
71
|
+
nenv (~> 0.1)
|
72
|
+
notiffany (~> 0.0)
|
73
|
+
pry (>= 0.13.0)
|
74
|
+
shellany (~> 0.0)
|
75
|
+
thor (>= 0.18.1)
|
76
|
+
guard-compat (1.2.1)
|
77
|
+
guard-rspec (4.7.3)
|
78
|
+
guard (~> 2.1)
|
79
|
+
guard-compat (~> 1.1)
|
80
|
+
rspec (>= 2.99.0, < 4.0)
|
81
|
+
kramdown (2.4.0)
|
82
|
+
rexml
|
83
|
+
kramdown-parser-gfm (1.1.0)
|
84
|
+
kramdown (~> 2.0)
|
85
|
+
listen (3.0.7)
|
86
|
+
rb-fsevent (>= 0.9.3)
|
87
|
+
rb-inotify (>= 0.9.7)
|
88
|
+
lumberjack (1.2.8)
|
89
|
+
method_source (1.0.0)
|
90
|
+
multipart-post (2.1.1)
|
91
|
+
nap (1.1.0)
|
92
|
+
nenv (0.3.0)
|
93
|
+
no_proxy_fix (0.1.2)
|
94
|
+
notiffany (0.1.3)
|
95
|
+
nenv (~> 0.1)
|
96
|
+
shellany (~> 0.0)
|
97
|
+
octokit (4.22.0)
|
98
|
+
faraday (>= 0.9)
|
99
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
100
|
+
open4 (1.3.4)
|
101
|
+
parallel (1.22.1)
|
102
|
+
parser (3.1.2.0)
|
103
|
+
ast (~> 2.4.1)
|
104
|
+
pry (0.14.1)
|
105
|
+
coderay (~> 1.1)
|
106
|
+
method_source (~> 1.0)
|
107
|
+
public_suffix (4.0.7)
|
108
|
+
rainbow (3.1.1)
|
109
|
+
rake (10.5.0)
|
110
|
+
rb-fsevent (0.11.1)
|
111
|
+
rb-inotify (0.10.1)
|
112
|
+
ffi (~> 1.0)
|
113
|
+
rchardet (1.8.0)
|
114
|
+
regexp_parser (2.4.0)
|
115
|
+
rexml (3.2.5)
|
116
|
+
rspec (3.11.0)
|
117
|
+
rspec-core (~> 3.11.0)
|
118
|
+
rspec-expectations (~> 3.11.0)
|
119
|
+
rspec-mocks (~> 3.11.0)
|
120
|
+
rspec-core (3.11.0)
|
121
|
+
rspec-support (~> 3.11.0)
|
122
|
+
rspec-expectations (3.11.0)
|
123
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
124
|
+
rspec-support (~> 3.11.0)
|
125
|
+
rspec-mocks (3.11.1)
|
126
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
127
|
+
rspec-support (~> 3.11.0)
|
128
|
+
rspec-support (3.11.0)
|
129
|
+
rubocop (1.29.1)
|
130
|
+
parallel (~> 1.10)
|
131
|
+
parser (>= 3.1.0.0)
|
132
|
+
rainbow (>= 2.2.2, < 4.0)
|
133
|
+
regexp_parser (>= 1.8, < 3.0)
|
134
|
+
rexml (>= 3.2.5, < 4.0)
|
135
|
+
rubocop-ast (>= 1.17.0, < 2.0)
|
136
|
+
ruby-progressbar (~> 1.7)
|
137
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
138
|
+
rubocop-ast (1.18.0)
|
139
|
+
parser (>= 3.1.1.0)
|
140
|
+
ruby-progressbar (1.11.0)
|
141
|
+
ruby2_keywords (0.0.5)
|
142
|
+
sawyer (0.8.2)
|
143
|
+
addressable (>= 2.3.5)
|
144
|
+
faraday (> 0.8, < 2.0)
|
145
|
+
shellany (0.0.1)
|
146
|
+
terminal-table (3.0.2)
|
147
|
+
unicode-display_width (>= 1.1.1, < 3)
|
148
|
+
thor (1.2.1)
|
149
|
+
unicode-display_width (2.1.0)
|
150
|
+
webrick (1.7.0)
|
151
|
+
yard (0.9.27)
|
152
|
+
webrick (~> 1.7.0)
|
153
|
+
|
154
|
+
PLATFORMS
|
155
|
+
ruby
|
156
|
+
|
157
|
+
DEPENDENCIES
|
158
|
+
bundler (~> 2.0)
|
159
|
+
danger-rubocop_disable_checker!
|
160
|
+
guard (~> 2.14)
|
161
|
+
guard-rspec (~> 4.7)
|
162
|
+
listen (= 3.0.7)
|
163
|
+
pry
|
164
|
+
rake (~> 10.0)
|
165
|
+
rspec (~> 3.4)
|
166
|
+
rubocop
|
167
|
+
yard
|
168
|
+
|
169
|
+
BUNDLED WITH
|
170
|
+
2.3.6
|
data/Guardfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A guardfile for making Danger Plugins
|
4
|
+
# For more info see https://github.com/guard/guard#readme
|
5
|
+
|
6
|
+
# To run, use `bundle exec guard`.
|
7
|
+
|
8
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
9
|
+
require "guard/rspec/dsl"
|
10
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
11
|
+
|
12
|
+
# RSpec files
|
13
|
+
rspec = dsl.rspec
|
14
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
15
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
16
|
+
watch(rspec.spec_files)
|
17
|
+
|
18
|
+
# Ruby files
|
19
|
+
ruby = dsl.ruby
|
20
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
21
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2022 Jared Smith <jared.smith@chime.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# danger-rubocop_disable_checker
|
2
|
+
|
3
|
+
A description of danger-rubocop_disable_checker.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install danger-rubocop_disable_checker
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Methods and attributes from this plugin are available in
|
12
|
+
your `Dangerfile` under the `rubocop_disable_checker` namespace.
|
13
|
+
|
14
|
+
## Development
|
15
|
+
|
16
|
+
1. Clone this repo
|
17
|
+
2. Run `bundle install` to setup dependencies.
|
18
|
+
3. Run `bundle exec rake spec` to run the tests.
|
19
|
+
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
20
|
+
5. Make your changes.
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "rubocop/rake_task"
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:specs)
|
8
|
+
|
9
|
+
task default: :specs
|
10
|
+
|
11
|
+
task :spec do
|
12
|
+
Rake::Task["specs"].invoke
|
13
|
+
Rake::Task["rubocop"].invoke
|
14
|
+
Rake::Task["spec_docs"].invoke
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run RuboCop on the lib/specs directory"
|
18
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
19
|
+
task.patterns = ["lib/**/*.rb", "spec/**/*.rb"]
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Ensure that the plugin passes `danger plugins lint`"
|
23
|
+
task :spec_docs do
|
24
|
+
sh "bundle exec danger plugins lint"
|
25
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "rubocop_disable_checker/gem_version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "danger-rubocop_disable_checker"
|
9
|
+
spec.version = RubocopDisableChecker::VERSION
|
10
|
+
spec.authors = ["Jared Smith"]
|
11
|
+
spec.email = ["jared.smith@chime.com"]
|
12
|
+
spec.description = "A Danger plugin to check for RuboCop disable comments."
|
13
|
+
spec.summary = "Checks for circumvention of RuboCop via `rubocop:disabe` and " \
|
14
|
+
"links to documentation of the rule for each one (if there is any)."
|
15
|
+
spec.homepage = "https://github.com/jaredsmithse/danger-rubocop_disable_checker"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_runtime_dependency "danger-plugin-api", "~> 1.0"
|
24
|
+
|
25
|
+
# General ruby development
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
|
29
|
+
# Testing support
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
31
|
+
|
32
|
+
# Linting code and docs
|
33
|
+
spec.add_development_dependency "rubocop"
|
34
|
+
spec.add_development_dependency "yard"
|
35
|
+
|
36
|
+
# Makes testing easy via `bundle exec guard`
|
37
|
+
spec.add_development_dependency "guard", "~> 2.14"
|
38
|
+
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
39
|
+
|
40
|
+
# If you want to work on older builds of ruby
|
41
|
+
spec.add_development_dependency "listen", "3.0.7"
|
42
|
+
|
43
|
+
# This gives you the chance to run a REPL inside your tests
|
44
|
+
# via:
|
45
|
+
#
|
46
|
+
# require 'pry'
|
47
|
+
# binding.pry
|
48
|
+
#
|
49
|
+
# This will stop test execution and let you inspect the results
|
50
|
+
spec.add_development_dependency "pry"
|
51
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# !!!!!! TODO !!!!!!!
|
4
|
+
# [!] Don't forget to create a Pull Request on https://gitlab.com/danger-systems/danger.systems/raw/master/plugins-search-generated.json
|
5
|
+
# to add your plugin to the plugins.json file once it is released!
|
6
|
+
|
7
|
+
module Danger
|
8
|
+
# Checks for circumvention of RuboCop via `rubocop:disabe` and links
|
9
|
+
# to documentation of the rule for each one (if there is any).
|
10
|
+
#
|
11
|
+
# @example Check for usage of `rubocop:disable` for added lines
|
12
|
+
# ```rb
|
13
|
+
# rubocop_disable_checker.run(
|
14
|
+
# ignore_paths: ["Dangerfile", "gems/"],
|
15
|
+
# message: "Please don't disable RuboCop unless absolutely necessary!",
|
16
|
+
# tag_reviewers: ["yourgithubteamhandle"]
|
17
|
+
# )
|
18
|
+
# ```
|
19
|
+
#
|
20
|
+
# @see jaredsmithse/danger-rubocop_disable_checker
|
21
|
+
# @tags ruby, rubocop, linter
|
22
|
+
#
|
23
|
+
class DangerRubocopDisableChecker < Plugin
|
24
|
+
EMPTY_CONFIG = {}.freeze
|
25
|
+
|
26
|
+
COMMENT = <<~COMMENT.gsub("\n", " ")
|
27
|
+
Disabling a rule is usually an indication of a code smell and can be easily avoided.
|
28
|
+
If you feel this is an exceptional case, please add a comment above with justification.
|
29
|
+
COMMENT
|
30
|
+
|
31
|
+
IGNORE_PATHS = ["Dangerfile"].freeze
|
32
|
+
|
33
|
+
# An attribute that you can read/write from your Dangerfile
|
34
|
+
#
|
35
|
+
# @return [Array<String>]
|
36
|
+
attr_reader :ignore_paths
|
37
|
+
|
38
|
+
# An attribute that you can read/write from your Dangerfile
|
39
|
+
#
|
40
|
+
# @return [String]
|
41
|
+
attr_reader :message
|
42
|
+
|
43
|
+
# If there are disables, you can optionally tag teammates
|
44
|
+
#
|
45
|
+
# @return [Array<String>]
|
46
|
+
attr_reader :tag_reviewers
|
47
|
+
|
48
|
+
# A method that you can call from your Dangerfile
|
49
|
+
# @param config [Hash] configuration options when running the checker
|
50
|
+
# @return [void]
|
51
|
+
def run(config = EMPTY_CONFIG)
|
52
|
+
@ignore_paths = config.fetch(:ignore_paths, IGNORE_PATHS)
|
53
|
+
@message = config.fetch(:message, COMMENT)
|
54
|
+
@tag_reviewers = config.fetch(:tag_reviewers, [])
|
55
|
+
|
56
|
+
disable_violations = violations(file_diffs(git.diff))
|
57
|
+
inline_comments(disable_violations)
|
58
|
+
pr_comment if disable_violations.any?
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def inline_comments(disable_violations)
|
64
|
+
disable_violations.each do |violation|
|
65
|
+
warn(inline_format(violation[:disabled_cops]), violation.slice(:file, :line))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def pr_comment
|
70
|
+
reviewers = tag_reviewers.map { |reviewer| "@#{reviewer}"}.join(", ")
|
71
|
+
warn("Detected use of `rubocop:disable` directive. cc #{reviewers}")
|
72
|
+
end
|
73
|
+
|
74
|
+
def inline_format(cops)
|
75
|
+
disable_comment =
|
76
|
+
if cops.none?
|
77
|
+
"Detected `rubocop:disable`"
|
78
|
+
elsif cops.one?
|
79
|
+
"Detected `rubocop:disable` for #{cops.first}"
|
80
|
+
else
|
81
|
+
cops.map! { |cop| "- #{cop}" }
|
82
|
+
"Detected `rubocop:disable` for the following cops: \n #{cops.join("\n")}"
|
83
|
+
end
|
84
|
+
|
85
|
+
<<~COMMENT
|
86
|
+
#{disable_comment}\n\n
|
87
|
+
> **Note**
|
88
|
+
> #{message}
|
89
|
+
COMMENT
|
90
|
+
end
|
91
|
+
|
92
|
+
def violations(diffs)
|
93
|
+
diffs.flat_map do |file, insertions|
|
94
|
+
insertions
|
95
|
+
.select { |line| line[:content].include?("# rubocop:disable") }
|
96
|
+
.map do |line|
|
97
|
+
{
|
98
|
+
file: file,
|
99
|
+
line: line[:line_number],
|
100
|
+
disabled_cops: parse_cops(line[:content]),
|
101
|
+
}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def parse_cops(line_content)
|
107
|
+
match_data = line_content.match(/# rubocop:disable (?<cops>.*)/)
|
108
|
+
return [] unless match_data
|
109
|
+
|
110
|
+
match_data[:cops].split(",").map { |cop| add_url(cop.strip) }
|
111
|
+
end
|
112
|
+
|
113
|
+
def add_url(cop)
|
114
|
+
doc_link = `bundle exec rubocop --show-docs-url #{cop}`.tr("\n", "")
|
115
|
+
doc_link.empty? ? cop : "[#{cop}](#{doc_link})"
|
116
|
+
end
|
117
|
+
|
118
|
+
def file_diffs(git_diffs)
|
119
|
+
git_diffs
|
120
|
+
.select { |diff| ignore_paths.none? { |path| diff.path.include?(path) } }
|
121
|
+
.each_with_object({}) do |diff, diff_obj|
|
122
|
+
diff_obj[diff.path] = chunks_for_file(diff)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def chunks_for_file(full_diff)
|
127
|
+
full_diff
|
128
|
+
.patch
|
129
|
+
.split("\n@@")
|
130
|
+
.tap(&:shift)
|
131
|
+
.flat_map { |chunk| process_chunk(chunk) }
|
132
|
+
.compact
|
133
|
+
end
|
134
|
+
|
135
|
+
def process_chunk(chunk)
|
136
|
+
first_line, *diff = chunk.split("\n")
|
137
|
+
line_number = first_line.match(/\+(\d+),?(\d?)/).captures.first.to_i
|
138
|
+
|
139
|
+
diff.each_with_object([]) do |line, insertions|
|
140
|
+
if line.start_with?("+")
|
141
|
+
insertions << { content: line, line_number: line_number }
|
142
|
+
end
|
143
|
+
|
144
|
+
line_number += 1 unless line.start_with?("-")
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("spec_helper", __dir__)
|
4
|
+
|
5
|
+
module Danger
|
6
|
+
describe Danger::DangerRubocopDisableChecker do
|
7
|
+
it "should be a plugin" do
|
8
|
+
expect(Danger::DangerRubocopDisableChecker.new(nil)).to be_a Danger::Plugin
|
9
|
+
end
|
10
|
+
|
11
|
+
#
|
12
|
+
# You should test your custom attributes and methods here
|
13
|
+
#
|
14
|
+
describe "with Dangerfile" do
|
15
|
+
before do
|
16
|
+
@dangerfile = testing_dangerfile
|
17
|
+
@my_plugin = @dangerfile.rubocop_disable_checker
|
18
|
+
|
19
|
+
# mock the PR data
|
20
|
+
# you can then use this, eg. github.pr_author, later in the spec
|
21
|
+
json = File.read("#{File.dirname(__FILE__)}/support/fixtures/github_pr.json") # example json: `curl https://api.github.com/repos/danger/danger-plugin-template/pulls/18 > github_pr.json`
|
22
|
+
allow(@my_plugin.github).to receive(:pr_json).and_return(json)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Some examples for writing tests
|
26
|
+
# You should replace these with your own.
|
27
|
+
|
28
|
+
it "Warns on a monday" do
|
29
|
+
monday_date = Date.parse("2016-07-11")
|
30
|
+
allow(Date).to receive(:today).and_return monday_date
|
31
|
+
|
32
|
+
@my_plugin.warn_on_mondays
|
33
|
+
|
34
|
+
expect(@dangerfile.status_report[:warnings]).to eq(["Trying to merge code on a Monday"])
|
35
|
+
end
|
36
|
+
|
37
|
+
it "Does nothing on a tuesday" do
|
38
|
+
monday_date = Date.parse("2016-07-12")
|
39
|
+
allow(Date).to receive(:today).and_return monday_date
|
40
|
+
|
41
|
+
@my_plugin.warn_on_mondays
|
42
|
+
|
43
|
+
expect(@dangerfile.status_report[:warnings]).to eq([])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
ROOT = Pathname.new(File.expand_path("..", __dir__))
|
5
|
+
$:.unshift("#{ROOT}lib".to_s)
|
6
|
+
$:.unshift("#{ROOT}spec".to_s)
|
7
|
+
|
8
|
+
require "bundler/setup"
|
9
|
+
require "pry"
|
10
|
+
|
11
|
+
require "rspec"
|
12
|
+
require "danger"
|
13
|
+
|
14
|
+
if `git remote -v` == ""
|
15
|
+
puts "You cannot run tests without setting a local git remote on this repo"
|
16
|
+
puts "It's a weird side-effect of Danger's internals."
|
17
|
+
exit(0)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Use coloured output, it's the best.
|
21
|
+
RSpec.configure do |config|
|
22
|
+
config.filter_gems_from_backtrace "bundler"
|
23
|
+
config.color = true
|
24
|
+
config.tty = true
|
25
|
+
end
|
26
|
+
|
27
|
+
require "danger_plugin"
|
28
|
+
|
29
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
30
|
+
# If you are expanding these files, see if it's already been done ^.
|
31
|
+
|
32
|
+
# A silent version of the user interface,
|
33
|
+
# it comes with an extra function `.string` which will
|
34
|
+
# strip all ANSI colours from the string.
|
35
|
+
|
36
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
37
|
+
def testing_ui
|
38
|
+
@output = StringIO.new
|
39
|
+
def @output.winsize
|
40
|
+
[20, 9999]
|
41
|
+
end
|
42
|
+
|
43
|
+
cork = Cork::Board.new(out: @output)
|
44
|
+
def cork.string
|
45
|
+
out.string.gsub(/\e\[([;\d]+)?m/, "")
|
46
|
+
end
|
47
|
+
cork
|
48
|
+
end
|
49
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
50
|
+
|
51
|
+
# Example environment (ENV) that would come from
|
52
|
+
# running a PR on TravisCI
|
53
|
+
def testing_env
|
54
|
+
{
|
55
|
+
"HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
|
56
|
+
"TRAVIS_PULL_REQUEST" => "800",
|
57
|
+
"TRAVIS_REPO_SLUG" => "artsy/eigen",
|
58
|
+
"TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
|
59
|
+
"DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
# A stubbed out Dangerfile for use in tests
|
64
|
+
def testing_dangerfile
|
65
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
66
|
+
Danger::Dangerfile.new(env, testing_ui)
|
67
|
+
end
|
metadata
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-rubocop_disable_checker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jared Smith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-02-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: danger-plugin-api
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.14'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.14'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.7'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.7'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: listen
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 3.0.7
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 3.0.7
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: A Danger plugin to check for RuboCop disable comments.
|
154
|
+
email:
|
155
|
+
- jared.smith@chime.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".github/workflows/gem-push.yml"
|
161
|
+
- ".gitignore"
|
162
|
+
- ".rubocop.yml"
|
163
|
+
- ".ruby-version"
|
164
|
+
- ".travis.yml"
|
165
|
+
- Gemfile
|
166
|
+
- Gemfile.lock
|
167
|
+
- Guardfile
|
168
|
+
- LICENSE.txt
|
169
|
+
- README.md
|
170
|
+
- Rakefile
|
171
|
+
- danger-rubocop_disable_checker.gemspec
|
172
|
+
- lib/danger_plugin.rb
|
173
|
+
- lib/danger_rubocop_disable_checker.rb
|
174
|
+
- lib/rubocop_disable_checker/gem_version.rb
|
175
|
+
- lib/rubocop_disable_checker/plugin.rb
|
176
|
+
- spec/rubocop_disable_checker_spec.rb
|
177
|
+
- spec/spec_helper.rb
|
178
|
+
homepage: https://github.com/jaredsmithse/danger-rubocop_disable_checker
|
179
|
+
licenses:
|
180
|
+
- MIT
|
181
|
+
metadata: {}
|
182
|
+
post_install_message:
|
183
|
+
rdoc_options: []
|
184
|
+
require_paths:
|
185
|
+
- lib
|
186
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
196
|
+
requirements: []
|
197
|
+
rubygems_version: 3.1.6
|
198
|
+
signing_key:
|
199
|
+
specification_version: 4
|
200
|
+
summary: Checks for circumvention of RuboCop via `rubocop:disabe` and links to documentation
|
201
|
+
of the rule for each one (if there is any).
|
202
|
+
test_files:
|
203
|
+
- spec/rubocop_disable_checker_spec.rb
|
204
|
+
- spec/spec_helper.rb
|