Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-20 02:18:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-20 02:18:09 +0300
commit6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch)
treedc4d20fe6064752c0bd323187252c77e0a89144b /rubocop/cop/gitlab/finder_with_find_by.rb
parent9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff)
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'rubocop/cop/gitlab/finder_with_find_by.rb')
-rw-r--r--rubocop/cop/gitlab/finder_with_find_by.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/rubocop/cop/gitlab/finder_with_find_by.rb b/rubocop/cop/gitlab/finder_with_find_by.rb
index 8fa9fe4a2f9..ac454398f9c 100644
--- a/rubocop/cop/gitlab/finder_with_find_by.rb
+++ b/rubocop/cop/gitlab/finder_with_find_by.rb
@@ -3,8 +3,10 @@
module RuboCop
module Cop
module Gitlab
- class FinderWithFindBy < RuboCop::Cop::Cop
- FIND_PATTERN = /\Afind(_by\!?)?\z/.freeze
+ class FinderWithFindBy < RuboCop::Cop::Base
+ extend RuboCop::Cop::AutoCorrector
+
+ FIND_PATTERN = /\Afind(_by!?)?\z/.freeze
ALLOWED_MODULES = ['FinderMethods'].freeze
def message(used_method)
@@ -18,13 +20,9 @@ module RuboCop
end
def on_send(node)
- if find_on_execute?(node) && !allowed_module?(node)
- add_offense(node, location: :selector, message: message(node.method_name))
- end
- end
+ return unless find_on_execute?(node) && !allowed_module?(node)
- def autocorrect(node)
- lambda do |corrector|
+ add_offense(node.loc.selector, message: message(node.method_name)) do |corrector|
upto_including_execute = node.descendants.first.source_range
before_execute = node.descendants[1].source_range
range_to_remove = node.source_range