rubocop-rails 2.14.0 → 2.14.1
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/lib/rubocop/cop/rails/migration_class_name.rb +13 -3
 - data/lib/rubocop/rails/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c8ac7c4db62e8518ff9316e0a3ac8919ac440eaf9ba84eacf883cf902fffca7a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8a4b1e0c90e4ea2b8ba06352bc7525b56c4d95af49e618fb77a6bfd4bc5dafdb
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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 
     | 
    
         
            -
                       
     | 
| 
      
 32 
     | 
    
         
            +
                      basename = basename_without_timestamp_and_suffix
         
     | 
| 
      
 33 
     | 
    
         
            +
                      return if snake_class_name == basename
         
     | 
| 
       30 
34 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                      corrected_class_name = to_camelcase( 
     | 
| 
      
 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  
     | 
| 
      
 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
         
     | 
    
        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. 
     | 
| 
      
 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- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2022-03-16 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: activesupport
         
     |