rubocop-extension-generator 0.5.2 → 0.6.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -0
- data/README.md +8 -4
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/exe/rubocop-extension-generator +1 -0
- data/lib/rubocop/extension/generator/cli.rb +2 -0
- data/lib/rubocop/extension/generator/generator.rb +52 -33
- data/lib/rubocop/extension/generator/version.rb +3 -1
- data/lib/rubocop/extension/generator.rb +2 -0
- data/rubocop-extension-generator.gemspec +4 -2
- data/smoke/smoke.rb +4 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c0f67a779d53faf1f517f4479848dab47a1f2d64e6d26caae1f273ee3b914ad
|
4
|
+
data.tar.gz: a8bbd3a759b3acec39b598bc4d873f507546e5dfe13928e700d777925a6a6a09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b0a678228716c9a05c9b4a8878dc25007d2cc1aac63e82549658ef119436be795fd6438bc8fbd4f8202ca01534ea0a4ee2d5948d36f2c4f10b5c2c42524389b
|
7
|
+
data.tar.gz: a5d2e5c95b9fba2d955c8be74e669cc1c90d8c989d7ba5a684ac466a13d2693f2e93e266bc7e504ab54ae8aac5e0f6582a69607d84dd2624ba2ec4ae8d521a80
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# master (unreleased)
|
2
2
|
|
3
|
+
## v0.6.1
|
4
|
+
|
5
|
+
* [#28](https://github.com/rubocop/rubocop-extension-generator/pull/28): Prevent errors when internally using cops that rely on configuration options.
|
6
|
+
|
7
|
+
## v0.6.0
|
8
|
+
|
9
|
+
* [#27](https://github.com/rubocop/rubocop-extension-generator/pull/27): Support RuboCop extension plugin.
|
10
|
+
|
3
11
|
## v0.5.2
|
4
12
|
|
5
13
|
* [#19](https://github.com/rubocop/rubocop-extension-generator/pull/19): Support `bundle gem` gem name placeholder.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -26,27 +26,32 @@ Creating gem 'rubocop-foobar'...
|
|
26
26
|
create rubocop-foobar/Gemfile
|
27
27
|
create rubocop-foobar/lib/rubocop/foobar.rb
|
28
28
|
create rubocop-foobar/lib/rubocop/foobar/version.rb
|
29
|
+
create rubocop-foobar/sig/rubocop/foobar.rbs
|
29
30
|
create rubocop-foobar/rubocop-foobar.gemspec
|
30
31
|
create rubocop-foobar/Rakefile
|
31
32
|
create rubocop-foobar/README.md
|
32
33
|
create rubocop-foobar/bin/console
|
33
34
|
create rubocop-foobar/bin/setup
|
34
35
|
create rubocop-foobar/.gitignore
|
35
|
-
|
36
|
+
create rubocop-foobar/LICENSE.txt
|
36
37
|
Gem 'rubocop-foobar' was successfully created. For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html
|
37
38
|
create rubocop-foobar/lib/rubocop-foobar.rb
|
38
|
-
create rubocop-foobar/lib/rubocop/foobar/
|
39
|
+
create rubocop-foobar/lib/rubocop/foobar/plugin.rb
|
39
40
|
create rubocop-foobar/lib/rubocop/cop/foobar_cops.rb
|
40
41
|
create rubocop-foobar/config/default.yml
|
41
42
|
create rubocop-foobar/spec/spec_helper.rb
|
42
43
|
create rubocop-foobar/.rspec
|
43
|
-
|
44
|
+
create rubocop-foobar/.rubocop.yml
|
44
45
|
update lib/rubocop/foobar.rb
|
45
46
|
update lib/rubocop/foobar/version.rb
|
47
|
+
update README.md
|
48
|
+
update rubocop-foobar.gemspec
|
46
49
|
update rubocop-foobar.gemspec
|
47
50
|
update rubocop-foobar.gemspec
|
48
51
|
update Rakefile
|
49
52
|
update Gemfile
|
53
|
+
update README.md
|
54
|
+
delete sig
|
50
55
|
|
51
56
|
It's done! You can start developing a new extension of RuboCop in rubocop-foobar.
|
52
57
|
For the next step, you can use the cop generator.
|
@@ -67,4 +72,3 @@ You can execute a smoke test with `ruby smoke/smoke.rb`. Check it is success bef
|
|
67
72
|
## Contributing
|
68
73
|
|
69
74
|
Bug reports and pull requests are welcome on GitHub at https://github.com/rubocop/rubocop-extension-generator.
|
70
|
-
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Extension
|
3
5
|
module Generator
|
@@ -16,30 +18,39 @@ module RuboCop
|
|
16
18
|
|
17
19
|
require_relative '#{dirname}'
|
18
20
|
require_relative '#{dirname}/version'
|
19
|
-
require_relative '#{dirname}/
|
20
|
-
|
21
|
-
RuboCop::#{classname}::Inject.defaults!
|
21
|
+
require_relative '#{dirname}/plugin'
|
22
22
|
|
23
|
-
require_relative '#{cops_file_name.sub(/\.rb$/, '').sub(
|
23
|
+
require_relative '#{cops_file_name.sub(/\.rb$/, '').sub(%r{^lib/}, '')}'
|
24
24
|
RUBY
|
25
25
|
|
26
|
-
put "lib/#{dirname}/
|
26
|
+
put "lib/#{dirname}/plugin.rb", <<~RUBY
|
27
27
|
# frozen_string_literal: true
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
require 'lint_roller'
|
30
|
+
|
31
31
|
module RuboCop
|
32
32
|
module #{classname}
|
33
|
-
#
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
33
|
+
# A plugin that integrates #{name} with RuboCop's plugin system.
|
34
|
+
class Plugin < LintRoller::Plugin
|
35
|
+
def about
|
36
|
+
LintRoller::About.new(
|
37
|
+
name: '#{name}',
|
38
|
+
version: VERSION,
|
39
|
+
homepage: "TODO: Put your plugin's homepage URL here.",
|
40
|
+
description: "TODO: Put your plugin's description here."
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def supported?(context)
|
45
|
+
context.engine == :rubocop
|
46
|
+
end
|
47
|
+
|
48
|
+
def rules(_context)
|
49
|
+
LintRoller::Rules.new(
|
50
|
+
type: :path,
|
51
|
+
config_format: :rubocop,
|
52
|
+
value: Pathname.new(__dir__).join('../../../config/default.yml')
|
53
|
+
)
|
43
54
|
end
|
44
55
|
end
|
45
56
|
end
|
@@ -61,8 +72,6 @@ module RuboCop
|
|
61
72
|
require 'rubocop/rspec/support'
|
62
73
|
|
63
74
|
RSpec.configure do |config|
|
64
|
-
config.include RuboCop::RSpec::ExpectOffense
|
65
|
-
|
66
75
|
config.disable_monkey_patching!
|
67
76
|
config.raise_errors_for_deprecations!
|
68
77
|
config.raise_on_warning = true
|
@@ -80,28 +89,26 @@ module RuboCop
|
|
80
89
|
TEXT
|
81
90
|
|
82
91
|
put '.rubocop.yml', <<~YML
|
92
|
+
plugins:
|
93
|
+
- rubocop-internal_affairs
|
94
|
+
- #{name}
|
95
|
+
|
83
96
|
Naming/FileName:
|
84
|
-
|
85
|
-
|
97
|
+
Exclude:
|
98
|
+
- lib/#{name}.rb
|
86
99
|
YML
|
87
100
|
|
88
|
-
patch "lib/#{dirname}.rb", /^ end\nend/, <<~RUBY
|
89
|
-
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
|
90
|
-
CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
|
91
|
-
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
92
|
-
|
93
|
-
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
RUBY
|
97
|
-
|
98
101
|
patch "lib/#{dirname}.rb", 'module Rubocop', 'module RuboCop'
|
99
102
|
patch "lib/#{dirname}/version.rb", 'module Rubocop', 'module RuboCop'
|
103
|
+
patch 'README.md', 'Rubocop', 'RuboCop'
|
100
104
|
patch "#{name}.gemspec", 'Rubocop', 'RuboCop'
|
101
|
-
|
105
|
+
patch "#{name}.gemspec", /required_ruby_version = ">= \d.\d.\d"/, 'required_ruby_version = ">= 2.7.0"'
|
102
106
|
patch "#{name}.gemspec", /^end/, <<~RUBY
|
103
107
|
|
104
|
-
spec.
|
108
|
+
spec.metadata['default_lint_roller_plugin'] = 'RuboCop::#{classname}::Plugin'
|
109
|
+
|
110
|
+
spec.add_dependency 'lint_roller', '~> 1.1'
|
111
|
+
spec.add_dependency 'rubocop', '>= 1.72.2'
|
105
112
|
end
|
106
113
|
RUBY
|
107
114
|
|
@@ -134,6 +141,7 @@ module RuboCop
|
|
134
141
|
RUBY
|
135
142
|
|
136
143
|
patch 'Gemfile', /\z/, <<~RUBY
|
144
|
+
gem 'rubocop', '>= 1.72.2'
|
137
145
|
gem 'rspec'
|
138
146
|
RUBY
|
139
147
|
|
@@ -143,6 +151,10 @@ module RuboCop
|
|
143
151
|
patch 'README.md', /^gem '#{name}'$/, "gem '#{name}', require: false"
|
144
152
|
end
|
145
153
|
|
154
|
+
# NOTE: Since useful type definitions are usually not provided, they are not generated by default.
|
155
|
+
# Users can create them as needed.
|
156
|
+
delete "sig"
|
157
|
+
|
146
158
|
puts
|
147
159
|
puts <<~MESSAGE
|
148
160
|
It's done! You can start developing a new extension of RuboCop in #{root_path}.
|
@@ -164,9 +176,16 @@ module RuboCop
|
|
164
176
|
path = root_path / path
|
165
177
|
file = path.read
|
166
178
|
raise "Cannot apply patch for #{path} because #{pattern} is missing" unless file.match?(pattern)
|
179
|
+
|
167
180
|
path.write file.sub(pattern, replacement)
|
168
181
|
end
|
169
182
|
|
183
|
+
private def delete(path)
|
184
|
+
puts "delete #{path}"
|
185
|
+
path = root_path / path
|
186
|
+
FileUtils.rm_r(path)
|
187
|
+
end
|
188
|
+
|
170
189
|
private def root_path
|
171
190
|
@root_path ||= Pathname(name)
|
172
191
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'lib/rubocop/extension/generator/version'
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
@@ -9,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
9
11
|
spec.summary = %q{A generator of RuboCop's custom cops gem}
|
10
12
|
spec.description = %q{A generator of RuboCop's custom cops gem}
|
11
13
|
spec.homepage = "https://github.com/rubocop/rubocop-extension-generator"
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
13
15
|
spec.licenses = ['MIT']
|
14
16
|
|
15
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
@@ -27,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
27
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
30
|
spec.require_paths = ["lib"]
|
29
31
|
|
30
|
-
spec.add_runtime_dependency 'rubocop', '>= 1.
|
32
|
+
spec.add_runtime_dependency 'rubocop', '>= 1.72.2'
|
31
33
|
spec.add_runtime_dependency 'bundler'
|
32
34
|
spec.add_runtime_dependency 'activesupport'
|
33
35
|
end
|
data/smoke/smoke.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Smoke testing for this gem
|
2
4
|
|
3
5
|
require 'tmpdir'
|
@@ -18,11 +20,12 @@ Dir.mktmpdir('-rubocop-extension-generator-smoke') do |base_dir|
|
|
18
20
|
gemspec[/spec\.summary.+/] = 'spec.summary = "a gem for smoke testing"'
|
19
21
|
gemspec.gsub!(/^.+spec\.description.+$/, '')
|
20
22
|
gemspec.gsub!(/^.+spec\.homepage.+$/, '')
|
21
|
-
gemspec.gsub!(/^.+spec\.metadata.+$/, '')
|
23
|
+
gemspec.gsub!(/^.+spec\.metadata\["(homepage_uri|source_code_uri|changelog_uri)"\].+$/, '')
|
22
24
|
|
23
25
|
gemspec_path.write gemspec
|
24
26
|
|
25
27
|
system('bundle', 'install', exception: true, chdir: gem_dir)
|
26
28
|
system('bundle', 'exec', 'rake', 'new_cop[Smoke/Foo]', exception: true, chdir: gem_dir)
|
29
|
+
system('bundle', 'exec', 'rubocop', '-a', exception: true, chdir: gem_dir)
|
27
30
|
system('bundle', 'exec', 'rake', 'spec', exception: true, chdir: gem_dir)
|
28
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-extension-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka Pocke Kuwabara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.72.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.72.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,14 +90,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 2.
|
93
|
+
version: 2.7.0
|
94
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
96
|
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
|
-
rubygems_version: 3.2.
|
100
|
+
rubygems_version: 3.2.33
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: A generator of RuboCop's custom cops gem
|