sevencop 0.7.0 → 0.8.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/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/config/default.yml +7 -0
- data/lib/rubocop/cop/sevencop/to_s_with_argument.rb +39 -0
- data/lib/sevencop/version.rb +1 -1
- data/lib/sevencop.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 021c0c8e909037a665540671725553ec8a0a071aea513ea2ad39e62a104141cc
|
4
|
+
data.tar.gz: af3cbb3aaae938b0fa209995ca76dd65622aed3a4039d48a91dd4eaada3108eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df542292fe608cc072d4770263cbcaa3df4ad040d3b59c93362b3188ac54ab56285a36199451a95476927b85cbb92d67c164d3cf5b184834c87a78d3745ef343
|
7
|
+
data.tar.gz: 7289c90669cbe86f3eb025b71d2083fd60b1993ba8e5035bea7f06aecb2f1ccd8c274e53b29daea81358ac5d641a5be325189cda929035fae8b0dd127a4b360a
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/config/default.yml
CHANGED
@@ -25,6 +25,13 @@ Sevencop/RedundantExistenceCheck:
|
|
25
25
|
Safe: false
|
26
26
|
VersionAdded: '0.1'
|
27
27
|
|
28
|
+
Sevencop/ToSWithArgument:
|
29
|
+
Description: |
|
30
|
+
Identifies passing any argument to `#to_s`.
|
31
|
+
Enabled: false
|
32
|
+
Safe: false
|
33
|
+
VersionAdded: '0.8'
|
34
|
+
|
28
35
|
Sevencop/UniquenessValidatorExplicitCaseSensitivity:
|
29
36
|
Description: |
|
30
37
|
Specify :case_sensitivity option on use of UniquenessValidator.
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Sevencop
|
6
|
+
# Identifies passing any argument to `#to_s`.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
#
|
10
|
+
# # bad
|
11
|
+
# to_s(:delimited)
|
12
|
+
#
|
13
|
+
# # good
|
14
|
+
# to_formatted_s(:delimited)
|
15
|
+
#
|
16
|
+
class ToSWithArgument < Base
|
17
|
+
extend AutoCorrector
|
18
|
+
|
19
|
+
MSG = 'Use `to_formatted_s(...)` instead of `to_s(...)`.'
|
20
|
+
|
21
|
+
def_node_matcher :to_s_with_any_argument?, <<~PATTERN
|
22
|
+
(call _ :to_s _+)
|
23
|
+
PATTERN
|
24
|
+
|
25
|
+
def on_send(node)
|
26
|
+
return unless to_s_with_any_argument?(node)
|
27
|
+
|
28
|
+
add_offense(node) do |rewriter|
|
29
|
+
rewriter.replace(
|
30
|
+
node.loc.selector,
|
31
|
+
'to_formatted_s'
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
alias on_csend on_send
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/sevencop/version.rb
CHANGED
data/lib/sevencop.rb
CHANGED
@@ -10,6 +10,7 @@ require_relative 'rubocop/cop/sevencop/belongs_to_optional'
|
|
10
10
|
require_relative 'rubocop/cop/sevencop/hash_literal_order'
|
11
11
|
require_relative 'rubocop/cop/sevencop/order_field'
|
12
12
|
require_relative 'rubocop/cop/sevencop/redundant_existence_check'
|
13
|
+
require_relative 'rubocop/cop/sevencop/to_s_with_argument'
|
13
14
|
require_relative 'rubocop/cop/sevencop/uniqueness_validator_explicit_case_sensitivity'
|
14
15
|
require_relative 'rubocop/cop/sevencop/where_not'
|
15
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sevencop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- lib/rubocop/cop/sevencop/hash_literal_order.rb
|
46
46
|
- lib/rubocop/cop/sevencop/order_field.rb
|
47
47
|
- lib/rubocop/cop/sevencop/redundant_existence_check.rb
|
48
|
+
- lib/rubocop/cop/sevencop/to_s_with_argument.rb
|
48
49
|
- lib/rubocop/cop/sevencop/uniqueness_validator_explicit_case_sensitivity.rb
|
49
50
|
- lib/rubocop/cop/sevencop/where_not.rb
|
50
51
|
- lib/sevencop.rb
|