diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-18 21:08:27 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-18 21:08:27 +0000 |
commit | 3b67d92c35cfe77b66668c303907c8b465d479b7 (patch) | |
tree | 192cd378ac69dbc4530b838394a06b2476fccc32 /rubocop | |
parent | 6c0a6dd200eb62a82e2af9fb92f466a77b2b39f2 (diff) | |
download | gitlab-ce-3b67d92c35cfe77b66668c303907c8b465d479b7.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r-- | rubocop/cop/qa/duplicate_testcase_link.rb | 46 | ||||
-rw-r--r-- | rubocop/cop/qa/testcase_link_format.rb | 45 |
2 files changed, 0 insertions, 91 deletions
diff --git a/rubocop/cop/qa/duplicate_testcase_link.rb b/rubocop/cop/qa/duplicate_testcase_link.rb deleted file mode 100644 index 82549707a83..00000000000 --- a/rubocop/cop/qa/duplicate_testcase_link.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -module RuboCop - module Cop - module QA - # This cop checks for duplicate testcase links across e2e specs - # - # @example - # - # # bad - # it 'some test', testcase: '(...)/quality/test_cases/1892' - # it 'another test, testcase: '(...)/quality/test_cases/1892' - # - # # good - # it 'some test', testcase: '(...)/quality/test_cases/1892' - # it 'another test, testcase: '(...)/quality/test_cases/1894' - class DuplicateTestcaseLink < RuboCop::Cop::Cop - MESSAGE = "Don't reuse the same testcase link in different tests. Replace one of `%s`." - - @testcase_set = Set.new - - def_node_matcher :duplicate_testcase_link, <<~PATTERN - (block - (send nil? ... - ... - (hash - (pair - (sym :testcase) - (str $_))...)...)...) - PATTERN - - def on_block(node) - duplicate_testcase_link(node) do |link| - break unless self.class.duplicate?(link) - - add_offense(node, message: MESSAGE % link) - end - end - - def self.duplicate?(link) - !@testcase_set.add?(link) - end - end - end - end -end diff --git a/rubocop/cop/qa/testcase_link_format.rb b/rubocop/cop/qa/testcase_link_format.rb deleted file mode 100644 index 683098e6eec..00000000000 --- a/rubocop/cop/qa/testcase_link_format.rb +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../qa_helpers' - -module RuboCop - module Cop - module QA - # This cop checks for correct format of testcase links across e2e specs - # - # @example - # - # # bad - # it 'some test', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/557' - # it 'another test, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/2455' - # - # # good - # it 'some test', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348312' - # it 'another test, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348236' - class TestcaseLinkFormat < RuboCop::Cop::Cop - include QAHelpers - - TESTCASE_FORMAT = %r{https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/\d+}.freeze - MESSAGE = "Testcase link format incorrect. Please link a test case from the GitLab project. See: https://docs.gitlab.com/ee/development/testing_guide/end_to_end/best_practices.html#link-a-test-to-its-test-case." - - def_node_matcher :testcase_link_format, <<~PATTERN - (block - (send nil? ... - ... - (hash - (pair - (sym :testcase) - (str $_))...)...)...) - PATTERN - - def on_block(node) - return unless in_qa_file?(node) - - testcase_link_format(node) do |link| - add_offense(node, message: MESSAGE % link) unless TESTCASE_FORMAT =~ link - end - end - end - end - end -end |