diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-11 00:09:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-11 00:09:29 +0300 |
commit | 4f584f7b63332ac0ffc5e533a1dde89b0c365728 (patch) | |
tree | 7654fbc027d2038a3fc140281437d99c8b1bd7b7 /rubocop | |
parent | 82ea71eb4f4a7cc5583ddbc3d6ab2444b3d4213a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r-- | rubocop/cop/migration/add_limit_to_text_columns.rb | 3 | ||||
-rw-r--r-- | rubocop/cop/migration/prevent_strings.rb | 3 | ||||
-rw-r--r-- | rubocop/migration_helpers.rb | 10 |
3 files changed, 16 insertions, 0 deletions
diff --git a/rubocop/cop/migration/add_limit_to_text_columns.rb b/rubocop/cop/migration/add_limit_to_text_columns.rb index 15c28bb9266..b578e73f19e 100644 --- a/rubocop/cop/migration/add_limit_to_text_columns.rb +++ b/rubocop/cop/migration/add_limit_to_text_columns.rb @@ -39,6 +39,9 @@ module RuboCop private def text_operation?(node) + # Don't complain about text arrays + return false if array_column?(node) + modifier = node.children[0] migration_method = node.children[1] diff --git a/rubocop/cop/migration/prevent_strings.rb b/rubocop/cop/migration/prevent_strings.rb index 25c00194698..bfeabd2c78d 100644 --- a/rubocop/cop/migration/prevent_strings.rb +++ b/rubocop/cop/migration/prevent_strings.rb @@ -33,6 +33,9 @@ module RuboCop private def string_operation?(node) + # Don't complain about string arrays + return false if array_column?(node) + modifier = node.children[0] migration_method = node.children[1] diff --git a/rubocop/migration_helpers.rb b/rubocop/migration_helpers.rb index b5e8c853f99..43f6387efd7 100644 --- a/rubocop/migration_helpers.rb +++ b/rubocop/migration_helpers.rb @@ -34,6 +34,16 @@ module RuboCop File.basename(node.location.expression.source_buffer.name).split('_').first.to_i end + # Returns true if a column definition is for an array + # rubocop:disable Lint/BooleanSymbol + def array_column?(node) + node.each_descendant(:pair).any? do |pair_node| + pair_node.child_nodes[0].value == :array && # Searching for a (pair (sym :array) (true)) node + pair_node.child_nodes[1].type == :true # RuboCop::AST::Node uses symbols for types, even when that is a :true + end + end + # rubocop:enable Lint/BooleanSymbol + private def dirname(node) |