From 045961111a8adb21d05abb500c24b9f2e0161bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Peignier?= Date: Fri, 15 Sep 2023 13:56:16 -0700 Subject: [PATCH] Remove ColumnDefault cop --- lib/rubocop-sequel.rb | 1 - lib/rubocop/cop/sequel/column_default.rb | 23 ------------------- .../rubocop/cop/sequel/column_default_spec.rb | 17 -------------- 3 files changed, 41 deletions(-) delete mode 100644 lib/rubocop/cop/sequel/column_default.rb delete mode 100644 spec/rubocop/cop/sequel/column_default_spec.rb diff --git a/lib/rubocop-sequel.rb b/lib/rubocop-sequel.rb index 540e7bd..1d09ae9 100644 --- a/lib/rubocop-sequel.rb +++ b/lib/rubocop-sequel.rb @@ -3,7 +3,6 @@ require 'rubocop' require 'rubocop/sequel/version' -require 'rubocop/cop/sequel/column_default' require 'rubocop/cop/sequel/concurrent_index' require 'rubocop/cop/sequel/json_column' require 'rubocop/cop/sequel/migration_name' diff --git a/lib/rubocop/cop/sequel/column_default.rb b/lib/rubocop/cop/sequel/column_default.rb deleted file mode 100644 index e2b9246..0000000 --- a/lib/rubocop/cop/sequel/column_default.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -module RuboCop - module Cop - module Sequel - # ColumnDefault looks for column creation with a default value. - class ColumnDefault < Base - MSG = "Don't create new column with default values" - RESTRICT_ON_SEND = %i[add_column].freeze - - def_node_matcher :add_column_default?, <<-MATCHER - (send _ :add_column ... (hash (pair (sym :default) _))) - MATCHER - - def on_send(node) - return unless add_column_default?(node) - - add_offense(node.loc.selector, message: MSG) - end - end - end - end -end diff --git a/spec/rubocop/cop/sequel/column_default_spec.rb b/spec/rubocop/cop/sequel/column_default_spec.rb deleted file mode 100644 index 079e6a0..0000000 --- a/spec/rubocop/cop/sequel/column_default_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe RuboCop::Cop::Sequel::ColumnDefault do - subject(:cop) { described_class.new } - - it 'registers an offense when setting a default' do - offenses = inspect_source('add_column(:products, :type, :text, default: "cop")') - expect(offenses.size).to eq(1) - end - - it 'does not register an offense when not setting a default' do - offenses = inspect_source('add_column(:products, :type, :text)') - expect(offenses).to be_empty - end -end