diff options
98 files changed, 1249 insertions, 441 deletions
diff --git a/.gitlab/ci/review.gitlab-ci.yml b/.gitlab/ci/review.gitlab-ci.yml index d26685645f9..46a281cd48f 100644 --- a/.gitlab/ci/review.gitlab-ci.yml +++ b/.gitlab/ci/review.gitlab-ci.yml @@ -233,7 +233,6 @@ danger-review: - .review:rules:danger image: registry.gitlab.com/gitlab-org/gitlab-build-images:danger stage: test - allow_failure: true needs: [] script: - source scripts/utils.sh diff --git a/.haml-lint.yml b/.haml-lint.yml index 399fa9656a0..33a960f7efe 100644 --- a/.haml-lint.yml +++ b/.haml-lint.yml @@ -80,8 +80,8 @@ linters: ignored_cops: - Layout/BlockAlignment - Layout/EndAlignment + - Layout/LineLength - Lint/Void - - Metrics/LineLength - Naming/FileName - Style/AlignParameters - Style/BlockNesting @@ -92,7 +92,6 @@ linters: - Style/IfUnlessModifier - Style/IndentationWidth - Style/Next - - Style/TrailingBlankLines - Style/TrailingWhitespace - Style/WhileUntilModifier @@ -112,7 +111,7 @@ linters: - Layout/SpaceInsideArrayLiteralBrackets - Layout/SpaceInsideHashLiteralBraces - Layout/SpaceInsideStringInterpolation - - Layout/TrailingBlankLines + - Layout/TrailingEmptyLines - Lint/BooleanSymbol - Lint/LiteralInInterpolation - Lint/ParenthesesAsGroupedExpression diff --git a/.haml-lint_todo.yml b/.haml-lint_todo.yml index fe2c766f76c..e65143a06f2 100644 --- a/.haml-lint_todo.yml +++ b/.haml-lint_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `haml-lint --auto-gen-config` -# on 2020-04-20 07:11:26 +0000 using Haml-Lint version 0.34.0. +# on 2020-05-21 10:58:59 -0400 using Haml-Lint version 0.34.0. # The point is for the user to remove these configuration records # one by one as the lints are removed from the code base. # Note that changes in the inspected code, or installation of new diff --git a/.rubocop.yml b/.rubocop.yml index 920db8cc91d..aafcc4c7d9e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -13,7 +13,7 @@ inherit_mode: AllCops: TargetRubyVersion: 2.6 - TargetRailsVersion: 5.0 + TargetRailsVersion: 6.0 Exclude: - 'vendor/**/*' - 'node_modules/**/*' @@ -186,6 +186,14 @@ Rails/FindBy: - 'spec/**/*.rb' - 'ee/spec/**/*.rb' +# This is currently exiting with a rubocop exception error and should be +# resolved hopefully a future update +# An error occurred while Rails/UniqueValidationWithoutIndex cop was inspecting +# app/models/abuse_report.rb:15:2. +# To see the complete backtrace run rubocop -d. +Rails/UniqueValidationWithoutIndex: + Enabled: false + # GitLab ################################################################### Gitlab/ModuleWithInstanceVariables: @@ -260,7 +268,7 @@ Style/ReturnNil: Performance/RegexpMatch: Enabled: false -ActiveRecordAssociationReload: +Cop/ActiveRecordAssociationReload: Enabled: true Exclude: - 'spec/**/*' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bd0f9184cd6..a4c56feda27 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,30 +1,21 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-01-16 11:53:06 -0800 using RuboCop version 0.74.0. +# on 2020-05-20 16:32:14 -0400 using RuboCop version 0.82.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 299 +# Offense count: 308 # Cop supports --auto-correct. Capybara/CurrentPathExpectation: Enabled: false -# Offense count: 1432 +# Offense count: 1715 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: with_first_argument, with_fixed_indentation -Layout/AlignArguments: - Enabled: false - -# Offense count: 1630 -# Cop supports --auto-correct. -# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/AlignHash: +Layout/ArgumentAlignment: Enabled: false # Offense count: 13 @@ -41,7 +32,7 @@ Layout/ClosingHeredocIndentation: - 'spec/rubocop/cop/active_record_association_reload_spec.rb' - 'spec/services/task_list_toggle_service_spec.rb' -# Offense count: 9 +# Offense count: 13 # Cop supports --auto-correct. Layout/ClosingParenthesisIndentation: Exclude: @@ -52,7 +43,7 @@ Layout/ClosingParenthesisIndentation: - 'spec/support/helpers/stub_object_storage.rb' - 'spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb' -# Offense count: 69 +# Offense count: 72 # Cop supports --auto-correct. Layout/EmptyLinesAroundArguments: Exclude: @@ -60,46 +51,61 @@ Layout/EmptyLinesAroundArguments: - 'app/models/concerns/resolvable_discussion.rb' - 'app/models/diff_discussion.rb' - 'app/models/discussion.rb' - - 'ee/app/helpers/license_helper.rb' - 'ee/spec/models/geo/project_registry_spec.rb' - 'lib/banzai/pipeline/broadcast_message_pipeline.rb' - 'lib/banzai/pipeline/gfm_pipeline.rb' - 'lib/banzai/pipeline/single_line_pipeline.rb' - 'spec/features/markdown/copy_as_gfm_spec.rb' -# Offense count: 305 +# Offense count: 413 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/IndentFirstArrayElement: +Layout/FirstArrayElementIndentation: Enabled: false -# Offense count: 1005 +# Offense count: 1218 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/IndentFirstHashElement: +Layout/FirstHashElementIndentation: Enabled: false # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: consistent, align_parentheses -Layout/IndentFirstParameter: +Layout/FirstParameterIndentation: Exclude: - 'lib/gitlab/cross_project_access.rb' - 'lib/gitlab/data_builder/push.rb' - 'spec/support/helpers/repo_helpers.rb' - 'spec/support/helpers/stub_object_storage.rb' -# Offense count: 54 +# Offense count: 2164 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Enabled: false + +# Offense count: 9396 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 1313 + +# Offense count: 94 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented Layout/MultilineOperationIndentation: Enabled: false -# Offense count: 10 +# Offense count: 9 # Cop supports --auto-correct. Layout/RescueEnsureAlignment: Exclude: @@ -107,21 +113,33 @@ Layout/RescueEnsureAlignment: - 'app/models/project.rb' - 'app/services/prometheus/proxy_service.rb' - 'app/workers/delete_stored_files_worker.rb' - - 'app/workers/reactive_caching_worker.rb' - 'config/initializers/1_settings.rb' - 'config/initializers/trusted_proxies.rb' - 'lib/gitlab/background_migration/archive_legacy_traces.rb' - 'lib/gitlab/highlight.rb' - 'lib/tasks/gitlab/lfs/migrate.rake' -# Offense count: 522 +# Offense count: 36 +# Cop supports --auto-correct. +Layout/SpaceAroundMethodCallOperator: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Layout/SpaceBeforeFirstArg: + Exclude: + - 'spec/requests/api/runner_spec.rb' + - 'spec/support/shared_examples/requests/api/custom_attributes_shared_examples.rb' + +# Offense count: 642 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: require_no_space, require_space Layout/SpaceInLambdaLiteral: Enabled: false -# Offense count: 796 +# Offense count: 926 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space @@ -129,7 +147,7 @@ Layout/SpaceInLambdaLiteral: Layout/SpaceInsideBlockBraces: Enabled: false -# Offense count: 315 +# Offense count: 401 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space @@ -153,12 +171,47 @@ Lint/DuplicateMethods: - 'lib/gitlab/git/tree.rb' - 'lib/gitlab/git/wiki_page.rb' -# Offense count: 122 +# Offense count: 157 # Configuration parameters: MaximumRangeSize. Lint/MissingCopEnableDirective: Enabled: false -# Offense count: 6 +# Offense count: 11 +# Cop supports --auto-correct. +Lint/NonDeterministicRequireOrder: + Exclude: + - 'ee/spec/spec_helper.rb' + - 'qa/spec/spec_helper.rb' + - 'spec/spec_helper.rb' + +# Offense count: 3 +# Configuration parameters: AllowedImplicitNamespaces. +# AllowedImplicitNamespaces: Gem +Lint/RaiseException: + Exclude: + - 'db/migrate/20190402150158_backport_enterprise_schema.rb' + - 'ee/spec/requests/api/helpers_spec.rb' + - 'spec/requests/api/helpers_spec.rb' + +# Offense count: 27 +# Cop supports --auto-correct. +Lint/RedundantCopDisableDirective: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/SendWithMixinArgument: + Exclude: + - 'config/initializers/trusted_proxies.rb' + +# Offense count: 3 +Lint/StructNewOverride: + Exclude: + - 'app/presenters/sentry_error_presenter.rb' + - 'app/serializers/environment_serializer.rb' + - 'lib/gitlab/ci/pipeline/duration.rb' + +# Offense count: 7 Lint/UriEscapeUnescape: Exclude: - 'app/controllers/application_controller.rb' @@ -166,14 +219,20 @@ Lint/UriEscapeUnescape: - 'spec/lib/google_api/auth_spec.rb' - 'spec/requests/api/files_spec.rb' -# Offense count: 165 +# Offense count: 3 # Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Metrics/LineLength: - Max: 176 +Lint/UriRegexp: + Exclude: + - 'app/models/concerns/mentionable/reference_regexes.rb' + - 'app/services/projects/download_service.rb' + - 'lib/gitlab/ci/pipeline/chain/config/content/remote.rb' + +# Offense count: 65 +# Cop supports --auto-correct. +Migration/DepartmentName: + Enabled: false -# Offense count: 143 +# Offense count: 156 # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS Naming/FileName: @@ -190,43 +249,78 @@ Naming/HeredocDelimiterCase: - 'spec/support/helpers/repo_helpers.rb' - 'spec/support/helpers/seed_repo.rb' -# Offense count: 211 -# Configuration parameters: Blacklist. -# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) +# Offense count: 239 +# Configuration parameters: ForbiddenDelimiters. +# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) Naming/HeredocDelimiterNaming: Enabled: false -# Offense count: 139 +# Offense count: 5 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp +Naming/MethodParameterName: + Exclude: + - 'lib/gitlab/diff/inline_diff.rb' + - 'spec/support/helpers/key_generator_helper.rb' + +# Offense count: 162 # Cop supports --auto-correct. # Configuration parameters: PreferredName. Naming/RescuedExceptionsVariableName: Enabled: false -# Offense count: 9913 +# Offense count: 20 +# Cop supports --auto-correct. +Performance/Count: + Exclude: + - 'app/helpers/groups_helper.rb' + - 'app/services/merge_requests/add_context_service.rb' + - 'ee/lib/gitlab/geo/fdw.rb' + - 'ee/lib/gitlab/graphql/aggregations/epics/epic_node.rb' + - 'ee/spec/controllers/projects/feature_flags_controller_spec.rb' + - 'ee/spec/requests/api/feature_flags_spec.rb' + - 'lib/gitlab/sidekiq_status.rb' + - 'spec/lib/gitlab/conflict/file_spec.rb' + - 'spec/lib/gitlab/git/tree_spec.rb' + - 'spec/models/ci/build_spec.rb' + - 'spec/support/matchers/exceed_query_limit.rb' + +# Offense count: 25 +# Cop supports --auto-correct. +Performance/Detect: + Exclude: + - 'ee/spec/controllers/projects/dependencies_controller_spec.rb' + - 'ee/spec/controllers/projects/feature_flags_controller_spec.rb' + - 'ee/spec/requests/api/unleash_spec.rb' + - 'spec/lib/gitlab/git/tree_spec.rb' + - 'spec/lib/gitlab/import_export/project/tree_restorer_spec.rb' + - 'spec/models/event_spec.rb' + - 'spec/requests/api/jobs_spec.rb' + +# Offense count: 11832 # Configuration parameters: Prefixes. # Prefixes: when, with, without RSpec/ContextWording: Enabled: false -# Offense count: 879 +# Offense count: 1121 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: method_call, block RSpec/ExpectChange: Enabled: false -# Offense count: 660 +# Offense count: 751 RSpec/ExpectInHook: Enabled: false -# Offense count: 10 +# Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: it_behaves_like, it_should_behave_like RSpec/ItBehavesLike: Exclude: - 'spec/lib/gitlab/git/commit_spec.rb' - - 'spec/lib/gitlab/git/repository_spec.rb' - 'spec/services/notification_service_spec.rb' # Offense count: 68 @@ -244,30 +338,28 @@ RSpec/LetBeforeExamples: - 'spec/rubocop/cop/migration/update_column_in_batches_spec.rb' - 'spec/serializers/pipeline_details_entity_spec.rb' -# Offense count: 2018 +# Offense count: 2188 # Cop supports --auto-correct. # Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers. # SupportedStyles: inflected, explicit RSpec/PredicateMatcher: Enabled: false -# Offense count: 584 +# Offense count: 635 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: and_return, block RSpec/ReturnFromStub: Enabled: false -# Offense count: 380 +# Offense count: 518 RSpec/ScatteredLet: Enabled: false -# Offense count: 8 +# Offense count: 4 RSpec/ScatteredSetup: Exclude: - - 'spec/lib/gitlab/bitbucket_import/importer_spec.rb' - 'spec/requests/api/jobs_spec.rb' - - 'spec/services/projects/create_service_spec.rb' # Offense count: 10 # Cop supports --auto-correct. @@ -284,67 +376,92 @@ Rails/ApplicationController: - 'spec/controllers/concerns/continue_params_spec.rb' - 'spec/lib/marginalia_spec.rb' -# Offense count: 8 +# Offense count: 3 # Cop supports --auto-correct. Rails/BelongsTo: Exclude: - 'app/models/deployment.rb' - 'app/models/environment.rb' - - 'ee/app/models/prometheus_alert.rb' - - 'ee/app/models/prometheus_alert_event.rb' -# Offense count: 151 +# Offense count: 71 +# Configuration parameters: Database, Include. +# SupportedDatabases: mysql, postgresql +# Include: db/migrate/*.rb +Rails/BulkChangeTable: + Enabled: false + +# Offense count: 208 # Configuration parameters: Include. # Include: db/migrate/*.rb Rails/CreateTableWithTimestamps: Enabled: false -# Offense count: 266 +# Offense count: 346 # Configuration parameters: EnforcedStyle. # SupportedStyles: slashes, arguments Rails/FilePath: Enabled: false -# Offense count: 211 +# Offense count: 264 # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/HasManyOrHasOneDependent: Enabled: false -# Offense count: 431 +# Offense count: 467 # Configuration parameters: Include. # Include: app/helpers/**/*.rb Rails/HelperInstanceVariable: Enabled: false -# Offense count: 103 +# Offense count: 15 +# Cop supports --auto-correct. +Rails/IndexBy: + Exclude: + - 'app/models/ci/pipeline.rb' + - 'app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb' + - 'ee/app/services/projects/update_mirror_service.rb' + - 'ee/app/services/security/store_report_service.rb' + - 'ee/lib/ee/gitlab/auth/ldap/sync/group.rb' + - 'ee/lib/ee/gitlab/background_migration/backfill_version_data_from_gitaly.rb' + - 'ee/lib/gitlab/analytics/type_of_work/tasks_by_type.rb' + - 'ee/lib/gitlab/elastic/document_reference.rb' + - 'ee/lib/gitlab/group_plans_preloader.rb' + - 'lib/gitlab/database/count/reltuples_count_strategy.rb' + - 'lib/gitlab/language_detection.rb' + +# Offense count: 36 +# Cop supports --auto-correct. +Rails/IndexWith: + Enabled: false + +# Offense count: 105 # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/InverseOf: Enabled: false -# Offense count: 51 +# Offense count: 55 # Configuration parameters: Include. # Include: app/controllers/**/*.rb Rails/LexicallyScopedActionFilter: Enabled: false -# Offense count: 4 +# Offense count: 3 # Cop supports --auto-correct. Rails/LinkToBlank: Exclude: - 'app/helpers/projects_helper.rb' - 'app/helpers/wiki_helper.rb' - 'ee/app/helpers/ee/user_callouts_helper.rb' - - 'ee/app/helpers/license_helper.rb' -# Offense count: 35 +# Offense count: 34 # Configuration parameters: Include. # Include: **/Rakefile, **/*.rake Rails/RakeEnvironment: Enabled: false -# Offense count: 868 +# Offense count: 926 # Configuration parameters: Blacklist, Whitelist. # Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters Rails/SkipsModelValidations: @@ -360,13 +477,18 @@ Security/YAMLLoad: - 'spec/initializers/secret_token_spec.rb' - 'spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb' -# Offense count: 34 -# Configuration parameters: EnforcedStyle. +# Offense count: 10 +# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols. # SupportedStyles: inline, group Style/AccessModifierDeclarations: - Enabled: false + Exclude: + - 'app/helpers/issues_helper.rb' + - 'app/helpers/lazy_image_tag_helper.rb' + - 'lib/gitlab/cache/request_cache.rb' + - 'lib/gitlab/request_profiler.rb' + - 'spec/support/forgery_protection.rb' -# Offense count: 127 +# Offense count: 148 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: percent_q, bare_percent @@ -379,7 +501,7 @@ Style/CommentedKeyword: - 'lib/tasks/gitlab/backup.rake' - 'spec/tasks/gitlab/backup_rake_spec.rb' -# Offense count: 6 +# Offense count: 5 # Cop supports --auto-correct. Style/EachWithObject: Exclude: @@ -388,9 +510,8 @@ Style/EachWithObject: - 'lib/gitlab/hook_data/issuable_builder.rb' - 'lib/gitlab/i18n/po_linter.rb' - 'lib/gitlab/import_export/members_mapper.rb' - - 'lib/gitlab/import_export/relation_factory.rb' -# Offense count: 41 +# Offense count: 46 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty, nil, both @@ -404,7 +525,7 @@ Style/EmptyLambdaParameter: - 'app/models/ci/build.rb' - 'app/models/ci/runner.rb' -# Offense count: 8 +# Offense count: 7 # Cop supports --auto-correct. Style/EmptyLiteral: Exclude: @@ -414,38 +535,66 @@ Style/EmptyLiteral: - 'spec/helpers/merge_requests_helper_spec.rb' - 'spec/lib/gitlab/workhorse_spec.rb' - 'spec/requests/api/jobs_spec.rb' - - 'spec/support/shared_examples/chat_slash_commands_shared_examples.rb' -# Offense count: 148 +# Offense count: 170 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: compact, expanded Style/EmptyMethod: Enabled: false -# Offense count: 346 +# Offense count: 431 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: format, sprintf, percent Style/FormatString: Enabled: false -# Offense count: 692 +# Offense count: 769 # Configuration parameters: MinBodyLength. Style/GuardClause: Enabled: false -# Offense count: 27 +# Offense count: 47 +# Cop supports --auto-correct. +Style/HashEachMethods: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +Style/HashTransformKeys: + Exclude: + - 'ee/app/models/vulnerabilities/occurrence.rb' + - 'ee/spec/lib/gitlab/ci/templates/dependency_scanning_gitlab_ci_yaml_spec.rb' + - 'lib/banzai/filter/commit_trailers_filter.rb' + - 'lib/gitlab/analytics/cycle_analytics/stage_events.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +Style/HashTransformValues: + Exclude: + - 'app/validators/addressable_url_validator.rb' + - 'config/initializers/action_dispatch_journey_formatter.rb' + - 'ee/app/helpers/compliance_management/compliance_framework/project_settings_helper.rb' + - 'ee/app/services/packages/nuget/metadata_extraction_service.rb' + - 'lib/gitlab/config/entry/configurable.rb' + - 'lib/gitlab/config/entry/node.rb' + - 'lib/gitlab/discussions_diff/file_collection.rb' + - 'lib/gitlab/error_tracking.rb' + - 'lib/rspec_flaky/flaky_examples_collection.rb' + - 'spec/lib/gitlab/database_importers/common_metrics/prometheus_metric_spec.rb' + +# Offense count: 31 # Configuration parameters: AllowIfModifier. Style/IfInsideElse: Enabled: false -# Offense count: 1474 +# Offense count: 1313 # Cop supports --auto-correct. Style/IfUnlessModifier: Enabled: false -# Offense count: 314 +# Offense count: 377 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: line_count_dependent, lambda, literal @@ -460,51 +609,49 @@ Style/MethodMissingSuper: Style/MissingRespondToMissing: Enabled: false -# Offense count: 6 +# Offense count: 5 Style/MixinUsage: Exclude: - 'spec/factories/ci/builds.rb' - 'spec/factories/ci/job_artifacts.rb' - 'spec/factories/lfs_objects.rb' - 'spec/factories/notes.rb' - - 'spec/lib/gitlab/import_export/project_tree_restorer_spec.rb' - 'spec/lib/gitlab/import_export/version_checker_spec.rb' -# Offense count: 4 +# Offense count: 2 # Cop supports --auto-correct. Style/MultilineIfModifier: Exclude: - - 'app/helpers/snippets_helper.rb' - 'app/services/ci/process_pipeline_service.rb' - 'lib/api/commit_statuses.rb' -# Offense count: 25 +# Offense count: 29 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinBodyLength. # SupportedStyles: skip_modifier_ifs, always Style/Next: Enabled: false -# Offense count: 71 +# Offense count: 89 # Cop supports --auto-correct. # Configuration parameters: EnforcedOctalStyle. # SupportedOctalStyles: zero_with_o, zero_only Style/NumericLiteralPrefix: Enabled: false -# Offense count: 234 +# Offense count: 255 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. # SupportedStyles: predicate, comparison Style/NumericPredicate: Enabled: false -# Offense count: 106 +# Offense count: 117 # Cop supports --auto-correct. Style/ParallelAssignment: Enabled: false -# Offense count: 1692 +# Offense count: 2035 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: @@ -526,51 +673,60 @@ Style/PerlBackrefs: - 'lib/gitlab/search_results.rb' - 'lib/gitlab/sherlock/query.rb' -# Offense count: 165 +# Offense count: 200 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: compact, exploded Style/RaiseArgs: Enabled: false -# Offense count: 221 +# Offense count: 246 # Cop supports --auto-correct. Style/RedundantFreeze: Enabled: false -# Offense count: 15 +# Offense count: 123 +# Cop supports --auto-correct. +Style/RedundantInterpolation: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +Style/RedundantParentheses: + Exclude: + - 'ee/app/models/ee/merge_request.rb' + +# Offense count: 33 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/controllers/concerns/issuable_actions.rb' - - 'app/controllers/groups/application_controller.rb' - - 'app/controllers/omniauth_callbacks_controller.rb' - - 'app/controllers/profiles/keys_controller.rb' - - 'app/controllers/projects/application_controller.rb' - - 'app/services/access_token_validation_service.rb' - - 'lib/gitlab/utils.rb' - - 'lib/google_api/auth.rb' + Enabled: false -# Offense count: 739 +# Offense count: 801 # Cop supports --auto-correct. Style/RedundantSelf: Enabled: false -# Offense count: 80 +# Offense count: 2 +# Cop supports --auto-correct. +Style/RedundantSort: + Exclude: + - 'ee/app/presenters/packages/nuget/search_results_presenter.rb' + - 'ee/spec/presenters/packages/nuget/search_results_presenter_spec.rb' + +# Offense count: 120 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed Style/RegexpLiteral: Enabled: false -# Offense count: 42 +# Offense count: 46 # Cop supports --auto-correct. Style/RescueModifier: Enabled: false -# Offense count: 237 +# Offense count: 286 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, explicit @@ -592,28 +748,23 @@ Style/SingleLineMethods: Exclude: - 'lib/gitlab/ci/ansi2html.rb' -# Offense count: 94 +# Offense count: 102 # Cop supports --auto-correct. # Configuration parameters: . # SupportedStyles: use_perl_names, use_english_names Style/SpecialGlobalVars: EnforcedStyle: use_perl_names -# Offense count: 75 +# Offense count: 93 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: single_quotes, double_quotes Style/StringLiteralsInInterpolation: Enabled: false -# Offense count: 216 +# Offense count: 233 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. # IgnoredMethods: respond_to, define_method Style/SymbolProc: Enabled: false - -# Offense count: 99 -# Cop supports --auto-correct. -Style/UnneededInterpolation: - Enabled: false @@ -361,10 +361,10 @@ group :development, :test do gem 'spring', '~> 2.0.0' gem 'spring-commands-rspec', '~> 1.0.4' - gem 'gitlab-styles', '~> 3.2.0', require: false + gem 'gitlab-styles', '~> 4.2.0', require: false # Pin these dependencies, otherwise a new rule could break the CI pipelines - gem 'rubocop', '~> 0.74.0' - gem 'rubocop-performance', '~> 1.4.1' + gem 'rubocop', '~> 0.82.0' + gem 'rubocop-performance', '~> 1.5.2' gem 'rubocop-rspec', '~> 1.37.0' gem 'scss_lint', '~> 0.56.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 45325603396..05c8e40a9c9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -400,11 +400,11 @@ GEM gitlab-puma (>= 2.7, < 5) gitlab-sidekiq-fetcher (0.5.2) sidekiq (~> 5) - gitlab-styles (3.2.0) - rubocop (~> 0.74.0) + gitlab-styles (4.2.0) + rubocop (~> 0.82.0) rubocop-gitlab-security (~> 0.1.0) - rubocop-performance (~> 1.4.1) - rubocop-rails (~> 2.0) + rubocop-performance (~> 1.5.2) + rubocop-rails (~> 2.5) rubocop-rspec (~> 1.36) gitlab_chronic_duration (0.10.6.2) numerizer (~> 0.2) @@ -748,7 +748,7 @@ GEM orm_adapter (0.5.0) os (1.0.0) parallel (1.19.1) - parser (2.7.0.4) + parser (2.7.1.2) ast (~> 2.4.0) parslet (1.8.2) peek (1.1.0) @@ -886,6 +886,7 @@ GEM mime-types (>= 1.16, < 4.0) netrc (~> 0.8) retriable (3.1.2) + rexml (3.2.4) rinku (2.0.0) rotp (2.1.2) rouge (3.19.0) @@ -929,18 +930,20 @@ GEM pg rails sqlite3 - rubocop (0.74.0) + rubocop (0.82.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) - parser (>= 2.6) + parser (>= 2.7.0.1) rainbow (>= 2.2.2, < 4.0) + rexml ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) + unicode-display_width (>= 1.4.0, < 2.0) rubocop-gitlab-security (0.1.1) rubocop (>= 0.51) - rubocop-performance (1.4.1) + rubocop-performance (1.5.2) rubocop (>= 0.71.0) - rubocop-rails (2.4.0) + rubocop-rails (2.5.2) + activesupport rack (>= 1.1) rubocop (>= 0.72.0) rubocop-rspec (1.37.0) @@ -1081,7 +1084,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.5) - unicode-display_width (1.6.0) + unicode-display_width (1.7.0) unicode_plot (0.0.4) enumerable-statistics (>= 2.0.1) unicode_utils (1.4.0) @@ -1243,7 +1246,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 (~> 3.2.0) + gitlab-styles (~> 4.2.0) gitlab_chronic_duration (~> 0.10.6.2) gitlab_omniauth-ldap (~> 2.1.1) gon (~> 6.2) @@ -1355,8 +1358,8 @@ DEPENDENCIES rspec-retry (~> 0.6.1) rspec_junit_formatter rspec_profiling (~> 0.0.5) - rubocop (~> 0.74.0) - rubocop-performance (~> 1.4.1) + rubocop (~> 0.82.0) + rubocop-performance (~> 1.5.2) rubocop-rspec (~> 1.37.0) ruby-fogbugz (~> 0.2.1) ruby-prof (~> 1.3.0) diff --git a/app/assets/javascripts/clusters/clusters_bundle.js b/app/assets/javascripts/clusters/clusters_bundle.js index d8bfbdb458c..f15efb2fdeb 100644 --- a/app/assets/javascripts/clusters/clusters_bundle.js +++ b/app/assets/javascripts/clusters/clusters_bundle.js @@ -468,6 +468,11 @@ export default class Clusters { return; } + if (appId === KNATIVE && !params.hostname && !params.pages_domain_id) { + reject(s__('ClusterIntegration|You must specify a domain before you can install Knative.')); + return; + } + resolve(); }); } @@ -520,6 +525,7 @@ export default class Clusters { this.store.updateAppProperty(appId, 'isEditingDomain', true); this.store.updateAppProperty(appId, 'hostname', domain); this.store.updateAppProperty(appId, 'pagesDomain', domainId ? { id: domainId, domain } : null); + this.store.updateAppProperty(appId, 'validationError', null); } setCrossplaneProviderStack(data) { diff --git a/app/assets/javascripts/clusters/components/knative_domain_editor.vue b/app/assets/javascripts/clusters/components/knative_domain_editor.vue index 8136704d13b..ac61cd8e242 100644 --- a/app/assets/javascripts/clusters/components/knative_domain_editor.vue +++ b/app/assets/javascripts/clusters/components/knative_domain_editor.vue @@ -82,6 +82,9 @@ export default { showDomainsDropdown() { return this.availableDomains.length > 0; }, + validationError() { + return this.knative.validationError; + }, }, watch: { knativeUpdateSuccessful(updateSuccessful) { @@ -157,6 +160,8 @@ export default { type="text" class="form-control js-knative-domainname" /> + + <span v-if="validationError" class="gl-field-error">{{ validationError }}</span> </div> <template v-if="knativeInstalled"> diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index c4930d831df..a9e538df136 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -757,13 +757,13 @@ module Ci # and use that for `ExpireBuildInstanceArtifactsWorker`? def erase_erasable_artifacts! - job_artifacts.erasable.destroy_all # rubocop: disable DestroyAll + job_artifacts.erasable.destroy_all # rubocop: disable Cop/DestroyAll end def erase(opts = {}) return false unless erasable? - job_artifacts.destroy_all # rubocop: disable DestroyAll + job_artifacts.destroy_all # rubocop: disable Cop/DestroyAll erase_trace! update_erased!(opts[:erased_by]) end diff --git a/app/models/design_management/design.rb b/app/models/design_management/design.rb index e9b69eab7a7..6434d7cfa57 100644 --- a/app/models/design_management/design.rb +++ b/app/models/design_management/design.rb @@ -126,68 +126,23 @@ module DesignManagement # #12["filename with [] in it.jpg"] def to_reference(from = nil, full: false) infix = full ? '/designs' : '' - totally_simple = %r{ \A #{self.class.simple_file_name} \z }x - safe_name = if totally_simple.match?(filename) - filename - elsif filename =~ /[<>]/ - %Q{base64:#{Base64.strict_encode64(filename)}} - else - escaped = filename.gsub(%r{[\\"]}) { |x| "\\#{x}" } - %Q{"#{escaped}"} - end + safe_name = Sanitize.fragment(filename) "#{issue.to_reference(from, full: full)}#{infix}[#{safe_name}]" end def self.reference_pattern - @reference_pattern ||= begin - # Filenames can be escaped with double quotes to name filenames - # that include square brackets, or other special characters - %r{ - #{Issue.reference_pattern} - (\/designs)? - \[ - (?<design> #{simple_file_name} | #{quoted_file_name} | #{base_64_encoded_name}) - \] - }x - end - end - - def self.simple_file_name - %r{ - (?<simple_file_name> - ( \w | [_:,'-] | \. | \s )+ - \. - \w+ - ) - }x - end - - def self.base_64_encoded_name - %r{ - base64: - (?<base_64_encoded_name> - [A-Za-z0-9+\n]+ - =? - ) - }x - end - - def self.quoted_file_name - %r{ - " - (?<escaped_filename> - (\\ \\ | \\ " | [^"\\])+ - ) - " - }x + # no-op: We only support link_reference_pattern parsing end def self.link_reference_pattern @link_reference_pattern ||= begin - exts = SAFE_IMAGE_EXT + DANGEROUS_IMAGE_EXT path_segment = %r{issues/#{Gitlab::Regex.issue}/designs} - filename_pattern = %r{(?<simple_file_name>[a-z0-9_=-]+\.(#{exts.join('|')}))}i + ext = Regexp.new(Regexp.union(SAFE_IMAGE_EXT + DANGEROUS_IMAGE_EXT).source, Regexp::IGNORECASE) + valid_char = %r{[^/\s]} # any char that is not a forward slash or whitespace + filename_pattern = %r{ + (?<url_filename> #{valid_char}+ \. #{ext}) + }x super(path_segment, filename_pattern) end diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb index 6a86aebae39..3761484b15d 100644 --- a/app/models/lfs_object.rb +++ b/app/models/lfs_object.rb @@ -44,13 +44,13 @@ class LfsObject < ApplicationRecord file_store == LfsObjectUploader::Store::LOCAL end - # rubocop: disable DestroyAll + # rubocop: disable Cop/DestroyAll def self.destroy_unreferenced joins("LEFT JOIN lfs_objects_projects ON lfs_objects_projects.lfs_object_id = #{table_name}.id") .where(lfs_objects_projects: { id: nil }) .destroy_all end - # rubocop: enable DestroyAll + # rubocop: enable Cop/DestroyAll def self.calculate_oid(path) self.hexdigest(path) diff --git a/app/models/user.rb b/app/models/user.rb index e2455e667be..5275a7dd8ed 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -718,7 +718,7 @@ class User < ApplicationRecord otp_grace_period_started_at: nil, otp_backup_codes: nil ) - self.u2f_registrations.destroy_all # rubocop: disable DestroyAll + self.u2f_registrations.destroy_all # rubocop: disable Cop/DestroyAll end end diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index 48a56cded0e..d3b3a46bf74 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -15,6 +15,8 @@ class UserPreference < ApplicationRecord less_than_or_equal_to: Gitlab::TabWidth::MAX } + enum experience_level: { novice: 0, experienced: 1 } + default_value_for :tab_width, value: Gitlab::TabWidth::DEFAULT, allows_nil: false default_value_for :timezone, value: Time.zone.tzinfo.name, allows_nil: false default_value_for :time_display_relative, value: true, allows_nil: false diff --git a/app/services/alert_management/create_alert_issue_service.rb b/app/services/alert_management/create_alert_issue_service.rb index 0197f29145d..beacd240b08 100644 --- a/app/services/alert_management/create_alert_issue_service.rb +++ b/app/services/alert_management/create_alert_issue_service.rb @@ -29,8 +29,7 @@ module AlertManagement delegate :project, to: :alert def allowed? - Feature.enabled?(:alert_management_create_alert_issue, project) && - user.can?(:create_issue, project) + user.can?(:create_issue, project) end def create_issue(alert, user, alert_payload) diff --git a/app/services/award_emojis/destroy_service.rb b/app/services/award_emojis/destroy_service.rb index a61a7911a9d..cfd194262f9 100644 --- a/app/services/award_emojis/destroy_service.rb +++ b/app/services/award_emojis/destroy_service.rb @@ -13,7 +13,7 @@ module AwardEmojis return error("User has not awarded emoji of type #{name} on the awardable", status: :forbidden) end - award = awards.destroy_all.first # rubocop: disable DestroyAll + award = awards.destroy_all.first # rubocop: disable Cop/DestroyAll after_destroy(award) success(award: award) diff --git a/app/services/labels/promote_service.rb b/app/services/labels/promote_service.rb index cc91fd4b4d2..9ed10f6a11b 100644 --- a/app/services/labels/promote_service.rb +++ b/app/services/labels/promote_service.rb @@ -90,7 +90,7 @@ module Labels # rubocop: disable CodeReuse/ActiveRecord def destroy_project_labels(label_ids) - Label.where(id: label_ids).destroy_all # rubocop: disable DestroyAll + Label.where(id: label_ids).destroy_all # rubocop: disable Cop/DestroyAll end # rubocop: enable CodeReuse/ActiveRecord diff --git a/app/services/milestones/promote_service.rb b/app/services/milestones/promote_service.rb index 80e6456f729..2431318cbb2 100644 --- a/app/services/milestones/promote_service.rb +++ b/app/services/milestones/promote_service.rb @@ -76,7 +76,7 @@ module Milestones # rubocop: disable CodeReuse/ActiveRecord def destroy_old_milestones(milestone) - Milestone.where(id: milestone_ids_for_merge(milestone)).destroy_all # rubocop: disable DestroyAll + Milestone.where(id: milestone_ids_for_merge(milestone)).destroy_all # rubocop: disable Cop/DestroyAll end # rubocop: enable CodeReuse/ActiveRecord diff --git a/app/services/pages/delete_service.rb b/app/services/pages/delete_service.rb index d4de6bb750d..7408943e78c 100644 --- a/app/services/pages/delete_service.rb +++ b/app/services/pages/delete_service.rb @@ -4,7 +4,7 @@ module Pages class DeleteService < BaseService def execute project.remove_pages - project.pages_domains.destroy_all # rubocop: disable DestroyAll + project.pages_domains.destroy_all # rubocop: disable Cop/DestroyAll end end end diff --git a/app/services/projects/move_deploy_keys_projects_service.rb b/app/services/projects/move_deploy_keys_projects_service.rb index 01419563538..51d84af249e 100644 --- a/app/services/projects/move_deploy_keys_projects_service.rb +++ b/app/services/projects/move_deploy_keys_projects_service.rb @@ -28,7 +28,7 @@ module Projects # rubocop: enable CodeReuse/ActiveRecord def remove_remaining_deploy_keys_projects - source_project.deploy_keys_projects.destroy_all # rubocop: disable DestroyAll + source_project.deploy_keys_projects.destroy_all # rubocop: disable Cop/DestroyAll end end end diff --git a/app/services/projects/move_lfs_objects_projects_service.rb b/app/services/projects/move_lfs_objects_projects_service.rb index 8cc420d7ba7..57a8d3d69c6 100644 --- a/app/services/projects/move_lfs_objects_projects_service.rb +++ b/app/services/projects/move_lfs_objects_projects_service.rb @@ -20,7 +20,7 @@ module Projects end def remove_remaining_lfs_objects_project - source_project.lfs_objects_projects.destroy_all # rubocop: disable DestroyAll + source_project.lfs_objects_projects.destroy_all # rubocop: disable Cop/DestroyAll end # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/services/projects/move_notification_settings_service.rb b/app/services/projects/move_notification_settings_service.rb index 65a888fe26b..efe06f158cc 100644 --- a/app/services/projects/move_notification_settings_service.rb +++ b/app/services/projects/move_notification_settings_service.rb @@ -21,7 +21,7 @@ module Projects # Remove remaining notification settings from source_project def remove_remaining_notification_settings - source_project.notification_settings.destroy_all # rubocop: disable DestroyAll + source_project.notification_settings.destroy_all # rubocop: disable Cop/DestroyAll end # Get users of current notification_settings diff --git a/app/services/projects/move_project_group_links_service.rb b/app/services/projects/move_project_group_links_service.rb index d1aa9af2bcb..349953ff973 100644 --- a/app/services/projects/move_project_group_links_service.rb +++ b/app/services/projects/move_project_group_links_service.rb @@ -25,7 +25,7 @@ module Projects # Remove remaining project group links from source_project def remove_remaining_project_group_links - source_project.reset.project_group_links.destroy_all # rubocop: disable DestroyAll + source_project.reset.project_group_links.destroy_all # rubocop: disable Cop/DestroyAll end def group_links_in_target_project diff --git a/app/services/projects/move_project_members_service.rb b/app/services/projects/move_project_members_service.rb index de4e7e5a1e3..9a1b7c6d1b6 100644 --- a/app/services/projects/move_project_members_service.rb +++ b/app/services/projects/move_project_members_service.rb @@ -25,7 +25,7 @@ module Projects def remove_remaining_members # Remove remaining members and authorizations from source_project - source_project.project_members.destroy_all # rubocop: disable DestroyAll + source_project.project_members.destroy_all # rubocop: disable Cop/DestroyAll end def project_members_in_target_project diff --git a/app/services/protected_branches/legacy_api_update_service.rb b/app/services/protected_branches/legacy_api_update_service.rb index 65dc3297ae8..0cad23f20f7 100644 --- a/app/services/protected_branches/legacy_api_update_service.rb +++ b/app/services/protected_branches/legacy_api_update_service.rb @@ -39,11 +39,11 @@ module ProtectedBranches def delete_redundant_access_levels unless developers_can_merge.nil? - protected_branch.merge_access_levels.destroy_all # rubocop: disable DestroyAll + protected_branch.merge_access_levels.destroy_all # rubocop: disable Cop/DestroyAll end unless developers_can_push.nil? - protected_branch.push_access_levels.destroy_all # rubocop: disable DestroyAll + protected_branch.push_access_levels.destroy_all # rubocop: disable Cop/DestroyAll end end end diff --git a/app/services/snippets/bulk_destroy_service.rb b/app/services/snippets/bulk_destroy_service.rb index d9cc383a5a6..7056415f7cb 100644 --- a/app/services/snippets/bulk_destroy_service.rb +++ b/app/services/snippets/bulk_destroy_service.rb @@ -19,7 +19,7 @@ module Snippets user_can_delete_snippets! attempt_delete_repositories! - snippets.destroy_all # rubocop: disable DestroyAll + snippets.destroy_all # rubocop: disable Cop/DestroyAll ServiceResponse.success(message: 'Snippets were deleted.') rescue SnippetAccessError diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index fa707b73d3e..54cbed87bd5 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -86,7 +86,7 @@ %li %span.light Current sign-in IP: %strong - - if @user.current_sign_in_ip + - if @user.current_sign_in_ip # rubocop:disable Style/RedundantCondition = @user.current_sign_in_ip - else never @@ -102,7 +102,7 @@ %li %span.light Last sign-in IP: %strong - - if @user.last_sign_in_ip + - if @user.last_sign_in_ip # rubocop:disable Style/RedundantCondition = @user.last_sign_in_ip - else never diff --git a/app/views/shared/_field.html.haml b/app/views/shared/_field.html.haml index 4f416c483f2..cb5fd29b260 100644 --- a/app/views/shared/_field.html.haml +++ b/app/views/shared/_field.html.haml @@ -21,7 +21,7 @@ - elsif type == 'checkbox' = form.check_box name - elsif type == 'select' - = form.select name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control"} + = form.select name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control"} # rubocop:disable Style/RedundantCondition - elsif type == 'password' = form.password_field name, autocomplete: "new-password", placeholder: placeholder, class: "form-control", required: value.blank? && required, data: { qa_selector: "#{name.downcase.gsub('\s', '')}_field" } - if help diff --git a/app/workers/remove_expired_group_links_worker.rb b/app/workers/remove_expired_group_links_worker.rb index 8226f22837c..0dc46cd2b9b 100644 --- a/app/workers/remove_expired_group_links_worker.rb +++ b/app/workers/remove_expired_group_links_worker.rb @@ -7,7 +7,7 @@ class RemoveExpiredGroupLinksWorker # rubocop:disable Scalability/IdempotentWork feature_category :authentication_and_authorization def perform - ProjectGroupLink.expired.destroy_all # rubocop: disable DestroyAll + ProjectGroupLink.expired.destroy_all # rubocop: disable Cop/DestroyAll GroupGroupLink.expired.find_in_batches do |link_batch| Groups::GroupLinks::DestroyService.new(nil, nil).execute(link_batch) diff --git a/changelogs/unreleased/218045-feature-flag-remove-feature-flag-for-create-issue-from-alert-detai.yml b/changelogs/unreleased/218045-feature-flag-remove-feature-flag-for-create-issue-from-alert-detai.yml new file mode 100644 index 00000000000..65b51037ce6 --- /dev/null +++ b/changelogs/unreleased/218045-feature-flag-remove-feature-flag-for-create-issue-from-alert-detai.yml @@ -0,0 +1,5 @@ +--- +title: Add button to create an issue from an alert management alert +merge_request: 33221 +author: +type: added diff --git a/changelogs/unreleased/add-experience-level-to-user-preferences.yml b/changelogs/unreleased/add-experience-level-to-user-preferences.yml new file mode 100644 index 00000000000..2029ebc90d5 --- /dev/null +++ b/changelogs/unreleased/add-experience-level-to-user-preferences.yml @@ -0,0 +1,5 @@ +--- +title: Add experience_level to user_preferences +merge_request: 32784 +author: +type: added diff --git a/changelogs/unreleased/ajk-design-ref-filter.yml b/changelogs/unreleased/ajk-design-ref-filter.yml new file mode 100644 index 00000000000..0f77e344d65 --- /dev/null +++ b/changelogs/unreleased/ajk-design-ref-filter.yml @@ -0,0 +1,5 @@ +--- +title: Enable GitLab-Flavored Markdown processing for design links +merge_request: 32446 +author: +type: added diff --git a/config/webpack.config.js b/config/webpack.config.js index 7c130b010b6..8481d99afeb 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -329,9 +329,6 @@ module.exports = { // automatically configure monaco editor web workers new MonacoWebpackPlugin(), - // prevent pikaday from including moment.js - new webpack.IgnorePlugin(/moment/, /pikaday/), - // fix legacy jQuery plugins which depend on globals new webpack.ProvidePlugin({ $: 'jquery', diff --git a/config/webpack.vendor.config.js b/config/webpack.vendor.config.js index bebd1d656b5..3ac1121fca4 100644 --- a/config/webpack.vendor.config.js +++ b/config/webpack.vendor.config.js @@ -38,7 +38,7 @@ module.exports = { 'katex', 'three', 'select2', - 'moment', + 'moment-mini', 'aws-sdk', 'sanitize-html', 'bootstrap/dist/js/bootstrap.js', diff --git a/db/migrate/20200521022725_add_experience_level_to_user_preferences.rb b/db/migrate/20200521022725_add_experience_level_to_user_preferences.rb new file mode 100644 index 00000000000..e70a13599c3 --- /dev/null +++ b/db/migrate/20200521022725_add_experience_level_to_user_preferences.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddExperienceLevelToUserPreferences < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :user_preferences, :experience_level, :integer, limit: 2 + end +end diff --git a/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb b/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb index 1eb49d60da5..7399404ca0a 100644 --- a/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb +++ b/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb @@ -1,6 +1,6 @@ require_relative '../migrate/20180223120443_create_user_interacted_projects_table.rb' -# rubocop:disable AddIndex -# rubocop:disable AddConcurrentForeignKey +# rubocop:disable Migration/AddIndex +# rubocop:disable Migration/AddConcurrentForeignKey class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers diff --git a/db/structure.sql b/db/structure.sql index a8192b2f78e..f8ed845cb77 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -6711,7 +6711,8 @@ CREATE TABLE public.user_preferences ( setup_for_company boolean, render_whitespace_in_code boolean, tab_width smallint, - feature_filter_type bigint + feature_filter_type bigint, + experience_level smallint ); CREATE SEQUENCE public.user_preferences_id_seq @@ -13951,6 +13952,7 @@ COPY "schema_migrations" (version) FROM STDIN; 20200519171058 20200519194042 20200520103514 +20200521022725 20200525114553 20200525121014 20200526120714 diff --git a/doc/administration/pages/index.md b/doc/administration/pages/index.md index 612ead3d26b..c3d496c7a42 100644 --- a/doc/administration/pages/index.md +++ b/doc/administration/pages/index.md @@ -366,6 +366,10 @@ Pages access control is disabled by default. To enable it: 1. [Reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure). 1. Users can now configure it in their [projects' settings](../../user/project/pages/pages_access_control.md). +NOTE: **Important:** +For multi-node setups, in order for this setting to be effective, it has to be applied +to all the App nodes as well as the Sidekiq nodes. + #### Disabling public access to all Pages websites > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/32095) in GitLab 12.7. diff --git a/doc/api/oauth2.md b/doc/api/oauth2.md index 0bf7ae399f0..cc8b31ecf17 100644 --- a/doc/api/oauth2.md +++ b/doc/api/oauth2.md @@ -173,11 +173,14 @@ the following parameters: } ``` +Also you must use HTTP Basic authentication using the `client_id` and`client_secret` +values to authenticate the client that performs a request. + Example cURL request: ```shell echo 'grant_type=password&username=<your_username>&password=<your_password>' > auth.txt -curl --data "@auth.txt" --request POST "https://gitlab.example.com/oauth/token" +curl --data "@auth.txt" --user client_id:client_secret --request POST "https://gitlab.example.com/oauth/token" ``` Then, you'll receive the access token back in the response: @@ -190,6 +193,8 @@ Then, you'll receive the access token back in the response: } ``` +By default, the scope of the access token is `api`, which provides complete read/write access. + For testing, you can use the `oauth2` Ruby gem: ```ruby diff --git a/doc/ci/cloud_deployment/index.md b/doc/ci/cloud_deployment/index.md index e59846e0f12..a1e722b131e 100644 --- a/doc/ci/cloud_deployment/index.md +++ b/doc/ci/cloud_deployment/index.md @@ -7,13 +7,18 @@ type: howto # Cloud deployment -Interacting with a major cloud provider such as Amazon AWS may have become a much needed task that's +Interacting with a major cloud provider may have become a much needed task that's part of your delivery process. GitLab is making this process less painful by providing Docker images that come with the needed libraries and tools pre-installed. By referencing them in your CI/CD pipeline, you'll be able to interact with your chosen cloud provider more easily. -## Run AWS commands from GitLab CI/CD +## AWS + +GitLab provides Docker images to simplify working with AWS, and a template to make +it easier to [deploy to AWS](#deploy-your-application-to-the-aws-elastic-container-service-ecs). + +### Run AWS commands from GitLab CI/CD > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/31167) in GitLab 12.6. @@ -54,7 +59,7 @@ Some credentials are required to be able to run `aws` commands: Container Registry](../../user/packages/container_registry/index.md) and is ready to use. Alternatively, replace the image with one hosted on AWS ECR. -## Use an AWS Elastic Container Registry (ECR) image in your CI/CD +### Use an AWS Elastic Container Registry (ECR) image in your CI/CD Instead of referencing an image hosted on the GitLab Registry, you can reference an image hosted on any third-party registry, such as the @@ -65,7 +70,7 @@ repository](https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-e Then reference it in your `.gitlab-ci.yml` file and replace the `image` path to point to your ECR image. -## Deploy your application to the AWS Elastic Container Service (ECS) +### Deploy your application to the AWS Elastic Container Service (ECS) > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/207962) in GitLab 12.9. diff --git a/doc/user/markdown.md b/doc/user/markdown.md index 07855a789a6..1cb5af8f74d 100644 --- a/doc/user/markdown.md +++ b/doc/user/markdown.md @@ -442,7 +442,7 @@ In addition to this, links to some objects are also recognized and formatted. So - Comments on issues: `"https://gitlab.com/gitlab-org/gitlab/-/issues/1234#note_101075757"`, which will be rendered as `#1234 (note1)` - The issues designs tab: `"https://gitlab.com/gitlab-org/gitlab/-/issues/1234/designs"`, which will be rendered as `#1234 (designs)`. - **(PREMIUM)** +- Links to individual designs: `"https://gitlab.com/gitlab-org/gitlab/-/issues/1234/designs/layout.png"`, which will be rendered as `#1234[layout.png]`. ### Task lists diff --git a/doc/user/packages/container_registry/img/container_registry_group_repositories_v13_1.png b/doc/user/packages/container_registry/img/container_registry_group_repositories_v13_1.png Binary files differindex 3ac0407cb2e..bbbba44eb9b 100644 --- a/doc/user/packages/container_registry/img/container_registry_group_repositories_v13_1.png +++ b/doc/user/packages/container_registry/img/container_registry_group_repositories_v13_1.png diff --git a/doc/user/packages/container_registry/img/container_registry_repositories_v13_1.png b/doc/user/packages/container_registry/img/container_registry_repositories_v13_1.png Binary files differindex 2f07db80a2d..13a6d1a4470 100644 --- a/doc/user/packages/container_registry/img/container_registry_repositories_v13_1.png +++ b/doc/user/packages/container_registry/img/container_registry_repositories_v13_1.png diff --git a/doc/user/packages/container_registry/img/container_registry_repositories_with_quickstart_v13_1.png b/doc/user/packages/container_registry/img/container_registry_repositories_with_quickstart_v13_1.png Binary files differindex 0fe575e12aa..35a02182a77 100644 --- a/doc/user/packages/container_registry/img/container_registry_repositories_with_quickstart_v13_1.png +++ b/doc/user/packages/container_registry/img/container_registry_repositories_with_quickstart_v13_1.png diff --git a/doc/user/project/issues/design_management.md b/doc/user/project/issues/design_management.md index dda1bc35159..ac887e7d988 100644 --- a/doc/user/project/issues/design_management.md +++ b/doc/user/project/issues/design_management.md @@ -176,3 +176,44 @@ Different discussions have different pin numbers: From GitLab 12.5 on, new discussions will be outputted to the issue activity, so that everyone involved can participate in the discussion. + +## Referring to designs in Markdown + +> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/217160) in **GitLab 13.1**. +> - It is deployed behind a feature flag, disabled by default. +> - It is disabled on GitLab.com. +> - It is not recommended for production use. +> - To use it in GitLab self-managed instances, ask a GitLab administrator to [enable it](#enable-or-disable-design-references-core-only). **(CORE ONLY)** + +We support referring to designs in [Markdown](../../markdown.md), which is available +throughout the application, including in merge request and issue descriptions, in discussions and comments, and in wiki pages. + +At present, full URL references are supported. For example, if we refer to a design +somewhere with: + +```markdown +See http://gitlab.com/your-group/your-project/-/issues/123/designs/homescreen.png +``` + +This will be rendered as: + +> See [#123[homescreen.png]](http://gitlab.com/your-group/your-project/-/issues/123/designs/homescreen.png) + +### Enable or disable design references **(CORE ONLY)** + +Design reference parsing is under development and not ready for production use. It is +deployed behind a feature flag that is **disabled by default**. +[GitLab administrators with access to the GitLab Rails console](../../../administration/feature_flags.md) +can enable it for your instance. + +To enable it: + +```ruby +Feature.enable(:design_management_reference_filter_gfm_pipeline) +``` + +To disable it: + +```ruby +Feature.disable(:design_management_reference_filter_gfm_pipeline) +``` diff --git a/doc/user/project/operations/alert_management.md b/doc/user/project/operations/alert_management.md index 2dcf72aaf01..fae834e589b 100644 --- a/doc/user/project/operations/alert_management.md +++ b/doc/user/project/operations/alert_management.md @@ -72,8 +72,20 @@ You will need at least Developer [permissions](../../permissions.md) to view Ale Navigate to the Alert Management detail view by visiting the [Alert Management list](#alert-management-list) and selecting an Alert from the list. -![Alert Management Detail View](img/alert_detail_v13_0.png) +![Alert Management Detail Overview](img/alert_detail_overview_v13_1.png) + +![Alert Management Full Details](img/alert_detail_full_v13_1.png) ### Update an Alert's status -The Alert Management detail view allows users to update the Alert Status. See [Alert Management statuses](#alert-management-statuses) for more details. +The Alert Management detail view enables you to update the Alert Status. +See [Alert Management statuses](#alert-management-statuses) for more details. + +### Create an Issue from an Alert + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/217745) in GitLab 13.1. + +The Alert Management detail view enables you to create an issue with a +description automatically populated from an alert. To create the issue, +click the **Create Issue** button. You can then view the issue from the +alert by clicking the **View Issue** button. diff --git a/doc/user/project/operations/img/alert_detail_full_v13_1.png b/doc/user/project/operations/img/alert_detail_full_v13_1.png Binary files differnew file mode 100644 index 00000000000..18a6f4fb67b --- /dev/null +++ b/doc/user/project/operations/img/alert_detail_full_v13_1.png diff --git a/doc/user/project/operations/img/alert_detail_overview_v13_1.png b/doc/user/project/operations/img/alert_detail_overview_v13_1.png Binary files differnew file mode 100644 index 00000000000..10c945d3810 --- /dev/null +++ b/doc/user/project/operations/img/alert_detail_overview_v13_1.png diff --git a/doc/user/project/operations/img/alert_detail_v13_0.png b/doc/user/project/operations/img/alert_detail_v13_0.png Binary files differdeleted file mode 100644 index 7da09407cd5..00000000000 --- a/doc/user/project/operations/img/alert_detail_v13_0.png +++ /dev/null diff --git a/doc/user/project/operations/img/alert_issue_v13_1.png b/doc/user/project/operations/img/alert_issue_v13_1.png Binary files differnew file mode 100644 index 00000000000..da79074aa2f --- /dev/null +++ b/doc/user/project/operations/img/alert_issue_v13_1.png diff --git a/doc/user/project/operations/img/alert_management_1_v13_1.png b/doc/user/project/operations/img/alert_management_1_v13_1.png Binary files differindex c01b4749eda..3adc5e799eb 100644 --- a/doc/user/project/operations/img/alert_management_1_v13_1.png +++ b/doc/user/project/operations/img/alert_management_1_v13_1.png diff --git a/lib/banzai/filter/design_reference_filter.rb b/lib/banzai/filter/design_reference_filter.rb new file mode 100644 index 00000000000..7455dfe00ef --- /dev/null +++ b/lib/banzai/filter/design_reference_filter.rb @@ -0,0 +1,121 @@ +# frozen_string_literal: true + +module Banzai + module Filter + class DesignReferenceFilter < AbstractReferenceFilter + FEATURE_FLAG = :design_management_reference_filter_gfm_pipeline + + class Identifier + include Comparable + attr_reader :issue_iid, :filename + + def initialize(issue_iid:, filename:) + @issue_iid = issue_iid + @filename = filename + end + + def as_composite_id(id_for_iid) + id = id_for_iid[issue_iid] + return unless id + + { issue_id: id, filename: filename } + end + + def <=>(other) + return unless other.is_a?(Identifier) + + [issue_iid, filename] <=> [other.issue_iid, other.filename] + end + alias_method :eql?, :== + + def hash + [issue_iid, filename].hash + end + end + + self.reference_type = :design + + # This filter must be enabled by setting the + # design_management_reference_filter_gfm_pipeline flag + def call + return doc unless enabled? + + super + end + + def find_object(project, identifier) + records_per_parent[project][identifier] + end + + def parent_records(project, identifiers) + return [] unless project.design_management_enabled? + + iids = identifiers.map(&:issue_iid).to_set + issues = project.issues.where(iid: iids) + id_for_iid = issues.index_by(&:iid).transform_values(&:id) + issue_by_id = issues.index_by(&:id) + + designs(identifiers, id_for_iid).each do |d| + issue = issue_by_id[d.issue_id] + # optimisation: assign values we have already fetched + d.project = project + d.issue = issue + end + end + + def relation_for_paths(paths) + super.includes(:route, :namespace, :group) + end + + def parent_type + :project + end + + # optimisation to reuse the parent_per_reference query information + def parent_from_ref(ref) + parent_per_reference[ref || current_parent_path] + end + + def url_for_object(design, project) + path_options = { vueroute: design.filename } + Gitlab::Routing.url_helpers.designs_project_issue_path(project, design.issue, path_options) + end + + def data_attributes_for(_text, _project, design, **_kwargs) + super.merge(issue: design.issue_id) + end + + def self.object_class + ::DesignManagement::Design + end + + def self.object_sym + :design + end + + def self.parse_symbol(raw, match_data) + filename = match_data[:url_filename] + iid = match_data[:issue].to_i + Identifier.new(filename: CGI.unescape(filename), issue_iid: iid) + end + + def record_identifier(design) + Identifier.new(filename: design.filename, issue_iid: design.issue.iid) + end + + private + + def designs(identifiers, id_for_iid) + identifiers + .map { |identifier| identifier.as_composite_id(id_for_iid) } + .compact + .in_groups_of(100, false) # limitation of by_issue_id_and_filename, so we batch + .flat_map { |ids| DesignManagement::Design.by_issue_id_and_filename(ids) } + end + + def enabled? + Feature.enabled?(FEATURE_FLAG, parent) + end + end + end +end diff --git a/lib/banzai/filter/issue_reference_filter.rb b/lib/banzai/filter/issue_reference_filter.rb index 37e66387f2e..1a1030c2a1c 100644 --- a/lib/banzai/filter/issue_reference_filter.rb +++ b/lib/banzai/filter/issue_reference_filter.rb @@ -44,7 +44,7 @@ module Banzai end def read_designs?(issue) - Ability.allowed?(current_user, :read_design, issue) + issue.project.design_management_enabled? end end end diff --git a/lib/banzai/pipeline/gfm_pipeline.rb b/lib/banzai/pipeline/gfm_pipeline.rb index 329bbb270bd..2ea5fd3388a 100644 --- a/lib/banzai/pipeline/gfm_pipeline.rb +++ b/lib/banzai/pipeline/gfm_pipeline.rb @@ -56,6 +56,7 @@ module Banzai [ Filter::UserReferenceFilter, Filter::ProjectReferenceFilter, + Filter::DesignReferenceFilter, Filter::IssueReferenceFilter, Filter::ExternalIssueReferenceFilter, Filter::MergeRequestReferenceFilter, diff --git a/lib/gitlab/background_migration/.rubocop.yml b/lib/gitlab/background_migration/.rubocop.yml index 8242821cedc..50112a51675 100644 --- a/lib/gitlab/background_migration/.rubocop.yml +++ b/lib/gitlab/background_migration/.rubocop.yml @@ -15,7 +15,7 @@ Metrics/AbcSize: Metrics/PerceivedComplexity: Enabled: true -Metrics/LineLength: +Layout/LineLength: Enabled: true Details: > Long lines are very hard to read and make it more difficult to review diff --git a/lib/gitlab/import_export/members_mapper.rb b/lib/gitlab/import_export/members_mapper.rb index 263c49c509f..31d1f7b48bd 100644 --- a/lib/gitlab/import_export/members_mapper.rb +++ b/lib/gitlab/import_export/members_mapper.rb @@ -49,7 +49,7 @@ module Gitlab def ensure_default_member! return if user_already_member? - @importable.members.destroy_all # rubocop: disable DestroyAll + @importable.members.destroy_all # rubocop: disable Cop/DestroyAll relation_class.create!(user: @user, access_level: highest_access_level, source_id: @importable.id, importing: true) rescue => e diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 1ecbda9c7f5..904acc7241b 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -5368,6 +5368,9 @@ msgstr "" msgid "ClusterIntegration|You must have an RBAC-enabled cluster to install Knative." msgstr "" +msgid "ClusterIntegration|You must specify a domain before you can install Knative." +msgstr "" + msgid "ClusterIntegration|You should select at least two subnets" msgstr "" diff --git a/package.json b/package.json index 6dda80eb8da..fb058ed0ea4 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,6 @@ "bootstrap": "4.3.1", "brace-expansion": "^1.1.8", "cache-loader": "^4.1.0", - "chart.js": "2.7.2", "classlist-polyfill": "^1.2.0", "clipboard": "^1.7.1", "codemirror": "^5.48.4", diff --git a/spec/controllers/omniauth_callbacks_controller_spec.rb b/spec/controllers/omniauth_callbacks_controller_spec.rb index 0d8a6827afe..302c11ec0c0 100644 --- a/spec/controllers/omniauth_callbacks_controller_spec.rb +++ b/spec/controllers/omniauth_callbacks_controller_spec.rb @@ -212,7 +212,7 @@ describe OmniauthCallbacksController, type: :controller do end it 'allows linking the disabled provider' do - user.identities.destroy_all # rubocop: disable DestroyAll + user.identities.destroy_all # rubocop: disable Cop/DestroyAll sign_in(user) expect { post provider }.to change { user.reload.identities.count }.by(1) diff --git a/spec/controllers/projects/tags/releases_controller_spec.rb b/spec/controllers/projects/tags/releases_controller_spec.rb index cb12e074732..261c141d06f 100644 --- a/spec/controllers/projects/tags/releases_controller_spec.rb +++ b/spec/controllers/projects/tags/releases_controller_spec.rb @@ -16,7 +16,7 @@ describe Projects::Tags::ReleasesController do describe 'GET #edit' do it 'initializes a new release' do tag_id = release.tag - project.releases.destroy_all # rubocop: disable DestroyAll + project.releases.destroy_all # rubocop: disable Cop/DestroyAll response = get :edit, params: { namespace_id: project.namespace, project_id: project, tag_id: tag_id } diff --git a/spec/features/projects/issues/design_management/user_links_to_designs_in_issue_spec.rb b/spec/features/projects/issues/design_management/user_links_to_designs_in_issue_spec.rb new file mode 100644 index 00000000000..bb9f902833d --- /dev/null +++ b/spec/features/projects/issues/design_management/user_links_to_designs_in_issue_spec.rb @@ -0,0 +1,123 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'viewing issues with design references' do + include DesignManagementTestHelpers + + let_it_be(:public_project) { create(:project_empty_repo, :public) } + let_it_be(:private_project) { create(:project_empty_repo) } + + let(:user) { create(:user) } + let(:design_issue) { create(:issue, project: project) } + let(:design_a) { create(:design, :with_file, issue: design_issue) } + let(:design_b) { create(:design, :with_file, issue: design_issue) } + let(:issue_ref) { design_issue.to_reference(public_project) } + let(:design_ref_a) { design_a.to_reference(public_project) } + let(:design_ref_b) { design_b.to_reference(public_project) } + let(:design_tab_ref) { "#{issue_ref} (designs)" } + + let(:description) do + <<~MD + The designs I mentioned: + + * #{url_for_designs(design_issue)} + * #{url_for_design(design_a)} + * #{url_for_design(design_b)} + MD + end + + def visit_page_with_design_references + public_issue = create(:issue, project: public_project, description: description) + visit project_issue_path(public_issue.project, public_issue) + end + + shared_examples 'successful use of design link references' do + before do + enable_design_management + end + + it 'shows the issue description and design references', :aggregate_failures do + visit_page_with_design_references + + expect(page).to have_text('The designs I mentioned') + expect(page).to have_link(design_tab_ref) + expect(page).to have_link(design_ref_a) + expect(page).to have_link(design_ref_b) + end + end + + context 'the user has access to a public project' do + let(:project) { public_project } + + it_behaves_like 'successful use of design link references' + end + + context 'the user does not have access to a private project' do + let(:project) { private_project } + + it 'redacts inaccessible design references', :aggregate_failures do + visit_page_with_design_references + + expect(page).to have_text('The designs I mentioned') + expect(page).not_to have_link(issue_ref) + expect(page).not_to have_link(design_tab_ref) + expect(page).not_to have_link(design_ref_a) + expect(page).not_to have_link(design_ref_b) + end + end + + context 'the user has access to a private project' do + let(:project) { private_project } + + before do + project.add_developer(user) + sign_in(user) + end + + it_behaves_like 'successful use of design link references' + + context 'design management is entirely disabled' do + it 'processes design links as issue references', :aggregate_failures do + enable_design_management(false) + + visit_page_with_design_references + + expect(page).to have_text('The designs I mentioned') + expect(page).to have_link(issue_ref) + expect(page).not_to have_link(design_tab_ref) + expect(page).not_to have_link(design_ref_a) + expect(page).not_to have_link(design_ref_b) + end + end + + context 'design management is enabled, but the filter is disabled globally' do + before do + enable_design_management + stub_feature_flags( + Banzai::Filter::DesignReferenceFilter::FEATURE_FLAG => false + ) + end + + it 'processes design tab links successfully, and design references as issue references', :aggregate_failures do + visit_page_with_design_references + + expect(page).to have_text('The designs I mentioned') + expect(page).to have_link(design_tab_ref) + expect(page).to have_link(issue_ref) + expect(page).not_to have_link(design_ref_a) + expect(page).not_to have_link(design_ref_b) + end + end + + context 'design management is enabled, and the filter is enabled for the current project' do + before do + stub_feature_flags( + Banzai::Filter::DesignReferenceFilter::FEATURE_FLAG => public_project + ) + end + + it_behaves_like 'successful use of design link references' + end + end +end diff --git a/spec/frontend/clusters/clusters_bundle_spec.js b/spec/frontend/clusters/clusters_bundle_spec.js index 9d0ed423759..a9870e4db57 100644 --- a/spec/frontend/clusters/clusters_bundle_spec.js +++ b/spec/frontend/clusters/clusters_bundle_spec.js @@ -268,13 +268,18 @@ describe('Clusters', () => { cluster.store.state.applications[applicationId].status = INSTALLABLE; + const params = {}; + if (applicationId === 'knative') { + params.hostname = 'test-example.com'; + } + // eslint-disable-next-line promise/valid-params cluster - .installApplication({ id: applicationId }) + .installApplication({ id: applicationId, params }) .then(() => { expect(cluster.store.state.applications[applicationId].status).toEqual(INSTALLING); expect(cluster.store.state.applications[applicationId].requestReason).toEqual(null); - expect(cluster.service.installApplication).toHaveBeenCalledWith(applicationId, undefined); + expect(cluster.service.installApplication).toHaveBeenCalledWith(applicationId, params); done(); }) .catch(); diff --git a/spec/lib/banzai/filter/design_reference_filter_spec.rb b/spec/lib/banzai/filter/design_reference_filter_spec.rb new file mode 100644 index 00000000000..8a6c2e3b3f9 --- /dev/null +++ b/spec/lib/banzai/filter/design_reference_filter_spec.rb @@ -0,0 +1,307 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Banzai::Filter::DesignReferenceFilter do + include FilterSpecHelper + include DesignManagementTestHelpers + + let_it_be(:issue) { create(:issue, iid: 10) } + let_it_be(:issue_proj_2) { create(:issue, iid: 20) } + let_it_be(:issue_b) { create(:issue, project: issue.project) } + let_it_be(:developer) { create(:user, developer_projects: [issue.project, issue_proj_2.project]) } + let_it_be(:design_a) { create(:design, :with_versions, issue: issue) } + let_it_be(:design_b) { create(:design, :with_versions, issue: issue_b) } + let_it_be(:design_proj_2) { create(:design, :with_versions, issue: issue_proj_2) } + let_it_be(:project_with_no_lfs) { create(:project, :public, lfs_enabled: false) } + + let(:design) { design_a } + let(:project) { issue.project } + let(:project_2) { issue_proj_2.project } + let(:reference) { design.to_reference } + let(:design_url) { url_for_design(design) } + let(:input_text) { "Added #{design_url}" } + let(:doc) { process_doc(input_text) } + let(:current_user) { developer } + + before do + enable_design_management + end + + shared_examples 'a no-op filter' do + it 'does nothing' do + expect(process(input_text)).to eq(baseline(input_text).to_html) + end + end + + shared_examples 'a good link reference' do + let(:link) { doc.css('a').first } + let(:href) { url_for_design(design) } + let(:title) { design.filename } + + it 'produces a good link', :aggregate_failures do + expect(link.attr('href')).to eq(href) + expect(link.attr('title')).to eq(title) + expect(link.attr('class')).to eq('gfm gfm-design has-tooltip') + expect(link.attr('data-project')).to eq(design.project.id.to_s) + expect(link.attr('data-issue')).to eq(design.issue.id.to_s) + expect(link.attr('data-original')).to eq(href) + expect(link.attr('data-reference-type')).to eq('design') + expect(link.text).to eq(design.to_reference(project)) + end + end + + describe '.call' do + it 'requires project context' do + expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) + end + end + + it 'does not error when we add redaction to the pipeline' do + enable_design_management + + res = reference_pipeline(redact: true).to_document(input_text) + + expect(res.css('a').first).to be_present + end + + describe '#call' do + describe 'feature flags' do + context 'design management is not enabled' do + before do + enable_design_management(false) + end + + it_behaves_like 'a no-op filter' + end + + context 'design reference filter is not enabled' do + before do + stub_feature_flags(described_class::FEATURE_FLAG => false) + end + + it_behaves_like 'a no-op filter' + + it 'issues no queries' do + expect { process(input_text) }.not_to exceed_query_limit(0) + end + end + + context 'the filter is enabled for the context project' do + before do + stub_feature_flags(described_class::FEATURE_FLAG => project) + end + + it_behaves_like 'a good link reference' + end + end + end + + %w(pre code a style).each do |elem| + context "wrapped in a <#{elem}/>" do + let(:input_text) { "<#{elem}>Design #{url_for_design(design)}</#{elem}>" } + + it_behaves_like 'a no-op filter' + end + end + + describe '.identifier' do + where(:filename) do + [ + ['simple.png'], + ['SIMPLE.PNG'], + ['has spaces.png'], + ['has-hyphen.jpg'], + ['snake_case.svg'], + ['has "quotes".svg'], + ['has <special> characters [o].svg'] + ] + end + + with_them do + let(:design) { build(:design, issue: issue, filename: filename) } + let(:url) { url_for_design(design) } + let(:pattern) { described_class.object_class.link_reference_pattern } + let(:parsed) do + m = pattern.match(url) + described_class.identifier(m) if m + end + + it 'can parse the reference' do + expect(parsed).to have_attributes( + filename: filename, + issue_iid: issue.iid + ) + end + end + end + + describe 'static properties' do + specify do + expect(described_class).to have_attributes( + object_sym: :design, + object_class: ::DesignManagement::Design + ) + end + end + + describe '#data_attributes_for' do + let(:subject) { filter_instance.data_attributes_for(input_text, project, design) } + + specify do + is_expected.to include(issue: design.issue_id, + original: input_text, + project: project.id, + design: design.id) + end + end + + context 'a design with a quoted filename' do + let(:filename) { %q{A "very" good file.png} } + let(:design) { create(:design, :with_versions, issue: issue, filename: filename) } + + it 'links to the design' do + expect(doc.css('a').first.attr('href')) + .to eq url_for_design(design) + end + end + + context 'internal reference' do + it_behaves_like 'a reference containing an element node' + + context 'the reference is valid' do + it_behaves_like 'a good link reference' + + context 'the filename needs to be escaped' do + where(:filename) do + [ + ['with some spaces.png'], + ['with <script>console.log("pwded")<%2Fscript>.png'] + ] + end + + with_them do + let(:design) { create(:design, :with_versions, filename: filename, issue: issue) } + let(:link) { doc.css('a').first } + + it 'replaces the content with the reference, but keeps the link', :aggregate_failures do + expect(doc.text).to eq(CGI.unescapeHTML("Added #{design.to_reference}")) + expect(link.attr('title')).to eq(design.filename) + expect(link.attr('href')).to eq(design_url) + end + end + end + end + + context 'the reference is to a non-existant design' do + let(:design_url) { url_for_design(build(:design, issue: issue)) } + + it_behaves_like 'a no-op filter' + end + + context 'design management is disabled for the referenced project' do + let(:public_issue) { create(:issue, project: project_with_no_lfs) } + let(:design) { create(:design, :with_versions, issue: public_issue) } + + it_behaves_like 'a no-op filter' + end + end + + describe 'link pattern' do + let(:reference) { url_for_design(design) } + + it 'matches' do + expect(reference).to match(DesignManagement::Design.link_reference_pattern) + end + end + + context 'cross-project / cross-namespace complete reference' do + let(:design) { design_proj_2 } + + it_behaves_like 'a reference containing an element node' + + it_behaves_like 'a good link reference' + + it 'links to a valid reference' do + expect(doc.css('a').first.attr('href')).to eq(design_url) + end + + context 'design management is disabled for that project' do + let(:design) { create(:design, project: project_with_no_lfs) } + + it_behaves_like 'a no-op filter' + end + + it 'link has valid text' do + ref = "#{design.project.full_path}##{design.issue.iid}[#{design.filename}]" + + expect(doc.css('a').first.text).to eql(ref) + end + + it 'includes default classes' do + expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-design has-tooltip' + end + + context 'the reference is invalid' do + let(:design_url) { url_for_design(design).gsub(/jpg/, 'gif') } + + it_behaves_like 'a no-op filter' + end + end + + describe 'performance' do + it 'is linear in the number of projects with design management enabled each design refers to' do + design_c = build(:design, :with_versions, issue: issue) + design_d = build(:design, :with_versions, issue: issue_b) + design_e = build(:design, :with_versions, issue: build_stubbed(:issue, project: project_2)) + + one_ref_per_project = <<~MD + Design #{url_for_design(design_a)}, #{url_for_design(design_proj_2)} + MD + + multiple_references = <<~MD + Designs that affect the count: + * #{url_for_design(design_a)} + * #{url_for_design(design_b)} + * #{url_for_design(design_c)} + * #{url_for_design(design_d)} + * #{url_for_design(design_proj_2)} + * #{url_for_design(design_e)} + + Things that do not affect the count: + * #{url_for_design(build_stubbed(:design, project: project_with_no_lfs))} + * #{url_for_designs(issue)} + * #1[not a valid reference.gif] + MD + + baseline = ActiveRecord::QueryRecorder.new { process(one_ref_per_project) } + + # each project mentioned requires 2 queries: + # + # * SELECT "issues".* FROM "issues" WHERE "issues"."project_id" = 1 AND ... + # :in `parent_records'*/ + # * SELECT "_designs".* FROM "_designs" + # WHERE (issue_id = ? AND filename = ?) OR ... + # :in `parent_records'*/ + # + # In addition there is a 1 query overhead for all the projects at the + # start. Currently, the baseline for 2 projects is `2 * 2 + 1 = 5` queries + # + expect { process(multiple_references) }.not_to exceed_query_limit(baseline.count) + end + end + + private + + def process_doc(text) + reference_filter(text, project: project) + end + + def baseline(text) + null_filter(text, project: project) + end + + def process(text) + process_doc(text).to_html + end +end diff --git a/spec/lib/banzai/filter/issue_reference_filter_spec.rb b/spec/lib/banzai/filter/issue_reference_filter_spec.rb index 61c59162a30..0f0d4af55ea 100644 --- a/spec/lib/banzai/filter/issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/issue_reference_filter_spec.rb @@ -374,6 +374,16 @@ describe Banzai::Filter::IssueReferenceFilter do expect(link.attr('href')).to eq(designs_tab_url) expect(link.text).to eq("#{issue.to_reference} (designs)") end + + context 'design management is not available' do + before do + enable_design_management(false) + end + + it 'links to the issue, but not to the designs tab' do + expect(link.text).to eq(issue.to_reference) + end + end end context 'group context' do diff --git a/spec/lib/gitlab/import/merge_request_creator_spec.rb b/spec/lib/gitlab/import/merge_request_creator_spec.rb index ff2c3032dbf..48a57f9b251 100644 --- a/spec/lib/gitlab/import/merge_request_creator_spec.rb +++ b/spec/lib/gitlab/import/merge_request_creator_spec.rb @@ -15,7 +15,7 @@ describe Gitlab::Import::MergeRequestCreator do it 'updates the data' do commits_count = commits.count - merge_request.merge_request_diffs.destroy_all # rubocop: disable DestroyAll + merge_request.merge_request_diffs.destroy_all # rubocop: disable Cop/DestroyAll expect(merge_request.merge_request_diffs.count).to eq(0) diff --git a/spec/models/ci/build_trace_chunk_spec.rb b/spec/models/ci/build_trace_chunk_spec.rb index f08f05a09bf..85873847fca 100644 --- a/spec/models/ci/build_trace_chunk_spec.rb +++ b/spec/models/ci/build_trace_chunk_spec.rb @@ -33,7 +33,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do expect(subjects.count).to be > 0 expect { subjects.first.destroy }.to raise_error('`destroy` and `destroy_all` are forbidden. Please use `fast_destroy_all`') - expect { subjects.destroy_all }.to raise_error('`destroy` and `destroy_all` are forbidden. Please use `fast_destroy_all`') # rubocop: disable DestroyAll + expect { subjects.destroy_all }.to raise_error('`destroy` and `destroy_all` are forbidden. Please use `fast_destroy_all`') # rubocop: disable Cop/DestroyAll expect(subjects.count).to be > 0 expect(external_data_counter).to be > 0 diff --git a/spec/models/design_management/design_spec.rb b/spec/models/design_management/design_spec.rb index 95782c1f674..fa8215dbc78 100644 --- a/spec/models/design_management/design_spec.rb +++ b/spec/models/design_management/design_spec.rb @@ -460,38 +460,6 @@ describe DesignManagement::Design do it 'uses the simple format' do expect(reference).to eq "#1[homescreen.jpg]" end - - context 'when the filename contains spaces, hyphens, periods, single-quotes, underscores and colons' do - let(:filename) { %q{a complex filename: containing - _ : etc., but still 'simple'.gif} } - - it 'uses the simple format' do - expect(reference).to eq "#1[#{filename}]" - end - end - - context 'when the filename contains HTML angle brackets' do - let(:filename) { 'a <em>great</em> filename.jpg' } - - it 'uses Base64 encoding' do - expect(reference).to eq "#1[base64:#{Base64.strict_encode64(filename)}]" - end - end - - context 'when the filename contains quotation marks' do - let(:filename) { %q{a "great" filename.jpg} } - - it 'uses enclosing quotes, with backslash encoding' do - expect(reference).to eq %q{#1["a \"great\" filename.jpg"]} - end - end - - context 'when the filename contains square brackets' do - let(:filename) { %q{a [great] filename.jpg} } - - it 'uses enclosing quotes' do - expect(reference).to eq %q{#1["a [great] filename.jpg"]} - end - end end context 'when full is true' do @@ -525,31 +493,55 @@ describe DesignManagement::Design do end describe 'reference_pattern' do - let(:match) { described_class.reference_pattern.match(ref) } - let(:ref) { design.to_reference } - let(:design) { build(:design, filename: filename) } + it 'is nil' do + expect(described_class.reference_pattern).to be_nil + end + end - context 'simple_file_name' do - let(:filename) { 'simple-file-name.jpg' } + describe 'link_reference_pattern' do + it 'is not nil' do + expect(described_class.link_reference_pattern).not_to be_nil + end + + it 'does not match the designs tab' do + expect(described_class.link_reference_pattern).not_to match(url_for_designs(issue)) + end - it 'matches :simple_file_name' do - expect(match[:simple_file_name]).to eq(filename) + where(:ext) do + (described_class::SAFE_IMAGE_EXT + described_class::DANGEROUS_IMAGE_EXT).flat_map do |ext| + [[ext], [ext.upcase]] end end - context 'quoted_file_name' do - let(:filename) { 'simple "file" name.jpg' } + with_them do + let(:filename) { "my-file.#{ext}" } + let(:design) { build(:design, filename: filename) } + let(:url) { url_for_design(design) } + let(:captures) { described_class.link_reference_pattern.match(url)&.named_captures } - it 'matches :simple_file_name' do - expect(match[:escaped_filename].gsub(/\\"/, '"')).to eq(filename) + it 'matches the URL' do + expect(captures).to include( + 'url_filename' => filename, + 'issue' => design.issue.iid.to_s, + 'namespace' => design.project.namespace.to_param, + 'project' => design.project.name + ) end - end - context 'Base64 name' do - let(:filename) { '<>.png' } + context 'the file needs to be encoded' do + let(:filename) { "my file.#{ext}" } - it 'matches base_64_encoded_name' do - expect(Base64.decode64(match[:base_64_encoded_name])).to eq(filename) + it 'extracts the encoded filename' do + expect(captures).to include('url_filename' => 'my%20file.' + ext) + end + end + + context 'the file is all upper case' do + let(:filename) { "file.#{ext}".upcase } + + it 'extracts the encoded filename' do + expect(captures).to include('url_filename' => filename) + end end end end diff --git a/spec/models/fork_network_member_spec.rb b/spec/models/fork_network_member_spec.rb index eab758248de..d7a0dd5be65 100644 --- a/spec/models/fork_network_member_spec.rb +++ b/spec/models/fork_network_member_spec.rb @@ -13,7 +13,7 @@ describe ForkNetworkMember do let(:fork_network) { fork_network_member.fork_network } it 'removes the fork network if it was the last member' do - fork_network.fork_network_members.destroy_all # rubocop: disable DestroyAll + fork_network.fork_network_members.destroy_all # rubocop: disable Cop/DestroyAll expect(ForkNetwork.count).to eq(0) end diff --git a/spec/models/hooks/system_hook_spec.rb b/spec/models/hooks/system_hook_spec.rb index 94f1b0cba2e..2e836c19e3c 100644 --- a/spec/models/hooks/system_hook_spec.rb +++ b/spec/models/hooks/system_hook_spec.rb @@ -75,7 +75,7 @@ describe SystemHook do it "project member destroy hook" do project.add_maintainer(user) - project.project_members.destroy_all # rubocop: disable DestroyAll + project.project_members.destroy_all # rubocop: disable Cop/DestroyAll expect(WebMock).to have_requested(:post, system_hook.url).with( body: /user_remove_from_team/, @@ -121,7 +121,7 @@ describe SystemHook do it 'group member destroy hook' do group.add_maintainer(user) - group.group_members.destroy_all # rubocop: disable DestroyAll + group.group_members.destroy_all # rubocop: disable Cop/DestroyAll expect(WebMock).to have_requested(:post, system_hook.url).with( body: /user_remove_from_group/, diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 87d982c1cff..1c3f0c9a93f 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -2623,7 +2623,7 @@ describe MergeRequest do context 'with no discussions' do before do - merge_request.notes.destroy_all # rubocop: disable DestroyAll + merge_request.notes.destroy_all # rubocop: disable Cop/DestroyAll end it 'returns true' do diff --git a/spec/models/project_group_link_spec.rb b/spec/models/project_group_link_spec.rb index 9c51180b55b..41fb956b4a5 100644 --- a/spec/models/project_group_link_spec.rb +++ b/spec/models/project_group_link_spec.rb @@ -60,7 +60,7 @@ describe ProjectGroupLink do project.project_group_links.create(group: group) group_users.each { |user| expect(user.authorized_projects).to include(project) } - project.project_group_links.destroy_all # rubocop: disable DestroyAll + project.project_group_links.destroy_all # rubocop: disable Cop/DestroyAll group_users.each { |user| expect(user.authorized_projects).not_to include(project) } end end diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb index 9faddfd00e5..6b17a8285a2 100644 --- a/spec/policies/group_policy_spec.rb +++ b/spec/policies/group_policy_spec.rb @@ -175,7 +175,7 @@ describe GroupPolicy do nested_group.add_guest(developer) nested_group.add_guest(maintainer) - group.owners.destroy_all # rubocop: disable DestroyAll + group.owners.destroy_all # rubocop: disable Cop/DestroyAll group.add_guest(owner) nested_group.add_owner(owner) diff --git a/spec/requests/api/graphql/project/merge_requests_spec.rb b/spec/requests/api/graphql/project/merge_requests_spec.rb index 8e5876af29e..49fdfe29874 100644 --- a/spec/requests/api/graphql/project/merge_requests_spec.rb +++ b/spec/requests/api/graphql/project/merge_requests_spec.rb @@ -42,7 +42,7 @@ describe 'getting merge request listings nested in a project' do # all the gitaly calls. Selecting combinations of fields may mask this due to # memoization. context 'requesting a single field' do - let(:fresh_mr) { create(:merge_request, :unique_branches, source_project: project) } + let_it_be(:fresh_mr) { create(:merge_request, :unique_branches, source_project: project) } let(:search_params) { { iids: [fresh_mr.iid.to_s] } } before do diff --git a/spec/requests/api/oauth_tokens_spec.rb b/spec/requests/api/oauth_tokens_spec.rb index 80eae97f41a..3266fed1741 100644 --- a/spec/requests/api/oauth_tokens_spec.rb +++ b/spec/requests/api/oauth_tokens_spec.rb @@ -4,15 +4,32 @@ require 'spec_helper' describe 'OAuth tokens' do context 'Resource Owner Password Credentials' do - def request_oauth_token(user) - post '/oauth/token', params: { username: user.username, password: user.password, grant_type: 'password' } + def basic_auth_header(username, password) + { + 'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials( + username, + password + ) + } end + def client_basic_auth_header(client) + basic_auth_header(client.uid, client.secret) + end + + def request_oauth_token(user, headers = {}) + post '/oauth/token', + params: { username: user.username, password: user.password, grant_type: 'password' }, + headers: headers + end + + let_it_be(:client) { create(:oauth_application) } + context 'when user has 2FA enabled' do it 'does not create an access token' do user = create(:user, :two_factor) - request_oauth_token(user) + request_oauth_token(user, client_basic_auth_header(client)) expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response['error']).to eq('invalid_grant') @@ -20,13 +37,46 @@ describe 'OAuth tokens' do end context 'when user does not have 2FA enabled' do - it 'creates an access token' do - user = create(:user) + # NOTE: using ROPS grant flow without client credentials will be deprecated + # and removed in the next version of Doorkeeper. + # See https://gitlab.com/gitlab-org/gitlab/-/issues/219137 + context 'when no client credentials provided' do + it 'creates an access token' do + user = create(:user) + + request_oauth_token(user) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['access_token']).not_to be_nil + end + end + + context 'when client credentials provided' do + context 'with valid credentials' do + it 'creates an access token' do + user = create(:user) + + request_oauth_token(user, client_basic_auth_header(client)) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['access_token']).not_to be_nil + end + end + + context 'with invalid credentials' do + it 'does not create an access token' do + # NOTE: remove this after update to Doorkeeper 5.5 or newer, see + # https://gitlab.com/gitlab-org/gitlab/-/issues/219137 + pending 'Enable this example after upgrading Doorkeeper to 5.5 or newer' + + user = create(:user) - request_oauth_token(user) + request_oauth_token(user, basic_auth_header(client.uid, 'invalid secret')) - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['access_token']).not_to be_nil + expect(response).to have_gitlab_http_status(:unauthorized) + expect(json_response['error']).to eq('invalid_client') + end + end end end @@ -40,7 +90,7 @@ describe 'OAuth tokens' do before do user.block - request_oauth_token(user) + request_oauth_token(user, client_basic_auth_header(client)) end include_examples 'does not create an access token' @@ -50,7 +100,7 @@ describe 'OAuth tokens' do before do user.ldap_block - request_oauth_token(user) + request_oauth_token(user, client_basic_auth_header(client)) end include_examples 'does not create an access token' @@ -60,7 +110,7 @@ describe 'OAuth tokens' do before do user.update!(confirmed_at: nil) - request_oauth_token(user) + request_oauth_token(user, client_basic_auth_header(client)) end include_examples 'does not create an access token' diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index e28236b9600..0818bab6bc2 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -468,13 +468,14 @@ describe API::Users, :do_not_mock_admin_mode do context "when authenticated and ldap is enabled" do it "returns non-ldap user" do - create :omniauth_user, provider: "ldapserver1" + ldap_user = create :omniauth_user, provider: "ldapserver1" get api("/users", user), params: { skip_ldap: "true" } expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_an Array - expect(json_response.first["username"]).to eq user.username + expect(json_response.map { |u| u['username'] }) + .not_to include(ldap_user.username) end end end diff --git a/spec/rubocop/cop/active_record_association_reload_spec.rb b/spec/rubocop/cop/active_record_association_reload_spec.rb index 3cd7a35f12f..d9c8069f0c3 100644 --- a/spec/rubocop/cop/active_record_association_reload_spec.rb +++ b/spec/rubocop/cop/active_record_association_reload_spec.rb @@ -11,7 +11,7 @@ describe RuboCop::Cop::ActiveRecordAssociationReload do context 'when using ActiveRecord::Base' do it 'registers an offense on reload usage' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) users = User.all users.reload ^^^^^^ Use reset instead of reload. For more details check the https://gitlab.com/gitlab-org/gitlab-foss/issues/60218. @@ -19,7 +19,7 @@ describe RuboCop::Cop::ActiveRecordAssociationReload do end it 'does not register an offense on reset usage' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) users = User.all users.reset PATTERN @@ -28,7 +28,7 @@ describe RuboCop::Cop::ActiveRecordAssociationReload do context 'when using ActiveRecord::Relation' do it 'registers an offense on reload usage' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) user = User.new user.reload ^^^^^^ Use reset instead of reload. For more details check the https://gitlab.com/gitlab-org/gitlab-foss/issues/60218. @@ -36,7 +36,7 @@ describe RuboCop::Cop::ActiveRecordAssociationReload do end it 'does not register an offense on reset usage' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) user = User.new user.reset PATTERN @@ -45,14 +45,14 @@ describe RuboCop::Cop::ActiveRecordAssociationReload do context 'when using on self' do it 'registers an offense on reload usage' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) reload ^^^^^^ Use reset instead of reload. For more details check the https://gitlab.com/gitlab-org/gitlab-foss/issues/60218. PATTERN end it 'does not register an offense on reset usage' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) reset PATTERN end diff --git a/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb b/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb index c9eb61ccc72..207c3420fbd 100644 --- a/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb +++ b/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb @@ -14,14 +14,14 @@ describe RuboCop::Cop::AvoidRouteRedirectLeadingSlash do end it 'registers an offense when redirect has a leading slash' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) root to: redirect("/-/route") ^^^^^^^^^^^^^^^^^^^^ Do not use a leading "/" in route redirects PATTERN end it 'does not register an offense when redirect does not have a leading slash' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) root to: redirect("-/route") PATTERN end diff --git a/spec/rubocop/cop/destroy_all_spec.rb b/spec/rubocop/cop/destroy_all_spec.rb index ac8aa56e040..d06c0b2f3cf 100644 --- a/spec/rubocop/cop/destroy_all_spec.rb +++ b/spec/rubocop/cop/destroy_all_spec.rb @@ -11,13 +11,13 @@ describe RuboCop::Cop::DestroyAll do subject(:cop) { described_class.new } it 'flags the use of destroy_all with a send receiver' do - inspect_source('foo.destroy_all # rubocop: disable DestroyAll') + inspect_source('foo.destroy_all # rubocop: disable Cop/DestroyAll') expect(cop.offenses.size).to eq(1) end it 'flags the use of destroy_all with a constant receiver' do - inspect_source('User.destroy_all # rubocop: disable DestroyAll') + inspect_source('User.destroy_all # rubocop: disable Cop/DestroyAll') expect(cop.offenses.size).to eq(1) end @@ -31,7 +31,7 @@ describe RuboCop::Cop::DestroyAll do it 'flags the use of destroy_all with a local variable receiver' do inspect_source(<<~RUBY) users = User.all - users.destroy_all # rubocop: disable DestroyAll + users.destroy_all # rubocop: disable Cop/DestroyAll RUBY expect(cop.offenses.size).to eq(1) diff --git a/spec/rubocop/cop/gitlab/change_timezone_spec.rb b/spec/rubocop/cop/gitlab/change_timezone_spec.rb index af76559a9fa..1e4b4048cf4 100644 --- a/spec/rubocop/cop/gitlab/change_timezone_spec.rb +++ b/spec/rubocop/cop/gitlab/change_timezone_spec.rb @@ -12,7 +12,7 @@ describe RuboCop::Cop::Gitlab::ChangeTimezone do context 'Time.zone=' do it 'registers an offense with no 2nd argument' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) Time.zone = 'Awkland' ^^^^^^^^^^^^^^^^^^^^^ Do not change timezone in the runtime (application or rspec), it could result in silently modifying other behavior. PATTERN diff --git a/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb b/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb index 0ff06b431eb..bf0434e7afe 100644 --- a/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb +++ b/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb @@ -12,7 +12,7 @@ describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do context 'Object.const_get' do it 'registers an offense with no 2nd argument' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) Object.const_get(:CONSTANT) ^^^^^^^^^ Use inherit=false when using const_get. PATTERN @@ -24,7 +24,7 @@ describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do context 'inherit=false' do it 'does not register an offense' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) Object.const_get(:CONSTANT, false) PATTERN end @@ -32,7 +32,7 @@ describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do context 'inherit=true' do it 'registers an offense' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) Object.const_get(:CONSTANT, true) ^^^^^^^^^ Use inherit=false when using const_get. PATTERN @@ -46,7 +46,7 @@ describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do context 'const_get for a nested class' do it 'registers an offense on reload usage' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) Nested::Blog.const_get(:CONSTANT) ^^^^^^^^^ Use inherit=false when using const_get. PATTERN @@ -58,7 +58,7 @@ describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do context 'inherit=false' do it 'does not register an offense' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) Nested::Blog.const_get(:CONSTANT, false) PATTERN end @@ -66,7 +66,7 @@ describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do context 'inherit=true' do it 'registers an offense if inherit is true' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) Nested::Blog.const_get(:CONSTANT, true) ^^^^^^^^^ Use inherit=false when using const_get. PATTERN diff --git a/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb b/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb index 87dd2f14b31..3a0a74a4713 100644 --- a/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb +++ b/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb @@ -20,7 +20,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do context 'Non-EE spec file' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, full_path('spec/foo_spec.rb')) + expect_no_offenses(<<~SOURCE, full_path('spec/foo_spec.rb')) describe 'Foo' do end SOURCE @@ -29,7 +29,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do context 'Non-EE application file' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, full_path('app/models/blog_post.rb')) + expect_no_offenses(<<~SOURCE, full_path('app/models/blog_post.rb')) class BlogPost end SOURCE @@ -38,7 +38,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do context 'EE application file' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, full_path('ee/app/models/blog_post.rb')) + expect_no_offenses(<<~SOURCE, full_path('ee/app/models/blog_post.rb')) class BlogPost end SOURCE @@ -49,7 +49,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do let(:spec_file_path) { full_path('ee/spec/controllers/foo_spec.rb') } it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, spec_file_path) + expect_no_offenses(<<~SOURCE, spec_file_path) describe 'Foo' do end SOURCE @@ -65,7 +65,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do end it 'marks the describe as offending' do - expect_offense(<<~SOURCE.strip_indent, spec_file_path) + expect_offense(<<~SOURCE, spec_file_path) describe 'Foo' do ^^^^^^^^^^^^^^ Duplicate spec location in `ee/spec/controllers/ee/foo_spec.rb`. end @@ -78,7 +78,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do let(:spec_file_path) { full_path('ee/spec/controllers/ee/foo_spec.rb') } it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, spec_file_path) + expect_no_offenses(<<~SOURCE, spec_file_path) describe 'Foo' do end SOURCE @@ -94,7 +94,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do end it 'marks the describe as offending' do - expect_offense(<<~SOURCE.strip_indent, spec_file_path) + expect_offense(<<~SOURCE, spec_file_path) describe 'Foo' do ^^^^^^^^^^^^^^ Duplicate spec location in `ee/spec/controllers/foo_spec.rb`. end diff --git a/spec/rubocop/cop/migration/add_index_spec.rb b/spec/rubocop/cop/migration/add_index_spec.rb index 0c3f87e5bf8..ca1aadb381b 100644 --- a/spec/rubocop/cop/migration/add_index_spec.rb +++ b/spec/rubocop/cop/migration/add_index_spec.rb @@ -18,7 +18,7 @@ describe RuboCop::Cop::Migration::AddIndex do end it 'registers an offense when add_index is used' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) def change add_index :table, :column ^^^^^^^^^ `add_index` requires downtime, use `add_concurrent_index` instead @@ -29,7 +29,7 @@ describe RuboCop::Cop::Migration::AddIndex do context 'outside of migration' do it 'registers no offense' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) def change add_index :table, :column end diff --git a/spec/rubocop/cop/put_group_routes_under_scope_spec.rb b/spec/rubocop/cop/put_group_routes_under_scope_spec.rb index fc4d0015dde..c77412f91b4 100644 --- a/spec/rubocop/cop/put_group_routes_under_scope_spec.rb +++ b/spec/rubocop/cop/put_group_routes_under_scope_spec.rb @@ -14,7 +14,7 @@ describe RuboCop::Cop::PutGroupRoutesUnderScope do end it 'registers an offense when route is outside scope' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) scope(path: 'groups/*group_id/-', module: :groups) do resource :issues end @@ -25,7 +25,7 @@ describe RuboCop::Cop::PutGroupRoutesUnderScope do end it 'does not register an offense when resource inside the scope' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) scope(path: 'groups/*group_id/-', module: :groups) do resource :issues resource :notes @@ -34,7 +34,7 @@ describe RuboCop::Cop::PutGroupRoutesUnderScope do end it 'does not register an offense when resource is deep inside the scope' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) scope(path: 'groups/*group_id/-', module: :groups) do resource :issues resource :projects do diff --git a/spec/rubocop/cop/put_project_routes_under_scope_spec.rb b/spec/rubocop/cop/put_project_routes_under_scope_spec.rb index b0f1e52f397..80ac4cc52e9 100644 --- a/spec/rubocop/cop/put_project_routes_under_scope_spec.rb +++ b/spec/rubocop/cop/put_project_routes_under_scope_spec.rb @@ -14,7 +14,7 @@ describe RuboCop::Cop::PutProjectRoutesUnderScope do end it 'registers an offense when route is outside scope' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) scope '-' do resource :issues end @@ -25,7 +25,7 @@ describe RuboCop::Cop::PutProjectRoutesUnderScope do end it 'does not register an offense when resource inside the scope' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) scope '-' do resource :issues resource :notes @@ -34,7 +34,7 @@ describe RuboCop::Cop::PutProjectRoutesUnderScope do end it 'does not register an offense when resource is deep inside the scope' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) scope '-' do resource :issues resource :projects do diff --git a/spec/rubocop/cop/rspec/top_level_describe_path_spec.rb b/spec/rubocop/cop/rspec/top_level_describe_path_spec.rb index 258144d4000..ee6b6d39cb4 100644 --- a/spec/rubocop/cop/rspec/top_level_describe_path_spec.rb +++ b/spec/rubocop/cop/rspec/top_level_describe_path_spec.rb @@ -15,7 +15,7 @@ describe RuboCop::Cop::RSpec::TopLevelDescribePath do context 'when the file ends in _spec.rb' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, 'spec/foo_spec.rb') + expect_no_offenses(<<~SOURCE, 'spec/foo_spec.rb') describe 'Foo' do end SOURCE @@ -24,7 +24,7 @@ describe RuboCop::Cop::RSpec::TopLevelDescribePath do context 'when the file is a frontend fixture' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, 'spec/frontend/fixtures/foo.rb') + expect_no_offenses(<<~SOURCE, 'spec/frontend/fixtures/foo.rb') describe 'Foo' do end SOURCE @@ -34,7 +34,7 @@ describe RuboCop::Cop::RSpec::TopLevelDescribePath do context 'when the describe is in a shared example' do context 'with shared_examples' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, 'spec/foo.rb') + expect_no_offenses(<<~SOURCE, 'spec/foo.rb') shared_examples 'Foo' do describe '#bar' do end @@ -45,7 +45,7 @@ describe RuboCop::Cop::RSpec::TopLevelDescribePath do context 'with shared_examples_for' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, 'spec/foo.rb') + expect_no_offenses(<<~SOURCE, 'spec/foo.rb') shared_examples_for 'Foo' do describe '#bar' do end @@ -57,7 +57,7 @@ describe RuboCop::Cop::RSpec::TopLevelDescribePath do context 'when the describe is at the top level' do it 'marks the describe as offending' do - expect_offense(<<~SOURCE.strip_indent, 'spec/foo.rb') + expect_offense(<<~SOURCE, 'spec/foo.rb') describe 'Foo' do ^^^^^^^^^^^^^^ #{described_class::MESSAGE} end diff --git a/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb b/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb index 8107cfa8957..3c78a158836 100644 --- a/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb +++ b/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb @@ -12,7 +12,7 @@ describe RuboCop::Cop::Scalability::BulkPerformWithContext do subject(:cop) { described_class.new } it "adds an offense when calling bulk_perform_async" do - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) Worker.bulk_perform_async(args) CODE @@ -20,7 +20,7 @@ describe RuboCop::Cop::Scalability::BulkPerformWithContext do end it "adds an offense when calling bulk_perform_in" do - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) diffs.each_batch(of: BATCH_SIZE) do |relation, index| ids = relation.pluck_primary_key.map { |id| [id] } DeleteDiffFilesWorker.bulk_perform_in(index * 5.minutes, ids) @@ -33,7 +33,7 @@ describe RuboCop::Cop::Scalability::BulkPerformWithContext do it "does not add an offense for migrations" do allow(cop).to receive(:in_migration?).and_return(true) - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) Worker.bulk_perform_in(args) CODE @@ -43,7 +43,7 @@ describe RuboCop::Cop::Scalability::BulkPerformWithContext do it "does not add an offence for specs" do allow(cop).to receive(:in_spec?).and_return(true) - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) Worker.bulk_perform_in(args) CODE @@ -51,7 +51,7 @@ describe RuboCop::Cop::Scalability::BulkPerformWithContext do end it "does not add an offense for scheduling BackgroundMigrations" do - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) BackgroundMigrationWorker.bulk_perform_in(args) CODE diff --git a/spec/rubocop/cop/scalability/cron_worker_context_spec.rb b/spec/rubocop/cop/scalability/cron_worker_context_spec.rb index 460514d9bed..aab32c7331f 100644 --- a/spec/rubocop/cop/scalability/cron_worker_context_spec.rb +++ b/spec/rubocop/cop/scalability/cron_worker_context_spec.rb @@ -12,7 +12,7 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do subject(:cop) { described_class.new } it 'adds an offense when including CronjobQueue' do - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) class SomeWorker include CronjobQueue end @@ -22,14 +22,14 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do end it 'does not add offenses for other workers' do - expect_no_offenses(<<~CODE.strip_indent) + expect_no_offenses(<<~CODE) class SomeWorker end CODE end it 'does not add an offense when the class defines a context' do - expect_no_offenses(<<~CODE.strip_indent) + expect_no_offenses(<<~CODE) class SomeWorker include CronjobQueue @@ -39,7 +39,7 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do end it 'does not add an offense when the worker calls `with_context`' do - expect_no_offenses(<<~CODE.strip_indent) + expect_no_offenses(<<~CODE) class SomeWorker include CronjobQueue @@ -53,7 +53,7 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do end it 'does not add an offense when the worker calls `bulk_perform_async_with_contexts`' do - expect_no_offenses(<<~CODE.strip_indent) + expect_no_offenses(<<~CODE) class SomeWorker include CronjobQueue @@ -67,7 +67,7 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do end it 'does not add an offense when the worker calls `bulk_perform_in_with_contexts`' do - expect_no_offenses(<<~CODE.strip_indent) + expect_no_offenses(<<~CODE) class SomeWorker include CronjobQueue diff --git a/spec/rubocop/cop/scalability/file_uploads_spec.rb b/spec/rubocop/cop/scalability/file_uploads_spec.rb index a35d423581c..5bfc2d48fb8 100644 --- a/spec/rubocop/cop/scalability/file_uploads_spec.rb +++ b/spec/rubocop/cop/scalability/file_uploads_spec.rb @@ -15,7 +15,7 @@ describe RuboCop::Cop::Scalability::FileUploads do context 'with required params' do it 'detects File in types array' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) params do requires :certificate, allow_blank: false, types: [String, File] ^^^^ #{message} @@ -24,7 +24,7 @@ describe RuboCop::Cop::Scalability::FileUploads do end it 'detects File as type argument' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) params do requires :attachment, type: File ^^^^ #{message} @@ -35,7 +35,7 @@ describe RuboCop::Cop::Scalability::FileUploads do context 'with optional params' do it 'detects File in types array' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) params do optional :certificate, allow_blank: false, types: [String, File] ^^^^ #{message} @@ -44,7 +44,7 @@ describe RuboCop::Cop::Scalability::FileUploads do end it 'detects File as type argument' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) params do optional :attachment, type: File ^^^^ #{message} diff --git a/spec/rubocop/cop/scalability/idempotent_worker_spec.rb b/spec/rubocop/cop/scalability/idempotent_worker_spec.rb index 7abd602f8bc..4551ec75e9f 100644 --- a/spec/rubocop/cop/scalability/idempotent_worker_spec.rb +++ b/spec/rubocop/cop/scalability/idempotent_worker_spec.rb @@ -18,7 +18,7 @@ describe RuboCop::Cop::Scalability::IdempotentWorker do end it 'adds an offense when not defining idempotent method' do - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) class SomeWorker end CODE @@ -27,7 +27,7 @@ describe RuboCop::Cop::Scalability::IdempotentWorker do end it 'adds an offense when not defining idempotent method' do - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) class SomeWorker idempotent! 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 c8b1eec8cb1..9bc8b731dc1 100644 --- a/spec/services/alert_management/create_alert_issue_service_spec.rb +++ b/spec/services/alert_management/create_alert_issue_service_spec.rb @@ -118,17 +118,6 @@ RSpec.describe AlertManagement::CreateAlertIssueService do expect(execute.message).to eq(_('An issue already exists')) end end - - context 'when alert_management_create_alert_issue feature flag is disabled' do - before do - stub_feature_flags(alert_management_create_alert_issue: false) - end - - it 'responds with error' do - expect(execute).to be_error - expect(execute.message).to eq(_('You have no permissions')) - end - end end context 'when a user is not allowed to create an issue' do diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb index 6655728d939..bb40c399b6e 100644 --- a/spec/services/merge_requests/create_service_spec.rb +++ b/spec/services/merge_requests/create_service_spec.rb @@ -136,11 +136,11 @@ describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do let!(:pipeline_3) { create(:ci_pipeline, project: project, ref: "other_branch", project_id: project.id) } before do - # rubocop: disable DestroyAll + # rubocop: disable Cop/DestroyAll project.merge_requests .where(source_branch: opts[:source_branch], target_branch: opts[:target_branch]) .destroy_all - # rubocop: enable DestroyAll + # rubocop: enable Cop/DestroyAll end it 'sets head pipeline' do diff --git a/spec/services/merge_requests/delete_non_latest_diffs_service_spec.rb b/spec/services/merge_requests/delete_non_latest_diffs_service_spec.rb index a1c86467f34..2adf808619d 100644 --- a/spec/services/merge_requests/delete_non_latest_diffs_service_spec.rb +++ b/spec/services/merge_requests/delete_non_latest_diffs_service_spec.rb @@ -48,12 +48,12 @@ describe MergeRequests::DeleteNonLatestDiffsService, :clean_gitlab_redis_shared_ end it 'schedules no removal if there is no non-latest diffs' do - # rubocop: disable DestroyAll + # rubocop: disable Cop/DestroyAll merge_request .merge_request_diffs .where.not(id: merge_request.latest_merge_request_diff_id) .destroy_all - # rubocop: enable DestroyAll + # rubocop: enable Cop/DestroyAll expect(DeleteDiffFilesWorker).not_to receive(:bulk_perform_in) diff --git a/spec/support/helpers/design_management_test_helpers.rb b/spec/support/helpers/design_management_test_helpers.rb index bf41e2f5079..1daa92e8ad4 100644 --- a/spec/support/helpers/design_management_test_helpers.rb +++ b/spec/support/helpers/design_management_test_helpers.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true module DesignManagementTestHelpers - def enable_design_management(enabled = true, ref_filter = true) + def enable_design_management(enabled = true) stub_lfs_setting(enabled: enabled) - stub_feature_flags(design_management_reference_filter_gfm_pipeline: ref_filter) end def delete_designs(*designs) diff --git a/spec/support/helpers/filter_spec_helper.rb b/spec/support/helpers/filter_spec_helper.rb index c165128040f..ca844b33ba8 100644 --- a/spec/support/helpers/filter_spec_helper.rb +++ b/spec/support/helpers/filter_spec_helper.rb @@ -56,14 +56,11 @@ module FilterSpecHelper pipeline.call(body) end - def reference_pipeline(context = {}) + def reference_pipeline(filter: described_class, **context) context.reverse_merge!(project: project) if defined?(project) context.reverse_merge!(current_user: current_user) if defined?(current_user) - filters = [ - Banzai::Filter::AutolinkFilter, - described_class - ] + filters = [Banzai::Filter::AutolinkFilter, filter].compact redact = context.delete(:redact) filters.push(Banzai::Filter::ReferenceRedactorFilter) if redact @@ -75,8 +72,13 @@ module FilterSpecHelper reference_pipeline(context).call(body) end - def reference_filter(html, context = {}) - reference_pipeline(context).to_document(html) + def reference_filter(text, context = {}) + reference_pipeline(**context).to_document(text) + end + + # Use to test no-ops + def null_filter(text, context = {}) + reference_pipeline(filter: nil, **context).to_document(text) end # Modify a String reference to make it invalid diff --git a/spec/workers/repository_check/single_repository_worker_spec.rb b/spec/workers/repository_check/single_repository_worker_spec.rb index 1c8aea3131d..43998f912ef 100644 --- a/spec/workers/repository_check/single_repository_worker_spec.rb +++ b/spec/workers/repository_check/single_repository_worker_spec.rb @@ -8,7 +8,7 @@ describe RepositoryCheck::SingleRepositoryWorker do it 'skips when the project has no push events' do project = create(:project, :repository, :wiki_disabled) - project.events.destroy_all # rubocop: disable DestroyAll + project.events.destroy_all # rubocop: disable Cop/DestroyAll break_project(project) expect(worker).not_to receive(:git_fsck) diff --git a/tooling/overcommit/Gemfile b/tooling/overcommit/Gemfile index 5525662e43e..120cb1ad8d0 100644 --- a/tooling/overcommit/Gemfile +++ b/tooling/overcommit/Gemfile @@ -4,6 +4,6 @@ source 'https://rubygems.org' gem 'overcommit' -gem 'gitlab-styles', '~> 3.1.0', require: false +gem 'gitlab-styles', '~> 4.2.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 15b80426c03..7ab10f741ed 100644 --- a/tooling/overcommit/Gemfile.lock +++ b/tooling/overcommit/Gemfile.lock @@ -1,55 +1,68 @@ GEM remote: https://rubygems.org/ specs: + activesupport (6.0.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) ast (2.4.0) childprocess (3.0.0) - ffi (1.12.1) - gitlab-styles (3.1.0) - rubocop (~> 0.74.0) + concurrent-ruby (1.1.6) + ffi (1.12.2) + gitlab-styles (4.2.0) + rubocop (~> 0.82.0) rubocop-gitlab-security (~> 0.1.0) - rubocop-performance (~> 1.4.1) - rubocop-rails (~> 2.0) + rubocop-performance (~> 1.5.2) + rubocop-rails (~> 2.5) rubocop-rspec (~> 1.36) haml (5.1.2) temple (>= 0.8.0) tilt - haml_lint (0.34.1) + haml_lint (0.34.0) haml (>= 4.0, < 5.2) rainbow rubocop (>= 0.50.0) sysexits (~> 1.1) - iniparse (1.4.4) + i18n (1.8.2) + concurrent-ruby (~> 1.0) + iniparse (1.5.0) jaro_winkler (1.5.4) - overcommit (0.52.1) + minitest (5.11.3) + overcommit (0.53.0) childprocess (>= 0.6.3, < 4) iniparse (~> 1.4) parallel (1.19.1) - parser (2.7.0.2) + parser (2.7.1.2) ast (~> 2.4.0) - rack (2.1.1) + rack (2.0.9) rainbow (3.0.0) rake (12.3.3) - rb-fsevent (0.10.3) - rb-inotify (0.10.1) - ffi (~> 1.0) - rubocop (0.74.0) + rb-fsevent (0.10.2) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + rexml (3.2.4) + rubocop (0.82.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) - parser (>= 2.6) + parser (>= 2.7.0.1) rainbow (>= 2.2.2, < 4.0) + rexml ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) + unicode-display_width (>= 1.4.0, < 2.0) rubocop-gitlab-security (0.1.1) rubocop (>= 0.51) - rubocop-performance (1.4.1) + rubocop-performance (1.5.2) rubocop (>= 0.71.0) - rubocop-rails (2.4.1) + rubocop-rails (2.5.2) + activesupport rack (>= 1.1) rubocop (>= 0.72.0) - rubocop-rspec (1.37.1) + rubocop-rspec (1.37.0) rubocop (>= 0.68.1) ruby-progressbar (1.10.1) - sass (3.5.7) + sass (3.5.5) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) @@ -59,14 +72,18 @@ GEM sass (~> 3.5.3) sysexits (1.2.0) temple (0.8.2) + thread_safe (0.3.6) tilt (2.0.10) - unicode-display_width (1.6.1) + tzinfo (1.2.7) + thread_safe (~> 0.1) + unicode-display_width (1.7.0) + zeitwerk (2.3.0) PLATFORMS ruby DEPENDENCIES - gitlab-styles (~> 3.1.0) + gitlab-styles (~> 4.2.0) haml_lint (~> 0.34.0) overcommit scss_lint (~> 0.56.0) diff --git a/yarn.lock b/yarn.lock index b3f4be1897e..fbef3987222 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2623,29 +2623,6 @@ charenc@~0.0.1: resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" integrity sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc= -chart.js@2.7.2: - version "2.7.2" - resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-2.7.2.tgz#3c9fde4dc5b95608211bdefeda7e5d33dffa5714" - integrity sha512-90wl3V9xRZ8tnMvMlpcW+0Yg13BelsGS9P9t0ClaDxv/hdypHDr/YAGf+728m11P5ljwyB0ZHfPKCapZFqSqYA== - dependencies: - chartjs-color "^2.1.0" - moment "^2.10.2" - -chartjs-color-string@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/chartjs-color-string/-/chartjs-color-string-0.5.0.tgz#8d3752d8581d86687c35bfe2cb80ac5213ceb8c1" - integrity sha512-amWNvCOXlOUYxZVDSa0YOab5K/lmEhbFNKI55PWc4mlv28BDzA7zaoQTGxSBgJMHIW+hGX8YUrvw/FH4LyhwSQ== - dependencies: - color-name "^1.0.0" - -chartjs-color@^2.1.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/chartjs-color/-/chartjs-color-2.2.0.tgz#84a2fb755787ed85c39dd6dd8c7b1d88429baeae" - integrity sha1-hKL7dVeH7YXDndbdjHsdiEKbrq4= - dependencies: - chartjs-color-string "^0.5.0" - color-convert "^0.5.3" - check-types@^7.3.0: version "7.3.0" resolved "https://registry.yarnpkg.com/check-types/-/check-types-7.3.0.tgz#468f571a4435c24248f5fd0cb0e8d87c3c341e7d" @@ -2858,11 +2835,6 @@ collection-visit@^1.0.0: map-visit "^1.0.0" object-visit "^1.0.0" -color-convert@^0.5.3, color-convert@~0.5.0: - version "0.5.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-0.5.3.tgz#bdb6c69ce660fadffe0b0007cc447e1b9f7282bd" - integrity sha1-vbbGnOZg+t/+CwAHzER+G59ygr0= - color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" @@ -2870,7 +2842,12 @@ color-convert@^1.9.0: dependencies: color-name "1.1.3" -color-name@1.1.3, color-name@^1.0.0: +color-convert@~0.5.0: + version "0.5.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-0.5.3.tgz#bdb6c69ce660fadffe0b0007cc447e1b9f7282bd" + integrity sha1-vbbGnOZg+t/+CwAHzER+G59ygr0= + +color-name@1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= @@ -7968,11 +7945,6 @@ moment-mini@^2.22.1: resolved "https://registry.yarnpkg.com/moment-mini/-/moment-mini-2.22.1.tgz#bc32d73e43a4505070be6b53494b17623183420d" integrity sha512-OUCkHOz7ehtNMYuZjNciXUfwTuz8vmF1MTbAy59ebf+ZBYZO5/tZKuChVWCX+uDo+4idJBpGltNfV8st+HwsGw== -moment@^2.10.2: - version "2.24.0" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b" - integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg== - monaco-editor-webpack-plugin@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/monaco-editor-webpack-plugin/-/monaco-editor-webpack-plugin-1.7.0.tgz#920cbeecca25f15d70d568a7e11b0ba4daf1ae83" |