rubocop-sequel 0.0.4 → 0.0.5
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/.rubocop.yml +4 -1
- data/.travis.yml +2 -0
- data/Gemfile +2 -0
- data/lib/rubocop-sequel.rb +2 -0
- data/lib/rubocop/cop/sequel/column_default.rb +3 -1
- data/lib/rubocop/cop/sequel/concurrent_index.rb +6 -4
- data/lib/rubocop/cop/sequel/migration_name.rb +5 -1
- data/lib/rubocop/cop/sequel/save_changes.rb +3 -1
- data/lib/rubocop/sequel.rb +2 -0
- data/rubocop-sequel.gemspec +3 -1
- data/spec/rubocop/cop/sequel/column_default_spec.rb +2 -0
- data/spec/rubocop/cop/sequel/concurrent_index_spec.rb +21 -9
- data/spec/rubocop/cop/sequel/migration_name_spec.rb +2 -0
- data/spec/rubocop/cop/sequel/save_changes_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1426529648e896758505cc0f580c8a9dfd04eaaadf041e01fe8a38f1452fc549
         | 
| 4 | 
            +
              data.tar.gz: 8105c3044c2536f0f57fc79346ecf2349036b5d918fa7312f1d35e55ffc41bc0
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3eb093802d46566d8a0e0e4920af488673448bbd1ae9e8dab89b4dd2aedd11494f2222bfd4ae1fcaff01104b848d50510fef518daa0b947e741f85d009a04d33
         | 
| 7 | 
            +
              data.tar.gz: 5570ee0d798a47808cacb9a162db33a141c0055147dbedbb88fba614ecc9b14ce6c50bd66f9911f01136515f5d94ed4634cbdb76355a68d628755426b8d4c3d4
         | 
    
        data/.rubocop.yml
    CHANGED
    
    | @@ -1,10 +1,13 @@ | |
| 1 1 | 
             
            require:
         | 
| 2 2 | 
             
              - rubocop-rspec
         | 
| 3 3 |  | 
| 4 | 
            +
            AllCops:
         | 
| 5 | 
            +
              TargetRubyVersion: 2.3
         | 
| 6 | 
            +
             | 
| 4 7 | 
             
            # Offense count: 1
         | 
| 5 8 | 
             
            # Configuration parameters: CountComments, ExcludedMethods.
         | 
| 6 9 | 
             
            Metrics/BlockLength:
         | 
| 7 | 
            -
              Max:  | 
| 10 | 
            +
              Max: 31
         | 
| 8 11 |  | 
| 9 12 | 
             
            # Offense count: 1
         | 
| 10 13 | 
             
            # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
         | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/Gemfile
    CHANGED
    
    
    
        data/lib/rubocop-sequel.rb
    CHANGED
    
    
| @@ -1,9 +1,11 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module RuboCop
         | 
| 2 4 | 
             
              module Cop
         | 
| 3 5 | 
             
                module Sequel
         | 
| 4 6 | 
             
                  # ColumnDefault looks for column creation with a default value.
         | 
| 5 7 | 
             
                  class ColumnDefault < Cop
         | 
| 6 | 
            -
                    MSG = "Don't create new column with default values" | 
| 8 | 
            +
                    MSG = "Don't create new column with default values"
         | 
| 7 9 |  | 
| 8 10 | 
             
                    def_node_matcher :add_column_default, <<-MATCHER
         | 
| 9 11 | 
             
                      (send _ :add_column ... (hash (pair (sym :default) _)))
         | 
| @@ -1,16 +1,18 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module RuboCop
         | 
| 2 4 | 
             
              module Cop
         | 
| 3 5 | 
             
                module Sequel
         | 
| 4 6 | 
             
                  # ConcurrentIndex looks for non-concurrent index creation.
         | 
| 5 7 | 
             
                  class ConcurrentIndex < Cop
         | 
| 6 | 
            -
                    MSG = 'Prefer creating new index concurrently' | 
| 8 | 
            +
                    MSG = 'Prefer creating or dropping new index concurrently'
         | 
| 7 9 |  | 
| 8 | 
            -
                    def_node_matcher : | 
| 9 | 
            -
                      (send _ :add_index $...)
         | 
| 10 | 
            +
                    def_node_matcher :indexes, <<-MATCHER
         | 
| 11 | 
            +
                      (send _ {:add_index :drop_index} $...)
         | 
| 10 12 | 
             
                    MATCHER
         | 
| 11 13 |  | 
| 12 14 | 
             
                    def on_send(node)
         | 
| 13 | 
            -
                       | 
| 15 | 
            +
                      indexes(node) do |args|
         | 
| 14 16 | 
             
                        if offensive?(args)
         | 
| 15 17 | 
             
                          add_offense(node, location: :selector, message: MSG)
         | 
| 16 18 | 
             
                        end
         | 
| @@ -1,9 +1,13 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module RuboCop
         | 
| 2 4 | 
             
              module Cop
         | 
| 3 5 | 
             
                module Sequel
         | 
| 4 6 | 
             
                  # MigrationName looks for migration files named with a default name.
         | 
| 5 7 | 
             
                  class MigrationName < Cop
         | 
| 6 | 
            -
                     | 
| 8 | 
            +
                    include RangeHelp
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                    MSG = 'Migration files should not use default name.'
         | 
| 7 11 |  | 
| 8 12 | 
             
                    def investigate(processed_source)
         | 
| 9 13 | 
             
                      file_path = processed_source.buffer.name
         | 
| @@ -1,10 +1,12 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module RuboCop
         | 
| 2 4 | 
             
              module Cop
         | 
| 3 5 | 
             
                module Sequel
         | 
| 4 6 | 
             
                  # SaveChanges promotes the use of save_changes.
         | 
| 5 7 | 
             
                  class SaveChanges < Cop
         | 
| 6 8 | 
             
                    MSG = 'Use `Sequel::Model#save_changes` instead of '\
         | 
| 7 | 
            -
                      '`Sequel::Model#save`.' | 
| 9 | 
            +
                      '`Sequel::Model#save`.'
         | 
| 8 10 |  | 
| 9 11 | 
             
                    def_node_matcher :model_save, <<-MATCHER
         | 
| 10 12 | 
             
                      (send _ :save)
         | 
    
        data/lib/rubocop/sequel.rb
    CHANGED
    
    
    
        data/rubocop-sequel.gemspec
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            Gem::Specification.new do |gem|
         | 
| 2 4 | 
             
              gem.authors       = ['Timothée Peignier']
         | 
| 3 5 | 
             
              gem.email         = ['timothee.peignier@tryphon.org']
         | 
| @@ -11,7 +13,7 @@ Gem::Specification.new do |gem| | |
| 11 13 | 
             
              gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
         | 
| 12 14 | 
             
              gem.name          = 'rubocop-sequel'
         | 
| 13 15 | 
             
              gem.require_paths = ['lib']
         | 
| 14 | 
            -
              gem.version       = '0.0. | 
| 16 | 
            +
              gem.version       = '0.0.5'
         | 
| 15 17 |  | 
| 16 18 | 
             
              gem.add_runtime_dependency 'rubocop', '~> 0.52', '>= 0.52'
         | 
| 17 19 |  | 
| @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'spec_helper'
         | 
| 2 4 |  | 
| 3 5 | 
             
            describe RuboCop::Cop::Sequel::ConcurrentIndex do
         | 
| @@ -5,25 +7,35 @@ describe RuboCop::Cop::Sequel::ConcurrentIndex do | |
| 5 7 |  | 
| 6 8 | 
             
              context 'without the concurrent option' do
         | 
| 7 9 | 
             
                it 'registers an offense without options' do
         | 
| 8 | 
            -
                  inspect_source( | 
| 9 | 
            -
             | 
| 10 | 
            +
                  inspect_source(<<~SOURCE)
         | 
| 11 | 
            +
                    add_index(:products, :name)
         | 
| 12 | 
            +
                    drop_index(:products, :name)
         | 
| 13 | 
            +
                  SOURCE
         | 
| 14 | 
            +
                  expect(cop.offenses.size).to eq(2)
         | 
| 10 15 | 
             
                end
         | 
| 11 16 |  | 
| 12 17 | 
             
                it 'registers an offense with other options' do
         | 
| 13 | 
            -
                  inspect_source( | 
| 14 | 
            -
             | 
| 18 | 
            +
                  inspect_source(<<~SOURCE)
         | 
| 19 | 
            +
                    add_index(:products, :name, unique: true)
         | 
| 20 | 
            +
                    drop_index(:products, :name, unique: true)
         | 
| 21 | 
            +
                  SOURCE
         | 
| 22 | 
            +
                  expect(cop.offenses.size).to eq(2)
         | 
| 15 23 | 
             
                end
         | 
| 16 24 |  | 
| 17 25 | 
             
                it 'registers an offense with composite index' do
         | 
| 18 | 
            -
                  inspect_source( | 
| 19 | 
            -
             | 
| 26 | 
            +
                  inspect_source(<<~SOURCE)
         | 
| 27 | 
            +
                    add_index(:products, [:name, :price], unique: true)
         | 
| 28 | 
            +
                    drop_index(:products, [:name, :price])
         | 
| 29 | 
            +
                  SOURCE
         | 
| 30 | 
            +
                  expect(cop.offenses.size).to eq(2)
         | 
| 20 31 | 
             
                end
         | 
| 21 32 | 
             
              end
         | 
| 22 33 |  | 
| 23 34 | 
             
              it 'does not register an offense when using concurrent option' do
         | 
| 24 | 
            -
                inspect_source(
         | 
| 25 | 
            -
                   | 
| 26 | 
            -
             | 
| 35 | 
            +
                inspect_source(<<~SOURCE)
         | 
| 36 | 
            +
                  add_index(:products, :name, unique: true, concurrently: true)
         | 
| 37 | 
            +
                  drop_index(:products, :name, concurrently: true)
         | 
| 38 | 
            +
                SOURCE
         | 
| 27 39 | 
             
                expect(cop.offenses).to be_empty
         | 
| 28 40 | 
             
              end
         | 
| 29 41 | 
             
            end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rubocop-sequel
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Timothée Peignier
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018- | 
| 11 | 
            +
            date: 2018-03-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rubocop
         | 
| @@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 191 191 | 
             
                  version: '0'
         | 
| 192 192 | 
             
            requirements: []
         | 
| 193 193 | 
             
            rubyforge_project: 
         | 
| 194 | 
            -
            rubygems_version: 2.7. | 
| 194 | 
            +
            rubygems_version: 2.7.6
         | 
| 195 195 | 
             
            signing_key: 
         | 
| 196 196 | 
             
            specification_version: 4
         | 
| 197 197 | 
             
            summary: A plugin for the RuboCop code style & linting tool.
         |