diff --git a/.rubocop_todo/rails/file_path.yml b/.rubocop_todo/rails/file_path.yml index 467073eb2db..24a08fa5ee2 100644 --- a/.rubocop_todo/rails/file_path.yml +++ b/.rubocop_todo/rails/file_path.yml @@ -1,10 +1,7 @@ --- Rails/FilePath: - # Offense count: 212 - # Temporarily disabled due to too many offenses - Enabled: false + Details: grace period Exclude: - - 'app/controllers/clusters/clusters_controller.rb' - 'app/controllers/help_controller.rb' - 'app/helpers/startupjs_helper.rb' - 'app/models/clusters/applications/cert_manager.rb' @@ -29,6 +26,7 @@ Rails/FilePath: - 'ee/db/fixtures/development/21_dast_profiles.rb' - 'ee/db/fixtures/development/32_compliance_report_violations.rb' - 'ee/lib/ee/feature/definition.rb' + - 'ee/lib/ee/gitlab/audit/type/definition.rb' - 'ee/lib/ee/gitlab/usage/metric_definition.rb' - 'ee/lib/gitlab/geo/health_check.rb' - 'ee/lib/tasks/gitlab/seed/metrics.rake' @@ -48,6 +46,8 @@ Rails/FilePath: - 'lib/api/api.rb' - 'lib/error_tracking/collector/payload_validator.rb' - 'lib/feature/definition.rb' + - 'lib/gitlab/audit/type/definition.rb' + - 'lib/gitlab/ci/parsers/sbom/validators/cyclonedx_schema_validator.rb' - 'lib/gitlab/ci/reports/codequality_reports.rb' - 'lib/gitlab/database/migrations/runner.rb' - 'lib/gitlab/favicon.rb' @@ -69,14 +69,17 @@ Rails/FilePath: - 'lib/system_check/app/systemd_unit_files_or_init_script_up_to_date_check.rb' - 'lib/system_check/app/uploads_directory_exists_check.rb' - 'lib/system_check/incoming_email/imap_authentication_check.rb' + - 'lib/tasks/gitlab/db.rake' - 'lib/tasks/gitlab/metrics_exporter.rake' + - 'lib/tasks/gitlab/usage_data.rake' - 'lib/tasks/tanuki_emoji.rake' - 'metrics_server/metrics_server.rb' - 'spec/commands/metrics_server/metrics_server_spec.rb' - 'spec/config/object_store_settings_spec.rb' - - 'spec/controllers/help_controller_spec.rb' + - 'spec/db/development/add_security_training_providers_spec.rb' - 'spec/db/development/create_base_work_item_types_spec.rb' - 'spec/db/development/import_common_metrics_spec.rb' + - 'spec/db/production/add_security_training_providers_spec.rb' - 'spec/db/production/create_base_work_item_types_spec.rb' - 'spec/db/production/import_common_metrics_spec.rb' - 'spec/db/schema_spec.rb' @@ -100,7 +103,6 @@ Rails/FilePath: - 'spec/features/projects/settings/repository_settings_spec.rb' - 'spec/features/projects/settings/user_changes_avatar_spec.rb' - 'spec/features/projects/snippets/create_snippet_spec.rb' - - 'spec/features/projects/tags/user_edits_tags_spec.rb' - 'spec/features/projects/tree/upload_file_spec.rb' - 'spec/features/snippets/user_creates_snippet_spec.rb' - 'spec/features/snippets/user_edits_snippet_spec.rb' @@ -127,10 +129,12 @@ Rails/FilePath: - 'spec/models/clusters/applications/cert_manager_spec.rb' - 'spec/models/release_highlight_spec.rb' - 'spec/requests/api/internal/mail_room_spec.rb' + - 'spec/requests/api/usage_data_queries_spec.rb' - 'spec/serializers/review_app_setup_entity_spec.rb' - 'spec/services/clusters/aws/fetch_credentials_service_spec.rb' - 'spec/services/clusters/aws/provision_service_spec.rb' - 'spec/services/metrics/sample_metrics_service_spec.rb' + - 'spec/support/helpers/doc_url_helper.rb' - 'spec/support/helpers/test_env.rb' - 'spec/support/helpers/upload_helpers.rb' - 'spec/support/shared_examples/features/project_upload_files_shared_examples.rb' @@ -139,3 +143,4 @@ Rails/FilePath: - 'spec/support/shared_examples/models/wiki_shared_examples.rb' - 'spec/tasks/gitlab/db_rake_spec.rb' - 'spec/tasks/gitlab/generate_sample_prometheus_data_spec.rb' + - 'spec/tasks/gitlab/usage_data_rake_spec.rb' diff --git a/.rubocop_todo/style/case_like_if.yml b/.rubocop_todo/style/case_like_if.yml index 119ca3d800f..61f2e6bc238 100644 --- a/.rubocop_todo/style/case_like_if.yml +++ b/.rubocop_todo/style/case_like_if.yml @@ -1,9 +1,7 @@ --- # Cop supports --auto-correct. Style/CaseLikeIf: - # Offense count: 60 - # Temporarily disabled due to too many offenses - Enabled: false + Details: grace period Exclude: - 'app/controllers/concerns/issuable_actions.rb' - 'app/controllers/groups/dependency_proxy/application_controller.rb' @@ -13,6 +11,7 @@ Style/CaseLikeIf: - 'app/helpers/broadcast_messages_helper.rb' - 'app/helpers/issues_helper.rb' - 'app/helpers/routing/pseudonymization_helper.rb' + - 'app/helpers/todos_helper.rb' - 'app/models/integrations/jira.rb' - 'app/models/members/member_task.rb' - 'app/models/namespace.rb' @@ -21,8 +20,11 @@ Style/CaseLikeIf: - 'app/services/google_cloud/generate_pipeline_service.rb' - 'app/services/issuable/bulk_update_service.rb' - 'app/services/todo_service.rb' + - 'app/services/user_project_access_changed_service.rb' - 'ee/app/controllers/concerns/credentials_inventory_actions.rb' - 'ee/app/finders/ee/notes_finder.rb' + - 'ee/app/finders/security/scan_execution_policies_finder.rb' + - 'ee/app/finders/security/training_providers/secure_code_warrior_url_finder.rb' - 'ee/app/helpers/ee/branches_helper.rb' - 'ee/app/services/epics/tree_reorder_service.rb' - 'ee/app/services/merge_request_approval_settings/update_service.rb' @@ -43,18 +45,18 @@ Style/CaseLikeIf: - 'lib/gitlab/utils/strong_memoize.rb' - 'qa/qa/git/repository.rb' - 'qa/qa/scenario/bootable.rb' - - 'rubocop/cop/gitlab/keys_first_and_values_first.rb' - 'spec/features/boards/user_adds_lists_to_board_spec.rb' - 'spec/lib/gitlab/auth/auth_finders_spec.rb' - 'spec/lib/gitlab/database/load_balancing_spec.rb' - 'spec/lib/omni_auth/strategies/jwt_spec.rb' - 'spec/models/concerns/sha_attribute_spec.rb' - 'spec/models/preloaders/labels_preloader_spec.rb' + - 'spec/requests/api/personal_access_tokens_spec.rb' - 'spec/requests/api/rubygem_packages_spec.rb' - 'spec/requests/api/terraform/modules/v1/packages_spec.rb' + - 'spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb' - 'spec/services/resource_events/change_state_service_spec.rb' - 'spec/support/helpers/filter_spec_helper.rb' - - 'spec/support/matchers/abort_matcher.rb' - 'spec/support/shared_examples/metrics/active_record_subscriber_shared_examples.rb' - 'spec/support/shared_examples/requests/api/notes_shared_examples.rb' - 'spec/support/shared_examples/uploaders/object_storage_shared_examples.rb' diff --git a/.rubocop_todo/style/empty_method.yml b/.rubocop_todo/style/empty_method.yml index 3e6a1efec70..7fbec98ead5 100644 --- a/.rubocop_todo/style/empty_method.yml +++ b/.rubocop_todo/style/empty_method.yml @@ -1,16 +1,12 @@ --- # Cop supports --auto-correct. Style/EmptyMethod: - # Offense count: 240 - # Temporarily disabled due to too many offenses - Enabled: false + Details: grace period Exclude: - 'app/controllers/admin/application_settings/appearances_controller.rb' - 'app/controllers/admin/applications_controller.rb' - 'app/controllers/admin/broadcast_messages_controller.rb' - 'app/controllers/admin/deploy_keys_controller.rb' - - 'app/controllers/admin/hook_logs_controller.rb' - - 'app/controllers/admin/hooks_controller.rb' - 'app/controllers/admin/identities_controller.rb' - 'app/controllers/admin/labels_controller.rb' - 'app/controllers/admin/runners_controller.rb' @@ -35,13 +31,11 @@ Style/EmptyMethod: - 'app/controllers/projects/alert_management_controller.rb' - 'app/controllers/projects/ci/lints_controller.rb' - 'app/controllers/projects/ci/pipeline_editor_controller.rb' - - 'app/controllers/projects/ci/secure_files_controller.rb' - 'app/controllers/projects/confluences_controller.rb' - 'app/controllers/projects/deploy_keys_controller.rb' - 'app/controllers/projects/environments_controller.rb' - 'app/controllers/projects/feature_flags_controller.rb' - 'app/controllers/projects/feature_flags_user_lists_controller.rb' - - 'app/controllers/projects/hook_logs_controller.rb' - 'app/controllers/projects/import/jira_controller.rb' - 'app/controllers/projects/imports_controller.rb' - 'app/controllers/projects/incidents_controller.rb' @@ -55,30 +49,32 @@ Style/EmptyMethod: - 'app/controllers/projects/runners_controller.rb' - 'app/controllers/projects/settings/integrations_controller.rb' - 'app/controllers/projects/settings/packages_and_registries_controller.rb' - - 'app/controllers/projects/tags/releases_controller.rb' - 'app/controllers/projects/terraform_controller.rb' - 'app/controllers/projects/triggers_controller.rb' + - 'app/controllers/pwa_controller.rb' - 'app/controllers/registrations/welcome_controller.rb' - 'app/controllers/search_controller.rb' + - 'app/experiments/security_actions_continuous_onboarding_experiment.rb' - 'app/graphql/resolvers/concerns/caching_array_resolver.rb' - 'app/helpers/subscribable_banner_helper.rb' - 'app/helpers/users/callouts_helper.rb' - 'app/models/ci/bridge.rb' + - 'app/models/ci/job_artifact.rb' - 'app/models/concerns/cross_database_modification.rb' - 'app/models/concerns/reactive_caching.rb' - 'app/models/concerns/relative_positioning.rb' - 'app/models/hooks/web_hook.rb' - 'app/models/integrations/hangouts_chat.rb' - 'app/models/integrations/microsoft_teams.rb' + - 'app/models/integrations/pumble.rb' - 'app/models/integrations/unify_circuit.rb' - 'app/models/integrations/webex_teams.rb' - 'app/models/wiki.rb' - 'app/services/auto_merge/base_service.rb' - 'app/services/award_emojis/destroy_service.rb' + - 'app/services/groups/transfer_service.rb' - 'app/services/issuable_base_service.rb' - - 'app/services/issues/reopen_service.rb' - 'app/services/projects/transfer_service.rb' - - 'app/workers/authorized_projects_worker.rb' - 'app/workers/namespaces/root_statistics_worker.rb' - 'db/migrate/20210420012444_change_web_hook_events_default.rb' - 'db/migrate/20210507191949_add_remove_on_issue_close_to_labels.rb' @@ -92,6 +88,7 @@ Style/EmptyMethod: - 'db/post_migrate/20220324032250_migrate_shimo_confluence_service_category.rb' - 'db/post_migrate/20220412143552_consume_remaining_encrypt_integration_property_jobs.rb' - 'db/post_migrate/20220425121435_backfill_integrations_enable_ssl_verification.rb' + - 'db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb' - 'ee/app/controllers/admin/emails_controller.rb' - 'ee/app/controllers/admin/geo/designs_controller.rb' - 'ee/app/controllers/admin/geo/settings_controller.rb' @@ -101,9 +98,8 @@ Style/EmptyMethod: - 'ee/app/controllers/groups/analytics/devops_adoption_controller.rb' - 'ee/app/controllers/groups/compliance_frameworks_controller.rb' - 'ee/app/controllers/groups/feature_discovery_moments_controller.rb' - - 'ee/app/controllers/groups/hooks_controller.rb' - 'ee/app/controllers/groups/ldap_group_links_controller.rb' - - 'ee/app/controllers/groups/push_rules_controller.rb' + - 'ee/app/controllers/groups/settings/reporting_controller.rb' - 'ee/app/controllers/projects/analytics/code_reviews_controller.rb' - 'ee/app/controllers/projects/analytics/merge_request_analytics_controller.rb' - 'ee/app/controllers/projects/incident_management/escalation_policies_controller.rb' @@ -122,8 +118,10 @@ Style/EmptyMethod: - 'ee/app/controllers/subscriptions/groups_controller.rb' - 'ee/app/controllers/trial_registrations_controller.rb' - 'ee/app/controllers/trials_controller.rb' + - 'ee/app/controllers/users/identity_verification_controller.rb' - 'ee/app/experiments/cart_abandonment_modal_experiment.rb' - 'ee/app/models/ee/epic.rb' + - 'ee/app/models/geo/group_wiki_repository_registry.rb' - 'ee/app/services/feature_flag_issues/destroy_service.rb' - 'ee/db/geo/migrate/20170906174622_remove_duplicates_from_project_registry.rb' - 'lib/api/helpers/packages/conan/api_helpers.rb' @@ -135,6 +133,8 @@ Style/EmptyMethod: - 'lib/gitlab/alert_management/payload/base.rb' - 'lib/gitlab/background_migration/backfill_iteration_cadence_id_for_boards.rb' - 'lib/gitlab/background_migration/create_security_setting.rb' + - 'lib/gitlab/background_migration/delete_approval_rules_with_vulnerability.rb' + - 'lib/gitlab/background_migration/delete_invalid_epic_issues.rb' - 'lib/gitlab/background_migration/drop_invalid_remediations.rb' - 'lib/gitlab/background_migration/fix_incorrect_max_seats_used.rb' - 'lib/gitlab/background_migration/migrate_approver_to_approval_rules.rb' @@ -142,6 +142,7 @@ Style/EmptyMethod: - 'lib/gitlab/background_migration/migrate_approver_to_approval_rules_in_batch.rb' - 'lib/gitlab/background_migration/migrate_job_artifact_registry_to_ssf.rb' - 'lib/gitlab/background_migration/migrate_requirements_to_work_items.rb' + - 'lib/gitlab/background_migration/migrate_shared_vulnerability_scanners.rb' - 'lib/gitlab/background_migration/recalculate_vulnerability_finding_signatures_for_findings.rb' - 'lib/gitlab/background_migration/update_vulnerability_occurrences_location.rb' - 'lib/gitlab/ci/config/entry/need.rb' @@ -150,10 +151,10 @@ Style/EmptyMethod: - 'lib/gitlab/ci/pipeline/chain/validate/after_config.rb' - 'lib/gitlab/config/entry/node.rb' - 'lib/gitlab/config/entry/simplifiable.rb' - - 'lib/gitlab/email/message/in_product_marketing/experience.rb' - 'lib/gitlab/empty_search_results.rb' - 'lib/gitlab/git_access.rb' - 'lib/gitlab/import_export/json/ndjson_writer.rb' + - 'lib/gitlab/mailgun/webhook_processors/base.rb' - 'lib/gitlab/null_request_store.rb' - 'lib/gitlab/usage_data_non_sql_metrics.rb' - 'lib/mattermost/session.rb' @@ -162,7 +163,6 @@ Style/EmptyMethod: - 'qa/qa/resource/job.rb' - 'qa/qa/resource/package.rb' - 'qa/qa/resource/registry_repository.rb' - - 'qa/qa/resource/runner.rb' - 'qa/qa/service/cluster_provider/k3d.rb' - 'qa/qa/service/cluster_provider/k3s.rb' - 'qa/qa/service/cluster_provider/minikube.rb' @@ -173,7 +173,6 @@ Style/EmptyMethod: - 'spec/lib/gitlab/database/load_balancing/sidekiq_client_middleware_spec.rb' - 'spec/lib/gitlab/database/load_balancing/sidekiq_server_middleware_spec.rb' - 'spec/lib/gitlab/database/migration_helpers/restrict_gitlab_schema_spec.rb' - - 'spec/lib/gitlab/database/migrations/background_migration_helpers_spec.rb' - 'spec/lib/gitlab/database/partitioning/sliding_list_strategy_spec.rb' - 'spec/lib/gitlab/database/postgresql_adapter/dump_schema_versions_mixin_spec.rb' - 'spec/lib/gitlab/database/postgresql_database_tasks/load_schema_versions_mixin_spec.rb' @@ -192,4 +191,5 @@ Style/EmptyMethod: - 'spec/lib/gitlab/utils/delegator_override/validator_spec.rb' - 'spec/lib/gitlab/utils/delegator_override_spec.rb' - 'spec/lib/gitlab/utils/override_spec.rb' + - 'spec/lib/gitlab/utils/strong_memoize_spec.rb' - 'spec/workers/concerns/waitable_worker_spec.rb' diff --git a/app/assets/javascripts/blame/blame_redirect.js b/app/assets/javascripts/blame/blame_redirect.js new file mode 100644 index 00000000000..155e2a3a2cd --- /dev/null +++ b/app/assets/javascripts/blame/blame_redirect.js @@ -0,0 +1,23 @@ +import { setUrlParams } from '~/lib/utils/url_utility'; +import { createAlert } from '~/flash'; +import { __ } from '~/locale'; + +export default function redirectToCorrectBlamePage() { + const { hash } = window.location; + const linesPerPage = parseInt(document.querySelector('.js-per-page').dataset.perPage, 10); + const params = new URLSearchParams(window.location.search); + const currentPage = parseInt(params.get('page'), 10); + const isPaginationDisabled = params.get('no_pagination'); + if (hash && linesPerPage && !isPaginationDisabled) { + const lineNumber = parseInt(hash.split('#L')[1], 10); + const pageToRedirect = Math.ceil(lineNumber / linesPerPage); + const isRedirectNeeded = + (pageToRedirect > 1 && pageToRedirect !== currentPage) || pageToRedirect < currentPage; + if (isRedirectNeeded) { + createAlert({ + message: __('Please wait a few moments while we load the file history for this line.'), + }); + window.location.href = setUrlParams({ page: pageToRedirect }); + } + } +} diff --git a/app/assets/javascripts/editor/schema/ci.json b/app/assets/javascripts/editor/schema/ci.json index 848ba7dbeef..3b9d87134fd 100644 --- a/app/assets/javascripts/editor/schema/ci.json +++ b/app/assets/javascripts/editor/schema/ci.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://gitlab.com/.gitlab-ci.yml", - "title": "Gitlab CI configuration", "markdownDescription": "Gitlab has a built-in solution for doing CI called Gitlab CI. It is configured by supplying a file called `.gitlab-ci.yml`, which will list all the jobs that are going to run for the project. A full list of all options can be found [here](https://docs.gitlab.com/ee/ci/yaml). [Learn More](https://docs.gitlab.com/ee/ci/index.html).", "type": "object", "properties": { @@ -408,6 +407,13 @@ } }, "required": ["name"] + }, + { + "type": "array", + "minLength": 1, + "items": { + "type": "string" + } } ], "markdownDescription": "Specifies the docker image to use for the job or globally for all jobs. Job configuration takes precedence over global setting. Requires a certain kind of Gitlab runner executor. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#image)." @@ -1047,10 +1053,21 @@ ] }, "stage": { - "type": "string", "description": "Define what stage the job will run in.", - "minLength": 1 - }, + "anyOf": [ + { + "type": "string", + "minLength": 1 + }, + { + "type": "array", + "minLength": 1, + "items": { + "type": "string" + } + } + ] + }, "only": { "$ref": "#/definitions/filter", "description": "Job will run *only* when these filtering options match." @@ -1583,9 +1600,22 @@ }, "tags": { "type": "array", + "minLength": 1, "markdownDescription": "Used to select runners from the list of available runners. A runner must have all tags listed here to run the job. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#tags).", "items": { - "type": "string" + "anyOf": [ + { + "type": "string", + "minLength": 1 + }, + { + "type": "array", + "minLength": 1, + "items": { + "type": "string" + } + } + ] } } } diff --git a/app/assets/javascripts/pages/projects/blame/show/index.js b/app/assets/javascripts/pages/projects/blame/show/index.js index fa22c11d1d7..1e4b9de90f2 100644 --- a/app/assets/javascripts/pages/projects/blame/show/index.js +++ b/app/assets/javascripts/pages/projects/blame/show/index.js @@ -1,3 +1,5 @@ import initBlob from '~/pages/projects/init_blob'; +import redirectToCorrectPage from '~/blame/blame_redirect'; +redirectToCorrectPage(); initBlob(); diff --git a/app/assets/javascripts/pipelines/components/pipeline_tabs.vue b/app/assets/javascripts/pipelines/components/pipeline_tabs.vue index df59962569e..2a78636261b 100644 --- a/app/assets/javascripts/pipelines/components/pipeline_tabs.vue +++ b/app/assets/javascripts/pipelines/components/pipeline_tabs.vue @@ -56,7 +56,12 @@ export default {