rubocop-petal 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +5 -3
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +27 -0
- data/Gemfile.lock +5 -5
- data/README.md +9 -2
- data/config/default.yml +44 -0
- data/lib/rubocop/cop/grape/helpers_include_module.rb +61 -0
- data/lib/rubocop/cop/grape/prefer_namespace.rb +47 -0
- data/lib/rubocop/cop/grape/unnecessary_namespace.rb +64 -0
- data/lib/rubocop/cop/migration/foreign_key_option.rb +46 -0
- data/lib/rubocop/cop/migration/schema_statements_methods.rb +46 -0
- data/lib/rubocop/cop/rspec/authenticated_as.rb +32 -0
- data/lib/rubocop/cop/rspec/create_list_max.rb +42 -0
- data/lib/rubocop/petal/version.rb +1 -1
- data/rubocop-petal.gemspec +2 -2
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9c488168be9965605cec779d3496901a44c339bfab481d46b6bfd5a766584aa
|
4
|
+
data.tar.gz: 4aa0a079fc001b2f42f8b7920a43353ae217dbc5c0dc6154c020604c3e9928ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcbdc1f68ee6438939a848094d048e44da32aec786622dfcee20579e961c85eaf0aea1d88782eee2d85f8c1cc2304977e497e7be0a67e59e5e62d9d12ad0707b
|
7
|
+
data.tar.gz: c512bcd9560851dfaa04dab391b6fb2e760247af631ab6cc73d5cb411c166c4cfb2bda90f83bb93c32c485357ba3f132ffbaba76806621accea024ae8b845cbb
|
data/.github/workflows/build.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
# main
|
4
|
+
|
5
|
+
# v0.3.0
|
6
|
+
|
7
|
+
* Added cop `Added Migration/ForeignKeyOption` ([#11](https://github.com/petalmd/rubocop-petal/pull/11))
|
8
|
+
* Added cop `Added Grape/PreferNamespace` ([#6](https://github.com/petalmd/rubocop-petal/pull/6))
|
9
|
+
* Added cop `Added Migration/SchemaStatementsMethods` ([#14](https://github.com/petalmd/rubocop-petal/pull/14))
|
10
|
+
* Remove cop `Added Migration/UseChangeTableBulk` ([#15](https://github.com/petalmd/rubocop-petal/pull/15))
|
11
|
+
* Update cop `Grape/PreferNamespace` ([#16](https://github.com/petalmd/rubocop-petal/pull/16))
|
12
|
+
|
13
|
+
# v0.2.1
|
14
|
+
|
15
|
+
* Update lock dependencies `rubocop-rails` ([#9](https://github.com/petalmd/rubocop-petal/pull/9))
|
16
|
+
|
17
|
+
# v0.2.0
|
18
|
+
|
19
|
+
* Added cop `RSpec/AuthenticatedAs` ([#3](https://github.com/petalmd/rubocop-petal/pull/3))
|
20
|
+
* Added cop `Grape/UnnecessaryNamespace` ([#2](https://github.com/petalmd/rubocop-petal/pull/2))
|
21
|
+
* Added cop `RSpec/CreateListMax` ([#4](https://github.com/petalmd/rubocop-petal/pull/4))
|
22
|
+
* Added Cop `Migration/UseChangeTableBulk` ([#7](https://github.com/petalmd/rubocop-petal/pull/7))
|
23
|
+
* Added cop `Grape/HelpersIncludeModule` ([#1](https://github.com/petalmd/rubocop-petal/pull/1))
|
24
|
+
|
25
|
+
# v0.1.0
|
26
|
+
|
27
|
+
* First version
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubocop-petal (0.
|
5
|
-
rubocop
|
6
|
-
rubocop-rails
|
4
|
+
rubocop-petal (0.3.0)
|
5
|
+
rubocop (>= 1.7.0, < 2.0)
|
6
|
+
rubocop-rails (~> 2.10)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
@@ -51,10 +51,10 @@ GEM
|
|
51
51
|
unicode-display_width (>= 1.4.0, < 3.0)
|
52
52
|
rubocop-ast (1.15.0)
|
53
53
|
parser (>= 3.0.1.1)
|
54
|
-
rubocop-rails (2.
|
54
|
+
rubocop-rails (2.13.2)
|
55
55
|
activesupport (>= 4.2.0)
|
56
56
|
rack (>= 1.1)
|
57
|
-
rubocop (>=
|
57
|
+
rubocop (>= 1.7.0, < 2.0)
|
58
58
|
rubocop-rspec (2.6.0)
|
59
59
|
rubocop (~> 1.19)
|
60
60
|
ruby-progressbar (1.11.0)
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# RuboCop::Petal
|
2
2
|
|
3
3
|
[![Build](https://github.com/petalmd/rubocop-petal/actions/workflows/build.yml/badge.svg)](https://github.com/petalmd/rubocop-petal/actions/workflows/build.yml)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/rubocop-petal.svg)](https://badge.fury.io/rb/rubocop-petal)
|
4
5
|
|
5
6
|
Petal custom cops. List of cops can be find [here](https://github.com/petalmd/rubocop-petal/tree/main/lib/rubocop/cop).
|
6
7
|
|
@@ -26,21 +27,27 @@ In your `.rubocop.yml` file, add `rubocop-petal`
|
|
26
27
|
|
27
28
|
```yaml
|
28
29
|
require:
|
29
|
-
- rubocop-
|
30
|
+
- rubocop-petal
|
30
31
|
```
|
31
32
|
|
32
33
|
## Development
|
33
34
|
|
34
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
|
35
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
|
36
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
35
37
|
|
36
38
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
37
39
|
|
40
|
+
To run all checks like the CI simply run `bundle exec rake`.
|
41
|
+
|
38
42
|
## Create new cop
|
39
43
|
|
40
44
|
```shell
|
41
45
|
bundle exec rake 'new_cop[Rails/MyNewCop]'
|
42
46
|
```
|
43
47
|
|
48
|
+
Have a look to [RuboCop documentation](https://docs.rubocop.org/rubocop/1.23/development.html) to get started with
|
49
|
+
_node pattern_.
|
50
|
+
|
44
51
|
## Release
|
45
52
|
|
46
53
|
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
data/config/default.yml
CHANGED
@@ -1,3 +1,47 @@
|
|
1
|
+
Grape/PreferNamespace:
|
2
|
+
Description: 'Prevent usage of namespace aliases.'
|
3
|
+
Enabled: true
|
4
|
+
StyleGuide: https://github.com/ruby-grape/grape#namespace-validation-and-coercion
|
5
|
+
Include:
|
6
|
+
- app/api/**/*
|
7
|
+
|
8
|
+
Migration/ForeignKeyOption:
|
9
|
+
Description: 'Specify the foreign key option to create the constraint.'
|
10
|
+
Enabled: true
|
11
|
+
Include:
|
12
|
+
- db/migrate/**
|
13
|
+
|
14
|
+
Migration/SchemaStatementsConnection:
|
15
|
+
Description: 'Suggest to use SchemaStatements methods already defined in a migration class.'
|
16
|
+
Enabled: true
|
17
|
+
Include:
|
18
|
+
- db/migrate/**
|
19
|
+
|
20
|
+
RSpec/AuthenticatedAs:
|
21
|
+
Description: 'Suggest to use authenticated_as instead of legacy api_key.'
|
22
|
+
Enabled: true
|
23
|
+
Include:
|
24
|
+
- spec/api/**/*_spec.rb
|
25
|
+
|
26
|
+
RSpec/CreateListMax:
|
27
|
+
Description: 'Prevent creating to most records with `FactoryBot.create_list`.'
|
28
|
+
Enabled: true
|
29
|
+
Max: 5
|
30
|
+
Include:
|
31
|
+
- spec/**/*
|
32
|
+
|
33
|
+
Grape/HelpersIncludeModule:
|
34
|
+
Description: 'Prevent using helpers with block to include module'
|
35
|
+
Enabled: true
|
36
|
+
Include:
|
37
|
+
- app/api/**/*
|
38
|
+
|
39
|
+
Grape/UnnecessaryNamespace:
|
40
|
+
Description: 'Detect unnecessary usage of Grape namespace.'
|
41
|
+
Enabled: true
|
42
|
+
Include:
|
43
|
+
- app/api/**/*
|
44
|
+
|
1
45
|
Rails/EnumPrefix:
|
2
46
|
Description: 'Set prefix options when using enums.'
|
3
47
|
Enabled: true
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Grape
|
6
|
+
# Prevent usage of Grape `helpers` with a block to include module.
|
7
|
+
# Using a bloc will create a new unnecessary module.
|
8
|
+
#
|
9
|
+
# # bad
|
10
|
+
# helpers do
|
11
|
+
# include MyModule
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# # bad
|
15
|
+
# helpers do
|
16
|
+
# include MyModule
|
17
|
+
# include MyOtherModule
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# # good
|
21
|
+
# helpers MyModule
|
22
|
+
#
|
23
|
+
# # good
|
24
|
+
# helpers MyModule, MyOtherModule
|
25
|
+
class HelpersIncludeModule < Base
|
26
|
+
MSG = 'Use `helpers %<module_name>s` instead of `helpers` with a block.'
|
27
|
+
|
28
|
+
def_node_matcher :helpers?, <<~PATTERN
|
29
|
+
(send nil? :helpers)
|
30
|
+
PATTERN
|
31
|
+
|
32
|
+
def_node_matcher :called_include?, <<~PATTERN
|
33
|
+
(send nil? :include (const _ $_))
|
34
|
+
PATTERN
|
35
|
+
|
36
|
+
def on_send(node)
|
37
|
+
return unless helpers?(node)
|
38
|
+
|
39
|
+
helpers_block_node = node.block_node.children.last
|
40
|
+
block_nodes = block_nodes_in_helpers(helpers_block_node)
|
41
|
+
|
42
|
+
block_nodes.each do |block_node|
|
43
|
+
if (module_name = called_include?(block_node))
|
44
|
+
add_offense(block_node, message: format(MSG, module_name: module_name))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def block_nodes_in_helpers(node)
|
52
|
+
if node.begin_type?
|
53
|
+
node.children
|
54
|
+
else
|
55
|
+
[node]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Grape
|
6
|
+
# Prevent usage of `namespace` aliases
|
7
|
+
#
|
8
|
+
# # bad:
|
9
|
+
#
|
10
|
+
# group :my_group do ... end
|
11
|
+
# resource :my_resource do ... end
|
12
|
+
# resources :my_resources do ... end
|
13
|
+
# segment :my_segment do ... end
|
14
|
+
#
|
15
|
+
# # good:
|
16
|
+
#
|
17
|
+
# namespace :my_namespace do ... end
|
18
|
+
#
|
19
|
+
class PreferNamespace < Base
|
20
|
+
extend AutoCorrector
|
21
|
+
|
22
|
+
MSG = 'Prefer using `namespace` over its aliases.'
|
23
|
+
|
24
|
+
NAMESPACE_ALIASES = %i[resource resources group segment].freeze
|
25
|
+
RESTRICT_ON_SEND = NAMESPACE_ALIASES
|
26
|
+
|
27
|
+
def_node_matcher :using_alias_on_api?, <<~PATTERN
|
28
|
+
(send nil? ...)
|
29
|
+
PATTERN
|
30
|
+
|
31
|
+
def_node_matcher :namespace_alias, <<~PATTERN
|
32
|
+
(send nil? $_ ...)
|
33
|
+
PATTERN
|
34
|
+
|
35
|
+
def on_send(node)
|
36
|
+
return unless using_alias_on_api? node
|
37
|
+
# Check if use block
|
38
|
+
return unless node.block_node&.children&.last
|
39
|
+
|
40
|
+
add_offense(node) do |corrector|
|
41
|
+
corrector.replace(node, node.source.gsub(/^#{namespace_alias(node)}/, 'namespace'))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Grape
|
6
|
+
# Detect unnecessary usage of Grape namespace.
|
7
|
+
#
|
8
|
+
# # bad
|
9
|
+
# namespace :my_namespace
|
10
|
+
# get {}
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# # good
|
14
|
+
# get :my_namespace {}
|
15
|
+
#
|
16
|
+
class UnnecessaryNamespace < Base
|
17
|
+
MSG = 'Unnecessary usage of Grape namespace. '\
|
18
|
+
'Specify endpoint name with a argument: `get :my_namespace`.'
|
19
|
+
HTTP_ACTIONS = Set.new(%i[get put post patch delete])
|
20
|
+
GRAPE_NAMESPACE_ALIAS = Set.new(%i[namespace resource resources])
|
21
|
+
METHOD_JUSTIFY_NAMESPACE = Set.new(%i[route_param namespaces resource resources version])
|
22
|
+
|
23
|
+
def_node_matcher :namespace?, <<~PATTERN
|
24
|
+
(send nil? GRAPE_NAMESPACE_ALIAS ({sym | str} _))
|
25
|
+
PATTERN
|
26
|
+
|
27
|
+
def_node_matcher :justify_namespace?, <<~PATTERN
|
28
|
+
(block (send nil? METHOD_JUSTIFY_NAMESPACE ...) ...)
|
29
|
+
PATTERN
|
30
|
+
|
31
|
+
def_node_matcher :http_action?, <<~PATTERN
|
32
|
+
(block (send nil? HTTP_ACTIONS) ...)
|
33
|
+
PATTERN
|
34
|
+
|
35
|
+
def on_send(node)
|
36
|
+
return unless namespace?(node)
|
37
|
+
|
38
|
+
node_to_select_http_action = namespace_node(node)
|
39
|
+
|
40
|
+
return if node_to_select_http_action.any? do |namespace_node|
|
41
|
+
justify_namespace?(namespace_node)
|
42
|
+
end
|
43
|
+
|
44
|
+
http_action_node = select_http_action_block_node(node_to_select_http_action)
|
45
|
+
add_offense(node) if http_action_node.size == 1
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def select_http_action_block_node(nodes)
|
51
|
+
nodes.select { |node| http_action?(node) }
|
52
|
+
end
|
53
|
+
|
54
|
+
def namespace_node(node)
|
55
|
+
if node.block_node.children.last.block_type?
|
56
|
+
[node.block_node.children.last]
|
57
|
+
else
|
58
|
+
node.block_node.children.last.children
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Migration
|
6
|
+
# Specify the foreign key option to create the constraint.
|
7
|
+
#
|
8
|
+
# # bad
|
9
|
+
# add_reference(:products, :user)
|
10
|
+
# add_reference(:products, :user, foreign_key: false)
|
11
|
+
# add_belongs_to(:products, :user)
|
12
|
+
# t.references(:user)
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# add_reference(:products, :user, foreign_key: true)
|
16
|
+
# add_reference(:products, :user, foreign_key: { to_table: users })
|
17
|
+
# add_belongs_to(:products, :user, foreign_key: true)
|
18
|
+
# t.references(:user, foreign_key: true)
|
19
|
+
#
|
20
|
+
class ForeignKeyOption < Base
|
21
|
+
MSG = 'Add `foreign_key: true` or `foreign_key: { to_table: :some_table }`'
|
22
|
+
|
23
|
+
ADDING_REFERENCES_METHODS = Set.new(%i[add_reference add_belongs_to references belongs_to]).freeze
|
24
|
+
|
25
|
+
def_node_matcher :adding_reference?, <<~PATTERN
|
26
|
+
(send _ ADDING_REFERENCES_METHODS ...)
|
27
|
+
PATTERN
|
28
|
+
|
29
|
+
def_node_matcher :foreign_key_option?, <<~PATTERN
|
30
|
+
(send _ ADDING_REFERENCES_METHODS ... (hash <(pair (sym :foreign_key) {true hash}) ...>))
|
31
|
+
PATTERN
|
32
|
+
|
33
|
+
def_node_matcher :polymorphic_reference?, <<~PATTERN
|
34
|
+
(... (hash <(pair (sym :polymorphic) true) ... >))
|
35
|
+
PATTERN
|
36
|
+
|
37
|
+
def on_send(node)
|
38
|
+
return unless adding_reference?(node)
|
39
|
+
return if polymorphic_reference?(node)
|
40
|
+
|
41
|
+
add_offense(node) unless foreign_key_option?(node)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Migration
|
6
|
+
# Use SchemaStatements methods already defined in a migration class.
|
7
|
+
# Using already defined method is sorter and will be log during migration.
|
8
|
+
#
|
9
|
+
# # bad
|
10
|
+
# ActiveRecord::Base.connection.table_exists? 'users'
|
11
|
+
#
|
12
|
+
# # bad
|
13
|
+
# ActiveRecord::Base.connection.column_exists? 'users', 'first_name'
|
14
|
+
#
|
15
|
+
# # bad
|
16
|
+
# ApplicationRecord.connection.execute('SELECT COUNT(*) FROM `users`')
|
17
|
+
#
|
18
|
+
# # good
|
19
|
+
# table_exists? 'users'
|
20
|
+
#
|
21
|
+
# # good
|
22
|
+
# column_exists? 'users', 'first_name'
|
23
|
+
#
|
24
|
+
# # good
|
25
|
+
# execute('SELECT COUNT(*) FROM `users`')
|
26
|
+
#
|
27
|
+
class SchemaStatementsMethods < Base
|
28
|
+
extend AutoCorrector
|
29
|
+
|
30
|
+
MSG = 'Use already defined methods. Remove `ActiveRecord::Base.connection`.'
|
31
|
+
|
32
|
+
def_node_matcher :use_connection, <<~PATTERN
|
33
|
+
(:send (... (:const ...) :connection) ...)
|
34
|
+
PATTERN
|
35
|
+
|
36
|
+
def on_send(node)
|
37
|
+
return unless use_connection(node)
|
38
|
+
|
39
|
+
add_offense(node.children[0]) do |corrector|
|
40
|
+
corrector.replace(node, node.source.gsub("#{node.children[0].source}.", ''))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
# Suggest to use authenticated_as instead of legacy api_key.
|
7
|
+
# It is faster, can be setup for multiple test.
|
8
|
+
#
|
9
|
+
# # bad
|
10
|
+
# get 'api/my_endpoint', headers: { HTTP_API_KEY: user.api_key }
|
11
|
+
#
|
12
|
+
# # good
|
13
|
+
# authenticated_as user
|
14
|
+
# get 'api/my_endpoint'
|
15
|
+
#
|
16
|
+
class AuthenticatedAs < Base
|
17
|
+
MSG = 'Use `authenticated_as` instead of legacy api_key.'
|
18
|
+
|
19
|
+
def_node_search :use_header_api_key, <<~PATTERN
|
20
|
+
(sym :HTTP_API_KEY)
|
21
|
+
PATTERN
|
22
|
+
|
23
|
+
def on_send(node)
|
24
|
+
api_key_usage = use_header_api_key(node).to_a.first
|
25
|
+
return unless api_key_usage
|
26
|
+
|
27
|
+
add_offense(api_key_usage)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
# Prevent creating to most records with `FactoryBot.create_list`.
|
7
|
+
# Creating to much records can significantly increase spec time.
|
8
|
+
#
|
9
|
+
# @example Max: 5 (default)
|
10
|
+
# # Maximum amount params allowed for `create_list`.
|
11
|
+
#
|
12
|
+
# # bad
|
13
|
+
# create_list :my_model, 10
|
14
|
+
#
|
15
|
+
# # good
|
16
|
+
# create_list :my_model, 5
|
17
|
+
#
|
18
|
+
# # good
|
19
|
+
# build_stubbed_list :my_model, 10
|
20
|
+
#
|
21
|
+
class CreateListMax < Base
|
22
|
+
MSG = 'Creating more than `%<max_config>s` records is discouraged.'
|
23
|
+
DEFAULT_MAX = 5
|
24
|
+
RESTRICT_ON_SEND = [:create_list].freeze
|
25
|
+
|
26
|
+
def_node_search :create_list, <<~PATTERN
|
27
|
+
(send _ :create_list (sym _) (:int $_) ...)
|
28
|
+
PATTERN
|
29
|
+
|
30
|
+
def on_send(node)
|
31
|
+
amount = create_list(node).to_a.first
|
32
|
+
|
33
|
+
return unless amount
|
34
|
+
|
35
|
+
max_config = cop_config['Max'] || DEFAULT_MAX
|
36
|
+
|
37
|
+
add_offense(node, message: format(MSG, max_config: max_config)) if amount > max_config
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/rubocop-petal.gemspec
CHANGED
@@ -31,6 +31,6 @@ Gem::Specification.new do |spec|
|
|
31
31
|
# For more information and examples about making a new gem, checkout our
|
32
32
|
# guide at: https://bundler.io/guides/creating_gem.html
|
33
33
|
|
34
|
-
spec.add_runtime_dependency 'rubocop'
|
35
|
-
spec.add_dependency 'rubocop-rails'
|
34
|
+
spec.add_runtime_dependency 'rubocop', '>= 1.7.0', '< 2.0'
|
35
|
+
spec.add_dependency 'rubocop-rails', '~> 2.10'
|
36
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-petal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Francis Bastien
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,28 +16,34 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.7.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
29
|
+
version: 1.7.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rubocop-rails
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
39
|
+
version: '2.10'
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
44
|
+
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
46
|
+
version: '2.10'
|
41
47
|
description:
|
42
48
|
email:
|
43
49
|
- jfbastien@petalmd.com
|
@@ -49,6 +55,7 @@ files:
|
|
49
55
|
- ".gitignore"
|
50
56
|
- ".rspec"
|
51
57
|
- ".rubocop.yml"
|
58
|
+
- CHANGELOG.md
|
52
59
|
- Gemfile
|
53
60
|
- Gemfile.lock
|
54
61
|
- LICENSE.txt
|
@@ -59,10 +66,17 @@ files:
|
|
59
66
|
- config/default.yml
|
60
67
|
- lib/rubocop-petal.rb
|
61
68
|
- lib/rubocop/cop/chewy/reset_on_type.rb
|
69
|
+
- lib/rubocop/cop/grape/helpers_include_module.rb
|
70
|
+
- lib/rubocop/cop/grape/prefer_namespace.rb
|
71
|
+
- lib/rubocop/cop/grape/unnecessary_namespace.rb
|
72
|
+
- lib/rubocop/cop/migration/foreign_key_option.rb
|
73
|
+
- lib/rubocop/cop/migration/schema_statements_methods.rb
|
62
74
|
- lib/rubocop/cop/petal_cops.rb
|
63
75
|
- lib/rubocop/cop/rails/enum_prefix.rb
|
64
76
|
- lib/rubocop/cop/rails/risky_activerecord_invocation.rb
|
65
77
|
- lib/rubocop/cop/rails/table_name.rb
|
78
|
+
- lib/rubocop/cop/rspec/authenticated_as.rb
|
79
|
+
- lib/rubocop/cop/rspec/create_list_max.rb
|
66
80
|
- lib/rubocop/petal.rb
|
67
81
|
- lib/rubocop/petal/inject.rb
|
68
82
|
- lib/rubocop/petal/version.rb
|