rubocop_auto_corrector 0.4.5 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 441e167174a1279880bfd7116306ee17af4a724d71081afba45e10e6eca41312
4
- data.tar.gz: e7866a2e713aa220c12ae604cb696d929f8b21e92495fcb5922a83861b318436
3
+ metadata.gz: 9e079481e71f940939ad708bcded9def83c707ec205019af753039aa4902888f
4
+ data.tar.gz: a41369b3d252d2915ef6345780f1913cbf0a88bc4c8fa27132b92ba04ca29c82
5
5
  SHA512:
6
- metadata.gz: 9416144dcdfb9d124bd7e0e7debb1c6e83c51ce1e4964664abbad4252cae3bc9ccf44a6745f81a57058704d93b755bd659e3a3eba3c20c7768ce36095794a1c9
7
- data.tar.gz: d1daa1c4eb297c2f78d87be36c990a653f7e9fd3264a03a8769636741c0fa271af4592f47088dd35e18991663ff2f427265f31a780b497d1045e9ca41dd8fd27
6
+ metadata.gz: 2665875db09f4a811d8ae6b343006a19aae845a84ec0efc8aef5594f8aed6c52efd296b5a5e8bfa48ec7280707fb2c0b1a5566232842024815e5c2c1ad68c2ab
7
+ data.tar.gz: 82d3347044bba0aa9a4006b022b155e85c4bd41142a5d65cbbb4f6006765c64eb0210cacc2020f09142020f73c0d4d914f4ec51e3a49d36236f27b22460f0b64
@@ -6,5 +6,7 @@ updates:
6
6
  directory: /
7
7
  schedule:
8
8
  interval: weekly
9
+ cooldown:
10
+ default-days: 7
9
11
  assignees:
10
12
  - sue445
@@ -30,9 +30,9 @@ jobs:
30
30
  runs-on: ubuntu-latest
31
31
  steps:
32
32
  - name: Checkout
33
- uses: actions/checkout@v4
33
+ uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
34
34
 
35
- - uses: ruby/setup-ruby@v1
35
+ - uses: ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71 # v1.268.0
36
36
  with:
37
37
  ruby-version: ruby
38
38
  bundler-cache: true
@@ -40,18 +40,18 @@ jobs:
40
40
  - run: bundle exec yard
41
41
 
42
42
  - name: Setup Pages
43
- uses: actions/configure-pages@v5
43
+ uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
44
44
  - name: Upload artifact
45
- uses: actions/upload-pages-artifact@v3
45
+ uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
46
46
  with:
47
47
  # Upload entire repository
48
48
  path: './doc'
49
49
  - name: Deploy to GitHub Pages
50
50
  id: deployment
51
- uses: actions/deploy-pages@main
51
+ uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
52
52
 
53
53
  - name: Slack Notification (not success)
54
- uses: act10ns/slack@v2
54
+ uses: act10ns/slack@cfcc30955fe9377f4f55e1079e5419ee1014269f # v2
55
55
  if: "! success()"
56
56
  continue-on-error: true
57
57
  with:
@@ -0,0 +1,41 @@
1
+ name: Publish gem to rubygems.org
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ release:
8
+ if: github.repository == 'sue445/rubocop_auto_corrector'
9
+ runs-on: ubuntu-latest
10
+
11
+ environment:
12
+ name: rubygems.org
13
+ url: https://rubygems.org/gems/rubocop_auto_corrector
14
+
15
+ permissions:
16
+ contents: write
17
+ id-token: write
18
+
19
+ steps:
20
+ - name: Harden Runner
21
+ uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
22
+ with:
23
+ egress-policy: audit
24
+
25
+ - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
26
+
27
+ - name: Set up Ruby
28
+ uses: ruby/setup-ruby@eaecf785f6a34567a6d97f686bbb7bccc1ac1e5c # v1.237.0
29
+ with:
30
+ bundler-cache: true
31
+ ruby-version: ruby
32
+
33
+ - name: Publish to RubyGems
34
+ uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1
35
+
36
+ - name: Create GitHub release
37
+ run: |
38
+ tag_name="$(git describe --tags --abbrev=0)"
39
+ gh release create "${tag_name}" --verify-tag --generate-notes
40
+ env:
41
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -27,11 +27,12 @@ jobs:
27
27
  - "3.1"
28
28
  - "3.2"
29
29
  - "3.3"
30
+ - "3.4"
30
31
 
31
32
  steps:
32
- - uses: actions/checkout@v4
33
+ - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
33
34
 
34
- - uses: ruby/setup-ruby@v1
35
+ - uses: ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71 # v1.268.0
35
36
  with:
36
37
  ruby-version: ${{ matrix.ruby }}
37
38
  bundler-cache: true
@@ -39,7 +40,7 @@ jobs:
39
40
  - run: bundle update --jobs $(nproc) --retry 3
40
41
 
41
42
  - name: Setup Code Climate Test Reporter
42
- uses: aktions/codeclimate-test-reporter@v1
43
+ uses: aktions/codeclimate-test-reporter@7634aa9ac7883182f583f15ff7b6ff519939dd0a # v1.2.0
43
44
  with:
44
45
  codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
45
46
  command: before-build
@@ -55,14 +56,14 @@ jobs:
55
56
  - run: bundle exec rubocop -P
56
57
 
57
58
  - name: Teardown Code Climate Test Reporter
58
- uses: aktions/codeclimate-test-reporter@v1
59
+ uses: aktions/codeclimate-test-reporter@7634aa9ac7883182f583f15ff7b6ff519939dd0a # v1.2.0
59
60
  with:
60
61
  codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
61
62
  command: after-build
62
63
  continue-on-error: true
63
64
 
64
65
  - name: Slack Notification (not success)
65
- uses: act10ns/slack@v2
66
+ uses: act10ns/slack@cfcc30955fe9377f4f55e1079e5419ee1014269f # v2
66
67
  if: "! success()"
67
68
  continue-on-error: true
68
69
  with:
@@ -78,7 +79,7 @@ jobs:
78
79
 
79
80
  steps:
80
81
  - name: Slack Notification (success)
81
- uses: act10ns/slack@v2
82
+ uses: act10ns/slack@cfcc30955fe9377f4f55e1079e5419ee1014269f # v2
82
83
  if: always()
83
84
  continue-on-error: true
84
85
  with:
data/.rubocop.yml CHANGED
@@ -26,3 +26,7 @@ Layout/LineLength:
26
26
 
27
27
  Style/Documentation:
28
28
  Enabled: false
29
+
30
+ Style/IfUnlessModifier:
31
+ Exclude:
32
+ - Gemfile
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## master
2
- [full changelog](http://github.com/sue445/rubocop_auto_corrector/compare/v0.4.5...master)
2
+ [full changelog](http://github.com/sue445/rubocop_auto_corrector/compare/v0.5.1...master)
3
+
4
+ ## v0.5.1
5
+ [full changelog](http://github.com/sue445/rubocop_auto_corrector/compare/v0.5.0...v0.5.1)
6
+
7
+ * Release gem from GitHub Actions
8
+ * https://github.com/sue445/rubocop_auto_corrector/pull/76
9
+
10
+ ## v0.5.0
11
+ [full changelog](http://github.com/sue445/rubocop_auto_corrector/compare/v0.4.5...v0.5.0)
12
+
13
+ * Support rubocop-rspec v3+
14
+ * https://github.com/sue445/rubocop_auto_corrector/pull/69
3
15
 
4
16
  ## v0.4.5
5
17
  [full changelog](http://github.com/sue445/rubocop_auto_corrector/compare/v0.4.4...v0.4.5)
data/Gemfile CHANGED
@@ -6,3 +6,9 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # Specify your gem's dependencies in rubocop_auto_corrector.gemspec
8
8
  gemspec
9
+
10
+ # rubocop:disable Gemspec/DevelopmentDependencies
11
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.7.0')
12
+ gem 'rubocop-factory_bot'
13
+ end
14
+ # rubocop:enable Gemspec/DevelopmentDependencies
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Run `rubocop --autocorrect && git commit` with each cop.
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/rubocop_auto_corrector.svg)](https://badge.fury.io/rb/rubocop_auto_corrector)
6
- [![Build Status](https://github.com/sue445/rubocop_auto_corrector/workflows/test/badge.svg?branch=master)](https://github.com/sue445/rubocop_auto_corrector/actions?query=workflow%3Atest)
6
+ [![test](https://github.com/sue445/rubocop_auto_corrector/actions/workflows/test.yml/badge.svg)](https://github.com/sue445/rubocop_auto_corrector/actions/workflows/test.yml)
7
7
  [![Maintainability](https://api.codeclimate.com/v1/badges/384834e50f94e344c439/maintainability)](https://codeclimate.com/github/sue445/rubocop_auto_corrector/maintainability)
8
8
  [![Coverage Status](https://coveralls.io/repos/github/sue445/rubocop_auto_corrector/badge.svg?branch=master)](https://coveralls.io/github/sue445/rubocop_auto_corrector?branch=master)
9
9
 
@@ -11,63 +11,100 @@ module RubocopAutoCorrector
11
11
 
12
12
  # Whether this cop is auto correctable
13
13
  # @return [Boolean]
14
- def auto_correctable?
15
- Object.new.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
16
- # begin
17
- # require 'rubocop-rspec'
18
- # rescue LoadError
19
- # end
20
- #
21
- # return ::RuboCop::Cop::RSpec::AlignLeftLetBrace.support_autocorrect? if ::RuboCop::Cop::RSpec::AlignLeftLetBrace.respond_to?(:support_autocorrect?)
22
- # ::RuboCop::Cop::RSpec::AlignLeftLetBrace.new.respond_to?(:autocorrect)
14
+ def auto_correctable? # rubocop:disable Metrics/MethodLength
15
+ cop_candidacies.any? do |cop_candidacy|
16
+ gem_name = cop_candidacy[:gem_name]
17
+ cop_class_name = cop_candidacy[:cop_class_name]
23
18
 
24
- begin
25
- require '#{gem_name}'
26
- rescue LoadError
27
- end
19
+ Object.new.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
20
+ # begin
21
+ # require 'rubocop-rspec'
22
+ # rescue LoadError
23
+ # end
24
+ #
25
+ # return ::RuboCop::Cop::RSpec::AlignLeftLetBrace.support_autocorrect? if ::RuboCop::Cop::RSpec::AlignLeftLetBrace.respond_to?(:support_autocorrect?)
26
+ # ::RuboCop::Cop::RSpec::AlignLeftLetBrace.new.respond_to?(:autocorrect)
28
27
 
29
- return #{cop_class_name}.support_autocorrect? if #{cop_class_name}.respond_to?(:support_autocorrect?)
30
- #{cop_class_name}.new.respond_to?(:autocorrect)
31
- RUBY
32
- rescue NameError
33
- false
34
- end
35
-
36
- # @return [String]
37
- def gem_name
38
- gem_name, = rubocop_cop_info
39
- gem_name
40
- end
28
+ begin
29
+ require '#{gem_name}'
30
+ rescue LoadError
31
+ end
41
32
 
42
- # @return [String]
43
- def cop_class_name
44
- _, cop_class = rubocop_cop_info
45
- cop_class
33
+ return #{cop_class_name}.support_autocorrect? if #{cop_class_name}.respond_to?(:support_autocorrect?)
34
+ #{cop_class_name}.new.respond_to?(:autocorrect)
35
+ RUBY
36
+ rescue NameError
37
+ false
38
+ end
46
39
  end
47
40
 
48
- private
49
-
50
41
  # rubocop:disable Metrics/MethodLength
51
- def rubocop_cop_info
52
- return @rubocop_cop_info if @rubocop_cop_info
53
-
42
+ # @return [Array<Hash<Symbol, String>>]
43
+ def cop_candidacies
54
44
  cop_class_suffix = cop_name.gsub('/', '::')
55
45
 
56
- @rubocop_cop_info =
57
- case cop_name
58
- when %r{^RSpec/}
59
- ['rubocop-rspec', "::RuboCop::Cop::#{cop_class_suffix}"]
60
- when %r{^(FactoryBot|Capybara)/}, 'Rails/HttpStatus'
61
- ['rubocop-rspec', "::RuboCop::Cop::RSpec::#{cop_class_suffix}"]
62
- when %r{^(Layout|Lint|Metrics|Naming|Security|Style|Bundler|Gemspec)/}
63
- # Official cops
64
- ['rubocop', "::RuboCop::Cop::#{cop_class_suffix}"]
65
- else
66
- # Unknown cops
67
- department_camel = cop_name.split('/').first
68
- department_snake = department_camel.gsub(/(?<=.)([A-Z])/) { |s| "_#{s}" }.downcase
69
- ["rubocop-#{department_snake}", "::RuboCop::Cop::#{cop_class_suffix}"]
70
- end
46
+ case cop_name
47
+ when %r{^RSpec/}
48
+ [
49
+ {
50
+ gem_name: 'rubocop-rspec',
51
+ cop_class_name: "::RuboCop::Cop::#{cop_class_suffix}"
52
+ }
53
+ ]
54
+ when 'Rails/HttpStatus'
55
+ [
56
+ # for rubocop-rspec < 2.28.0
57
+ {
58
+ gem_name: 'rubocop-rspec',
59
+ cop_class_name: "::RuboCop::Cop::RSpec::#{cop_class_suffix}"
60
+ }
61
+ ]
62
+ when %r{^FactoryBot/}
63
+ [
64
+ # for rubocop-rspec < 2.0.0
65
+ {
66
+ gem_name: 'rubocop-rspec',
67
+ cop_class_name: "::RuboCop::Cop::RSpec::#{cop_class_suffix}"
68
+ },
69
+ # for rubocop-rspec v3+
70
+ {
71
+ gem_name: 'rubocop-factory_bot',
72
+ cop_class_name: "::RuboCop::Cop::#{cop_class_suffix}"
73
+ }
74
+ ]
75
+ when %r{^Capybara/}
76
+ [
77
+ # for rubocop-rspec < 2.0.0
78
+ {
79
+ gem_name: 'rubocop-rspec',
80
+ cop_class_name: "::RuboCop::Cop::RSpec::#{cop_class_suffix}"
81
+ },
82
+ # for rubocop-rspec v3+
83
+ {
84
+ gem_name: 'rubocop-capybara',
85
+ cop_class_name: "::RuboCop::Cop::#{cop_class_suffix}"
86
+ }
87
+ ]
88
+ when %r{^(Layout|Lint|Metrics|Naming|Security|Style|Bundler|Gemspec)/}
89
+ # Official cops
90
+ [
91
+ {
92
+ gem_name: 'rubocop',
93
+ cop_class_name: "::RuboCop::Cop::#{cop_class_suffix}"
94
+ }
95
+ ]
96
+ else
97
+ # Unknown cops
98
+ department_camel = cop_name.split('/').first
99
+ department_snake = department_camel.gsub(/(?<=.)([A-Z])/) { |s| "_#{s}" }.downcase
100
+
101
+ [
102
+ {
103
+ gem_name: "rubocop-#{department_snake}",
104
+ cop_class_name: "::RuboCop::Cop::#{cop_class_suffix}"
105
+ }
106
+ ]
107
+ end
71
108
  end
72
109
  # rubocop:enable Metrics/MethodLength
73
110
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubocopAutoCorrector
4
- VERSION = '0.4.5'
4
+ VERSION = '0.5.1'
5
5
  end
@@ -43,6 +43,7 @@ Gem::Specification.new do |spec|
43
43
  spec.add_development_dependency 'rubocop', '>= 1.23.0'
44
44
  spec.add_development_dependency 'rubocop-rspec'
45
45
  spec.add_development_dependency 'simplecov', '< 0.18.0'
46
+ spec.add_development_dependency 'term-ansicolor', '!= 1.11.1' # ref. https://github.com/flori/term-ansicolor/issues/41
46
47
  spec.add_development_dependency 'unparser', '>= 0.4.5'
47
48
  spec.add_development_dependency 'yard'
48
49
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop_auto_corrector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-05-14 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rubocop
@@ -150,6 +149,20 @@ dependencies:
150
149
  - - "<"
151
150
  - !ruby/object:Gem::Version
152
151
  version: 0.18.0
152
+ - !ruby/object:Gem::Dependency
153
+ name: term-ansicolor
154
+ requirement: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "!="
157
+ - !ruby/object:Gem::Version
158
+ version: 1.11.1
159
+ type: :development
160
+ prerelease: false
161
+ version_requirements: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "!="
164
+ - !ruby/object:Gem::Version
165
+ version: 1.11.1
153
166
  - !ruby/object:Gem::Dependency
154
167
  name: unparser
155
168
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +202,7 @@ files:
189
202
  - ".coveralls.yml"
190
203
  - ".github/dependabot.yml"
191
204
  - ".github/workflows/pages.yml"
205
+ - ".github/workflows/release_gem.yml"
192
206
  - ".github/workflows/test.yml"
193
207
  - ".gitignore"
194
208
  - ".rspec"
@@ -217,7 +231,6 @@ metadata:
217
231
  changelog_uri: https://github.com/sue445/rubocop_auto_corrector/blob/master/CHANGELOG.md
218
232
  documentation_uri: https://sue445.github.io/rubocop_auto_corrector/
219
233
  rubygems_mfa_required: 'true'
220
- post_install_message:
221
234
  rdoc_options: []
222
235
  require_paths:
223
236
  - lib
@@ -232,8 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
245
  - !ruby/object:Gem::Version
233
246
  version: '0'
234
247
  requirements: []
235
- rubygems_version: 3.5.9
236
- signing_key:
248
+ rubygems_version: 3.6.7
237
249
  specification_version: 4
238
250
  summary: Run `rubocop --autocorrect && git commit` with each cop.
239
251
  test_files: []