Commit 53a4a4b5 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '277422-update-gitlab-styles-5.1.0' into 'master'

[RUN AS-IF-FOSS] Update gitlab-styles to 5.1.0

See merge request gitlab-org/gitlab!47408
parents 486ea8e0 e98d88ef
......@@ -359,11 +359,6 @@ RSpec/EmptyExampleGroup:
- 'ee/spec/services/personal_access_tokens/revoke_invalid_tokens_spec.rb'
- 'spec/services/projects/prometheus/alerts/notify_service_spec.rb'
# Offense count: 176
# Cop supports --auto-correct.
RSpec/EmptyLineAfterLetBlock:
Enabled: false
# Offense count: 1310
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
......
......@@ -370,7 +370,7 @@ group :development, :test do
gem 'spring', '~> 2.1.0'
gem 'spring-commands-rspec', '~> 1.0.4'
gem 'gitlab-styles', '~> 5.0.0', require: false
gem 'gitlab-styles', '~> 5.1.0', require: false
gem 'scss_lint', '~> 0.59.0', require: false
gem 'haml_lint', '~> 0.36.0', require: false
......
......@@ -449,7 +449,7 @@ GEM
gitlab-puma (>= 2.7, < 5)
gitlab-sidekiq-fetcher (0.5.2)
sidekiq (~> 5)
gitlab-styles (5.0.0)
gitlab-styles (5.1.0)
rubocop (~> 0.89.1)
rubocop-gitlab-security (~> 0.1.0)
rubocop-performance (~> 1.8.1)
......@@ -1355,7 +1355,7 @@ DEPENDENCIES
gitlab-puma (~> 4.3.3.gitlab.2)
gitlab-puma_worker_killer (~> 0.1.1.gitlab.1)
gitlab-sidekiq-fetcher (= 0.5.2)
gitlab-styles (~> 5.0.0)
gitlab-styles (~> 5.1.0)
gitlab_chronic_duration (~> 0.10.6.2)
gitlab_omniauth-ldap (~> 2.1.1)
gon (~> 6.2)
......
......@@ -9,6 +9,7 @@ RSpec.describe Analytics::MergeRequestMetricsCalculator do
let_it_be(:merge_request_note) do
create(:diff_note_on_merge_request, noteable: merge_request, project: merge_request.source_project, author: create(:user))
end
let_it_be(:merge_request_author_note) do
create(:diff_note_on_merge_request,
noteable: merge_request,
......@@ -17,6 +18,7 @@ RSpec.describe Analytics::MergeRequestMetricsCalculator do
created_at: 11.months.ago
)
end
let_it_be(:merge_request_bot_note) do
create(:diff_note_on_merge_request,
noteable: merge_request,
......
......@@ -9,6 +9,7 @@ RSpec.describe Gitlab::Audit::Events::Preloader do
create(:audit_event, created_at: 1.day.ago)
]
end
let(:audit_events_relation) { AuditEvent.where(id: audit_events.map(&:id)) }
describe '.preload!' do
......
......@@ -15,6 +15,7 @@ RSpec.describe Gitlab::Checks::MatchingMergeRequest do
target_branch: target_branch,
in_progress_merge_commit_sha: newrev)
end
let(:total_counter) { subject.send(:total_counter) }
let(:stale_counter) { subject.send(:stale_counter) }
......
......@@ -18,6 +18,7 @@ RSpec.describe AuditEvent, type: :model do
let_it_be(:details) do
{ author_name: 'Kungfu Panda', entity_path: 'gitlab-org/gitlab', target_details: 'Project X', target_type: 'User' }
end
let_it_be(:event) { create(:project_audit_event, details: details, entity_path: nil, target_details: nil) }
it 'sets author_name' do
......
......@@ -27,6 +27,7 @@ RSpec.describe Ci::DailyBuildGroupReportResult do
let_it_be(:new_build_group_report_result) do
create(:ci_daily_build_group_report_result, project: project, group_name: 'cobertura', coverage: 66.0)
end
let_it_be(:build_group_report_result_2) do
create(:ci_daily_build_group_report_result, project: project_2, group_name: 'rspec', coverage: 78.0)
end
......
......@@ -644,6 +644,7 @@ RSpec.describe Vulnerability do
project: project
)
end
let_it_be(:dismissal_feedback) do
create(
:vulnerability_feedback,
......
......@@ -543,6 +543,7 @@ RSpec.describe Vulnerabilities::Finding do
project: project
)
end
let_it_be(:feedback) do
create(
:vulnerability_feedback,
......
......@@ -10,6 +10,7 @@ RSpec.describe API::Analytics::CodeReviewAnalytics do
let_it_be(:reporter) do
create(:user).tap { |u| project.add_reporter(u) }
end
let_it_be(:guest) do
create(:user).tap { |u| project.add_guest(u) }
end
......
......@@ -241,6 +241,7 @@ RSpec.describe 'Query.vulnerabilities.location' do
raw_metadata: metadata.to_json
)
end
it 'returns the URL where the vulnerability was found' do
location = subject.first['location']
......
......@@ -7,6 +7,7 @@ RSpec.describe API::Issues, :mailer do
let_it_be(:project) do
create(:project, :public, creator_id: user.id, namespace: user.namespace)
end
let_it_be(:group) { create(:group) }
let_it_be(:epic) { create(:epic, group: group) }
let_it_be(:group_project) { create(:project, :public, creator_id: user.id, namespace: group) }
......
......@@ -91,6 +91,7 @@ RSpec.describe HistoricalUserData::CsvService do
let_it_be(:historical_datum) do
create(:historical_data, recorded_at: license_start_date, active_user_count: 1)
end
let_it_be(:historical_datum2) do
create(:historical_data, recorded_at: license_start_date + 1.day, active_user_count: 2)
end
......
# frozen_string_literal: true
module RuboCop
module Cop
# Ensures a line break around conditional blocks.
#
# @example
# # bad
# do_something
# if condition
# do_extra_stuff
# end
# do_something_more
#
# # good
# do_something
#
# if condition
# do_extra_stuff
# end
#
# do_something_more
#
# # bad
# do_something
# unless condition
# do_extra_stuff
# end
#
# do_something_more
#
# # good
# def a_method
# if condition
# do_something
# end
# end
#
# # good
# on_block do
# if condition
# do_something
# end
# end
class LineBreakAroundConditionalBlock < RuboCop::Cop::Cop
include RangeHelp
MSG = 'Add a line break around conditional blocks'
def on_if(node)
# This cop causes errors in haml files, so let's skip those
return if in_haml?(node)
return if node.single_line?
return unless node.if? || node.unless?
add_offense(node, location: :expression, message: MSG) unless previous_line_valid?(node)
add_offense(node, location: :expression, message: MSG) unless last_line_valid?(node)
end
def autocorrect(node)
lambda do |corrector|
line = range_by_whole_lines(node.source_range)
unless previous_line_valid?(node)
corrector.insert_before(line, "\n")
end
unless last_line_valid?(node)
corrector.insert_after(line, "\n")
end
end
end
private
def previous_line_valid?(node)
previous_line(node).empty? ||
start_clause_line?(previous_line(node)) ||
block_start?(previous_line(node)) ||
begin_line?(previous_line(node)) ||
assignment_line?(previous_line(node)) ||
rescue_line?(previous_line(node))
end
def last_line_valid?(node)
last_line(node).empty? ||
end_line?(last_line(node)) ||
end_clause_line?(last_line(node))
end
def previous_line(node)
processed_source[node.loc.line - 2]
end
def last_line(node)
processed_source[node.loc.last_line]
end
def start_clause_line?(line)
line =~ /^\s*(def|=end|#|module|class|if|unless|else|elsif|ensure|when)/
end
def end_clause_line?(line)
line =~ /^\s*(#|rescue|else|elsif|when)/
end
def begin_line?(line)
# an assignment followed by a begin or ust a begin
line =~ /^\s*(@?(\w|\|+|=|\[|\]|\s)+begin|begin)/
end
def assignment_line?(line)
line =~ /^\s*.*=/
end
def rescue_line?(line)
line =~ /^\s*rescue/
end
def block_start?(line)
line.match(/ (do|{)( \|.*?\|)?\s?(#.+)?\z/)
end
def end_line?(line)
line =~ /^\s*(end|})/
end
def in_haml?(node)
node.location.expression.source_buffer.name.end_with?('.haml.rb')
end
end
end
end
......@@ -155,6 +155,7 @@ RSpec.describe MetricsDashboard do
'.gitlab/dashboards/errors.yml' => dashboard_yml
}
end
let_it_be(:project) { create(:project, :custom_repo, files: dashboards) }
before do
......
......@@ -83,6 +83,7 @@ RSpec.describe 'Group milestones' do
description: 'Lorem Ipsum is simply dummy text'
)
end
let_it_be(:active_project_milestone2) { create(:milestone, project: other_project, state: 'active', title: 'v1.1') }
let_it_be(:closed_project_milestone1) { create(:milestone, project: project, state: 'closed', title: 'v2.0') }
let_it_be(:closed_project_milestone2) { create(:milestone, project: other_project, state: 'closed', title: 'v2.0') }
......
......@@ -13,6 +13,7 @@ RSpec.describe MergeRequests::ByApprovalsFinder do
create(:approval, merge_request: mr, user: first_user)
end
end
let_it_be(:merge_request_with_both_approvals) do
create(:merge_request).tap do |mr|
create(:approval, merge_request: mr, user: first_user)
......
......@@ -14,6 +14,7 @@ RSpec.describe Resolvers::MergeRequestPipelinesResolver do
sha: merge_request.diff_head_sha
)
end
let_it_be(:other_project_pipeline) { create(:ci_pipeline, project: merge_request.source_project, ref: 'other-ref') }
let_it_be(:other_pipeline) { create(:ci_pipeline) }
let(:current_user) { create(:user) }
......
......@@ -9,6 +9,7 @@ RSpec.describe MarkupHelper do
project.add_maintainer(user)
user
end
let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let_it_be(:snippet) { create(:project_snippet, project: project) }
......
......@@ -12,6 +12,7 @@ RSpec.describe TodosHelper do
project: issue.project,
note: 'I am note, hear me roar')
end
let_it_be(:design_todo) do
create(:todo, :mentioned,
user: user,
......@@ -20,6 +21,7 @@ RSpec.describe TodosHelper do
author: author,
note: note)
end
let_it_be(:alert_todo) do
alert = create(:alert_management_alert, iid: 1001)
create(:todo, target: alert)
......
......@@ -29,9 +29,11 @@ RSpec.describe Banzai::ReferenceParser::DesignParser do
let_it_be(:other_project_link) do
design_link(create(:design, :with_versions))
end
let_it_be(:public_link) do
design_link(create(:design, :with_versions, issue: create(:issue, project: public_project)))
end
let_it_be(:public_but_confidential_link) do
design_link(create(:design, :with_versions, issue: create(:issue, :confidential, project: public_project)))
end
......
......@@ -19,6 +19,7 @@ RSpec.describe Gitlab::ImportExport::JSON::StreamingSerializer do
group: group,
approvals_before_merge: 1)
end
let_it_be(:issue) do
create(:issue,
assignees: [user],
......
......@@ -973,6 +973,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do
create(:project, :builds_disabled, :issues_disabled,
{ name: 'project', path: 'project' })
end
let(:shared) { project.import_export_shared }
let(:project_tree_restorer) { described_class.new(user: user, shared: shared, project: project) }
......
......@@ -32,6 +32,7 @@ RSpec.describe RelativePositioning::Mover do
let_it_be(:one_free_space_set) do
indices.drop(1).map { |iid| create(:issue, project: one_free_space, iid: iid.succ) }
end
let_it_be(:three_sibs_set) do
[1, 2, 3].map { |iid| create(:issue, iid: iid, project: three_sibs) }
end
......
......@@ -13,6 +13,7 @@ RSpec.describe ::API::Admin::InstanceClusters do
user: admin_user,
projects: [project])
end
let(:project_cluster_id) { project_cluster.id }
describe "GET /admin/clusters" do
......
......@@ -17,6 +17,7 @@ RSpec.describe 'Getting Metrics Dashboard Annotations' do
let_it_be(:to_old_annotation) do
create(:metrics_dashboard_annotation, environment: environment, starting_at: Time.parse(from).advance(minutes: -5), dashboard_path: path)
end
let_it_be(:to_new_annotation) do
create(:metrics_dashboard_annotation, environment: environment, starting_at: to.advance(minutes: 5), dashboard_path: path)
end
......
......@@ -20,6 +20,7 @@ RSpec.describe 'Updating an image DiffNote' do
position_type: 'image'
)
end
let_it_be(:updated_body) { 'Updated body' }
let_it_be(:updated_width) { 50 }
let_it_be(:updated_height) { 100 }
......
......@@ -14,6 +14,7 @@ RSpec.describe 'Query.project(fullPath).issue(iid).designCollection.version(sha)
create(:design_version, issue: issue,
created_designs: create_list(:design, 3, issue: issue))
end
let_it_be(:version) do
create(:design_version, issue: issue,
modified_designs: old_version.designs,
......
......@@ -11,12 +11,15 @@ RSpec.describe 'Getting versions related to an issue' do
let_it_be(:version_a) do
create(:design_version, issue: issue)
end
let_it_be(:version_b) do
create(:design_version, issue: issue)
end
let_it_be(:version_c) do
create(:design_version, issue: issue)
end
let_it_be(:version_d) do
create(:design_version, issue: issue)
end
......
......@@ -19,6 +19,7 @@ RSpec.describe 'query Jira import data' do
total_issue_count: 4
)
end
let_it_be(:jira_import2) do
create(
:jira_import_state, :finished,
......@@ -31,6 +32,7 @@ RSpec.describe 'query Jira import data' do
total_issue_count: 3
)
end
let(:query) do
%(
query {
......
......@@ -19,6 +19,7 @@ RSpec.describe 'GroupMember' do
}
HEREDOC
end
let_it_be(:query) do
graphql_query_for('user', { id: member.user.to_global_id.to_s }, query_graphql_field("groupMemberships", {}, fields))
end
......
......@@ -19,6 +19,7 @@ RSpec.describe 'ProjectMember' do
}
HEREDOC
end
let_it_be(:query) do
graphql_query_for('user', { id: member.user.to_global_id.to_s }, query_graphql_field("projectMemberships", {}, fields))
end
......
......@@ -32,22 +32,27 @@ RSpec.describe 'getting user information' do
create(:merge_request, :unique_branches, :unique_author,
source_project: project_a, assignees: [user])
end
let_it_be(:assigned_mr_b) do
create(:merge_request, :unique_branches, :unique_author,
source_project: project_b, assignees: [user])
end
let_it_be(:assigned_mr_c) do
create(:merge_request, :unique_branches, :unique_author,
source_project: project_b, assignees: [user])
end
let_it_be(:authored_mr) do
create(:merge_request, :unique_branches,
source_project: project_a, author: user)
end
let_it_be(:authored_mr_b) do
create(:merge_request, :unique_branches,
source_project: project_b, author: user)
end
let_it_be(:authored_mr_c) do
create(:merge_request, :unique_branches,
source_project: project_b, author: user)
......
......@@ -54,11 +54,13 @@ RSpec.describe API::Issues do
let_it_be(:label) do
create(:label, title: 'label', color: '#FFAABB', project: project)
end
let!(:label_link) { create(:label_link, label: label, target: issue) }
let(:milestone) { create(:milestone, title: '1.0.0', project: project) }
let_it_be(:empty_milestone) do
create(:milestone, title: '2.0.0', project: project)
end
let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) }
let(:no_milestone_title) { 'None' }
......
......@@ -54,11 +54,13 @@ RSpec.describe API::Issues do
let_it_be(:label) do
create(:label, title: 'label', color: '#FFAABB', project: project)
end
let!(:label_link) { create(:label_link, label: label, target: issue) }
let(:milestone) { create(:milestone, title: '1.0.0', project: project) }
let_it_be(:empty_milestone) do
create(:milestone, title: '2.0.0', project: project)
end
let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) }
let(:no_milestone_title) { 'None' }
......
......@@ -53,11 +53,13 @@ RSpec.describe API::Issues do
let_it_be(:label) do
create(:label, title: 'label', color: '#FFAABB', project: project)
end
let!(:label_link) { create(:label_link, label: label, target: issue) }
let(:milestone) { create(:milestone, title: '1.0.0', project: project) }
let_it_be(:empty_milestone) do
create(:milestone, title: '2.0.0', project: project)
end
let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) }
let(:no_milestone_title) { 'None' }
......
......@@ -32,6 +32,7 @@ RSpec.describe 'Projects::Metrics::Dashboards::BuilderController' do
label: Legend Label
YML
end
let_it_be(:invalid_panel_yml) do
<<~YML
---
......
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../../rubocop/cop/line_break_around_conditional_block'
RSpec.describe RuboCop::Cop::LineBreakAroundConditionalBlock, type: :rubocop do
include CopHelper
subject(:cop) { described_class.new }
shared_examples 'examples with conditional' do |conditional|
it "flags violation for #{conditional} without line break before" do
source = <<~RUBY
do_something
#{conditional} condition
do_something_more
end
RUBY
inspect_source(source)
expect(cop.offenses.size).to eq(1)
offense = cop.offenses.first
expect(offense.line).to eq(2)
expect(cop.highlights).to eq(["#{conditional} condition\n do_something_more\nend"])
expect(offense.message).to eq('Add a line break around conditional blocks')
end
it "flags violation for #{conditional} without line break after" do
source = <<~RUBY
#{conditional} condition
do_something
end
do_something_more
RUBY
inspect_source(source)
expect(cop.offenses.size).to eq(1)
offense = cop.offenses.first
expect(offense.line).to eq(1)
expect(cop.highlights).to eq(["#{conditional} condition\n do_something\nend"])
expect(offense.message).to eq('Add a line break around conditional blocks')
end
it "doesn't flag violation for #{conditional} with line break before and after" do
source = <<~RUBY
#{conditional} condition
do_something
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by a method definition" do
source = <<~RUBY
def a_method
#{conditional} condition
do_something
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by a class definition" do
source = <<~RUBY
class Foo
#{conditional} condition
do_something
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by a module definition" do
source = <<~RUBY
module Foo
#{conditional} condition
do_something
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by a begin definition" do
source = <<~RUBY
begin
#{conditional} condition
do_something
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by an assign/begin definition" do
source = <<~RUBY
@project ||= begin
#{conditional} condition
do_something
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by a block definition" do
source = <<~RUBY
on_block(param_a) do |item|
#{conditional} condition
do_something
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by a block definition with a comment" do
source = <<~RUBY
on_block(param_a) do |item| # a short comment
#{conditional} condition
do_something
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by a block definition using brackets" do
source = <<~RUBY
on_block(param_a) { |item|
#{conditional} condition
do_something
end
}
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by a comment" do
source = <<~RUBY
# a short comment
#{conditional} condition
do_something
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by an assignment" do
source = <<~RUBY
foo =
#{conditional} condition
do_something
else
do_something_more
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by a multiline comment" do
source = <<~RUBY
=begin
a multiline comment
=end
#{conditional} condition
do_something
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by another conditional" do
source = <<~RUBY
#{conditional} condition_a
#{conditional} condition_b
do_something
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by an else" do
source = <<~RUBY
if condition_a
do_something
else
#{conditional} condition_b
do_something_extra
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by an elsif" do
source = <<~RUBY
if condition_a
do_something
elsif condition_b
#{conditional} condition_c
do_something_extra
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by an ensure" do
source = <<~RUBY
def a_method
ensure
#{conditional} condition_c
do_something_extra
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by a when" do
source = <<~RUBY
case field
when value
#{conditional} condition_c
do_something_extra
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} followed by a comment" do
source = <<~RUBY
#{conditional} condition
do_something
end
# a short comment
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} followed by an end" do
source = <<~RUBY
class Foo
#{conditional} condition
do_something
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} followed by an else" do
source = <<~RUBY
#{conditional} condition_a
#{conditional} condition_b
do_something
end
else
do_something_extra
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} followed by a when" do
source = <<~RUBY
case
when condition_a
#{conditional} condition_b
do_something
end
when condition_c
do_something_extra
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} followed by an elsif" do
source = <<~RUBY
if condition_a
#{conditional} condition_b
do_something
end
elsif condition_c
do_something_extra
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} preceded by a rescue" do
source = <<~RUBY
def a_method
do_something
rescue
#{conditional} condition
do_something
end
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} followed by a rescue" do
source = <<~RUBY
def a_method
#{conditional} condition
do_something
end
rescue
do_something_extra
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "autocorrects #{conditional} without line break before" do
source = <<~RUBY
do_something
#{conditional} condition
do_something_more
end
RUBY
autocorrected = autocorrect_source(source)
expected_source = <<~RUBY
do_something
#{conditional} condition
do_something_more
end
RUBY
expect(autocorrected).to eql(expected_source)
end
it "autocorrects #{conditional} without line break after" do
source = <<~RUBY
#{conditional} condition
do_something
end
do_something_more
RUBY
autocorrected = autocorrect_source(source)
expected_source = <<~RUBY
#{conditional} condition
do_something
end
do_something_more
RUBY
expect(autocorrected).to eql(expected_source)
end
it "autocorrects #{conditional} without line break before and after" do
source = <<~RUBY
do_something
#{conditional} condition
do_something_more
end
do_something_extra
RUBY
autocorrected = autocorrect_source(source)
expected_source = <<~RUBY
do_something
#{conditional} condition
do_something_more
end
do_something_extra
RUBY
expect(autocorrected).to eql(expected_source)
end
end
%w[if unless].each do |example|
it_behaves_like 'examples with conditional', example
end
it "doesn't flag violation for if with elsif" do
source = <<~RUBY
if condition
do_something
elsif another_condition
do_something_more
end
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
end
......@@ -18,6 +18,7 @@ RSpec.describe Admin::PropagateIntegrationService do
let_it_be(:inherited_integration) do
create(:jira_service, project: create(:project), inherit_from_id: instance_integration.id)
end
let_it_be(:different_type_inherited_integration) do
create(:redmine_service, project: project, inherit_from_id: instance_integration.id)
end
......
......@@ -12,6 +12,7 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
'generatorURL' => 'http://8d467bd4607a:9090/graph?g0.expr=vector%281%29&g0.tab=1'
}
end
let_it_be(:generic_alert, reload: true) { create(:alert_management_alert, :triggered, project: project, payload: payload) }
let_it_be(:prometheus_alert, reload: true) { create(:alert_management_alert, :triggered, :prometheus, project: project, payload: payload) }
let(:alert) { generic_alert }
......
......@@ -11,6 +11,7 @@ RSpec.describe Metrics::Dashboard::PanelPreviewService do
title: test panel
YML
end
let_it_be(:dashboard) do
{
panel_groups: [
......
......@@ -41,6 +41,7 @@ RSpec.describe Notes::DestroyService do
create(:merge_request, source_project: repo_project,
target_project: repo_project)
end
let_it_be(:note) do
create(:diff_note_on_merge_request, project: repo_project,
noteable: merge_request)
......
......@@ -848,6 +848,7 @@ RSpec.describe NotificationService, :mailer do
noteable: design,
note: "Hello #{member_and_mentioned.to_reference}, G'day #{non_member_and_mentioned.to_reference}")
end
let_it_be(:note_2) do
create(:diff_note_on_design, noteable: design, author: member_and_author_of_second_note)
end
......
......@@ -18,12 +18,14 @@ RSpec.shared_context 'four designs in three versions' do
modified_designs: [],
deleted_designs: [])
end
let_it_be(:second_version) do
create(:design_version, issue: issue,
created_designs: [design_b, design_c, design_d],
modified_designs: [design_a],
deleted_designs: [])
end
let_it_be(:third_version) do
create(:design_version, issue: issue,
created_designs: [],
......
......@@ -23,6 +23,7 @@ RSpec.shared_context 'MergeRequestsFinder multiple projects with merge requests
# We cannot use `let_it_be` here otherwise we get:
# Failure/Error: allow(RepositoryForkWorker).to receive(:perform_async).and_return(true)
# The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported.
let!(:project2) do
allow_gitaly_n_plus_1 do
fork_project(project1, user)
......@@ -40,9 +41,11 @@ RSpec.shared_context 'MergeRequestsFinder multiple projects with merge requests
let_it_be(:project4, reload: true) do
allow_gitaly_n_plus_1 { create(:project, :repository, group: subgroup) }
end
let_it_be(:project5, reload: true) do
allow_gitaly_n_plus_1 { create(:project, group: subgroup) }
end
let_it_be(:project6, reload: true) do
allow_gitaly_n_plus_1 { create(:project, group: subgroup) }
end
......
......@@ -116,6 +116,7 @@ RSpec.shared_context 'Jira projects request context' do
"uuid": "14935009-f8aa-481e-94bc-f7251f320b0e"
}]'
end
let_it_be(:empty_jira_projects_json) do
'{
"self": "https://your-domain.atlassian.net/rest/api/2/project/search?startAt=0&maxResults=2",
......
......@@ -4,6 +4,6 @@
source 'https://rubygems.org'
gem 'overcommit'
gem 'gitlab-styles', '~> 5.0.0', require: false
gem 'gitlab-styles', '~> 5.1.0', require: false
gem 'scss_lint', '~> 0.56.0', require: false
gem 'haml_lint', '~> 0.34.0', require: false
......@@ -11,7 +11,7 @@ GEM
childprocess (3.0.0)
concurrent-ruby (1.1.7)
ffi (1.12.2)
gitlab-styles (5.0.0)
gitlab-styles (5.1.0)
rubocop (~> 0.89.1)
rubocop-gitlab-security (~> 0.1.0)
rubocop-performance (~> 1.8.1)
......@@ -79,7 +79,7 @@ GEM
temple (0.8.2)
thread_safe (0.3.6)
tilt (2.0.10)
tzinfo (1.2.7)
tzinfo (1.2.8)
thread_safe (~> 0.1)
unicode-display_width (1.7.0)
zeitwerk (2.4.1)
......@@ -88,7 +88,7 @@ PLATFORMS
ruby
DEPENDENCIES
gitlab-styles (~> 5.0.0)
gitlab-styles (~> 5.1.0)
haml_lint (~> 0.34.0)
overcommit
scss_lint (~> 0.56.0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment