Skip to content

Commit

Permalink
Allow NotNullColumn to work with method calls
Browse files Browse the repository at this point in the history
At the NotNullColumn if a method is passed as arguments for `add_column`
an error is trigger.
In this commit we check if the argument is a method and return it's name
as a String.

Fixes rubocop#997
  • Loading branch information
fidalgo committed May 4, 2023
1 parent bd5a777 commit 3f074dc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rubocop/cop/rails/not_null_column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def on_send(node)

def check_add_column(node)
add_not_null_column?(node) do |type, pairs|
return if type.value == :virtual || type.value == 'virtual'
type_value = type.send_type? ? type.method_name.to_s : type.value
return if [:virtual, 'virtual'].include?(type_value)

check_pairs(pairs)
end
Expand Down

0 comments on commit 3f074dc

Please sign in to comment.