sevencop 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 435ef77ac8fd3b1e598c538068a02cf91bce3e1d3143bd1e48b45ed80b9a8cd1
4
- data.tar.gz: 8bc5d65cde82f92a7f6457041cd49a1448af80d1915841a44a4fc2c22b7b0877
3
+ metadata.gz: 021c0c8e909037a665540671725553ec8a0a071aea513ea2ad39e62a104141cc
4
+ data.tar.gz: af3cbb3aaae938b0fa209995ca76dd65622aed3a4039d48a91dd4eaada3108eb
5
5
  SHA512:
6
- metadata.gz: f53c512de8a6c32b2c4a409dc274dc22149c3ef15b680c8223e58a74bcac0015ccb3dd2d2e397fbb410bdf6f949e9f3d1de645c8332204a88dce7ab6ca5194da
7
- data.tar.gz: 2fd6cc8caf282c894b41744ae7df09d54017ce02d82ac3ab4925c85cde00a1aa0b8fd0ebc0fac5ec70f25dd8ab5fbfa79160102456a2a58ffafd3da1ffb92689
6
+ metadata.gz: df542292fe608cc072d4770263cbcaa3df4ad040d3b59c93362b3188ac54ab56285a36199451a95476927b85cbb92d67c164d3cf5b184834c87a78d3745ef343
7
+ data.tar.gz: 7289c90669cbe86f3eb025b71d2083fd60b1993ba8e5035bea7f06aecb2f1ccd8c274e53b29daea81358ac5d641a5be325189cda929035fae8b0dd127a4b360a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.8.0 - 2022-07-20
6
+
7
+ ### Added
8
+
9
+ - Add `Sevencop/ToSWithArgument` cop.
10
+
5
11
  ## 0.7.0 - 2022-07-15
6
12
 
7
13
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sevencop (0.7.0)
4
+ sevencop (0.8.0)
5
5
  rubocop
6
6
 
7
7
  GEM
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sevencop
4
- VERSION = '0.7.0'
4
+ VERSION = '0.8.0'
5
5
  end
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.7.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-15 00:00:00.000000000 Z
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