rucop-rubomatic-rails 1.0.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.adoc +9 -0
- data/LICENSE +22 -0
- data/README.adoc +86 -0
- data/lib/rubocop/cop/rubomatic-rails/generator/cop_readme_injector.rb +51 -0
- data/lib/rubocop/cop/rubomatic-rails/generator/dept_readme_injector.rb +114 -0
- data/lib/rubocop/cop/rubomatic-rails/generator.rb +283 -0
- data/lib/rubocop/cop/rubomatic_rails_cops.rb +1 -0
- data/lib/rubocop/rubomatic-rails/inject.rb +21 -0
- data/lib/rubocop/rubomatic-rails/version.rb +7 -0
- data/lib/rubocop/rubomatic-rails.rb +17 -0
- data/lib/rubocop-rubomatic-rails.rb +12 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0dffa07e43280ef8655da98959f7d13d95be48926aa2c8f70cec3f62d1d572b6
|
4
|
+
data.tar.gz: 6d65bddd422e3118a4b64a9a9da7dd26a630d6658649c919bff5fd8a49a19302
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5aba94522afa2fde59aee373762cf3d23a9c844b4a342b61704fe69aa06c5338051d2facdde35d0808fc33e3c929515e8d393bc5f7d9efaabfaba779bc9e7097
|
7
|
+
data.tar.gz: 3ce9c75b3e3cb9a3386262a2fe5975f2314a8f74b1018629021bc50e15057ef050cf1adab6974a9617cae944c8f1f00a7b255d1d537968a47eefae8ca5a06dc0
|
data/CHANGELOG.adoc
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2023 Brands Insurance Agency, Inc.
|
2
|
+
|
3
|
+
Copyright for portions of project Rubocop are held by Bozhidar Batsov and other contributors, as part of project Rubocop.
|
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.adoc
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
= Rubomatic
|
2
|
+
|
3
|
+
Gem for shared rails rubocop config and custom rails cops for BrandsInsurance
|
4
|
+
|
5
|
+
Put your Ruby code in the file ``lib/rubocop/rubomatic-rails``.
|
6
|
+
To experiment with that code, run
|
7
|
+
``bin/console`` for an interactive prompt.
|
8
|
+
|
9
|
+
== Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
[source,ruby]
|
14
|
+
----
|
15
|
+
gem 'rubocop-rubomatic-rails', require: false
|
16
|
+
----
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle install
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install rubocop-rubomatic-rails
|
25
|
+
|
26
|
+
== Usage
|
27
|
+
|
28
|
+
Add the following to your ``.rubocop.yml`` config file
|
29
|
+
|
30
|
+
[source,yaml]
|
31
|
+
----
|
32
|
+
inherit_gem:
|
33
|
+
rubocop-rubomatic-rails: config/rubocop.yml
|
34
|
+
----
|
35
|
+
|
36
|
+
If you need to override a setting:
|
37
|
+
|
38
|
+
[source,yaml]
|
39
|
+
----
|
40
|
+
# Add to Naming/VariableNumber.AllowedIdentifiers
|
41
|
+
inherit_gem:
|
42
|
+
rubocop-rubomatic-rails: config/rubocop.yml
|
43
|
+
|
44
|
+
Naming/VariableNumber:
|
45
|
+
inherit_mode:
|
46
|
+
merge:
|
47
|
+
- AllowedIdentifiers
|
48
|
+
AllowedIdentifiers:
|
49
|
+
- street_2
|
50
|
+
----
|
51
|
+
|
52
|
+
[source,yaml]
|
53
|
+
----
|
54
|
+
# Completely override Naming/VariableNumber.AllowedIdentifiers
|
55
|
+
inherit_gem:
|
56
|
+
rubocop-rubomatic-rails: config/rubocop.yml
|
57
|
+
|
58
|
+
Naming/VariableNumber:
|
59
|
+
inherit_mode:
|
60
|
+
override:
|
61
|
+
- AllowedIdentifiers
|
62
|
+
AllowedIdentifiers:
|
63
|
+
- street_2
|
64
|
+
----
|
65
|
+
|
66
|
+
== Custom Cops
|
67
|
+
|
68
|
+
Add ``RubomaticRails/*`` cops to your ``.rubocop.yml`` config file
|
69
|
+
|
70
|
+
[source,yaml]
|
71
|
+
----
|
72
|
+
RubomaticRails/Style/DisallowedMethods:
|
73
|
+
Enabled: true
|
74
|
+
----
|
75
|
+
|
76
|
+
== Departments
|
77
|
+
|
78
|
+
None yet
|
79
|
+
|
80
|
+
== Contributing
|
81
|
+
|
82
|
+
See xref:./CONTRIBUTING.adoc[CONTRIBUTING] for how to add your own rule
|
83
|
+
|
84
|
+
== Changelog
|
85
|
+
|
86
|
+
See xref:./CHANGELOG.adoc[CHANGELOG] see see changes
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RubomaticRails
|
6
|
+
class Generator
|
7
|
+
class CopReadmeInjector < DeptReadmeInjector
|
8
|
+
TEMPLATE =
|
9
|
+
'* xref:./%{cop_folder}/README.adoc[``%{department}/%{cop}``]'
|
10
|
+
|
11
|
+
# :nodoc:
|
12
|
+
def initialize(badge:, **kwargs)
|
13
|
+
super(badge: badge, **kwargs)
|
14
|
+
|
15
|
+
@cop = badge.cop_name
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# @return [String]
|
21
|
+
attr_reader :cop
|
22
|
+
|
23
|
+
# @see super
|
24
|
+
def new_readme_entry
|
25
|
+
format(TEMPLATE, {
|
26
|
+
department_folder: snake_case(department),
|
27
|
+
cop_folder: snake_case(cop),
|
28
|
+
department: department,
|
29
|
+
cop: cop
|
30
|
+
})
|
31
|
+
end
|
32
|
+
|
33
|
+
# @see super
|
34
|
+
def line_is_good?(line)
|
35
|
+
return true if super
|
36
|
+
|
37
|
+
matches = line.match(target_regex)
|
38
|
+
return false if matches.nil?
|
39
|
+
|
40
|
+
department == matches[:department] && cop < matches[:cop]
|
41
|
+
end
|
42
|
+
|
43
|
+
# @see super
|
44
|
+
def target_regex
|
45
|
+
%r{\* xref:\./docs/cops/[a-z_]+/[a-z_]+/README\.adoc\[``(?<department>[a-zA-Z_]+)/(?<cop>[a-zA-Z_]+)``\]}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RubomaticRails
|
6
|
+
class Generator
|
7
|
+
class DeptReadmeInjector
|
8
|
+
TEMPLATE = '* xref:./docs/cops/%{department_folder}/README.adoc[``%{department}``]'
|
9
|
+
|
10
|
+
# :nodoc:
|
11
|
+
def initialize(readme_file_path:, badge:, department:)
|
12
|
+
@readme_file_path = readme_file_path
|
13
|
+
@badge = badge
|
14
|
+
@department = department
|
15
|
+
@output = output
|
16
|
+
end
|
17
|
+
|
18
|
+
# Performs the actual string injection into the file
|
19
|
+
# modified version of `inject` from RuboCop::Cop::Generator::ConfigurationInjector
|
20
|
+
# Named `inject_string` becuase rubocop thought when called it was `Array#inject`
|
21
|
+
#
|
22
|
+
# @return [void]
|
23
|
+
#
|
24
|
+
def inject_string
|
25
|
+
target_line = find_target_line
|
26
|
+
|
27
|
+
if target_line
|
28
|
+
readme_entries.insert(target_line, "#{new_readme_entry}\n")
|
29
|
+
else
|
30
|
+
readme_entries.push(new_readme_entry)
|
31
|
+
end
|
32
|
+
|
33
|
+
File.write(readme_file_path, readme_entries.join(''))
|
34
|
+
|
35
|
+
yield if block_given?
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
attr_reader :readme_file_path
|
42
|
+
# @return [RuboCop::Cop::Badge]
|
43
|
+
attr_reader :badge
|
44
|
+
# @return [String]
|
45
|
+
attr_reader :department
|
46
|
+
# @return [*] Default $stdout
|
47
|
+
attr_reader :output
|
48
|
+
|
49
|
+
# Lines in <department>/README.adoc
|
50
|
+
#
|
51
|
+
# @return [Array<String>]
|
52
|
+
#
|
53
|
+
def readme_entries
|
54
|
+
@readme_entries ||= File.readlines(readme_file_path)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Modified version from Rubocop::Cop::Generator::ConfigurationInjector
|
58
|
+
#
|
59
|
+
# @return [String]
|
60
|
+
#
|
61
|
+
def new_readme_entry
|
62
|
+
format(TEMPLATE, {
|
63
|
+
department_folder: snake_case(department),
|
64
|
+
department: department
|
65
|
+
})
|
66
|
+
end
|
67
|
+
|
68
|
+
# Modified version from Rubocop::Cop::Generator::ConfigurationInjector
|
69
|
+
#
|
70
|
+
# @return [Integer, Nil]
|
71
|
+
#
|
72
|
+
def find_target_line
|
73
|
+
readme_entries.find.with_index do |line, index|
|
74
|
+
return index if line_is_good?(line)
|
75
|
+
end
|
76
|
+
|
77
|
+
return nil
|
78
|
+
end
|
79
|
+
|
80
|
+
# Determines if the given line is the same type we're trying to add and if it's alphabetically before
|
81
|
+
#
|
82
|
+
# @return [Boolean]
|
83
|
+
#
|
84
|
+
def line_is_good?(line)
|
85
|
+
matches = line.match(target_regex)
|
86
|
+
return false if matches.nil?
|
87
|
+
|
88
|
+
department < line.match(target_regex)[:department]
|
89
|
+
end
|
90
|
+
|
91
|
+
# Regex to look for in the readme
|
92
|
+
#
|
93
|
+
# @return [Regexp]
|
94
|
+
#
|
95
|
+
def target_regex
|
96
|
+
%r{\* xref:\./docs/cops/[a-z_]+/README\.adoc\[``(?<department>[a-zA-Z_]+)``\]}
|
97
|
+
end
|
98
|
+
|
99
|
+
# Copied from Rubocop::Cop::Generator
|
100
|
+
#
|
101
|
+
# @return [String]
|
102
|
+
#
|
103
|
+
def snake_case(camel_case_string)
|
104
|
+
camel_case_string
|
105
|
+
.gsub('RSpec', 'Rspec')
|
106
|
+
.gsub(%r{([^A-Z/])([A-Z]+)}, '\1_\2')
|
107
|
+
.gsub(%r{([A-Z])([A-Z][^A-Z\d/]+)}, '\1_\2')
|
108
|
+
.downcase
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,283 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './generator/dept_readme_injector'
|
4
|
+
|
5
|
+
require_relative './generator/cop_readme_injector'
|
6
|
+
|
7
|
+
module RuboCop
|
8
|
+
module Cop
|
9
|
+
module RubomaticRails
|
10
|
+
class Generator
|
11
|
+
COP_DOC = <<~RUBY
|
12
|
+
# TODO: Write cop description and example of bad / good code. For every
|
13
|
+
# `SupportedStyle` and unique configuration, there needs to be examples.
|
14
|
+
# Examples must have valid Ruby syntax. Do not use upticks.
|
15
|
+
#
|
16
|
+
# @safety
|
17
|
+
# Delete this section if the cop is not unsafe (`Safe: false` or
|
18
|
+
# `SafeAutoCorrect: false`), or use it to explain how the cop is
|
19
|
+
# unsafe.
|
20
|
+
#
|
21
|
+
# @example EnforcedStyle: bar (default)
|
22
|
+
# # Description of the `bar` style.
|
23
|
+
#
|
24
|
+
# # bad
|
25
|
+
# bad_bar_method
|
26
|
+
#
|
27
|
+
# # bad
|
28
|
+
# bad_bar_method(args)
|
29
|
+
#
|
30
|
+
# # good
|
31
|
+
# good_bar_method
|
32
|
+
#
|
33
|
+
# # good
|
34
|
+
# good_bar_method(args)
|
35
|
+
#
|
36
|
+
# @example EnforcedStyle: foo
|
37
|
+
# # Description of the `foo` style.
|
38
|
+
#
|
39
|
+
# # bad
|
40
|
+
# bad_foo_method
|
41
|
+
#
|
42
|
+
# # bad
|
43
|
+
# bad_foo_method(args)
|
44
|
+
#
|
45
|
+
# # good
|
46
|
+
# good_foo_method
|
47
|
+
#
|
48
|
+
# # good
|
49
|
+
# good_foo_method(args)
|
50
|
+
#
|
51
|
+
RUBY
|
52
|
+
SOURCE_TEMPLATE = <<~RUBY
|
53
|
+
# frozen_string_literal: true
|
54
|
+
|
55
|
+
module RuboCop
|
56
|
+
module Cop
|
57
|
+
module %{department}
|
58
|
+
class %{cop_name} < Base
|
59
|
+
# TODO: Implement the cop in here.
|
60
|
+
#
|
61
|
+
# In many cases, you can use a node matcher for matching node pattern.
|
62
|
+
# See https://github.com/rubocop/rubocop-ast/blob/master/lib/rubocop/ast/node_pattern.rb
|
63
|
+
#
|
64
|
+
# For example
|
65
|
+
MSG = 'Use `#good_method` instead of `#bad_method`.'
|
66
|
+
|
67
|
+
# TODO: Don't call `on_send` unless the method name is in this list
|
68
|
+
# If you don't need `on_send` in the cop you created, remove it.
|
69
|
+
RESTRICT_ON_SEND = %%i[bad_method].freeze
|
70
|
+
|
71
|
+
# @!method bad_method?(node)
|
72
|
+
def_node_matcher :bad_method?, <<~PATTERN
|
73
|
+
(send nil? :bad_method ...)
|
74
|
+
PATTERN
|
75
|
+
|
76
|
+
def on_send(node)
|
77
|
+
return unless bad_method?(node)
|
78
|
+
|
79
|
+
add_offense(node)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
RUBY
|
86
|
+
README_ADDED_MESSAGE = '[modify] A link for the %{dept_vs_cop} has been added into %{readme_file_path}.'
|
87
|
+
|
88
|
+
DEPT_README_TEMPLATE = <<~ADOC
|
89
|
+
= %{department}
|
90
|
+
|
91
|
+
Describe the department here
|
92
|
+
|
93
|
+
== Cops
|
94
|
+
|
95
|
+
ADOC
|
96
|
+
COP_README_TEMPLATE = <<~ADOC
|
97
|
+
= ``%{department}/%{cop_name}``
|
98
|
+
|
99
|
+
== Description
|
100
|
+
|
101
|
+
Add a description here
|
102
|
+
|
103
|
+
== Examples
|
104
|
+
|
105
|
+
[source,ruby]
|
106
|
+
----
|
107
|
+
# Bad
|
108
|
+
# Add a bad example here
|
109
|
+
|
110
|
+
# Good
|
111
|
+
# Add a good example here
|
112
|
+
----
|
113
|
+
|
114
|
+
== Configurable Attributes
|
115
|
+
|
116
|
+
|===
|
117
|
+
|Name |Default value |Configurable values
|
118
|
+
|
119
|
+
|Max
|
120
|
+
|120
|
121
|
+
|Integer
|
122
|
+
|
123
|
+
|===
|
124
|
+
|
125
|
+
== References
|
126
|
+
|
127
|
+
https://github.com/BrandsInsurance/expert-chainsaw/issues
|
128
|
+
ADOC
|
129
|
+
|
130
|
+
# :nodoc:
|
131
|
+
def initialize(name, output: $stdout)
|
132
|
+
name = ['RubomaticRails', name].join('/') unless name.start_with?('RubomaticRails/')
|
133
|
+
|
134
|
+
unless name.count('/') == 2
|
135
|
+
raise(
|
136
|
+
[
|
137
|
+
'You must provide a single department under RubomaticRails i.e. RubomaticRails/Department/CopName',
|
138
|
+
'or Department/CopName'
|
139
|
+
].join(' ')
|
140
|
+
)
|
141
|
+
end
|
142
|
+
|
143
|
+
@base_gen = RuboCop::Cop::Generator.new(name, output: output)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Calls methods in the base class
|
147
|
+
#
|
148
|
+
# @return [*]
|
149
|
+
#
|
150
|
+
def method_missing(...)
|
151
|
+
@base_gen.__send__(...)
|
152
|
+
end
|
153
|
+
|
154
|
+
# `self` responds to `method_name` if `@base_gen` does
|
155
|
+
#
|
156
|
+
def respond_to_missing?(method_name, include_private = false)
|
157
|
+
@base_gen.respond_to?(method_name, include_private)
|
158
|
+
end
|
159
|
+
|
160
|
+
# Creates the department readme if it doesn't exist
|
161
|
+
# Modified version of `wirte_source` from RuboCop::Cop::Generator
|
162
|
+
#
|
163
|
+
# @return [void]
|
164
|
+
#
|
165
|
+
def write_dept_readme
|
166
|
+
return if File.exist?(dept_docs_path)
|
167
|
+
|
168
|
+
write_unless_file_exists(dept_docs_path, generated_dept_docs)
|
169
|
+
end
|
170
|
+
|
171
|
+
# Creates the cop readme if it doesn't exist
|
172
|
+
# Modified version of `wirte_source` from RuboCop::Cop::Generator
|
173
|
+
#
|
174
|
+
# @return [void]
|
175
|
+
#
|
176
|
+
def write_cop_readme
|
177
|
+
write_unless_file_exists(docs_path, generated_cop_docs)
|
178
|
+
end
|
179
|
+
|
180
|
+
# Injects the, possibly new, department readme link into the base readme
|
181
|
+
# Modified version of `inject_config` from RuboCop::Cop::Generator
|
182
|
+
#
|
183
|
+
# @return [void]
|
184
|
+
#
|
185
|
+
def inject_dept_readme(readme_file_path: 'README.adoc')
|
186
|
+
# Add this dept to base readme if not already there
|
187
|
+
injector = DeptReadmeInjector.new(
|
188
|
+
readme_file_path: readme_file_path,
|
189
|
+
badge: badge,
|
190
|
+
department: department
|
191
|
+
)
|
192
|
+
|
193
|
+
injector.inject_string do
|
194
|
+
output.puts(format(README_ADDED_MESSAGE, readme_file_path: readme_file_path, dept_vs_cop: 'department'))
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
# Injects the new cop readme link into the department readme
|
199
|
+
# Modified version of `inject_config` from RuboCop::Cop::Generator
|
200
|
+
#
|
201
|
+
# @return [void]
|
202
|
+
#
|
203
|
+
def inject_cop_readme(readme_file_path: dept_docs_path)
|
204
|
+
# Add this cop to the dept readme
|
205
|
+
injector = CopReadmeInjector.new(
|
206
|
+
readme_file_path: readme_file_path,
|
207
|
+
badge: badge,
|
208
|
+
department: department
|
209
|
+
)
|
210
|
+
|
211
|
+
injector.inject_string do
|
212
|
+
output.puts(format(README_ADDED_MESSAGE, readme_file_path: readme_file_path, dept_vs_cop: 'cop'))
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
private
|
217
|
+
|
218
|
+
# The rubocop department without the RubomaticRails prefix
|
219
|
+
#
|
220
|
+
# @return [String]
|
221
|
+
#
|
222
|
+
def department
|
223
|
+
badge.department_name.gsub('RubomaticRails/', '')
|
224
|
+
end
|
225
|
+
|
226
|
+
# Modified version of `generated_source` from Rubocop::Cop::Generator
|
227
|
+
#
|
228
|
+
# @return [String]
|
229
|
+
#
|
230
|
+
def generated_dept_docs
|
231
|
+
generate_readme(DEPT_README_TEMPLATE)
|
232
|
+
end
|
233
|
+
|
234
|
+
# Modified version of `generated_source` from Rubocop::Cop::Generator
|
235
|
+
#
|
236
|
+
# @return [String]
|
237
|
+
#
|
238
|
+
def generated_cop_docs
|
239
|
+
generate_readme(COP_README_TEMPLATE)
|
240
|
+
end
|
241
|
+
|
242
|
+
# Modified version from Rubocop::Cop::Generator
|
243
|
+
#
|
244
|
+
# @return [String]
|
245
|
+
#
|
246
|
+
def generate_readme(template)
|
247
|
+
format(template, {
|
248
|
+
department: department,
|
249
|
+
cop_name: badge.cop_name,
|
250
|
+
cop_folder: snake_case(badge.cop_name.to_s)
|
251
|
+
})
|
252
|
+
end
|
253
|
+
|
254
|
+
# Path to <department>/README.adoc
|
255
|
+
#
|
256
|
+
# @return [String]
|
257
|
+
#
|
258
|
+
def dept_docs_path
|
259
|
+
File.join(
|
260
|
+
'docs',
|
261
|
+
'cops',
|
262
|
+
snake_case(department),
|
263
|
+
'README.adoc'
|
264
|
+
)
|
265
|
+
end
|
266
|
+
|
267
|
+
# Path to <department>/<cop>/README.adoc
|
268
|
+
#
|
269
|
+
# @return [String]
|
270
|
+
#
|
271
|
+
def docs_path
|
272
|
+
File.join(
|
273
|
+
'docs',
|
274
|
+
'cops',
|
275
|
+
snake_case(department),
|
276
|
+
snake_case(badge.cop_name.to_s),
|
277
|
+
'README.adoc'
|
278
|
+
)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# frozen_string_literal: true
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module RubomaticRails
|
5
|
+
module Inject
|
6
|
+
# This was a generated method from https://github.com/rubocop/rubocop-extension-generator
|
7
|
+
#
|
8
|
+
def self.defaults!
|
9
|
+
path = CONFIG_DEFAULT.to_s
|
10
|
+
hash = ConfigLoader.__send__(:load_yaml_configuration, path)
|
11
|
+
config = Config.new(hash, path).tap(&:make_excludes_absolute)
|
12
|
+
|
13
|
+
puts("configuration from #{path}") if ConfigLoader.debug?
|
14
|
+
|
15
|
+
config = ConfigLoader.merge_with_default(config, path)
|
16
|
+
|
17
|
+
ConfigLoader.instance_variable_set(:@default_configuration, config)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'rubomatic-rails/version'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module RuboCop
|
7
|
+
module RubomaticRails
|
8
|
+
class Error < StandardError
|
9
|
+
end
|
10
|
+
|
11
|
+
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
|
12
|
+
CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
|
13
|
+
CONFIG = ::YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
14
|
+
|
15
|
+
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubocop'
|
4
|
+
|
5
|
+
require_relative 'rubocop/cop/rubomatic-rails/generator'
|
6
|
+
require_relative 'rubocop/rubomatic-rails'
|
7
|
+
require_relative 'rubocop/rubomatic-rails/inject'
|
8
|
+
require_relative 'rubocop/rubomatic-rails/version'
|
9
|
+
|
10
|
+
RuboCop::RubomaticRails::Inject.defaults!
|
11
|
+
|
12
|
+
require_relative 'rubocop/cop/rubomatic_rails_cops'
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rucop-rubomatic-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.pre.rc.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brands Insurance
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-05-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop-rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.18.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.18.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubomatic
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.3.0
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- documents@brandsinsurance.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- CHANGELOG.adoc
|
49
|
+
- LICENSE
|
50
|
+
- README.adoc
|
51
|
+
- lib/rubocop-rubomatic-rails.rb
|
52
|
+
- lib/rubocop/cop/rubomatic-rails/generator.rb
|
53
|
+
- lib/rubocop/cop/rubomatic-rails/generator/cop_readme_injector.rb
|
54
|
+
- lib/rubocop/cop/rubomatic-rails/generator/dept_readme_injector.rb
|
55
|
+
- lib/rubocop/cop/rubomatic_rails_cops.rb
|
56
|
+
- lib/rubocop/rubomatic-rails.rb
|
57
|
+
- lib/rubocop/rubomatic-rails/inject.rb
|
58
|
+
- lib/rubocop/rubomatic-rails/version.rb
|
59
|
+
homepage: https://github.com/BrandsInsurance/rubomatic-rails/
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata:
|
63
|
+
rubygems_mfa_required: 'true'
|
64
|
+
homepage_uri: https://github.com/BrandsInsurance/rubomatic-rails/
|
65
|
+
source_code_uri: https://github.com/BrandsInsurance/rubomatic-rails
|
66
|
+
changelog_uri: https://github.com/BrandsInsurance/rubomatic-rails/blob/main/CHANGELOG.adoc
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.0.1
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.3.1
|
81
|
+
requirements: []
|
82
|
+
rubygems_version: 3.2.15
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Shared rails rubocop config for BrandsInsurance
|
86
|
+
test_files: []
|