ezcater_rubocop 7.1.2 → 8.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/Gemfile.lock +128 -0
- data/README.md +6 -1
- data/bin/check_configs.sh +23 -0
- data/config/default.yml +5 -0
- data/ezcater_rubocop.gemspec +2 -2
- data/lib/ezcater_rubocop/version.rb +1 -1
- data/lib/ezcater_rubocop.rb +17 -16
- data/lib/rubocop/cop/ezcater/migration/bigint_foreign_key.rb +264 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2a15bcc812b70fc80eeec6fc23e6e42f3ab5083292e558721b93096af34db61
|
4
|
+
data.tar.gz: c03044d686ebd1eb695988ab440eb80ca1efe929b91f96a87615a9683596883e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75618a8349b879090e8f7ef1a83c923fb15742db3f6975ade39bd4402ade7532724197d6dae3f6fe336348136ef5596e5bceb16f0dea41489a5fc923ba75563e
|
7
|
+
data.tar.gz: 119974969557ec72d6ad84f061b99714ea085a9f2547252813f572c5ce7573569ca2f45517b703945941320bf07029e2459939e9ffa877e80504693e8ba68b48
|
data/CHANGELOG.md
CHANGED
@@ -6,8 +6,20 @@ This gem is moving onto its own [Semantic Versioning](https://semver.org/) schem
|
|
6
6
|
|
7
7
|
Prior to v1.0.0 this gem was versioned based on the `MAJOR`.`MINOR` version of RuboCop. The first release of the ezcater_rubocop gem was `v0.49.0`.
|
8
8
|
|
9
|
+
## 8.0.1 (February 20, 2025)
|
10
|
+
|
11
|
+
- Pin maximum versions of `rubocop` and `rubocop-rails` to the versions before they moved to the `plugin` architecture in 1.72 and 2.28, respectively
|
12
|
+
|
13
|
+
## 8.0.0
|
14
|
+
|
15
|
+
- Add `Ezcater/Migration/BigintForeignKey` Cop, which enforces the use of `bigint` for foreign keys in migrations.
|
16
|
+
|
17
|
+
## 7.1.3
|
18
|
+
|
19
|
+
- Update internal CI processes to validate Rubocop config files
|
20
|
+
|
9
21
|
## 7.1.2
|
10
|
-
|
22
|
+
|
11
23
|
- Fix a stray space in `Rails/BulkChangeTable` definition
|
12
24
|
|
13
25
|
## 7.1.1
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ezcater_rubocop (8.1.0)
|
5
|
+
parser (>= 2.6)
|
6
|
+
rubocop (>= 1.16.0, < 1.72.0)
|
7
|
+
rubocop-graphql (>= 0.14.0, < 1.0)
|
8
|
+
rubocop-rails (>= 2.10.1, < 2.28.0)
|
9
|
+
rubocop-rspec (>= 2.22.0, < 2.28.0)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
activesupport (7.2.2.1)
|
15
|
+
base64
|
16
|
+
benchmark (>= 0.3)
|
17
|
+
bigdecimal
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
19
|
+
connection_pool (>= 2.2.5)
|
20
|
+
drb
|
21
|
+
i18n (>= 1.6, < 2)
|
22
|
+
logger (>= 1.4.2)
|
23
|
+
minitest (>= 5.1)
|
24
|
+
securerandom (>= 0.3)
|
25
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
26
|
+
ast (2.4.2)
|
27
|
+
base64 (0.2.0)
|
28
|
+
benchmark (0.4.0)
|
29
|
+
bigdecimal (3.1.9)
|
30
|
+
byebug (11.1.3)
|
31
|
+
coderay (1.1.3)
|
32
|
+
concurrent-ruby (1.3.5)
|
33
|
+
connection_pool (2.5.0)
|
34
|
+
diff-lcs (1.6.0)
|
35
|
+
docile (1.4.1)
|
36
|
+
drb (2.2.1)
|
37
|
+
i18n (1.14.7)
|
38
|
+
concurrent-ruby (~> 1.0)
|
39
|
+
json (2.10.1)
|
40
|
+
language_server-protocol (3.17.0.4)
|
41
|
+
logger (1.6.6)
|
42
|
+
method_source (1.1.0)
|
43
|
+
minitest (5.25.4)
|
44
|
+
parallel (1.26.3)
|
45
|
+
parser (3.3.7.1)
|
46
|
+
ast (~> 2.4.1)
|
47
|
+
racc
|
48
|
+
pry (0.14.2)
|
49
|
+
coderay (~> 1.1)
|
50
|
+
method_source (~> 1.0)
|
51
|
+
pry-byebug (3.10.1)
|
52
|
+
byebug (~> 11.0)
|
53
|
+
pry (>= 0.13, < 0.15)
|
54
|
+
racc (1.8.1)
|
55
|
+
rack (3.1.10)
|
56
|
+
rainbow (3.1.1)
|
57
|
+
rake (13.2.1)
|
58
|
+
regexp_parser (2.10.0)
|
59
|
+
rspec (3.13.0)
|
60
|
+
rspec-core (~> 3.13.0)
|
61
|
+
rspec-expectations (~> 3.13.0)
|
62
|
+
rspec-mocks (~> 3.13.0)
|
63
|
+
rspec-core (3.13.3)
|
64
|
+
rspec-support (~> 3.13.0)
|
65
|
+
rspec-expectations (3.13.3)
|
66
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
+
rspec-support (~> 3.13.0)
|
68
|
+
rspec-mocks (3.13.2)
|
69
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
+
rspec-support (~> 3.13.0)
|
71
|
+
rspec-support (3.13.2)
|
72
|
+
rspec_junit_formatter (0.6.0)
|
73
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
74
|
+
rubocop (1.71.2)
|
75
|
+
json (~> 2.3)
|
76
|
+
language_server-protocol (>= 3.17.0)
|
77
|
+
parallel (~> 1.10)
|
78
|
+
parser (>= 3.3.0.2)
|
79
|
+
rainbow (>= 2.2.2, < 4.0)
|
80
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
81
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
82
|
+
ruby-progressbar (~> 1.7)
|
83
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
84
|
+
rubocop-ast (1.38.0)
|
85
|
+
parser (>= 3.3.1.0)
|
86
|
+
rubocop-capybara (2.21.0)
|
87
|
+
rubocop (~> 1.41)
|
88
|
+
rubocop-factory_bot (2.26.1)
|
89
|
+
rubocop (~> 1.61)
|
90
|
+
rubocop-graphql (0.19.0)
|
91
|
+
rubocop (>= 0.87, < 2)
|
92
|
+
rubocop-rails (2.27.0)
|
93
|
+
activesupport (>= 4.2.0)
|
94
|
+
rack (>= 1.1)
|
95
|
+
rubocop (>= 1.52.0, < 2.0)
|
96
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
97
|
+
rubocop-rspec (2.27.1)
|
98
|
+
rubocop (~> 1.40)
|
99
|
+
rubocop-capybara (~> 2.17)
|
100
|
+
rubocop-factory_bot (~> 2.22)
|
101
|
+
ruby-progressbar (1.13.0)
|
102
|
+
securerandom (0.4.1)
|
103
|
+
simplecov (0.22.0)
|
104
|
+
docile (~> 1.1)
|
105
|
+
simplecov-html (~> 0.11)
|
106
|
+
simplecov_json_formatter (~> 0.1)
|
107
|
+
simplecov-html (0.13.1)
|
108
|
+
simplecov_json_formatter (0.1.4)
|
109
|
+
tzinfo (2.0.6)
|
110
|
+
concurrent-ruby (~> 1.0)
|
111
|
+
unicode-display_width (3.1.4)
|
112
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
113
|
+
unicode-emoji (4.0.4)
|
114
|
+
|
115
|
+
PLATFORMS
|
116
|
+
arm64-darwin-24
|
117
|
+
|
118
|
+
DEPENDENCIES
|
119
|
+
bundler
|
120
|
+
ezcater_rubocop!
|
121
|
+
pry-byebug
|
122
|
+
rake (~> 13.0)
|
123
|
+
rspec (~> 3.11)
|
124
|
+
rspec_junit_formatter
|
125
|
+
simplecov
|
126
|
+
|
127
|
+
BUNDLED WITH
|
128
|
+
2.3.7
|
data/README.md
CHANGED
@@ -48,6 +48,10 @@ Further customization of RuboCop for your local project may be added to this fil
|
|
48
48
|
- **rubocop_gem**: For use in Ruby gem projects, this inherits from the **rubocop** configuration.
|
49
49
|
- **rubocop_rails**: For Rails projects, this inherits from the **rubocop** configuration.
|
50
50
|
|
51
|
+
### Documentation
|
52
|
+
|
53
|
+
Visit https://gemdocs.org/gems/ezcater_rubocop to view the documentation for our custom cops in the latest release.
|
54
|
+
|
51
55
|
## Usage
|
52
56
|
|
53
57
|
Run `rubocop` for an entire project:
|
@@ -92,8 +96,9 @@ not add cops with `enabled: false` unless you want that cop to always be disable
|
|
92
96
|
* [RspecRequireFeatureFlagMock](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb) - Enforce use of `mock_feature_flag` helper instead of mocking `FeatureFlag.is_active?` directly.
|
93
97
|
* [RspecRequireHttpStatusMatcher](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/rspec_require_http_status_matcher.rb) - Use the HTTP status code matcher, like `expect(response).to have_http_status :bad_request`, rather than `expect(response.code).to eq 400`
|
94
98
|
* [StyleDig](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/style_dig.rb) - Recommend `dig` for deeply nested access.
|
99
|
+
* [Migration/BigintForeignKey](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/migration/bigint_foreign_key.rb) - Use `#bigint` instead of `#integer` for all foreign keys.
|
95
100
|
|
96
|
-
[GraphQL/NotAuthorizedScalarField]: https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/graphql/not_authorized_scalar_field.rb
|
101
|
+
[GraphQL/NotAuthorizedScalarField]: https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/graphql/not_authorized_scalar_field.rb
|
97
102
|
|
98
103
|
## Development
|
99
104
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Checks the validity of RuboCop config files in `conf/` directory (excluding the base config).
|
4
|
+
|
5
|
+
CONFIGS=(
|
6
|
+
"conf/rubocop_gem.yml"
|
7
|
+
"conf/rubocop_rails.yml"
|
8
|
+
)
|
9
|
+
|
10
|
+
exit_code=0
|
11
|
+
|
12
|
+
for config in "${CONFIGS[@]}"; do
|
13
|
+
if ! output=$(bundle exec rubocop --show-cops -c "$config" 2>&1); then
|
14
|
+
echo "❌ Error in $config"
|
15
|
+
echo "$output"
|
16
|
+
exit_code=1
|
17
|
+
fi
|
18
|
+
done
|
19
|
+
|
20
|
+
if [[ $exit_code -eq 0 ]]; then
|
21
|
+
echo "✅ All configs are valid"
|
22
|
+
fi
|
23
|
+
exit $exit_code
|
data/config/default.yml
CHANGED
data/ezcater_rubocop.gemspec
CHANGED
@@ -52,8 +52,8 @@ Gem::Specification.new do |spec|
|
|
52
52
|
spec.add_development_dependency "simplecov"
|
53
53
|
|
54
54
|
spec.add_runtime_dependency "parser", ">= 2.6"
|
55
|
-
spec.add_runtime_dependency "rubocop", ">= 1.16.0", "<
|
55
|
+
spec.add_runtime_dependency "rubocop", ">= 1.16.0", "< 1.72.0"
|
56
56
|
spec.add_runtime_dependency "rubocop-graphql", ">= 0.14.0", "< 1.0"
|
57
|
-
spec.add_runtime_dependency "rubocop-rails", ">= 2.10.1", "<
|
57
|
+
spec.add_runtime_dependency "rubocop-rails", ">= 2.10.1", "< 2.28.0"
|
58
58
|
spec.add_runtime_dependency "rubocop-rspec", ">= 2.22.0", "< 2.28.0"
|
59
59
|
end
|
data/lib/ezcater_rubocop.rb
CHANGED
@@ -16,19 +16,20 @@ puts "configuration from #{DEFAULT_FILES}" if RuboCop::ConfigLoader.debug?
|
|
16
16
|
config = RuboCop::ConfigLoader.merge_with_default(config, path)
|
17
17
|
RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
19
|
+
require_relative "rubocop/cop/ezcater/direct_env_check"
|
20
|
+
require_relative "rubocop/cop/ezcater/feature_flag_active"
|
21
|
+
require_relative "rubocop/cop/ezcater/feature_flag_name_valid"
|
22
|
+
require_relative "rubocop/cop/ezcater/graphql/not_authorized_scalar_field"
|
23
|
+
require_relative "rubocop/cop/ezcater/rails_configuration"
|
24
|
+
require_relative "rubocop/cop/ezcater/rails_env"
|
25
|
+
require_relative "rubocop/cop/ezcater/ruby_timeout"
|
26
|
+
require_relative "rubocop/cop/ezcater/rails_top_level_sql_execute"
|
27
|
+
require_relative "rubocop/cop/ezcater/require_custom_error"
|
28
|
+
require_relative "rubocop/cop/ezcater/require_gql_error_helpers"
|
29
|
+
require_relative "rubocop/cop/ezcater/rspec_match_ordered_array"
|
30
|
+
require_relative "rubocop/cop/ezcater/rspec_require_browser_mock"
|
31
|
+
require_relative "rubocop/cop/ezcater/rspec_require_feature_flag_mock"
|
32
|
+
require_relative "rubocop/cop/ezcater/rspec_require_http_status_matcher"
|
33
|
+
require_relative "rubocop/cop/ezcater/rspec_dot_not_self_dot"
|
34
|
+
require_relative "rubocop/cop/ezcater/style_dig"
|
35
|
+
require_relative "rubocop/cop/ezcater/migration/bigint_foreign_key"
|
@@ -0,0 +1,264 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Ezcater
|
6
|
+
module Migration
|
7
|
+
# Use `bigint` instead of `integer` for all foreign keys.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
#
|
11
|
+
# # bad
|
12
|
+
# create_table :foos do |t|
|
13
|
+
# t.integer :bar_id
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# # bad
|
17
|
+
# create_table :foos do |t|
|
18
|
+
# t.integer :bar_id, limit: 7
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# # bad
|
22
|
+
# add_column :foos, :bar_id, :integer
|
23
|
+
#
|
24
|
+
# # bad
|
25
|
+
# add_column :foos, :bar_id, :integer, limit: 7
|
26
|
+
#
|
27
|
+
# # bad
|
28
|
+
# add_reference :foos, :bar, type: :integer
|
29
|
+
#
|
30
|
+
# # bad
|
31
|
+
# add_reference :foos, :bar, type: :integer, limit: 7
|
32
|
+
#
|
33
|
+
# # good
|
34
|
+
# create_table :foos do |t|
|
35
|
+
# t.bigint :bar_id
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# # good
|
39
|
+
# create_table :foos do |t|
|
40
|
+
# t.references :bar
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# # good
|
44
|
+
# add_column :foos, :bar_id, :bigint
|
45
|
+
#
|
46
|
+
# # good
|
47
|
+
# add_reference :foos, :bar
|
48
|
+
#
|
49
|
+
class BigintForeignKey < Base # rubocop:disable Metrics/ClassLength
|
50
|
+
extend AutoCorrector
|
51
|
+
|
52
|
+
MSG = <<~MSG.chomp
|
53
|
+
Use `bigint` instead of `integer` for foreign keys. This ensures that they are capable of storing all possible values from referenced primary keys which are `bigint` or may eventually be migrated to `bigint`.
|
54
|
+
MSG
|
55
|
+
|
56
|
+
# Optimization: only call `on_send` for the methods in this list
|
57
|
+
RESTRICT_ON_SEND = %i(
|
58
|
+
integer
|
59
|
+
references
|
60
|
+
belongs_to
|
61
|
+
add_column
|
62
|
+
add_reference
|
63
|
+
add_belongs_to
|
64
|
+
).freeze
|
65
|
+
|
66
|
+
BIGINT_BYTES = 8
|
67
|
+
|
68
|
+
# @!method t_integer_method(node)
|
69
|
+
def_node_matcher :t_integer_method, <<~PATTERN
|
70
|
+
(send
|
71
|
+
# Any local variable that calls an `integer` method
|
72
|
+
(lvar _) :integer
|
73
|
+
|
74
|
+
# Column name: symbol or string ending in _id
|
75
|
+
{(sym #ends_with_id?) (str #ends_with_id?)}
|
76
|
+
|
77
|
+
# Optional hash that includes a limit key
|
78
|
+
(hash <(pair (sym :limit) (int $_)) ...>)?
|
79
|
+
)
|
80
|
+
PATTERN
|
81
|
+
|
82
|
+
# @!method t_references_method(node)
|
83
|
+
def_node_matcher :t_references_method, <<~PATTERN
|
84
|
+
(send
|
85
|
+
# Any local variable that calls a `references` or `belongs_to` method
|
86
|
+
(lvar _) {:references :belongs_to}
|
87
|
+
|
88
|
+
# Reference name
|
89
|
+
{(sym _) (str _)}
|
90
|
+
|
91
|
+
# A hash that includes `type: :integer`
|
92
|
+
(hash <(pair (sym :type) (sym :integer)) ...>)
|
93
|
+
)
|
94
|
+
PATTERN
|
95
|
+
|
96
|
+
# @!method add_column_method(node)
|
97
|
+
def_node_matcher :add_column_method, <<~PATTERN
|
98
|
+
# A call to an `add_column` method
|
99
|
+
(send nil? :add_column
|
100
|
+
# Table name
|
101
|
+
{(sym _) (str _)}
|
102
|
+
|
103
|
+
# Column name: a symbol or string ending in _id
|
104
|
+
{(sym #ends_with_id?) (str #ends_with_id?)}
|
105
|
+
|
106
|
+
# Column type
|
107
|
+
(sym :integer)
|
108
|
+
|
109
|
+
# Optional hash that includes a limit key
|
110
|
+
(hash <(pair (sym :limit) (int $_)) ...>)?
|
111
|
+
)
|
112
|
+
PATTERN
|
113
|
+
|
114
|
+
# @!method add_reference_method(node)
|
115
|
+
def_node_matcher :add_reference_method, <<~PATTERN
|
116
|
+
# A call to a `add_reference` or `add_belongs_to` method
|
117
|
+
(send nil? {:add_reference :add_belongs_to}
|
118
|
+
# Table name
|
119
|
+
{(sym _) (str _)}
|
120
|
+
|
121
|
+
# Reference name
|
122
|
+
{(sym _) (str _)}
|
123
|
+
|
124
|
+
# A hash that includes `type: :integer`
|
125
|
+
(hash <(pair (sym :type) (sym :integer)) ...>)
|
126
|
+
)
|
127
|
+
PATTERN
|
128
|
+
|
129
|
+
# @!method limit_pair(node)
|
130
|
+
def_node_search :limit_pair, <<~PATTERN
|
131
|
+
(pair (sym :limit) (int $_))
|
132
|
+
PATTERN
|
133
|
+
|
134
|
+
def on_send(node)
|
135
|
+
t_integer_method(node) do |captures|
|
136
|
+
check_integer_method(node, captures)
|
137
|
+
end
|
138
|
+
|
139
|
+
add_column_method(node) do |captures|
|
140
|
+
check_integer_method(node, captures)
|
141
|
+
end
|
142
|
+
|
143
|
+
t_references_method(node) do
|
144
|
+
check_reference_method(node)
|
145
|
+
end
|
146
|
+
|
147
|
+
add_reference_method(node) do
|
148
|
+
check_reference_method(node)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
private
|
153
|
+
|
154
|
+
def ends_with_id?(str)
|
155
|
+
str.end_with?("_id")
|
156
|
+
end
|
157
|
+
|
158
|
+
def check_integer_method(node, captures)
|
159
|
+
limit_value = captures.first
|
160
|
+
check_for_offense(node, limit_value)
|
161
|
+
end
|
162
|
+
|
163
|
+
def check_reference_method(node)
|
164
|
+
limit_vals = limit_pair(node)
|
165
|
+
limit_value = limit_vals.first
|
166
|
+
|
167
|
+
check_for_offense(node, limit_value)
|
168
|
+
end
|
169
|
+
|
170
|
+
def check_for_offense(node, limit_value)
|
171
|
+
return unless limit_value.nil? || limit_value < BIGINT_BYTES
|
172
|
+
|
173
|
+
add_offense(node) do |corrector|
|
174
|
+
make_correction(node, corrector)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def make_correction(node, corrector)
|
179
|
+
case node.method_name
|
180
|
+
when :integer
|
181
|
+
correct_integer_method(node, corrector)
|
182
|
+
when :references, :belongs_to
|
183
|
+
correct_references_method(node, corrector)
|
184
|
+
when :add_column
|
185
|
+
correct_add_column_method(node, corrector)
|
186
|
+
when :add_reference, :add_belongs_to
|
187
|
+
correct_add_reference_method(node, corrector)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def correct_integer_method(node, corrector)
|
192
|
+
# There's no hash argument or it has only one pair
|
193
|
+
if node.arguments.size == 1 ||
|
194
|
+
(node.arguments.size == 2 &&
|
195
|
+
(node.arguments[1].hash_type? &&
|
196
|
+
node.arguments[1].pairs.size == 1))
|
197
|
+
|
198
|
+
corrector.replace(
|
199
|
+
range_for_method_and_optional_limit(node),
|
200
|
+
"bigint #{node.arguments[0].source}"
|
201
|
+
)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def correct_references_method(node, corrector)
|
206
|
+
# There's only one hash pair (:type) or only two: :type and :limit
|
207
|
+
return unless node.arguments.size == 2 && node.arguments[1].hash_type?
|
208
|
+
|
209
|
+
hash_pairs = node.arguments[1].pairs
|
210
|
+
keys = hash_pairs.map { |pair| pair.key.source }
|
211
|
+
|
212
|
+
if keys.size == 1 ||
|
213
|
+
(keys.size == 2 && keys.include?("limit"))
|
214
|
+
|
215
|
+
corrector.replace(
|
216
|
+
range_for_method_and_optional_limit(node),
|
217
|
+
"#{node.method_name} #{node.arguments[0].source}"
|
218
|
+
)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def correct_add_column_method(node, corrector)
|
223
|
+
# There's no hash argument or it has only one pair (:limit)
|
224
|
+
if node.arguments.size == 3 ||
|
225
|
+
(node.arguments.size == 4 &&
|
226
|
+
(node.arguments[3].hash_type? &&
|
227
|
+
node.arguments[3].pairs.size == 1))
|
228
|
+
|
229
|
+
corrector.replace(
|
230
|
+
range_for_method_and_optional_limit(node),
|
231
|
+
"add_column #{node.arguments[0].source}, #{node.arguments[1].source}, :bigint"
|
232
|
+
)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def correct_add_reference_method(node, corrector)
|
237
|
+
# There's only one hash pair (:type) or only two: :type and :limit
|
238
|
+
return unless node.arguments.size == 3 && node.arguments[2].hash_type?
|
239
|
+
|
240
|
+
hash_pairs = node.arguments[2].pairs
|
241
|
+
keys = hash_pairs.map { |pair| pair.key.source }
|
242
|
+
|
243
|
+
if keys.size == 1 ||
|
244
|
+
(keys.size == 2 && keys.include?("limit"))
|
245
|
+
|
246
|
+
corrector.replace(
|
247
|
+
range_for_method_and_optional_limit(node),
|
248
|
+
"#{node.method_name} #{node.arguments[0].source}, #{node.arguments[1].source}"
|
249
|
+
)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def range_for_method_and_optional_limit(node)
|
254
|
+
Parser::Source::Range.new(
|
255
|
+
node.source_range.source_buffer,
|
256
|
+
node.selector.begin_pos,
|
257
|
+
node.source_range.end_pos
|
258
|
+
)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezcater_rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ezCater, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -117,7 +117,7 @@ dependencies:
|
|
117
117
|
version: 1.16.0
|
118
118
|
- - "<"
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
120
|
+
version: 1.72.0
|
121
121
|
type: :runtime
|
122
122
|
prerelease: false
|
123
123
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -127,7 +127,7 @@ dependencies:
|
|
127
127
|
version: 1.16.0
|
128
128
|
- - "<"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
130
|
+
version: 1.72.0
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: rubocop-graphql
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,7 +157,7 @@ dependencies:
|
|
157
157
|
version: 2.10.1
|
158
158
|
- - "<"
|
159
159
|
- !ruby/object:Gem::Version
|
160
|
-
version:
|
160
|
+
version: 2.28.0
|
161
161
|
type: :runtime
|
162
162
|
prerelease: false
|
163
163
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -167,7 +167,7 @@ dependencies:
|
|
167
167
|
version: 2.10.1
|
168
168
|
- - "<"
|
169
169
|
- !ruby/object:Gem::Version
|
170
|
-
version:
|
170
|
+
version: 2.28.0
|
171
171
|
- !ruby/object:Gem::Dependency
|
172
172
|
name: rubocop-rspec
|
173
173
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,8 +203,10 @@ files:
|
|
203
203
|
- ".tool-versions"
|
204
204
|
- CHANGELOG.md
|
205
205
|
- Gemfile
|
206
|
+
- Gemfile.lock
|
206
207
|
- LICENSE.txt
|
207
208
|
- README.md
|
209
|
+
- bin/check_configs.sh
|
208
210
|
- bin/circle_rubocop.rb
|
209
211
|
- conf/rubocop.yml
|
210
212
|
- conf/rubocop_gem.yml
|
@@ -217,6 +219,7 @@ files:
|
|
217
219
|
- lib/rubocop/cop/ezcater/feature_flag_active.rb
|
218
220
|
- lib/rubocop/cop/ezcater/feature_flag_name_valid.rb
|
219
221
|
- lib/rubocop/cop/ezcater/graphql/not_authorized_scalar_field.rb
|
222
|
+
- lib/rubocop/cop/ezcater/migration/bigint_foreign_key.rb
|
220
223
|
- lib/rubocop/cop/ezcater/rails_configuration.rb
|
221
224
|
- lib/rubocop/cop/ezcater/rails_env.rb
|
222
225
|
- lib/rubocop/cop/ezcater/rails_top_level_sql_execute.rb
|