betterlint 1.30.0 → 1.31.0
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/README.md +21 -0
- data/config/default.yml +7 -0
- data/lib/betterlint/version.rb +1 -1
- data/lib/rubocop/cop/betterment/no_send.rb +25 -0
- data/lib/rubocop/cop/betterment.rb +1 -0
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df6ab37fcacbca2232240ecc261718b03ce8cae9d9ec6860d01b1fe5aafa15de
|
|
4
|
+
data.tar.gz: 3c1aace8b60b77b649f621b5923f3defddb33d18922aff23211225cea7461af5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0405efeb7e9268e65ab0440399f375e482338b7008a9ffa4690cbdc0640d8f0d1e5ea5382ddf2f203f54beb517f76387386f104b0f2a20519615e9c34f3bd6fd
|
|
7
|
+
data.tar.gz: 668fba99358e61376714517009c13e3e335e74c5576541941293c56018a851dca599edb0333160d99c27a31b192ec730149dac7cdf53045dbbac2cc24f643fba
|
data/README.md
CHANGED
|
@@ -470,3 +470,24 @@ end
|
|
|
470
470
|
```
|
|
471
471
|
|
|
472
472
|
This cop is disabled by default, because it reports many offenses in applications with older specs. To use it, enable it in your `.rubocop.yml`. By default it examines all files in `spec/`, except for the `features`, `requests`, `routing`, `system`, and `views` directories, where integration style tests that don't test one class and method are common. Examples in shared example groups are also ignored.
|
|
473
|
+
|
|
474
|
+
### Betterment/NoSend
|
|
475
|
+
|
|
476
|
+
This cop flags calls to `send`, `public_send`, and `__send__`. Dynamic dispatch hides the call from Sorbet and code search, and `send` also reaches private methods. Call the method directly instead.
|
|
477
|
+
|
|
478
|
+
#### BAD:
|
|
479
|
+
|
|
480
|
+
```ruby
|
|
481
|
+
record.public_send(:name)
|
|
482
|
+
record.send(attribute_name)
|
|
483
|
+
job.send(:plaid_item)
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
#### GOOD:
|
|
487
|
+
|
|
488
|
+
```ruby
|
|
489
|
+
record.name
|
|
490
|
+
record.attributes.fetch(attribute_name)
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
This cop ignores files in `spec/`, and calls to `send` with no arguments, which are usually a different method named `send`.
|
data/config/default.yml
CHANGED
|
@@ -70,6 +70,13 @@ Betterment/NoDownMigrations:
|
|
|
70
70
|
Include:
|
|
71
71
|
- db/migrate/**/*.rb
|
|
72
72
|
|
|
73
|
+
Betterment/NoSend:
|
|
74
|
+
Description: Detects dynamic method calls through send, public_send and __send__.
|
|
75
|
+
StyleGuide: '#bettermentnosend'
|
|
76
|
+
Enabled: true
|
|
77
|
+
Exclude:
|
|
78
|
+
- spec/**/*
|
|
79
|
+
|
|
73
80
|
Betterment/NonNamespacedClass:
|
|
74
81
|
Description: Detects classes that are not namespaced under a module or constant
|
|
75
82
|
StyleGuide: '#bettermentnonamespacedclass'
|
data/lib/betterlint/version.rb
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Betterment
|
|
6
|
+
class NoSend < Base
|
|
7
|
+
MSG = <<~TEXT
|
|
8
|
+
Call the method directly instead of using `%<method>s`; dynamic dispatch is invisible to Sorbet and code search.
|
|
9
|
+
|
|
10
|
+
See here for more information on this cop:
|
|
11
|
+
https://github.com/Betterment/betterlint/blob/main/README.md#bettermentnosend
|
|
12
|
+
TEXT
|
|
13
|
+
|
|
14
|
+
RESTRICT_ON_SEND = %i(send public_send __send__).freeze
|
|
15
|
+
|
|
16
|
+
def on_send(node)
|
|
17
|
+
return unless node.arguments?
|
|
18
|
+
|
|
19
|
+
add_offense(node.loc.selector, message: format(MSG, method: node.method_name))
|
|
20
|
+
end
|
|
21
|
+
alias on_csend on_send
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -13,6 +13,7 @@ require 'rubocop/cop/betterment/implicit_redirect_type'
|
|
|
13
13
|
require 'rubocop/cop/betterment/internals_protection'
|
|
14
14
|
require 'rubocop/cop/betterment/memoization_with_arguments'
|
|
15
15
|
require 'rubocop/cop/betterment/no_down_migrations'
|
|
16
|
+
require 'rubocop/cop/betterment/no_send'
|
|
16
17
|
require 'rubocop/cop/betterment/non_namespaced_class'
|
|
17
18
|
require 'rubocop/cop/betterment/non_standard_actions'
|
|
18
19
|
require 'rubocop/cop/betterment/non_standard_controller'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: betterlint
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.31.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Development
|
|
@@ -180,6 +180,7 @@ files:
|
|
|
180
180
|
- lib/rubocop/cop/betterment/internals_protection.rb
|
|
181
181
|
- lib/rubocop/cop/betterment/memoization_with_arguments.rb
|
|
182
182
|
- lib/rubocop/cop/betterment/no_down_migrations.rb
|
|
183
|
+
- lib/rubocop/cop/betterment/no_send.rb
|
|
183
184
|
- lib/rubocop/cop/betterment/non_namespaced_class.rb
|
|
184
185
|
- lib/rubocop/cop/betterment/non_standard_actions.rb
|
|
185
186
|
- lib/rubocop/cop/betterment/non_standard_controller.rb
|
|
@@ -204,10 +205,10 @@ licenses:
|
|
|
204
205
|
- MIT
|
|
205
206
|
metadata:
|
|
206
207
|
homepage_uri: https://github.com/Betterment/betterlint
|
|
207
|
-
source_code_uri: https://github.com/Betterment/betterlint/tree/v1.
|
|
208
|
-
changelog_uri: https://github.com/Betterment/betterlint/blob/v1.
|
|
208
|
+
source_code_uri: https://github.com/Betterment/betterlint/tree/v1.31.0
|
|
209
|
+
changelog_uri: https://github.com/Betterment/betterlint/blob/v1.31.0/CHANGELOG.md
|
|
209
210
|
bug_tracker_uri: https://github.com/Betterment/betterlint/issues
|
|
210
|
-
documentation_uri: https://www.rubydoc.info/gems/betterlint/1.
|
|
211
|
+
documentation_uri: https://www.rubydoc.info/gems/betterlint/1.31.0
|
|
211
212
|
rubygems_mfa_required: 'true'
|
|
212
213
|
default_lint_roller_plugin: Betterlint::Plugin
|
|
213
214
|
rdoc_options: []
|
|
@@ -224,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
224
225
|
- !ruby/object:Gem::Version
|
|
225
226
|
version: '0'
|
|
226
227
|
requirements: []
|
|
227
|
-
rubygems_version: 4.0.
|
|
228
|
+
rubygems_version: 4.0.24
|
|
228
229
|
specification_version: 4
|
|
229
230
|
summary: Betterment rubocop configuration
|
|
230
231
|
test_files: []
|