rubocop-rails 2.14.0 → 2.14.1

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: bf7825df8f38360ce42c29846bd7b2e276447e6d87a5585acc35da05b829992f
4
- data.tar.gz: 6f219da0c0e0b92f9b5027bd1e50381435a4ac660484e5164a2718e79d52e6c7
3
+ metadata.gz: c8ac7c4db62e8518ff9316e0a3ac8919ac440eaf9ba84eacf883cf902fffca7a
4
+ data.tar.gz: 8a4b1e0c90e4ea2b8ba06352bc7525b56c4d95af49e618fb77a6bfd4bc5dafdb
5
5
  SHA512:
6
- metadata.gz: e3ebdfbd8f0d547d3c5becc45b95f2faa4c36651397e2082ec5c454c0388cfed7b09edc8d3bfbbdd1d70ea09b8a171e08efedf6f0eb660e39b24df2888d92547
7
- data.tar.gz: '06831b53608a82160e586d295aa04fe14670791545602386440fd9b40792391f2ddb8ac7d49b2dd677722251d7618c0f11388866bfd5dc1975b02ce99fb9246e'
6
+ metadata.gz: fb91cd3a6e867309efc10717843f0994a743bf1a4eb65b058863340d48904624377e88bb1b38cc0e091b9c2d5c676901987c1a31c3f6f50e5923863feb11f900
7
+ data.tar.gz: fe8208f3d1962a6c5400c74ab174b7b5b8c88641a564616f155cf90d91915ea85b6de031dc99a9737eb93fe3c39d878507f52d7f0aed85480142f630d0a082f5
@@ -20,15 +20,19 @@ module RuboCop
20
20
  #
21
21
  class MigrationClassName < Base
22
22
  extend AutoCorrector
23
+ include MigrationsHelper
23
24
 
24
25
  MSG = 'Replace with `%<corrected_class_name>s` that matches the file name.'
25
26
 
26
27
  def on_class(node)
28
+ return if in_migration?(node)
29
+
27
30
  snake_class_name = to_snakecase(node.identifier.source)
28
31
 
29
- return if snake_class_name == basename_without_timestamp
32
+ basename = basename_without_timestamp_and_suffix
33
+ return if snake_class_name == basename
30
34
 
31
- corrected_class_name = to_camelcase(basename_without_timestamp)
35
+ corrected_class_name = to_camelcase(basename)
32
36
  message = format(MSG, corrected_class_name: corrected_class_name)
33
37
 
34
38
  add_offense(node.identifier, message: message) do |corrector|
@@ -38,12 +42,18 @@ module RuboCop
38
42
 
39
43
  private
40
44
 
41
- def basename_without_timestamp
45
+ def basename_without_timestamp_and_suffix
42
46
  filepath = processed_source.file_path
43
47
  basename = File.basename(filepath, '.rb')
48
+ basename = remove_gem_suffix(basename)
44
49
  basename.sub(/\A\d+_/, '')
45
50
  end
46
51
 
52
+ # e.g.: from `add_blobs.active_storage` to `add_blobs`.
53
+ def remove_gem_suffix(file_name)
54
+ file_name.sub(/\..+\z/, '')
55
+ end
56
+
47
57
  def to_camelcase(word)
48
58
  word.split('_').map(&:capitalize).join
49
59
  end
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Rails
5
5
  # This module holds the RuboCop Rails version information.
6
6
  module Version
7
- STRING = '2.14.0'
7
+ STRING = '2.14.1'
8
8
 
9
9
  def self.document_version
10
10
  STRING.match('\d+\.\d+').to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.0
4
+ version: 2.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-03-15 00:00:00.000000000 Z
13
+ date: 2022-03-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport