diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ba6ee058218a7a5d41d30fd3870fdc3d14d93d7e..293c8fccf3315d69c28ac90a3b79a5c279fa54fd 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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. diff --git a/Gemfile b/Gemfile index deedaff52be87877626d7cce7c85adf3c2f51f98..a8d4bcdec75b3eb43359b9fe44f23a58b96ad52d 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 579fd2c8e88cbd2dafea33724be51c863b819705..0b6b3abb24030d0361a78623aef3d81d4c9c92c1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/ee/spec/lib/analytics/merge_request_metrics_calculator_spec.rb b/ee/spec/lib/analytics/merge_request_metrics_calculator_spec.rb index ea45c7e3896a8723c05881bba458ccbde20b9394..5353d2d7d8daed23f2be1ba63a4eedff18244636 100644 --- a/ee/spec/lib/analytics/merge_request_metrics_calculator_spec.rb +++ b/ee/spec/lib/analytics/merge_request_metrics_calculator_spec.rb @@ -9,6 +9,7 @@ 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 @@ created_at: 11.months.ago ) end + let_it_be(:merge_request_bot_note) do create(:diff_note_on_merge_request, noteable: merge_request, diff --git a/ee/spec/lib/gitlab/audit/events/preloader_spec.rb b/ee/spec/lib/gitlab/audit/events/preloader_spec.rb index 951606ab3c52c9af14678d42a853887960b830b7..dc6f482614f89a4c909b2406e7d1d8f6fc2f8cb1 100644 --- a/ee/spec/lib/gitlab/audit/events/preloader_spec.rb +++ b/ee/spec/lib/gitlab/audit/events/preloader_spec.rb @@ -9,6 +9,7 @@ create(:audit_event, created_at: 1.day.ago) ] end + let(:audit_events_relation) { AuditEvent.where(id: audit_events.map(&:id)) } describe '.preload!' do diff --git a/ee/spec/lib/gitlab/checks/matching_merge_request_spec.rb b/ee/spec/lib/gitlab/checks/matching_merge_request_spec.rb index c3d03d5173d5c253e8fa792dbaf781f3a42a8186..94ecb10eb624ca06c98838ecbbad7e72579ff9a6 100644 --- a/ee/spec/lib/gitlab/checks/matching_merge_request_spec.rb +++ b/ee/spec/lib/gitlab/checks/matching_merge_request_spec.rb @@ -15,6 +15,7 @@ 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) } diff --git a/ee/spec/models/audit_event_spec.rb b/ee/spec/models/audit_event_spec.rb index e490b10a2c66763311016d1d13e3f2621ed97ae2..73b8b0b3460cbaa45147cddc406ce0290e7540dd 100644 --- a/ee/spec/models/audit_event_spec.rb +++ b/ee/spec/models/audit_event_spec.rb @@ -18,6 +18,7 @@ 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 diff --git a/ee/spec/models/ci/daily_build_group_report_result_spec.rb b/ee/spec/models/ci/daily_build_group_report_result_spec.rb index 4922e5b74c7b407bc36adbdf31ff0e504df46f09..d08f54aea22a076249984a84d78513f25e9ca052 100644 --- a/ee/spec/models/ci/daily_build_group_report_result_spec.rb +++ b/ee/spec/models/ci/daily_build_group_report_result_spec.rb @@ -27,6 +27,7 @@ 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 diff --git a/ee/spec/models/ee/vulnerability_spec.rb b/ee/spec/models/ee/vulnerability_spec.rb index 9ee80d753342fb6a8788df90d8a5b8a62c63ef4f..7803e8e57ae499409c588de275a52a8eba4cfb3e 100644 --- a/ee/spec/models/ee/vulnerability_spec.rb +++ b/ee/spec/models/ee/vulnerability_spec.rb @@ -634,6 +634,7 @@ project: project ) end + let_it_be(:dismissal_feedback) do create( :vulnerability_feedback, diff --git a/ee/spec/models/vulnerabilities/finding_spec.rb b/ee/spec/models/vulnerabilities/finding_spec.rb index bacc09cc46765adcd166e1b211d8dda6a4d5d960..93732bd7c37009ef9cf8525abcf3c25803bab2dc 100644 --- a/ee/spec/models/vulnerabilities/finding_spec.rb +++ b/ee/spec/models/vulnerabilities/finding_spec.rb @@ -543,6 +543,7 @@ project: project ) end + let_it_be(:feedback) do create( :vulnerability_feedback, diff --git a/ee/spec/requests/api/analytics/code_review_analytics_spec.rb b/ee/spec/requests/api/analytics/code_review_analytics_spec.rb index 22a077128833fed9ff3d70ad5a5e6902b1d6bc27..eabc6af3dca984eaa089d2e1e610e35a763b92a3 100644 --- a/ee/spec/requests/api/analytics/code_review_analytics_spec.rb +++ b/ee/spec/requests/api/analytics/code_review_analytics_spec.rb @@ -10,6 +10,7 @@ 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 diff --git a/ee/spec/requests/api/graphql/vulnerabilities/location_spec.rb b/ee/spec/requests/api/graphql/vulnerabilities/location_spec.rb index 53a2041f13904951b637891d4b0197822fa5c5ff..ba54f48c8a94070325e0bd8892dc331fa5028935 100644 --- a/ee/spec/requests/api/graphql/vulnerabilities/location_spec.rb +++ b/ee/spec/requests/api/graphql/vulnerabilities/location_spec.rb @@ -241,6 +241,7 @@ raw_metadata: metadata.to_json ) end + it 'returns the URL where the vulnerability was found' do location = subject.first['location'] diff --git a/ee/spec/requests/api/issues_spec.rb b/ee/spec/requests/api/issues_spec.rb index 85fd90fe6ff114bd60c5686f249e173b1d76ef5b..1089c81b27438e6a6327df0ae317ff90eca7064b 100644 --- a/ee/spec/requests/api/issues_spec.rb +++ b/ee/spec/requests/api/issues_spec.rb @@ -7,6 +7,7 @@ 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) } diff --git a/ee/spec/services/historical_user_data/csv_service_spec.rb b/ee/spec/services/historical_user_data/csv_service_spec.rb index babbdac7a729e012f5e34191db060ddac9f7e517..744e044c01ae3186887428b50e219340d8012f60 100644 --- a/ee/spec/services/historical_user_data/csv_service_spec.rb +++ b/ee/spec/services/historical_user_data/csv_service_spec.rb @@ -91,6 +91,7 @@ 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 diff --git a/rubocop/cop/line_break_around_conditional_block.rb b/rubocop/cop/line_break_around_conditional_block.rb deleted file mode 100644 index 2523cc162f3bc380122def17cd2b38075e6a19e0..0000000000000000000000000000000000000000 --- a/rubocop/cop/line_break_around_conditional_block.rb +++ /dev/null @@ -1,132 +0,0 @@ -# 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 diff --git a/spec/controllers/concerns/metrics_dashboard_spec.rb b/spec/controllers/concerns/metrics_dashboard_spec.rb index 8a4d8828aaa3780c4e2b3479556a4902e2d92200..83546403ce59bc9fecc920f7f240e391725ac083 100644 --- a/spec/controllers/concerns/metrics_dashboard_spec.rb +++ b/spec/controllers/concerns/metrics_dashboard_spec.rb @@ -155,6 +155,7 @@ '.gitlab/dashboards/errors.yml' => dashboard_yml } end + let_it_be(:project) { create(:project, :custom_repo, files: dashboards) } before do diff --git a/spec/features/groups/milestone_spec.rb b/spec/features/groups/milestone_spec.rb index 3ae9a2b75551160d6e2f712b25f5f40c190e8b5d..8d1008b98a68574e19591c0dadbec965c62dda00 100644 --- a/spec/features/groups/milestone_spec.rb +++ b/spec/features/groups/milestone_spec.rb @@ -83,6 +83,7 @@ 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') } diff --git a/spec/finders/merge_requests/by_approvals_finder_spec.rb b/spec/finders/merge_requests/by_approvals_finder_spec.rb index 0e1856879f156639ca84a81634d2ba68d1a55fa7..5c56e610c0b5370758ab476af4f64dd3004f4fc6 100644 --- a/spec/finders/merge_requests/by_approvals_finder_spec.rb +++ b/spec/finders/merge_requests/by_approvals_finder_spec.rb @@ -13,6 +13,7 @@ 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) diff --git a/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb b/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb index ae3097c1d9ef5e2962be603331be694cc5524d96..deb5ff584cfebbb376a72c3f9fd76b9e0fa751bb 100644 --- a/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb +++ b/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb @@ -14,6 +14,7 @@ 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) } diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb index 302ab0cc1375c3613987e5c936544e3b152a3f50..6c5855eeb91b9be7502ceb434c794a05fd7815df 100644 --- a/spec/helpers/markup_helper_spec.rb +++ b/spec/helpers/markup_helper_spec.rb @@ -9,6 +9,7 @@ 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) } diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb index 6b658a475b1ed99b5bdd0b8b2a3d6fc6eda50c82..9481d756c160493206fc9b06f62be3e86d6e15df 100644 --- a/spec/helpers/todos_helper_spec.rb +++ b/spec/helpers/todos_helper_spec.rb @@ -12,6 +12,7 @@ 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 @@ author: author, note: note) end + let_it_be(:alert_todo) do alert = create(:alert_management_alert, iid: 1001) create(:todo, target: alert) diff --git a/spec/lib/banzai/reference_parser/design_parser_spec.rb b/spec/lib/banzai/reference_parser/design_parser_spec.rb index 92d3a4aaad29b5bf1c9d905920fab8023a802fc2..a9cb2952c26200428b8fada870f24830a5293216 100644 --- a/spec/lib/banzai/reference_parser/design_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/design_parser_spec.rb @@ -29,9 +29,11 @@ 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 diff --git a/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb b/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb index 949cfb5a34d35a42fdb779c15e0dc7d49bbfd0af..762687beedb7149ca9d231f57e038100f2639909 100644 --- a/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb +++ b/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb @@ -19,6 +19,7 @@ group: group, approvals_before_merge: 1) end + let_it_be(:issue) do create(:issue, assignees: [user], diff --git a/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb index b6a396afd6162b62acbecd5d370b59a409acf718..fd3b71deb370caf8b2831b7453597207198d7030 100644 --- a/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb @@ -973,6 +973,7 @@ def match_mr1_note(content_regex) 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) } diff --git a/spec/lib/gitlab/relative_positioning/mover_spec.rb b/spec/lib/gitlab/relative_positioning/mover_spec.rb index dafd34585a8eac91376096cf69f688b576d54836..cbb15ae876d35df4aa29015dd0d791b3dc1fa543 100644 --- a/spec/lib/gitlab/relative_positioning/mover_spec.rb +++ b/spec/lib/gitlab/relative_positioning/mover_spec.rb @@ -32,6 +32,7 @@ def create_issue(pos, parent = project) 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 diff --git a/spec/requests/api/admin/instance_clusters_spec.rb b/spec/requests/api/admin/instance_clusters_spec.rb index 9d0661089a9962ffb8120e4136a90ef910d52ef2..1052080aad44368a1096dd48b36c08c466814a3a 100644 --- a/spec/requests/api/admin/instance_clusters_spec.rb +++ b/spec/requests/api/admin/instance_clusters_spec.rb @@ -13,6 +13,7 @@ user: admin_user, projects: [project]) end + let(:project_cluster_id) { project_cluster.id } describe "GET /admin/clusters" do diff --git a/spec/requests/api/graphql/metrics/dashboard/annotations_spec.rb b/spec/requests/api/graphql/metrics/dashboard/annotations_spec.rb index ca5a9165760af3d3b442e1e057ce7fec237c08d4..72ec2b8e0706055b2210c30e8da69d6cc039c4b9 100644 --- a/spec/requests/api/graphql/metrics/dashboard/annotations_spec.rb +++ b/spec/requests/api/graphql/metrics/dashboard/annotations_spec.rb @@ -17,6 +17,7 @@ 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 diff --git a/spec/requests/api/graphql/mutations/notes/update/image_diff_note_spec.rb b/spec/requests/api/graphql/mutations/notes/update/image_diff_note_spec.rb index 634ce58da967ce037cb44d38c6221ad5f1a529e6..713b26a6a9bb318ee6a22ea8d492e20878edc2bc 100644 --- a/spec/requests/api/graphql/mutations/notes/update/image_diff_note_spec.rb +++ b/spec/requests/api/graphql/mutations/notes/update/image_diff_note_spec.rb @@ -20,6 +20,7 @@ position_type: 'image' ) end + let_it_be(:updated_body) { 'Updated body' } let_it_be(:updated_width) { 50 } let_it_be(:updated_height) { 100 } diff --git a/spec/requests/api/graphql/project/issue/design_collection/version_spec.rb b/spec/requests/api/graphql/project/issue/design_collection/version_spec.rb index 1b654e660e369938f205baf12b4f13607abdd875..4bce3c7fe0fc774ba744216ffc2fd879e587d352 100644 --- a/spec/requests/api/graphql/project/issue/design_collection/version_spec.rb +++ b/spec/requests/api/graphql/project/issue/design_collection/version_spec.rb @@ -14,6 +14,7 @@ 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, diff --git a/spec/requests/api/graphql/project/issue/design_collection/versions_spec.rb b/spec/requests/api/graphql/project/issue/design_collection/versions_spec.rb index 640ac95cd86b482ab91a7d65886d803dc4223fe6..ee0085718b3f974d9a62805bb7f699f84952cae3 100644 --- a/spec/requests/api/graphql/project/issue/design_collection/versions_spec.rb +++ b/spec/requests/api/graphql/project/issue/design_collection/versions_spec.rb @@ -11,12 +11,15 @@ 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 diff --git a/spec/requests/api/graphql/project/jira_import_spec.rb b/spec/requests/api/graphql/project/jira_import_spec.rb index 1cc30b9516268af98c5de00efcec5d47f543ca60..98a3f08baa6d8b3fbeb2ea885d5ebb0cc7f88d0a 100644 --- a/spec/requests/api/graphql/project/jira_import_spec.rb +++ b/spec/requests/api/graphql/project/jira_import_spec.rb @@ -19,6 +19,7 @@ total_issue_count: 4 ) end + let_it_be(:jira_import2) do create( :jira_import_state, :finished, @@ -31,6 +32,7 @@ total_issue_count: 3 ) end + let(:query) do %( query { diff --git a/spec/requests/api/graphql/user/group_member_query_spec.rb b/spec/requests/api/graphql/user/group_member_query_spec.rb index 3a16d9622149c6d51c112e907959443efd84fea5..e47cef8cc37c3c50033a2ca3b6cf740da9d351f0 100644 --- a/spec/requests/api/graphql/user/group_member_query_spec.rb +++ b/spec/requests/api/graphql/user/group_member_query_spec.rb @@ -19,6 +19,7 @@ } 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 diff --git a/spec/requests/api/graphql/user/project_member_query_spec.rb b/spec/requests/api/graphql/user/project_member_query_spec.rb index 0790e148cafdc5c87b6a0c06db8fb95369ac05dd..01827e94d5dfcdcc1f1bffece8266b8b8c7d462d 100644 --- a/spec/requests/api/graphql/user/project_member_query_spec.rb +++ b/spec/requests/api/graphql/user/project_member_query_spec.rb @@ -19,6 +19,7 @@ } 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 diff --git a/spec/requests/api/graphql/user_query_spec.rb b/spec/requests/api/graphql/user_query_spec.rb index d64fd3868c2e146204b29597edd47b7e9a1d9335..738e120549e3d73f5a0ef7c7b7d74daaa284c220 100644 --- a/spec/requests/api/graphql/user_query_spec.rb +++ b/spec/requests/api/graphql/user_query_spec.rb @@ -32,22 +32,27 @@ 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) diff --git a/spec/requests/api/issues/get_project_issues_spec.rb b/spec/requests/api/issues/get_project_issues_spec.rb index 4228ca2d5fd055a970a1a07638e72342a3af817b..da0bae8d5e7d2149499a2d773a34ff57966c2246 100644 --- a/spec/requests/api/issues/get_project_issues_spec.rb +++ b/spec/requests/api/issues/get_project_issues_spec.rb @@ -54,11 +54,13 @@ 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' } diff --git a/spec/requests/api/issues/issues_spec.rb b/spec/requests/api/issues/issues_spec.rb index b8cbddd9ed4b1fd9f4cb5680fd010870d904a969..0fe68be027ca0f7b79adef068dee41d9f2d51ecc 100644 --- a/spec/requests/api/issues/issues_spec.rb +++ b/spec/requests/api/issues/issues_spec.rb @@ -54,11 +54,13 @@ 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' } diff --git a/spec/requests/api/issues/post_projects_issues_spec.rb b/spec/requests/api/issues/post_projects_issues_spec.rb index a7fe4d4509a37e95d64b29e2a993630a3ce29f54..5b3e23636693b5504efc667701dc587ab2a6e918 100644 --- a/spec/requests/api/issues/post_projects_issues_spec.rb +++ b/spec/requests/api/issues/post_projects_issues_spec.rb @@ -53,11 +53,13 @@ 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' } diff --git a/spec/requests/projects/metrics/dashboards/builder_spec.rb b/spec/requests/projects/metrics/dashboards/builder_spec.rb index e59ed591f638b1eae302d0c2cc96385c87bee5ba..002acca2135bdf2d7873515d33b200ea0889799d 100644 --- a/spec/requests/projects/metrics/dashboards/builder_spec.rb +++ b/spec/requests/projects/metrics/dashboards/builder_spec.rb @@ -32,6 +32,7 @@ label: Legend Label YML end + let_it_be(:invalid_panel_yml) do <<~YML --- diff --git a/spec/rubocop/cop/line_break_around_conditional_block_spec.rb b/spec/rubocop/cop/line_break_around_conditional_block_spec.rb deleted file mode 100644 index 0a26ef49e359f508145a9bb088a6386ab05ffd61..0000000000000000000000000000000000000000 --- a/spec/rubocop/cop/line_break_around_conditional_block_spec.rb +++ /dev/null @@ -1,454 +0,0 @@ -# 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 diff --git a/spec/services/admin/propagate_integration_service_spec.rb b/spec/services/admin/propagate_integration_service_spec.rb index 5df6e5e50ff3a065df73098d10813a645ff94969..13320528e4f1f094182aee1462b22010407ea94c 100644 --- a/spec/services/admin/propagate_integration_service_spec.rb +++ b/spec/services/admin/propagate_integration_service_spec.rb @@ -18,6 +18,7 @@ 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 diff --git a/spec/services/alert_management/create_alert_issue_service_spec.rb b/spec/services/alert_management/create_alert_issue_service_spec.rb index f2be317a13d0ea52541bcdef5e3f7805f7aa431d..2834322be7bf26e17b38a62f0d4bae21cb1a05af 100644 --- a/spec/services/alert_management/create_alert_issue_service_spec.rb +++ b/spec/services/alert_management/create_alert_issue_service_spec.rb @@ -12,6 +12,7 @@ '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 } diff --git a/spec/services/metrics/dashboard/panel_preview_service_spec.rb b/spec/services/metrics/dashboard/panel_preview_service_spec.rb index d58dee3e7a329da8629be588abba117eb826a98a..2877d22d1f32c593d44ca460f9cace9f937b3473 100644 --- a/spec/services/metrics/dashboard/panel_preview_service_spec.rb +++ b/spec/services/metrics/dashboard/panel_preview_service_spec.rb @@ -11,6 +11,7 @@ title: test panel YML end + let_it_be(:dashboard) do { panel_groups: [ diff --git a/spec/services/notes/destroy_service_spec.rb b/spec/services/notes/destroy_service_spec.rb index f0e5b29ac9b0bd370748c94ce1a7a716c274d1dd..0859c28cbe7cbdd6c16d008b35630ecc51d9c6ab 100644 --- a/spec/services/notes/destroy_service_spec.rb +++ b/spec/services/notes/destroy_service_spec.rb @@ -41,6 +41,7 @@ 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) diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index e4ec3e56c203c9ac8443aba8096e08a56609efe4..55224a985e6fa36660c6168763e0f05baa3bd72c 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -848,6 +848,7 @@ def self.it_should_not_email! 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 diff --git a/spec/support/shared_contexts/design_management_shared_contexts.rb b/spec/support/shared_contexts/design_management_shared_contexts.rb index 3ff6a5213386b32f878f16e1f3995d7578b456c5..e6ae7e03664cb58f0603cb59477efa398d76f3e0 100644 --- a/spec/support/shared_contexts/design_management_shared_contexts.rb +++ b/spec/support/shared_contexts/design_management_shared_contexts.rb @@ -18,12 +18,14 @@ 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: [], diff --git a/spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb b/spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb index 010c445d8df339eb5c08b33156891bfff07bc4d0..88c31bf9cfd321e9a900acf642d7d2cb5e73cc40 100644 --- a/spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb +++ b/spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb @@ -23,6 +23,7 @@ def allow_gitaly_n_plus_1 # 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 @@ def allow_gitaly_n_plus_1 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 diff --git a/spec/support/shared_contexts/requests/api/graphql/jira_import/jira_projects_context.rb b/spec/support/shared_contexts/requests/api/graphql/jira_import/jira_projects_context.rb index edc5b3132201f6564e9aa0876eb672aaaa31fd45..de40b926a1ca3749d8c9fbbdc1a10aa311555e6a 100644 --- a/spec/support/shared_contexts/requests/api/graphql/jira_import/jira_projects_context.rb +++ b/spec/support/shared_contexts/requests/api/graphql/jira_import/jira_projects_context.rb @@ -116,6 +116,7 @@ "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", diff --git a/tooling/overcommit/Gemfile b/tooling/overcommit/Gemfile index 571ea1862a579f13d96b48775b303fb134e3c39c..08f08018ffb6f0ed9753a64db0998a15fd260396 100644 --- a/tooling/overcommit/Gemfile +++ b/tooling/overcommit/Gemfile @@ -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 diff --git a/tooling/overcommit/Gemfile.lock b/tooling/overcommit/Gemfile.lock index 6527ad3fcda70d1bd8f186ea348267896ffbeb52..5bada88e1dc7c31e2898d7263585071530b15c65 100644 --- a/tooling/overcommit/Gemfile.lock +++ b/tooling/overcommit/Gemfile.lock @@ -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)