rubocop-rails_deprecation 0.1.0 → 0.4.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: 9ff5c12830fa2efec748d3d13d6eaefe473fe1297626b63f1bc112a087de5464
4
- data.tar.gz: 6940ecd0c3afbf1de9c8d3e85af86f816ef0a2cb484a8eae24274d7575ef47bb
3
+ metadata.gz: df33d530f4332c047cc6a14af980d43085e74136a2b74221d94aad9d8ad5b43b
4
+ data.tar.gz: f0755472fffc30564bd332d9a21ec807cf3c34a43cbffc902ee205f7bfc441d2
5
5
  SHA512:
6
- metadata.gz: fab9d41ad7bbd440435a274b032c015e2c6bb6f2fb216d11731c572a10803ff63ffab4e7d80431fe31cc08866c701d1766cfe6c8205d2fb6742b91322bfc58d7
7
- data.tar.gz: a6ebef02c3bb65654e219ece8df7aaff11069e9750b09fcd8f974c6a50cdc164190a16062ac002ae53ee18817b065dafa1edeb0e8fe84e5d184cb1e16281fec1
6
+ metadata.gz: e2a4359d066d4db18317083cd458a94a37a288ec76864f8a2ff07fbf9d9443ed5500d826a3de27a72c219a8be5d3c2c71495f8e5e4762c6960996f489f211a57
7
+ data.tar.gz: 55c84e4f33eb00bc015651f06e1801ba6865d5751a7f0dc6c1ea6aa108eda992f3f135b95e8cba31baca6b42c34910b67ebdad240042004e84104d8fea5aa8e2
data/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.4.0
6
+
7
+ ### Added
8
+
9
+ - Support csend on RailsDeprecation/ToFormattedS.
10
+
11
+ ## 0.3.0
12
+
13
+ ### Changed
14
+
15
+ - Rename RailsDeprecation/ToFormattedS with Deprecation/ToFormattedS.
16
+ - Enable cop by default.
17
+
18
+ ## 0.2.0
19
+
20
+ ### Changed
21
+
22
+ - Make #to_fs the default replacement for #to_s(:format).
23
+
5
24
  ## 0.1.0
6
25
 
7
26
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-rails_deprecation (0.1.0)
4
+ rubocop-rails_deprecation (0.4.0)
5
5
  rubocop
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # rubocop-rails_deprecation
2
2
 
3
+ [![test](https://github.com/r7kamura/rubocop-rails_deprecation/actions/workflows/test.yml/badge.svg)](https://github.com/r7kamura/rubocop-rails_deprecation/actions/workflows/test.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/rubocop-rails_deprecation.svg)](https://rubygems.org/gems/rubocop-rails_deprecation)
5
+
3
6
  RuboCop extension for Rails deprecation.
4
7
 
5
8
  ## Installation
@@ -21,3 +24,11 @@ Or install it yourself as:
21
24
  ```
22
25
  gem install rubocop-rails_deprecation
23
26
  ```
27
+
28
+ ## Usage
29
+
30
+ ```yaml
31
+ # .rubocop.yml
32
+ require:
33
+ - rubocop-rails_deprecation
34
+ ```
data/config/default.yml CHANGED
@@ -1,4 +1,4 @@
1
- RailsDeprecation/ToFormattedS:
2
- Description: Use `to_formatted_s(...)` instead of `to_s(...)`.
3
- Enabled: pending
1
+ Deprecation/ToFormattedS:
2
+ Description: Use `to_fs(...)` instead of `to_s(...)`.
3
+ Enabled: true
4
4
  VersionAdded: '0.1'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module RailsDeprecation
5
+ module Deprecation
6
6
  class Base < ::RuboCop::Cop::Base
7
7
  DEFAULT_MINIMUM_TARGET_RAILS_VERSION = 5.0
8
8
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module RailsDeprecation
5
+ module Deprecation
6
6
  # This cop identifies passing a format to `#to_s`.
7
7
  #
8
8
  # @safety
9
- # This cop's auto-correction is unsafe because a custom or unrelated `to_s` method call would be change to `to_formatted_s`.
9
+ # This cop's auto-correction is unsafe because a custom or unrelated `to_s` method call would be change to `to_fs`.
10
10
  #
11
11
  # @example
12
12
  #
@@ -14,6 +14,9 @@ module RuboCop
14
14
  # to_s(:delimited)
15
15
  #
16
16
  # # good
17
+ # to_fs(:delimited)
18
+ #
19
+ # # good
17
20
  # to_formatted_s(:delimited)
18
21
  #
19
22
  # # good
@@ -24,10 +27,10 @@ module RuboCop
24
27
 
25
28
  self.minimum_target_rails_version = 7.0
26
29
 
27
- MSG = 'Use `to_formatted_s(...)` instead of `to_s(...)`.'
30
+ MSG = 'Use `to_fs(...)` instead of `to_s(...)`.'
28
31
 
29
32
  def_node_matcher :to_s_with_any_argument?, <<~PATTERN
30
- (send _ :to_s _ ...)
33
+ ({csend | send} _ :to_s _ ...)
31
34
  PATTERN
32
35
 
33
36
  def on_send(node)
@@ -36,10 +39,11 @@ module RuboCop
36
39
  add_offense(node) do |rewriter|
37
40
  rewriter.replace(
38
41
  node.loc.selector,
39
- 'to_formatted_s'
42
+ 'to_fs'
40
43
  )
41
44
  end
42
45
  end
46
+ alias on_csend on_send
43
47
  end
44
48
  end
45
49
  end
@@ -3,7 +3,7 @@
3
3
  # The original code is from https://github.com/rubocop/rubocop-rspec/blob/main/lib/rubocop/rspec/inject.rb
4
4
  # See https://github.com/rubocop/rubocop-rspec/blob/main/MIT-LICENSE.md
5
5
  module RuboCop
6
- module RailsDeprecation
6
+ module Deprecation
7
7
  # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
8
8
  # bit of our configuration.
9
9
  module Inject
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RuboCop
4
- module RailsDeprecation
5
- VERSION = '0.1.0'
4
+ module Deprecation
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@
3
3
  require_relative 'rails_deprecation/version'
4
4
 
5
5
  module RuboCop
6
- module RailsDeprecation
6
+ module Deprecation
7
7
  class Error < StandardError; end
8
8
  # Your code goes here...
9
9
  PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
@@ -6,6 +6,6 @@ require_relative 'rubocop/rails_deprecation'
6
6
  require_relative 'rubocop/rails_deprecation/version'
7
7
  require_relative 'rubocop/rails_deprecation/inject'
8
8
 
9
- RuboCop::RailsDeprecation::Inject.defaults!
9
+ RuboCop::Deprecation::Inject.defaults!
10
10
 
11
11
  require_relative 'rubocop/cop/rails_deprecation_cops'
@@ -4,7 +4,7 @@ require_relative 'lib/rubocop/rails_deprecation/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'rubocop-rails_deprecation'
7
- spec.version = RuboCop::RailsDeprecation::VERSION
7
+ spec.version = RuboCop::Deprecation::VERSION
8
8
  spec.authors = ['Ryo Nakamura']
9
9
  spec.email = ['r7kamura@gmail.com']
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rails_deprecation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.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-02-23 00:00:00.000000000 Z
11
+ date: 2022-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -49,7 +49,6 @@ files:
49
49
  - lib/rubocop/rails_deprecation/inject.rb
50
50
  - lib/rubocop/rails_deprecation/version.rb
51
51
  - rubocop-rails_deprecation.gemspec
52
- - sig/rubocop/rails_deprecation.rbs
53
52
  homepage: https://github.com/r7kamura/rubocop-rails_deprecation
54
53
  licenses:
55
54
  - MIT
@@ -1,6 +0,0 @@
1
- module Rubocop
2
- module RailsDeprecation
3
- VERSION: String
4
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
- end
6
- end