diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-27 03:12:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-27 03:12:17 +0300 |
commit | dfc8a99695e16feffcc811a536e58e2c9be75ce2 (patch) | |
tree | 34307394a3bde02dc1e8a18f94c5958a24cc91d5 /spec/tooling | |
parent | 277496b843d3c14cfd48286b1718b03775d83bbc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/tooling')
-rw-r--r-- | spec/tooling/danger/rubocop_inline_disable_suggestion_spec.rb | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/spec/tooling/danger/rubocop_inline_disable_suggestion_spec.rb b/spec/tooling/danger/rubocop_inline_disable_suggestion_spec.rb index 950c313b9b9..6b9ff667564 100644 --- a/spec/tooling/danger/rubocop_inline_disable_suggestion_spec.rb +++ b/spec/tooling/danger/rubocop_inline_disable_suggestion_spec.rb @@ -15,10 +15,15 @@ RSpec.describe Tooling::Danger::RubocopInlineDisableSuggestion, feature_category let(:template) do <<~SUGGESTION_MARKDOWN.chomp + ```suggestion + %<suggested_line>s + ``` Consider removing this inline disabling and adhering to the rubocop rule. - If that isn't possible, please provide context as a reply for reviewers. - See [rubocop best practices](https://docs.gitlab.com/ee/development/rubocop_development_guide.html). + + If that isn't possible, please provide the reason as a code comment in the + same line where the rule is disabled separated by ` -- `. + See [rubocop best practices](https://docs.gitlab.com/ee/development/rubocop_development_guide.html#disabling-rules-inline). ---- @@ -77,6 +82,9 @@ RSpec.describe Tooling::Danger::RubocopInlineDisableSuggestion, feature_category def show_my_new_dot?(project, namespace) return false unless ::Gitlab.com? # rubocop: todo Gitlab/AvoidGitlabInstanceChecks -- Reason for disabling + thatsfine = "".dup # rubocop:disable Lint/UselessAssignment,Performance/UnfreezeString -- That's OK + me = "".dup # rubocop:disable Lint/UselessAssignment,Performance/UnfreezeString + test = "".dup # rubocop:disable Lint/UselessAssignment, Performance/UnfreezeString return false if notification_dot_acknowledged? show_out_of_pipeline_minutes_notification?(project, namespace) @@ -102,6 +110,8 @@ RSpec.describe Tooling::Danger::RubocopInlineDisableSuggestion, feature_category + return false unless ::Gitlab.com? # rubocop:todo Gitlab/AvoidGitlabInstanceChecks + return false unless ::Gitlab.com? # rubocop: todo Gitlab/AvoidGitlabInstanceChecks + return false unless ::Gitlab.com? # rubocop: todo Gitlab/AvoidGitlabInstanceChecks -- Reason for disabling + + me = "".dup # rubocop:disable Lint/UselessAssignment,Performance/UnfreezeString + + test = "".dup # rubocop:disable Lint/UselessAssignment, Performance/UnfreezeString + return false unless ::Gitlab.com? # rubocop: todo Gitlab/AvoidGitlabInstanceChecks -- DIFF end @@ -119,8 +129,12 @@ RSpec.describe Tooling::Danger::RubocopInlineDisableSuggestion, feature_category end it 'adds comments at the correct lines', :aggregate_failures do - [3, 7, 13, 20, 27, 34, 41, 55].each do |line_number| - expect(rubocop).to receive(:markdown).with(template, file: filename, line: line_number) + [3, 7, 13, 20, 27, 34, 41, 50, 51, 58].each do |line_number| + existing_line = file_lines[line_number - 1].sub(/ --\s*$/, '') + suggested_line = "#{existing_line} -- TODO: Reason why the rule must be disabled" + comment = format(template, suggested_line: suggested_line) + + expect(rubocop).to receive(:markdown).with(comment, file: filename, line: line_number) end rubocop.add_suggestions_for(filename) |