diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-20 03:14:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-20 03:14:01 +0300 |
commit | d6085b68c5dcc2bd4dc884d2fa6b75831f85c883 (patch) | |
tree | 8b122dde681ec2acdde572b0d20979516c4abfa9 /rubocop | |
parent | 652d8b33ee36e9977c03d1ed7da12ddc03292cf4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r-- | rubocop/cop/static_translation_definition.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/rubocop/cop/static_translation_definition.rb b/rubocop/cop/static_translation_definition.rb index ac50fd94884..3475a2b3dca 100644 --- a/rubocop/cop/static_translation_definition.rb +++ b/rubocop/cop/static_translation_definition.rb @@ -8,11 +8,15 @@ module RuboCop TRANSLATION_METHODS = %i[_ s_ n_].freeze def_node_matcher :translation_method?, <<~PATTERN - (send _ _ str*) + (send _ _ str*) PATTERN def_node_matcher :lambda_node?, <<~PATTERN - (send _ :lambda) + (send _ :lambda) + PATTERN + + def_node_matcher :struct_constant_assignment?, <<~PATTERN + (casgn _ _ `(const _ :Struct)) PATTERN def on_send(node) @@ -27,7 +31,7 @@ module RuboCop receiver, _ = *ancestor break if lambda_node?(receiver) # translations defined in lambda nodes should be allowed - if constant_assignment?(ancestor) + if constant_assignment?(ancestor) && !struct_constant_assignment?(ancestor) add_offense(node, location: :expression) break |