diff options
author | Ash McKenzie <amckenzie@gitlab.com> | 2019-05-06 01:05:38 +0000 |
---|---|---|
committer | Ash McKenzie <amckenzie@gitlab.com> | 2019-05-06 01:05:38 +0000 |
commit | cf1fc5a1e81026b592bcbc88922cb96753472388 (patch) | |
tree | b0c4e3095d1c626d6269f8238a3c07d0dbca74c3 | |
parent | b08014a4508da9ea72a3124d8be5bea93e4b6a0b (diff) | |
parent | f93b2e02a56a3b1f3041119e8302d43aeafc8284 (diff) | |
download | gitlab-ce-cf1fc5a1e81026b592bcbc88922cb96753472388.tar.gz |
Merge branch 'sh-upgrade-rubocop-0.68.0-ce' into 'master'
Upgrade to Rubocop 0.68.1
See merge request gitlab-org/gitlab-ce!28046
62 files changed, 461 insertions, 251 deletions
diff --git a/.haml-lint.yml b/.haml-lint.yml index bad918ef35d..e9cc4a91a21 100644 --- a/.haml-lint.yml +++ b/.haml-lint.yml @@ -97,6 +97,7 @@ linters: - Cop/LineBreakAroundConditionalBlock - Cop/ProjectPathHelper - GitlabSecurity/PublicSend + - Layout/EmptyLineAfterGuardClause - Layout/LeadingCommentSpace - Layout/SpaceAfterColon - Layout/SpaceAfterComma @@ -112,11 +113,13 @@ linters: - Lint/LiteralInInterpolation - Lint/ParenthesesAsGroupedExpression - Lint/RedundantWithIndex + - Lint/SafeNavigationConsistency - Lint/Syntax - Metrics/BlockNesting - Naming/VariableName - Performance/RedundantMatch - Performance/StringReplacement + - Rails/LinkToBlank - Rails/Presence - Rails/RequestReferer - Style/AndOr @@ -134,6 +137,7 @@ linters: - Style/TernaryParentheses - Style/TrailingCommaInHashLiteral - Style/UnlessElse + - Style/UnneededCondition - Style/WordArray - Style/ZeroLengthPredicate diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 77ad4753c84..63b1685feda 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,42 +1,154 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-01-18 18:23:26 +0100 using RuboCop version 0.52.1. +# on 2019-05-04 16:01:00 +0000 using RuboCop version 0.68.1. # 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: 181 +# Offense count: 264 Capybara/CurrentPathExpectation: Enabled: false -# Offense count: 167 +# Offense count: 1097 # Cop supports --auto-correct. -Layout/EmptyLinesAroundArguments: +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_argument, with_fixed_indentation +Layout/AlignArguments: Enabled: false -# Offense count: 83 +# Offense count: 824 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/AlignHash: + Enabled: false + +# Offense count: 13 +# Cop supports --auto-correct. +Layout/ClosingHeredocIndentation: + Exclude: + - 'app/graphql/mutations/merge_requests/set_wip.rb' + - 'ee/db/geo/migrate/20180322062741_migrate_ci_job_artifacts_to_separate_registry.rb' + - 'ee/db/migrate/20160204190809_update_jenkins_service_category.rb' + - 'ee/lib/gitlab/background_migration/prune_orphaned_geo_events.rb' + - 'ee/lib/gitlab/geo/health_check.rb' + - 'lib/gitlab/background_migration/populate_untracked_uploads.rb' + - 'qa/qa/service/kubernetes_cluster.rb' + - 'spec/features/merge_request/user_sees_diff_spec.rb' + - 'spec/lib/gitlab/asciidoc_spec.rb' + - 'spec/lib/gitlab/checks/project_moved_spec.rb' + - 'spec/rubocop/cop/active_record_association_reload_spec.rb' + - 'spec/services/task_list_toggle_service_spec.rb' + +# Offense count: 14 +# Cop supports --auto-correct. +Layout/ClosingParenthesisIndentation: + Exclude: + - 'db/post_migrate/20180704145007_update_project_indexes.rb' + - 'ee/db/geo/migrate/20180405074130_add_partial_index_project_repository_verification.rb' + - 'ee/db/migrate/20180308234102_add_partial_index_to_project_repository_states_checksum_columns.rb' + - 'ee/db/post_migrate/20180605213516_fix_partial_index_to_project_repository_states_checksum_columns.rb' + - 'ee/lib/ee/gitlab/usage_data.rb' + - 'spec/services/issues/resolve_discussions_spec.rb' + - 'spec/services/projects/update_service_spec.rb' + - 'spec/support/helpers/stub_object_storage.rb' + - 'spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: leading, trailing +Layout/DotPosition: + Exclude: + - 'app/models/concerns/relative_positioning.rb' + - 'app/models/group.rb' + +# Offense count: 69 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundArguments: + Exclude: + - 'app/models/concerns/discussion_on_diff.rb' + - '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: 160 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/IndentArray: +Layout/IndentFirstArrayElement: Enabled: false -# Offense count: 237 +# Offense count: 631 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/IndentHash: +Layout/IndentFirstHashElement: Enabled: false -# Offense count: 93 +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: consistent, align_parentheses +Layout/IndentFirstParameter: + Exclude: + - 'app/models/ci/pipeline_schedule.rb' + - '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: 5 +# Cop supports --auto-correct. +Layout/LeadingBlankLines: + Exclude: + - 'app/workers/update_project_statistics_worker.rb' + - 'db/migrate/20161007073613_create_user_activities.rb' + - 'ee/spec/helpers/boards_helper_spec.rb' + - 'lib/tasks/yarn.rake' + - 'spec/javascripts/fixtures/merge_requests_diffs.rb' + +# Offense count: 30 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/MultilineOperationIndentation: + Enabled: false + +# Offense count: 13 +# Cop supports --auto-correct. +Layout/RescueEnsureAlignment: + Exclude: + - 'app/models/blob_viewer/dependency_manager.rb' + - 'app/models/ci/pipeline.rb' + - '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' + - 'ee/db/migrate/20151113115819_canonicalize_kerberos_identities.rb' + - 'lib/gitlab/background_migration/archive_legacy_traces.rb' + - 'lib/gitlab/highlight.rb' + - 'lib/tasks/gitlab/lfs/migrate.rake' + +# Offense count: 344 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: require_no_space, require_space Layout/SpaceInLambdaLiteral: Enabled: false -# Offense count: 327 +# Offense count: 583 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space @@ -44,20 +156,27 @@ Layout/SpaceInLambdaLiteral: Layout/SpaceInsideBlockBraces: Enabled: false -# Offense count: 156 +# Offense count: 255 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space Layout/SpaceInsideParens: Enabled: false -# Offense count: 26 +# Offense count: 1 +Lint/DisjunctiveAssignmentInConstructor: + Exclude: + - 'app/models/uploads/base.rb' + +# Offense count: 19 Lint/DuplicateMethods: Exclude: - - 'app/models/application_setting.rb' - 'app/models/commit.rb' - 'app/models/note.rb' - - 'app/services/merge_requests/merge_service.rb' - 'lib/bitbucket/representation/repo.rb' - 'lib/declarative_policy/base.rb' + - 'lib/gitlab/auth/ldap/person.rb' + - 'lib/gitlab/auth/o_auth/user.rb' - 'lib/gitlab/ci/build/artifacts/metadata/entry.rb' - 'lib/gitlab/cycle_analytics/base_event_fetcher.rb' - 'lib/gitlab/diff/formatters/base_formatter.rb' @@ -65,22 +184,34 @@ Lint/DuplicateMethods: - 'lib/gitlab/git/repository.rb' - 'lib/gitlab/git/tree.rb' - 'lib/gitlab/git/wiki_page.rb' - - 'lib/gitlab/auth/ldap/person.rb' - - 'lib/gitlab/auth/o_auth/user.rb' -# Offense count: 4 +# Offense count: 2 Lint/InterpolationCheck: Exclude: - 'spec/features/issues/filtered_search/filter_issues_spec.rb' - - 'spec/features/users_spec.rb' - 'spec/services/quick_actions/interpret_service_spec.rb' -# Offense count: 206 +# Offense count: 326 # Configuration parameters: MaximumRangeSize. Lint/MissingCopEnableDirective: Enabled: false -# Offense count: 9 +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: Whitelist. +# Whitelist: present?, blank?, presence, try, try! +Lint/SafeNavigationConsistency: + Exclude: + - 'lib/gitlab/gpg/commit.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Lint/ToJSON: + Exclude: + - 'lib/gitlab/cycle_analytics/usage_data.rb' + - 'lib/gitlab/template/base_template.rb' + +# Offense count: 7 Lint/UriEscapeUnescape: Exclude: - 'app/controllers/application_controller.rb' @@ -88,13 +219,25 @@ Lint/UriEscapeUnescape: - 'spec/lib/google_api/auth_spec.rb' - 'spec/requests/api/files_spec.rb' - 'spec/requests/api/internal_spec.rb' - - 'spec/requests/api/issues_spec.rb' # Offense count: 1 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# Configuration parameters: CheckForMethodsWithNoSideEffects. +Lint/Void: + Exclude: + - 'lib/gitlab/git/diff_collection.rb' + +# Offense count: 158 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: - Max: 1310 + Max: 176 + +# Offense count: 94 +# 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: + Enabled: false # Offense count: 11 # Configuration parameters: EnforcedStyle. @@ -107,61 +250,85 @@ Naming/HeredocDelimiterCase: - 'spec/support/helpers/repo_helpers.rb' - 'spec/support/helpers/seed_repo.rb' -# Offense count: 112 +# Offense count: 197 # Configuration parameters: Blacklist. -# Blacklist: END, (?-mix:EO[A-Z]{1}) +# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) Naming/HeredocDelimiterNaming: Enabled: false +# Offense count: 125 +# Cop supports --auto-correct. +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +Performance/InefficientHashSearch: + Exclude: + - 'app/controllers/concerns/sessionless_authentication.rb' + - 'app/models/note.rb' + - 'app/models/user_preference.rb' + - 'ee/app/models/ee/project.rb' + - 'lib/gitlab/import_export/members_mapper.rb' + - 'qa/spec/spec_helper.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Performance/ReverseEach: + Exclude: + - 'app/models/commit.rb' + - 'db/migrate/20190222051615_add_indexes_for_merge_request_diffs_query.rb' + - 'lib/gitlab/profiler.rb' -# Offense count: 3821 +# Offense count: 7081 # Configuration parameters: Prefixes. # Prefixes: when, with, without RSpec/ContextWording: Enabled: false -# Offense count: 293 +# Offense count: 407 +# Cop supports --auto-correct. RSpec/EmptyLineAfterFinalLet: Enabled: false -# Offense count: 188 +# Offense count: 232 +# Cop supports --auto-correct. RSpec/EmptyLineAfterSubject: Enabled: false -# Offense count: 258 +# Offense count: 719 +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: method_call, block RSpec/ExpectChange: Enabled: false -# Offense count: 221 +# Offense count: 512 RSpec/ExpectInHook: Enabled: false -# Offense count: 19 +# Offense count: 10 +# 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/lib/gitlab/shell_spec.rb' - 'spec/services/notification_service_spec.rb' - - 'spec/workers/git_garbage_collect_worker_spec.rb' -# Offense count: 5 +# Offense count: 3 RSpec/IteratedExpectation: Exclude: - 'spec/features/admin/admin_settings_spec.rb' - - 'spec/features/merge_requests/diff_notes_resolve_spec.rb' - - 'spec/features/projects/awards/user_interacts_with_awards_in_issue_spec.rb' - 'spec/lib/gitlab/gitlab_import/client_spec.rb' - 'spec/lib/gitlab/legacy_github_import/client_spec.rb' -# Offense count: 75 +# Offense count: 68 +# Cop supports --auto-correct. RSpec/LetBeforeExamples: Exclude: - - 'spec/controllers/projects/commit_controller_spec.rb' - 'spec/lib/banzai/filter/issue_reference_filter_spec.rb' - 'spec/lib/banzai/filter/user_reference_filter_spec.rb' - 'spec/lib/gitlab/email/handler/create_issue_handler_spec.rb' @@ -170,12 +337,11 @@ RSpec/LetBeforeExamples: - 'spec/models/commit_range_spec.rb' - 'spec/models/milestone_spec.rb' - 'spec/models/project_services/packagist_service_spec.rb' - - 'spec/models/repository_spec.rb' - 'spec/rubocop/cop/migration/update_column_in_batches_spec.rb' - 'spec/serializers/pipeline_details_entity_spec.rb' - - 'spec/views/ci/lints/show.html.haml_spec.rb' # Offense count: 1 +# Cop supports --auto-correct. RSpec/MultipleSubjects: Exclude: - 'spec/services/merge_requests/create_from_issue_service_spec.rb' @@ -188,95 +354,136 @@ RSpec/OverwritingSetup: - 'spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb' - 'spec/services/notes/quick_actions_service_spec.rb' -# Offense count: 965 +# Offense count: 1828 +# Cop supports --auto-correct. # Configuration parameters: Strict, EnforcedStyle. # SupportedStyles: inflected, explicit RSpec/PredicateMatcher: Enabled: false -# Offense count: 35 +# Offense count: 57 RSpec/RepeatedExample: Enabled: false -# Offense count: 140 +# Offense count: 474 +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: and_return, block RSpec/ReturnFromStub: Enabled: false -# Offense count: 112 +# Offense count: 188 RSpec/ScatteredLet: Enabled: false -# Offense count: 22 +# Offense count: 10 RSpec/ScatteredSetup: Exclude: - 'spec/controllers/projects/templates_controller_spec.rb' - 'spec/lib/gitlab/bitbucket_import/importer_spec.rb' - - 'spec/lib/gitlab/git/env_spec.rb' - 'spec/requests/api/jobs_spec.rb' - 'spec/services/projects/create_service_spec.rb' # Offense count: 1 +# Cop supports --auto-correct. RSpec/SharedContext: Exclude: - 'spec/features/admin/admin_groups_spec.rb' -# Offense count: 5 +# Offense count: 4 RSpec/VoidExpect: Exclude: - - 'spec/features/projects/artifacts/download_spec.rb' - 'spec/features/projects/services/user_activates_mattermost_slash_command_spec.rb' - 'spec/models/ci/group_spec.rb' - 'spec/models/ci/runner_spec.rb' - 'spec/services/users/destroy_service_spec.rb' -# Offense count: 41 +# Offense count: 8 +# 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: 80 # Configuration parameters: Include. # Include: db/migrate/*.rb Rails/CreateTableWithTimestamps: Enabled: false -# Offense count: 155 +# Offense count: 222 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: slashes, arguments Rails/FilePath: Enabled: false -# Offense count: 121 +# Offense count: 167 # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/HasManyOrHasOneDependent: Enabled: false -# Offense count: 157 +# Offense count: 40 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: numeric, symbolic +Rails/HttpStatus: + Enabled: false + +# Offense count: 2 +# Configuration parameters: Include. +# Include: app/controllers/**/*.rb +Rails/IgnoredSkipActionFilterOption: + Exclude: + - 'app/controllers/projects/snippets_controller.rb' + - 'app/controllers/snippets_controller.rb' + +# Offense count: 87 # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/InverseOf: Enabled: false -# Offense count: 48 +# Offense count: 46 # Configuration parameters: Include. # Include: app/controllers/**/*.rb Rails/LexicallyScopedActionFilter: Enabled: false -# Offense count: 14 +# Offense count: 4 +# 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: 11 # Cop supports --auto-correct. Rails/Presence: Exclude: - - 'app/controllers/projects/blob_controller.rb' - 'app/models/ci/pipeline.rb' - 'app/models/clusters/platforms/kubernetes.rb' - 'app/models/concerns/mentionable.rb' - - 'app/models/concerns/token_authenticatable.rb' - 'app/models/project_services/hipchat_service.rb' - 'app/models/project_services/irker_service.rb' - 'app/models/project_services/jira_service.rb' - 'app/models/project_services/kubernetes_service.rb' - 'app/models/project_services/packagist_service.rb' - 'app/models/wiki_page.rb' - - 'lib/gitlab/git/hook.rb' - 'lib/gitlab/github_import/importer/releases_importer.rb' +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/RedundantAllowNil: + Exclude: + - 'app/models/application_setting.rb' + # Offense count: 2 # Configuration parameters: Include. # Include: db/migrate/*.rb @@ -284,8 +491,8 @@ Rails/ReversibleMigration: Exclude: - 'db/migrate/20160824103857_drop_unused_ci_tables.rb' -# Offense count: 446 -# Configuration parameters: Blacklist. +# Offense count: 860 +# 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: Enabled: false @@ -297,21 +504,25 @@ Rails/UnknownEnv: Exclude: - 'db/migrate/20171124125748_populate_missing_merge_request_statuses.rb' -# Offense count: 13 +# Offense count: 11 # Cop supports --auto-correct. Security/YAMLLoad: Exclude: - - 'config/initializers/carrierwave.rb' - 'lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits.rb' - 'lib/gitlab/redis/wrapper.rb' - 'lib/system_check/incoming_email/imap_authentication_check.rb' - 'spec/config/mail_room_spec.rb' - 'spec/initializers/secret_token_spec.rb' - 'spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb' - - 'spec/models/clusters/platforms/kubernetes_spec.rb' - 'spec/models/project_services/kubernetes_service_spec.rb' -# Offense count: 64 +# Offense count: 34 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: inline, group +Style/AccessModifierDeclarations: + Enabled: false + +# Offense count: 121 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: percent_q, bare_percent @@ -324,17 +535,13 @@ Style/CommentedKeyword: - 'lib/tasks/gitlab/backup.rake' - 'spec/tasks/gitlab/backup_rake_spec.rb' -# Offense count: 30 -Style/DateTime: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. Style/Dir: Exclude: - 'qa/qa.rb' -# Offense count: 9 +# Offense count: 7 # Cop supports --auto-correct. Style/EachWithObject: Exclude: @@ -345,46 +552,42 @@ Style/EachWithObject: - 'lib/gitlab/i18n/po_linter.rb' - 'lib/gitlab/import_export/members_mapper.rb' - 'lib/gitlab/import_export/relation_factory.rb' - - 'scripts/static-analysis' -# Offense count: 24 +# Offense count: 34 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty, nil, both Style/EmptyElse: Enabled: false -# Offense count: 14 +# Offense count: 11 # Cop supports --auto-correct. Style/EmptyLambdaParameter: Exclude: - 'app/models/ci/build.rb' - 'app/models/ci/runner.rb' -# Offense count: 12 +# Offense count: 9 # Cop supports --auto-correct. Style/EmptyLiteral: Exclude: - - 'features/steps/project/commits/commits.rb' - 'lib/gitlab/fogbugz_import/importer.rb' - 'lib/gitlab/git/diff_collection.rb' - 'lib/gitlab/gitaly_client.rb' - - 'scripts/trigger-build' - - 'spec/features/merge_requests/versions_spec.rb' - 'spec/helpers/merge_requests_helper_spec.rb' - 'spec/lib/gitlab/request_context_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: 102 +# Offense count: 180 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: compact, expanded Style/EmptyMethod: Enabled: false -# Offense count: 23 +# Offense count: 40 # Cop supports --auto-correct. Style/Encoding: Enabled: false @@ -394,52 +597,52 @@ Style/EvalWithLocation: Exclude: - 'app/models/service.rb' -# Offense count: 35 +# Offense count: 203 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: format, sprintf, percent Style/FormatString: Enabled: false -# Offense count: 384 +# Offense count: 669 # Configuration parameters: MinBodyLength. Style/GuardClause: Enabled: false -# Offense count: 22 +# Offense count: 27 Style/IfInsideElse: Enabled: false -# Offense count: 809 +# Offense count: 1346 # Cop supports --auto-correct. Style/IfUnlessModifier: Enabled: false -# Offense count: 75 +# Offense count: 186 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: line_count_dependent, lambda, literal Style/Lambda: Enabled: false -# Offense count: 11 +# Offense count: 3 # Cop supports --auto-correct. Style/LineEndConcatenation: Exclude: - - 'app/helpers/tree_helper.rb' - - 'spec/features/issuables/markdown_references_spec.rb' - - 'spec/lib/gitlab/checks/project_moved_spec.rb' - 'spec/lib/gitlab/gfm/reference_rewriter_spec.rb' - 'spec/lib/gitlab/incoming_email_spec.rb' # Offense count: 18 -Style/MethodMissing: +Style/MethodMissingSuper: Enabled: false -# Offense count: 7 +# Offense count: 18 +Style/MissingRespondToMissing: + Enabled: false + +# Offense count: 6 Style/MixinUsage: Exclude: - - 'features/support/env.rb' - 'spec/factories/ci/builds.rb' - 'spec/factories/ci/job_artifacts.rb' - 'spec/factories/lfs_objects.rb' @@ -447,59 +650,63 @@ Style/MixinUsage: - 'spec/lib/gitlab/import_export/project_tree_restorer_spec.rb' - 'spec/lib/gitlab/import_export/version_checker_spec.rb' -# Offense count: 6 +# Offense count: 4 # Cop supports --auto-correct. Style/MultilineIfModifier: Exclude: - 'app/helpers/snippets_helper.rb' - 'app/models/project_wiki.rb' - 'app/services/ci/process_pipeline_service.rb' - - 'app/services/create_deployment_service.rb' - 'lib/api/commit_statuses.rb' - - 'lib/gitlab/ci/trace.rb' -# Offense count: 25 +# Offense count: 72 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Enabled: false + +# Offense count: 28 # Cop supports --auto-correct. # Configuration parameters: Whitelist. # Whitelist: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with Style/NestedParenthesizedCalls: Enabled: false -# Offense count: 19 +# Offense count: 31 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinBodyLength. # SupportedStyles: skip_modifier_ifs, always Style/Next: Enabled: false -# Offense count: 61 +# Offense count: 67 # Cop supports --auto-correct. # Configuration parameters: EnforcedOctalStyle. # SupportedOctalStyles: zero_with_o, zero_only Style/NumericLiteralPrefix: Enabled: false -# Offense count: 114 +# Offense count: 186 # Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle. +# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. # SupportedStyles: predicate, comparison Style/NumericPredicate: Enabled: false -# Offense count: 4 +# Offense count: 2 # Cop supports --auto-correct. Style/OrAssignment: Exclude: - - 'app/models/concerns/token_authenticatable.rb' - 'lib/api/commit_statuses.rb' - 'lib/gitlab/project_transfer.rb' -# Offense count: 50 +# Offense count: 79 # Cop supports --auto-correct. Style/ParallelAssignment: Enabled: false -# Offense count: 917 +# Offense count: 1390 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: @@ -521,25 +728,20 @@ Style/PerlBackrefs: - 'lib/gitlab/search_results.rb' - 'lib/gitlab/sherlock/query.rb' -# Offense count: 87 +# Offense count: 129 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: compact, exploded Style/RaiseArgs: Enabled: false -# Offense count: 9 +# Offense count: 3 # Cop supports --auto-correct. Style/RedundantBegin: Exclude: - - 'app/controllers/projects/clusters/gcp_controller.rb' - 'app/models/merge_request.rb' - 'app/services/projects/import_service.rb' - - 'lib/api/branches.rb' - - 'lib/gitlab/current_settings.rb' - - 'lib/gitlab/git/commit.rb' - 'lib/gitlab/health_checks/base_abstract_check.rb' - - 'lib/tasks/gitlab/task_helpers.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -547,7 +749,7 @@ Style/RedundantConditional: Exclude: - 'lib/system_check/helpers.rb' -# Offense count: 57 +# Offense count: 360 # Cop supports --auto-correct. Style/RedundantFreeze: Enabled: false @@ -567,41 +769,36 @@ Style/RedundantReturn: - 'lib/gitlab/utils.rb' - 'lib/google_api/auth.rb' -# Offense count: 460 +# Offense count: 700 # Cop supports --auto-correct. Style/RedundantSelf: Enabled: false -# Offense count: 142 +# Offense count: 28 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed Style/RegexpLiteral: - Enabled: true - EnforcedStyle: mixed - AllowInnerSlashes: false + Enabled: false -# Offense count: 36 +# Offense count: 41 # Cop supports --auto-correct. Style/RescueModifier: Enabled: false -# Offense count: 107 +# Offense count: 197 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, explicit Style/RescueStandardError: Enabled: false -# Offense count: 8 +# Offense count: 5 # Cop supports --auto-correct. Style/SelfAssignment: Exclude: - 'app/models/concerns/bulk_member_access_load.rb' - 'app/serializers/base_serializer.rb' - - 'app/services/notification_service.rb' - - 'lib/api/runners.rb' - - 'spec/features/merge_requests/diff_notes_resolve_spec.rb' - 'spec/features/projects/clusters/interchangeability_spec.rb' - 'spec/support/import_export/configuration_helper.rb' @@ -612,7 +809,7 @@ Style/SingleLineMethods: Exclude: - 'lib/gitlab/ci/ansi2html.rb' -# Offense count: 66 +# Offense count: 91 # Cop supports --auto-correct. # Configuration parameters: . # SupportedStyles: use_perl_names, use_english_names @@ -625,21 +822,21 @@ Style/StderrPuts: Exclude: - 'config/initializers/rspec_profiling.rb' -# Offense count: 45 +# Offense count: 65 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: single_quotes, double_quotes Style/StringLiteralsInInterpolation: Enabled: false -# Offense count: 106 +# Offense count: 187 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. # IgnoredMethods: respond_to, define_method Style/SymbolProc: Enabled: false -# Offense count: 9 +# Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, AllowSafeAssignment. # SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex @@ -647,45 +844,65 @@ Style/TernaryParentheses: Exclude: - 'app/finders/projects_finder.rb' - 'app/helpers/namespaces_helper.rb' - - 'features/support/capybara.rb' - 'lib/gitlab/ci/build/artifacts/metadata/entry.rb' - 'spec/requests/api/pipeline_schedules_spec.rb' - 'spec/support/capybara.rb' -# Offense count: 17 +# Offense count: 3 # Cop supports --auto-correct. -# Configuration parameters: AllowNamedUnderscoreVariables. -Style/TrailingUnderscoreVariable: +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArguments: Exclude: - - 'app/controllers/admin/background_jobs_controller.rb' - - 'app/controllers/invites_controller.rb' - - 'app/helpers/tab_helper.rb' - - 'lib/backup/manager.rb' - - 'lib/gitlab/logger.rb' - - 'lib/gitlab/upgrader.rb' - - 'lib/system_check/app/migrations_are_up_check.rb' - - 'lib/system_check/incoming_email/mail_room_running_check.rb' - - 'lib/tasks/gitlab/check.rake' - - 'lib/tasks/gitlab/task_helpers.rb' - - 'spec/lib/gitlab/etag_caching/middleware_spec.rb' - - 'spec/services/quick_actions/interpret_service_spec.rb' + - 'spec/features/markdown/copy_as_gfm_spec.rb' -# Offense count: 4 +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'ee/spec/models/project_spec.rb' + - 'spec/lib/gitlab/diff/position_tracer_spec.rb' + - 'spec/lib/gitlab/metrics/dashboard/processor_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'lib/gitlab/ci/ansi2html.rb' + - 'lib/gitlab/kubernetes.rb' + +# Offense count: 2 # Cop supports --auto-correct. Style/UnlessElse: Exclude: - 'lib/backup/manager.rb' - 'lib/gitlab/project_search_results.rb' - - 'lib/tasks/gitlab/check.rake' - - 'spec/features/issues/award_emoji_spec.rb' -# Offense count: 31 +# Offense count: 10 +# Cop supports --auto-correct. +Style/UnneededCondition: + Exclude: + - 'app/helpers/button_helper.rb' + - 'app/helpers/environment_helper.rb' + - 'app/models/project.rb' + - 'app/services/issuable/clone/base_service.rb' + - 'app/services/prometheus/adapter_service.rb' + - 'lib/gitlab/email/message/repository_push.rb' + - 'lib/gitlab/prometheus_client.rb' + - 'spec/lib/rspec_flaky/flaky_example_spec.rb' + +# Offense count: 73 # Cop supports --auto-correct. Style/UnneededInterpolation: Enabled: false -# Offense count: 22840 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Metrics/LineLength: - Max: 1310 +# Offense count: 2 +# Cop supports --auto-correct. +Style/UnneededSort: + Exclude: + - 'app/models/concerns/resolvable_discussion.rb' + - 'lib/gitlab/highlight.rb' @@ -349,13 +349,14 @@ group :development, :test do gem 'spring', '~> 2.0.0' gem 'spring-commands-rspec', '~> 1.0.4' - gem 'gitlab-styles', '~> 2.5', require: false + gem 'gitlab-styles', '~> 2.6', require: false # Pin these dependencies, otherwise a new rule could break the CI pipelines - gem 'rubocop', '~> 0.54.0' + gem 'rubocop', '~> 0.68.1' + gem 'rubocop-performance', '~> 1.1.0' gem 'rubocop-rspec', '~> 1.22.1' gem 'scss_lint', '~> 0.56.0', require: false - gem 'haml_lint', '~> 0.28.0', require: false + gem 'haml_lint', '~> 0.30.0', require: false gem 'simplecov', '~> 0.14.0', require: false gem 'bundler-audit', '~> 0.5.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock index e02de8292bd..bdcefd2e2b5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -297,9 +297,10 @@ GEM gitlab-markup (1.7.0) gitlab-sidekiq-fetcher (0.4.0) sidekiq (~> 5) - gitlab-styles (2.5.2) - rubocop (~> 0.54.0) + gitlab-styles (2.6.2) + rubocop (~> 0.68.1) rubocop-gitlab-security (~> 0.1.0) + rubocop-performance (~> 1.1.0) rubocop-rspec (~> 1.19) gitlab_omniauth-ldap (2.1.1) net-ldap (~> 0.16) @@ -357,7 +358,7 @@ GEM haml (5.0.4) temple (>= 0.8.0) tilt - haml_lint (0.28.0) + haml_lint (0.30.0) haml (>= 4.0, < 5.1) rainbow rake (>= 10, < 13) @@ -407,6 +408,7 @@ GEM jaeger-client (0.10.0) opentracing (~> 0.3) thrift + jaro_winkler (1.5.2) jira-ruby (1.4.1) activesupport multipart-post @@ -585,7 +587,7 @@ GEM rubypants (~> 0.2) orm_adapter (0.5.0) os (1.0.0) - parallel (1.12.1) + parallel (1.17.0) parser (2.5.3.0) ast (~> 2.4.0) parslet (1.8.2) @@ -615,7 +617,6 @@ GEM pg (1.1.4) po_to_json (1.0.1) json (>= 1.6.0) - powerpack (0.1.1) premailer (1.10.4) addressable css_parser (>= 1.4.10) @@ -787,15 +788,17 @@ GEM pg rails sqlite3 - rubocop (0.54.0) + rubocop (0.68.1) + jaro_winkler (~> 1.5.1) parallel (~> 1.10) - parser (>= 2.5) - powerpack (~> 0.1) + parser (>= 2.5, != 2.5.1.1) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) + unicode-display_width (>= 1.4.0, < 1.6) rubocop-gitlab-security (0.1.1) rubocop (>= 0.51) + rubocop-performance (1.1.0) + rubocop (>= 0.67.0) rubocop-rspec (1.22.2) rubocop (>= 0.52.1) ruby-enum (0.7.2) @@ -803,7 +806,7 @@ GEM ruby-fogbugz (0.2.1) crack (~> 0.4) ruby-prof (0.17.0) - ruby-progressbar (1.9.0) + ruby-progressbar (1.10.0) ruby-saml (1.7.2) nokogiri (>= 1.5.10) ruby_parser (3.11.0) @@ -929,7 +932,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.5) - unicode-display_width (1.3.2) + unicode-display_width (1.5.0) unicorn (5.4.1) kgio (~> 2.6) raindrops (~> 0.7) @@ -1065,7 +1068,7 @@ DEPENDENCIES gitlab-labkit (~> 0.2.0) gitlab-markup (~> 1.7.0) gitlab-sidekiq-fetcher (~> 0.4.0) - gitlab-styles (~> 2.5) + gitlab-styles (~> 2.6) gitlab_omniauth-ldap (~> 2.1.1) gon (~> 6.2) google-api-client (~> 0.23) @@ -1078,7 +1081,7 @@ DEPENDENCIES graphiql-rails (~> 1.4.10) graphql (~> 1.8.0) grpc (~> 1.19.0) - haml_lint (~> 0.28.0) + haml_lint (~> 0.30.0) hamlit (~> 2.8.8) hangouts-chat (~> 0.0.5) hashie-forbidden_attributes @@ -1171,7 +1174,8 @@ DEPENDENCIES rspec-set (~> 0.1.3) rspec_junit_formatter rspec_profiling (~> 0.0.5) - rubocop (~> 0.54.0) + rubocop (~> 0.68.1) + rubocop-performance (~> 1.1.0) rubocop-rspec (~> 1.22.1) ruby-fogbugz (~> 0.2.1) ruby-prof (~> 0.17.0) diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 10cdce98437..837c26c630a 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -7,7 +7,7 @@ class HelpController < ApplicationController # Taken from Jekyll # https://github.com/jekyll/jekyll/blob/3.5-stable/lib/jekyll/document.rb#L13 - YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m + YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m.freeze def index # Remove YAML frontmatter so that it doesn't look weird diff --git a/app/controllers/import/bitbucket_server_controller.rb b/app/controllers/import/bitbucket_server_controller.rb index 643a3bfed1f..f71ea8642cd 100644 --- a/app/controllers/import/bitbucket_server_controller.rb +++ b/app/controllers/import/bitbucket_server_controller.rb @@ -15,8 +15,8 @@ class Import::BitbucketServerController < Import::BaseController # (https://community.atlassian.com/t5/Answers-Developer-Questions/stash-repository-names/qaq-p/499054) # # Bitbucket Server starts personal project names with a tilde. - VALID_BITBUCKET_PROJECT_CHARS = /\A~?[\w\-\.\s]+\z/ - VALID_BITBUCKET_CHARS = /\A[\w\-\.\s]+\z/ + VALID_BITBUCKET_PROJECT_CHARS = /\A~?[\w\-\.\s]+\z/.freeze + VALID_BITBUCKET_CHARS = /\A[\w\-\.\s]+\z/.freeze def new end diff --git a/app/helpers/auth_helper.rb b/app/helpers/auth_helper.rb index b4ee648361c..076976175a9 100644 --- a/app/helpers/auth_helper.rb +++ b/app/helpers/auth_helper.rb @@ -2,7 +2,7 @@ module AuthHelper PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq).freeze - LDAP_PROVIDER = /\Aldap/ + LDAP_PROVIDER = /\Aldap/.freeze def ldap_enabled? Gitlab::Auth::LDAP::Config.enabled? diff --git a/app/helpers/sidekiq_helper.rb b/app/helpers/sidekiq_helper.rb index 32bf3526571..6326d98461e 100644 --- a/app/helpers/sidekiq_helper.rb +++ b/app/helpers/sidekiq_helper.rb @@ -8,7 +8,7 @@ module SidekiqHelper (?<state>[DIEKNRSTVWXZNLpsl\+<>/\d]+)\s+ (?<start>.+?)\s+ (?<command>(?:ruby\d+:\s+)?sidekiq.*\].*) - \z}x + \z}x.freeze def parse_sidekiq_ps(line) match = line.strip.match(SIDEKIQ_PS_REGEXP) diff --git a/app/models/application_setting_implementation.rb b/app/models/application_setting_implementation.rb index ee12a1d09f3..e51619b0f9c 100644 --- a/app/models/application_setting_implementation.rb +++ b/app/models/application_setting_implementation.rb @@ -8,7 +8,7 @@ module ApplicationSettingImplementation \s # any whitespace character | # or [\r\n] # any number of newline characters - }x + }x.freeze # Setting a key restriction to `-1` means that all keys of this type are # forbidden. diff --git a/app/models/commit_range.rb b/app/models/commit_range.rb index 920b1d092dd..08ca86bc902 100644 --- a/app/models/commit_range.rb +++ b/app/models/commit_range.rb @@ -28,12 +28,12 @@ class CommitRange # The beginning and ending refs can be named or SHAs, and # the range notation can be double- or triple-dot. - REF_PATTERN = /[0-9a-zA-Z][0-9a-zA-Z_.-]*[0-9a-zA-Z\^]/ - PATTERN = /#{REF_PATTERN}\.{2,3}#{REF_PATTERN}/ + REF_PATTERN = /[0-9a-zA-Z][0-9a-zA-Z_.-]*[0-9a-zA-Z\^]/.freeze + PATTERN = /#{REF_PATTERN}\.{2,3}#{REF_PATTERN}/.freeze # In text references, the beginning and ending refs can only be SHAs # between 7 and 40 hex characters. - STRICT_PATTERN = /\h{7,40}\.{2,3}\h{7,40}/ + STRICT_PATTERN = /\h{7,40}\.{2,3}\h{7,40}/.freeze def self.reference_prefix '@' diff --git a/app/models/concerns/maskable.rb b/app/models/concerns/maskable.rb index 8793f0ec965..2943872ffab 100644 --- a/app/models/concerns/maskable.rb +++ b/app/models/concerns/maskable.rb @@ -9,7 +9,7 @@ module Maskable # * No spaces # * Minimal length of 8 characters # * Absolutely no fun is allowed - REGEX = /\A\w{8,}\z/ + REGEX = /\A\w{8,}\z/.freeze included do validates :masked, inclusion: { in: [true, false] } diff --git a/app/models/concerns/redactable.rb b/app/models/concerns/redactable.rb index 5ad96d6cc46..53ae300ee2d 100644 --- a/app/models/concerns/redactable.rb +++ b/app/models/concerns/redactable.rb @@ -10,7 +10,7 @@ module Redactable extend ActiveSupport::Concern - UNSUBSCRIBE_PATTERN = %r{/sent_notifications/\h{32}/unsubscribe} + UNSUBSCRIBE_PATTERN = %r{/sent_notifications/\h{32}/unsubscribe}.freeze class_methods do def redact_field(field) diff --git a/app/models/concerns/taskable.rb b/app/models/concerns/taskable.rb index f147ce8ad6b..2f0e078c807 100644 --- a/app/models/concerns/taskable.rb +++ b/app/models/concerns/taskable.rb @@ -19,7 +19,7 @@ module Taskable \s+ # whitespace prefix has to be always presented for a list item (\[\s\]|\[[xX]\]) # checkbox (\s.+) # followed by whitespace and some text. - }x + }x.freeze def self.get_tasks(content) content.to_s.scan(ITEM_PATTERN).map do |checkbox, label| diff --git a/app/models/environment.rb b/app/models/environment.rb index 69224635e34..0eda7a2513f 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -3,8 +3,8 @@ class Environment < ApplicationRecord include Gitlab::Utils::StrongMemoize # Used to generate random suffixes for the slug - LETTERS = 'a'..'z' - NUMBERS = '0'..'9' + LETTERS = ('a'..'z').freeze + NUMBERS = ('0'..'9').freeze SUFFIX_CHARS = LETTERS.to_a + NUMBERS.to_a belongs_to :project, required: true diff --git a/app/models/error_tracking/project_error_tracking_setting.rb b/app/models/error_tracking/project_error_tracking_setting.rb index 72270ee8b4f..0b4fef5eac1 100644 --- a/app/models/error_tracking/project_error_tracking_setting.rb +++ b/app/models/error_tracking/project_error_tracking_setting.rb @@ -16,7 +16,7 @@ module ErrorTracking (?<project>[^/]+)/* )? \z - }x + }x.freeze self.reactive_cache_key = ->(setting) { [setting.class.model_name.singular, setting.project_id] } diff --git a/app/services/projects/import_error_filter.rb b/app/services/projects/import_error_filter.rb index a0fc5149bb4..737b794484d 100644 --- a/app/services/projects/import_error_filter.rb +++ b/app/services/projects/import_error_filter.rb @@ -4,7 +4,7 @@ module Projects # Used by project imports, it removes any potential paths # included in an error message that could be stored in the DB class ImportErrorFilter - ERROR_MESSAGE_FILTER = /[^\s]*#{File::SEPARATOR}[^\s]*(?=(\s|\z))/ + ERROR_MESSAGE_FILTER = /[^\s]*#{File::SEPARATOR}[^\s]*(?=(\s|\z))/.freeze FILTER_MESSAGE = '[FILTERED]' def self.filter_message(message) diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index e90599f2505..6dfe2bed0ba 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -14,8 +14,8 @@ class FileUploader < GitlabUploader include ObjectStorage::Concern prepend ObjectStorage::Extension::RecordsUploads - MARKDOWN_PATTERN = %r{\!?\[.*?\]\(/uploads/(?<secret>[0-9a-f]{32})/(?<file>.*?)\)} - DYNAMIC_PATH_PATTERN = %r{.*(?<secret>\h{32})/(?<identifier>.*)} + MARKDOWN_PATTERN = %r{\!?\[.*?\]\(/uploads/(?<secret>[0-9a-f]{32})/(?<file>.*?)\)}.freeze + DYNAMIC_PATH_PATTERN = %r{.*(?<secret>\h{32})/(?<identifier>.*)}.freeze after :remove, :prune_store_dir diff --git a/config/initializers/gettext_rails_i18n_patch.rb b/config/initializers/gettext_rails_i18n_patch.rb index c1342f48ebd..714dd505824 100644 --- a/config/initializers/gettext_rails_i18n_patch.rb +++ b/config/initializers/gettext_rails_i18n_patch.rb @@ -2,7 +2,7 @@ require 'gettext_i18n_rails/haml_parser' require 'gettext_i18n_rails_js/parser/javascript' require 'json' -VUE_TRANSLATE_REGEX = /((%[\w.-]+)(?:\s))?{{ (N|n|s)?__\((.*)\) }}/ +VUE_TRANSLATE_REGEX = /((%[\w.-]+)(?:\s))?{{ (N|n|s)?__\((.*)\) }}/.freeze module GettextI18nRails class HamlParser diff --git a/danger/commit_messages/Dangerfile b/danger/commit_messages/Dangerfile index 9be1ce2ff86..048c539bcf9 100644 --- a/danger/commit_messages/Dangerfile +++ b/danger/commit_messages/Dangerfile @@ -21,7 +21,7 @@ class EmojiChecker # alone is not enough, as we'd match `:foo:bar:baz`. Instead, we use this # regex to save us from having to check for all possible emoji names when we # know one definitely is not included. - LIKELY_EMOJI = /:[\+a-z0-9_\-]+:/ + LIKELY_EMOJI = /:[\+a-z0-9_\-]+:/.freeze def initialize names = JSON.parse(File.read(DIGESTS)).keys + diff --git a/db/migrate/20140414131055_change_state_to_allow_empty_merge_request_diffs.rb b/db/migrate/20140414131055_change_state_to_allow_empty_merge_request_diffs.rb index 148b46f8830..1f9ae3f0080 100644 --- a/db/migrate/20140414131055_change_state_to_allow_empty_merge_request_diffs.rb +++ b/db/migrate/20140414131055_change_state_to_allow_empty_merge_request_diffs.rb @@ -1,4 +1,3 @@ -# rubocop:disable all class ChangeStateToAllowEmptyMergeRequestDiffs < ActiveRecord::Migration[4.2] def up change_column :merge_request_diffs, :state, :string, null: true, diff --git a/lib/api/api.rb b/lib/api/api.rb index a572cca24e9..f4a96b9711b 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -6,7 +6,7 @@ module API LOG_FILENAME = Rails.root.join("log", "api_json.log") - NO_SLASH_URL_PART_REGEX = %r{[^/]+} + NO_SLASH_URL_PART_REGEX = %r{[^/]+}.freeze NAMESPACE_OR_PROJECT_REQUIREMENTS = { id: NO_SLASH_URL_PART_REGEX }.freeze COMMIT_ENDPOINT_REQUIREMENTS = NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(sha: NO_SLASH_URL_PART_REGEX).freeze USER_REQUIREMENTS = { user_id: NO_SLASH_URL_PART_REGEX }.freeze diff --git a/lib/banzai/color_parser.rb b/lib/banzai/color_parser.rb index 6d01d51955c..cce79e73d2d 100644 --- a/lib/banzai/color_parser.rb +++ b/lib/banzai/color_parser.rb @@ -2,13 +2,13 @@ module Banzai module ColorParser - ALPHA = /0(?:\.\d+)?|\.\d+|1(?:\.0+)?/ # 0.0..1.0 - PERCENTS = /(?:\d{1,2}|100)%/ # 00%..100% - ALPHA_CHANNEL = /(?:,\s*(?:#{ALPHA}|#{PERCENTS}))?/ - BITS = /\d{1,2}|1\d\d|2(?:[0-4]\d|5[0-5])/ # 00..255 - DEGS = /-?\d+(?:deg)?/i # [-]digits[deg] - RADS = /-?(?:\d+(?:\.\d+)?|\.\d+)rad/i # [-](digits[.digits] OR .digits)rad - HEX_FORMAT = /\#(?:\h{3}|\h{4}|\h{6}|\h{8})/ + ALPHA = /0(?:\.\d+)?|\.\d+|1(?:\.0+)?/.freeze # 0.0..1.0 + PERCENTS = /(?:\d{1,2}|100)%/.freeze # 00%..100% + ALPHA_CHANNEL = /(?:,\s*(?:#{ALPHA}|#{PERCENTS}))?/.freeze + BITS = /\d{1,2}|1\d\d|2(?:[0-4]\d|5[0-5])/.freeze # 00..255 + DEGS = /-?\d+(?:deg)?/i.freeze # [-]digits[deg] + RADS = /-?(?:\d+(?:\.\d+)?|\.\d+)rad/i.freeze # [-](digits[.digits] OR .digits)rad + HEX_FORMAT = /\#(?:\h{3}|\h{4}|\h{6}|\h{8})/.freeze RGB_FORMAT = %r{ (?:rgba? \( @@ -20,7 +20,7 @@ module Banzai #{ALPHA_CHANNEL} \) ) - }xi + }xi.freeze HSL_FORMAT = %r{ (?:hsla? \( @@ -28,11 +28,11 @@ module Banzai #{ALPHA_CHANNEL} \) ) - }xi + }xi.freeze FORMATS = [HEX_FORMAT, RGB_FORMAT, HSL_FORMAT].freeze - COLOR_FORMAT = /\A(#{Regexp.union(FORMATS)})\z/ix + COLOR_FORMAT = /\A(#{Regexp.union(FORMATS)})\z/ix.freeze # Public: Analyzes whether the String is a color code. # diff --git a/lib/banzai/filter/autolink_filter.rb b/lib/banzai/filter/autolink_filter.rb index 086adf59d2b..56214043d87 100644 --- a/lib/banzai/filter/autolink_filter.rb +++ b/lib/banzai/filter/autolink_filter.rb @@ -33,7 +33,7 @@ module Banzai # https://github.com/vmg/rinku/blob/v2.0.1/ext/rinku/autolink.c#L65 # # Rubular: http://rubular.com/r/nrL3r9yUiq - LINK_PATTERN = %r{([a-z][a-z0-9\+\.-]+://[^\s>]+)(?<!\?|!|\.|,|:)} + LINK_PATTERN = %r{([a-z][a-z0-9\+\.-]+://[^\s>]+)(?<!\?|!|\.|,|:)}.freeze # Text matching LINK_PATTERN inside these elements will not be linked IGNORE_PARENTS = %w(a code kbd pre script style).to_set diff --git a/lib/banzai/filter/front_matter_filter.rb b/lib/banzai/filter/front_matter_filter.rb index a27d18facd1..544231adea4 100644 --- a/lib/banzai/filter/front_matter_filter.rb +++ b/lib/banzai/filter/front_matter_filter.rb @@ -20,7 +20,7 @@ module Banzai \s* ^\k<delim> # closing front matter marker \s* - }mx + }mx.freeze def call html.sub(PATTERN) do |_match| diff --git a/lib/banzai/filter/spaced_link_filter.rb b/lib/banzai/filter/spaced_link_filter.rb index 50bf823929c..ee7f10ebdf6 100644 --- a/lib/banzai/filter/spaced_link_filter.rb +++ b/lib/banzai/filter/spaced_link_filter.rb @@ -33,7 +33,7 @@ module Banzai (?<new_link>.+?) (?<title>\ ".+?")? \) - }x + }x.freeze # Text matching LINK_OR_IMAGE_PATTERN inside these elements will not be linked IGNORE_PARENTS = %w(a code kbd pre script style).to_set diff --git a/lib/banzai/filter/table_of_contents_filter.rb b/lib/banzai/filter/table_of_contents_filter.rb index f2ae17b44fa..1a68d773048 100644 --- a/lib/banzai/filter/table_of_contents_filter.rb +++ b/lib/banzai/filter/table_of_contents_filter.rb @@ -17,7 +17,7 @@ module Banzai # :toc - String containing Table of Contents data as a `ul` element with # `li` child elements. class TableOfContentsFilter < HTML::Pipeline::Filter - PUNCTUATION_REGEXP = /[^\p{Word}\- ]/u + PUNCTUATION_REGEXP = /[^\p{Word}\- ]/u.freeze def call return doc if context[:no_header_anchors] diff --git a/lib/declarative_policy/preferred_scope.rb b/lib/declarative_policy/preferred_scope.rb index 239780d8626..9b7d1548056 100644 --- a/lib/declarative_policy/preferred_scope.rb +++ b/lib/declarative_policy/preferred_scope.rb @@ -1,4 +1,3 @@ -# rubocop:disable Naming/FileName # frozen_string_literal: true module DeclarativePolicy diff --git a/lib/gitlab.rb b/lib/gitlab.rb index 1204e53ee2e..d301efc3205 100644 --- a/lib/gitlab.rb +++ b/lib/gitlab.rb @@ -36,8 +36,8 @@ module Gitlab end COM_URL = 'https://gitlab.com'.freeze - APP_DIRS_PATTERN = %r{^/?(app|config|ee|lib|spec|\(\w*\))} - SUBDOMAIN_REGEX = %r{\Ahttps://[a-z0-9]+\.gitlab\.com\z} + APP_DIRS_PATTERN = %r{^/?(app|config|ee|lib|spec|\(\w*\))}.freeze + SUBDOMAIN_REGEX = %r{\Ahttps://[a-z0-9]+\.gitlab\.com\z}.freeze VERSION = File.read(root.join("VERSION")).strip.freeze INSTALLATION_TYPE = File.read(root.join("INSTALLATION_TYPE")).strip.freeze diff --git a/lib/gitlab/auth/result.rb b/lib/gitlab/auth/result.rb index 78fa25c5516..4ebf2afb9cb 100644 --- a/lib/gitlab/auth/result.rb +++ b/lib/gitlab/auth/result.rb @@ -1,4 +1,3 @@ -# rubocop:disable Naming/FileName # frozen_string_literal: true module Gitlab diff --git a/lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb b/lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb index a84f794bfae..1924f2ffee2 100644 --- a/lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb +++ b/lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb @@ -8,8 +8,8 @@ module Gitlab self.table_name = 'untracked_files_for_uploads' # Ends with /:random_hex/:filename - FILE_UPLOADER_PATH = %r{/\h+/[^/]+\z} - FULL_PATH_CAPTURE = /\A(.+)#{FILE_UPLOADER_PATH}/ + FILE_UPLOADER_PATH = %r{/\h+/[^/]+\z}.freeze + FULL_PATH_CAPTURE = /\A(.+)#{FILE_UPLOADER_PATH}/.freeze # These regex patterns are tested against a relative path, relative to # the upload directory. diff --git a/lib/gitlab/background_migration/prepare_untracked_uploads.rb b/lib/gitlab/background_migration/prepare_untracked_uploads.rb index 81ca2b0a9b7..1ee44a3a5a9 100644 --- a/lib/gitlab/background_migration/prepare_untracked_uploads.rb +++ b/lib/gitlab/background_migration/prepare_untracked_uploads.rb @@ -16,7 +16,7 @@ module Gitlab RELATIVE_UPLOAD_DIR ) FOLLOW_UP_MIGRATION = 'PopulateUntrackedUploads'.freeze - START_WITH_ROOT_REGEX = %r{\A#{Gitlab.config.uploads.storage_path}/} + START_WITH_ROOT_REGEX = %r{\A#{Gitlab.config.uploads.storage_path}/}.freeze EXCLUDED_HASHED_UPLOADS_PATH = "#{ABSOLUTE_UPLOAD_DIR}/@hashed/*".freeze EXCLUDED_TMP_UPLOADS_PATH = "#{ABSOLUTE_UPLOAD_DIR}/tmp/*".freeze diff --git a/lib/gitlab/ci/build/artifacts/metadata.rb b/lib/gitlab/ci/build/artifacts/metadata.rb index 7011dd1aaf2..1c3ce08be76 100644 --- a/lib/gitlab/ci/build/artifacts/metadata.rb +++ b/lib/gitlab/ci/build/artifacts/metadata.rb @@ -11,8 +11,8 @@ module Gitlab ParserError = Class.new(StandardError) InvalidStreamError = Class.new(StandardError) - VERSION_PATTERN = /^[\w\s]+(\d+\.\d+\.\d+)/ - INVALID_PATH_PATTERN = %r{(^\.?\.?/)|(/\.?\.?/)} + VERSION_PATTERN = /^[\w\s]+(\d+\.\d+\.\d+)/.freeze + INVALID_PATH_PATTERN = %r{(^\.?\.?/)|(/\.?\.?/)}.freeze attr_reader :stream, :path, :full_version diff --git a/lib/gitlab/ci/pipeline/chain/command.rb b/lib/gitlab/ci/pipeline/chain/command.rb index 03af99ba9a5..c911bfa7ff6 100644 --- a/lib/gitlab/ci/pipeline/chain/command.rb +++ b/lib/gitlab/ci/pipeline/chain/command.rb @@ -1,4 +1,3 @@ -# rubocop:disable Naming/FileName # frozen_string_literal: true module Gitlab diff --git a/lib/gitlab/ci/pipeline/chain/skip.rb b/lib/gitlab/ci/pipeline/chain/skip.rb index 7d6e0704d4a..df92e229f12 100644 --- a/lib/gitlab/ci/pipeline/chain/skip.rb +++ b/lib/gitlab/ci/pipeline/chain/skip.rb @@ -7,7 +7,7 @@ module Gitlab class Skip < Chain::Base include ::Gitlab::Utils::StrongMemoize - SKIP_PATTERN = /\[(ci[ _-]skip|skip[ _-]ci)\]/i + SKIP_PATTERN = /\[(ci[ _-]skip|skip[ _-]ci)\]/i.freeze def perform! if skipped? diff --git a/lib/gitlab/content_disposition.rb b/lib/gitlab/content_disposition.rb index 32207514ce5..ff6154a5b26 100644 --- a/lib/gitlab/content_disposition.rb +++ b/lib/gitlab/content_disposition.rb @@ -22,13 +22,13 @@ module Gitlab end # rubocop:disable Style/VariableInterpolation - TRADITIONAL_ESCAPED_CHAR = /[^ A-Za-z0-9!#$+.^_`|~-]/ + TRADITIONAL_ESCAPED_CHAR = /[^ A-Za-z0-9!#$+.^_`|~-]/.freeze def ascii_filename 'filename="' + percent_escape(::I18n.transliterate(filename), TRADITIONAL_ESCAPED_CHAR) + '"' end - RFC_5987_ESCAPED_CHAR = /[^A-Za-z0-9!#$&+.^_`|~-]/ + RFC_5987_ESCAPED_CHAR = /[^A-Za-z0-9!#$&+.^_`|~-]/.freeze # rubocop:enable Style/VariableInterpolation def utf8_filename diff --git a/lib/gitlab/danger/helper.rb b/lib/gitlab/danger/helper.rb index 68890aa8e30..3ef19d801b7 100644 --- a/lib/gitlab/danger/helper.rb +++ b/lib/gitlab/danger/helper.rb @@ -103,8 +103,6 @@ module Gitlab none: "", qa: "~QA" }.freeze - - # rubocop:disable Style/RegexpLiteral CATEGORIES = { %r{\Adoc/} => :none, # To reinstate roulette for documentation, set to `:docs`. %r{\A(CONTRIBUTING|LICENSE|MAINTENANCE|PHILOSOPHY|PROCESS|README)(\.md)?\z} => :none, # To reinstate roulette for documentation, set to `:docs`. @@ -151,7 +149,6 @@ module Gitlab %r{\.(md|txt)\z} => :none, # To reinstate roulette for documentation, set to `:docs`. %r{\.js\z} => :frontend }.freeze - # rubocop:enable Style/RegexpLiteral end end end diff --git a/lib/gitlab/git/pre_receive_error.rb b/lib/gitlab/git/pre_receive_error.rb index b46d4ba0b02..ef9b1bf5224 100644 --- a/lib/gitlab/git/pre_receive_error.rb +++ b/lib/gitlab/git/pre_receive_error.rb @@ -14,7 +14,7 @@ module Gitlab 'GL-HOOK-ERR:' # Messages marked as safe by user ].freeze - SAFE_MESSAGE_REGEX = /^(#{SAFE_MESSAGE_PREFIXES.join('|')})\s*(?<safe_message>.+)/ + SAFE_MESSAGE_REGEX = /^(#{SAFE_MESSAGE_PREFIXES.join('|')})\s*(?<safe_message>.+)/.freeze def initialize(message = '') super(sanitize(message)) diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index d34b50c5215..4908f236cd1 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -26,7 +26,7 @@ module Gitlab end end - PEM_REGEX = /\-+BEGIN CERTIFICATE\-+.+?\-+END CERTIFICATE\-+/m + PEM_REGEX = /\-+BEGIN CERTIFICATE\-+.+?\-+END CERTIFICATE\-+/m.freeze SERVER_VERSION_FILE = 'GITALY_SERVER_VERSION' MAXIMUM_GITALY_CALLS = 30 CLIENT_NAME = (Sidekiq.server? ? 'gitlab-sidekiq' : 'gitlab-web').freeze diff --git a/lib/gitlab/github_import/representation/diff_note.rb b/lib/gitlab/github_import/representation/diff_note.rb index be1334ca98a..d336b1ba797 100644 --- a/lib/gitlab/github_import/representation/diff_note.rb +++ b/lib/gitlab/github_import/representation/diff_note.rb @@ -13,7 +13,7 @@ module Gitlab :diff_hunk, :author, :note, :created_at, :updated_at, :github_id - NOTEABLE_ID_REGEX = %r{/pull/(?<iid>\d+)}i + NOTEABLE_ID_REGEX = %r{/pull/(?<iid>\d+)}i.freeze # Builds a diff note from a GitHub API response. # diff --git a/lib/gitlab/github_import/representation/note.rb b/lib/gitlab/github_import/representation/note.rb index 070e3b2db8d..5b98ce7d5ed 100644 --- a/lib/gitlab/github_import/representation/note.rb +++ b/lib/gitlab/github_import/representation/note.rb @@ -12,7 +12,7 @@ module Gitlab expose_attribute :noteable_id, :noteable_type, :author, :note, :created_at, :updated_at, :github_id - NOTEABLE_TYPE_REGEX = %r{/(?<type>(pull|issues))/(?<iid>\d+)}i + NOTEABLE_TYPE_REGEX = %r{/(?<type>(pull|issues))/(?<iid>\d+)}i.freeze # Builds a note from a GitHub API response. # diff --git a/lib/gitlab/health_checks/metric.rb b/lib/gitlab/health_checks/metric.rb index 62a5216d159..184083de2bc 100644 --- a/lib/gitlab/health_checks/metric.rb +++ b/lib/gitlab/health_checks/metric.rb @@ -1,4 +1,3 @@ -# rubocop:disable Naming/FileName # frozen_string_literal: true module Gitlab::HealthChecks diff --git a/lib/gitlab/health_checks/result.rb b/lib/gitlab/health_checks/result.rb index d32a6980eb8..4586b1d94a7 100644 --- a/lib/gitlab/health_checks/result.rb +++ b/lib/gitlab/health_checks/result.rb @@ -1,4 +1,3 @@ -# rubocop:disable Naming/FileName # frozen_string_literal: true module Gitlab::HealthChecks diff --git a/lib/gitlab/metrics/metric.rb b/lib/gitlab/metrics/metric.rb index 9e4d70a71ff..30f181542be 100644 --- a/lib/gitlab/metrics/metric.rb +++ b/lib/gitlab/metrics/metric.rb @@ -4,7 +4,7 @@ module Gitlab module Metrics # Class for storing details of a single metric (label, value, etc). class Metric - JITTER_RANGE = 0.000001..0.001 + JITTER_RANGE = (0.000001..0.001).freeze attr_reader :series, :values, :tags, :type diff --git a/lib/gitlab/middleware/read_only.rb b/lib/gitlab/middleware/read_only.rb index 83c52a6c6e0..8e17073abab 100644 --- a/lib/gitlab/middleware/read_only.rb +++ b/lib/gitlab/middleware/read_only.rb @@ -3,7 +3,7 @@ module Gitlab module Middleware class ReadOnly - API_VERSIONS = (3..4) + API_VERSIONS = (3..4).freeze def self.internal_routes @internal_routes ||= diff --git a/lib/gitlab/middleware/release_env.rb b/lib/gitlab/middleware/release_env.rb index 849cf8f759b..0719fb2e8c6 100644 --- a/lib/gitlab/middleware/release_env.rb +++ b/lib/gitlab/middleware/release_env.rb @@ -1,4 +1,3 @@ -# rubocop:disable Naming/FileName # frozen_string_literal: true module Gitlab diff --git a/lib/gitlab/push_options.rb b/lib/gitlab/push_options.rb index 810aba436cc..3137676ba4b 100644 --- a/lib/gitlab/push_options.rb +++ b/lib/gitlab/push_options.rb @@ -15,7 +15,7 @@ module Gitlab mr: :merge_request }).freeze - OPTION_MATCHER = /(?<namespace>[^\.]+)\.(?<key>[^=]+)=?(?<value>.*)/ + OPTION_MATCHER = /(?<namespace>[^\.]+)\.(?<key>[^=]+)=?(?<value>.*)/.freeze attr_reader :options diff --git a/lib/gitlab/quick_actions/spend_time_and_date_separator.rb b/lib/gitlab/quick_actions/spend_time_and_date_separator.rb index f5176376a60..4a62e83e8e9 100644 --- a/lib/gitlab/quick_actions/spend_time_and_date_separator.rb +++ b/lib/gitlab/quick_actions/spend_time_and_date_separator.rb @@ -11,7 +11,7 @@ module Gitlab # if date doesn't present return time with current date # in other cases return nil class SpendTimeAndDateSeparator - DATE_REGEX = %r{(\d{2,4}[/\-.]\d{1,2}[/\-.]\d{1,2})} + DATE_REGEX = %r{(\d{2,4}[/\-.]\d{1,2}[/\-.]\d{1,2})}.freeze def initialize(spend_command_arg) @spend_arg = spend_command_arg diff --git a/lib/gitlab/sanitizers/svg.rb b/lib/gitlab/sanitizers/svg.rb index 0d4e6be2129..98f78c5e74b 100644 --- a/lib/gitlab/sanitizers/svg.rb +++ b/lib/gitlab/sanitizers/svg.rb @@ -9,7 +9,7 @@ module Gitlab class Scrubber < Loofah::Scrubber # http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#embedding-custom-non-visible-data-with-the-data-*-attributes - DATA_ATTR_PATTERN = /\Adata-(?!xml)[a-z_][\w.\u00E0-\u00F6\u00F8-\u017F\u01DD-\u02AF-]*\z/u + DATA_ATTR_PATTERN = /\Adata-(?!xml)[a-z_][\w.\u00E0-\u00F6\u00F8-\u017F\u01DD-\u02AF-]*\z/u.freeze def scrub(node) unless Whitelist::ALLOWED_ELEMENTS.include?(node.name) diff --git a/lib/gitlab/sherlock/middleware.rb b/lib/gitlab/sherlock/middleware.rb index 747cb0f9142..f7b08d58e49 100644 --- a/lib/gitlab/sherlock/middleware.rb +++ b/lib/gitlab/sherlock/middleware.rb @@ -4,9 +4,9 @@ module Gitlab module Sherlock # Rack middleware used for tracking request metrics. class Middleware - CONTENT_TYPES = %r{text/html|application/json}i + CONTENT_TYPES = %r{text/html|application/json}i.freeze - IGNORE_PATHS = %r{^/sherlock} + IGNORE_PATHS = %r{^/sherlock}.freeze def initialize(app) @app = app diff --git a/lib/gitlab/sherlock/query.rb b/lib/gitlab/sherlock/query.rb index 11561eec32a..159ce27e702 100644 --- a/lib/gitlab/sherlock/query.rb +++ b/lib/gitlab/sherlock/query.rb @@ -15,7 +15,7 @@ module Gitlab |GROUP\s+BY |ORDER\s+BY |LIMIT - |OFFSET)\s+}ix # Vim indent breaks when this is on a newline :< + |OFFSET)\s+}ix.freeze # Vim indent breaks when this is on a newline :< # Creates a new Query using a String and a separate Array of bindings. # diff --git a/lib/gitlab/slash_commands/result.rb b/lib/gitlab/slash_commands/result.rb index 607c9c8dec1..a66a2e0726b 100644 --- a/lib/gitlab/slash_commands/result.rb +++ b/lib/gitlab/slash_commands/result.rb @@ -1,4 +1,3 @@ -# rubocop:disable Naming/FileName # frozen_string_literal: true module Gitlab diff --git a/lib/gitlab/sql/pattern.rb b/lib/gitlab/sql/pattern.rb index b698391c8bd..fd108b4c124 100644 --- a/lib/gitlab/sql/pattern.rb +++ b/lib/gitlab/sql/pattern.rb @@ -6,7 +6,7 @@ module Gitlab extend ActiveSupport::Concern MIN_CHARS_FOR_PARTIAL_MATCHING = 3 - REGEX_QUOTED_WORD = /(?<=\A| )"[^"]+"(?= |\z)/ + REGEX_QUOTED_WORD = /(?<=\A| )"[^"]+"(?= |\z)/.freeze class_methods do def fuzzy_search(query, columns) diff --git a/lib/gitlab/user_extractor.rb b/lib/gitlab/user_extractor.rb index f0557f6ad68..ede60c9ab1d 100644 --- a/lib/gitlab/user_extractor.rb +++ b/lib/gitlab/user_extractor.rb @@ -7,7 +7,7 @@ module Gitlab class UserExtractor # Not using `Devise.email_regexp` to filter out any chars that an email # does not end with and not pinning the email to a start of end of a string. - EMAIL_REGEXP = /(?<email>([^@\s]+@[^@\s]+(?<!\W)))/ + EMAIL_REGEXP = /(?<email>([^@\s]+@[^@\s]+(?<!\W)))/.freeze USERNAME_REGEXP = User.reference_pattern def initialize(text) diff --git a/lib/haml_lint/inline_javascript.rb b/lib/haml_lint/inline_javascript.rb index 2e98227a05e..1b17162f71d 100644 --- a/lib/haml_lint/inline_javascript.rb +++ b/lib/haml_lint/inline_javascript.rb @@ -1,4 +1,3 @@ -# rubocop:disable Naming/FileName # frozen_string_literal: true unless Rails.env.production? diff --git a/lib/tasks/gemojione.rake b/lib/tasks/gemojione.rake index 560a52053d8..8cf7c9e89f0 100644 --- a/lib/tasks/gemojione.rake +++ b/lib/tasks/gemojione.rake @@ -209,7 +209,7 @@ namespace :gemojione do image.destroy! end - EMOJI_IMAGE_PATH_RE = /(.*?)(([0-9a-f]-?)+)\.png$/i + EMOJI_IMAGE_PATH_RE = /(.*?)(([0-9a-f]-?)+)\.png$/i.freeze def rename_to_named_emoji_image!(emoji_unicode_string_to_name_map, image_path) # Rename file from unicode to emoji name matches = EMOJI_IMAGE_PATH_RE.match(image_path) diff --git a/qa/qa/page/project/settings/ci_cd.rb b/qa/qa/page/project/settings/ci_cd.rb index 44a62cf6ccf..b8c5c563da6 100644 --- a/qa/qa/page/project/settings/ci_cd.rb +++ b/qa/qa/page/project/settings/ci_cd.rb @@ -1,4 +1,3 @@ -# rubocop:disable Naming/FileName # frozen_string_literal: true module QA diff --git a/qa/qa/runtime/key/ecdsa.rb b/qa/qa/runtime/key/ecdsa.rb index 6e5c0a2deca..46a1e5f54cf 100644 --- a/qa/qa/runtime/key/ecdsa.rb +++ b/qa/qa/runtime/key/ecdsa.rb @@ -1,4 +1,3 @@ -# rubocop:disable Naming/FileName # frozen_string_literal: true module QA diff --git a/qa/qa/runtime/key/ed25519.rb b/qa/qa/runtime/key/ed25519.rb index 53b556d744d..3a3567d55da 100644 --- a/qa/qa/runtime/key/ed25519.rb +++ b/qa/qa/runtime/key/ed25519.rb @@ -1,4 +1,3 @@ -# rubocop:disable Naming/FileName # frozen_string_literal: true module QA diff --git a/rubocop/cop/gitlab/finder_with_find_by.rb b/rubocop/cop/gitlab/finder_with_find_by.rb index f45a37ddc06..764a5073143 100644 --- a/rubocop/cop/gitlab/finder_with_find_by.rb +++ b/rubocop/cop/gitlab/finder_with_find_by.rb @@ -2,7 +2,7 @@ module RuboCop module Cop module Gitlab class FinderWithFindBy < RuboCop::Cop::Cop - FIND_PATTERN = /\Afind(_by\!?)?\z/ + FIND_PATTERN = /\Afind(_by\!?)?\z/.freeze ALLOWED_MODULES = ['FinderMethods'].freeze def message(used_method) @@ -36,7 +36,7 @@ module RuboCop def find_on_execute?(node) chained_on_node = node.descendants.first node.method_name.to_s =~ FIND_PATTERN && - chained_on_node&.method_name == :execute + chained_on_node.is_a?(RuboCop::AST::SendNode) && chained_on_node.method_name == :execute end def allowed_module?(node) diff --git a/rubocop/rubocop.rb b/rubocop/rubocop.rb index ce6bdbf292c..e2a19978839 100644 --- a/rubocop/rubocop.rb +++ b/rubocop/rubocop.rb @@ -1,4 +1,3 @@ -# rubocop:disable Naming/FileName require_relative 'cop/gitlab/module_with_instance_variables' require_relative 'cop/gitlab/predicate_memoization' require_relative 'cop/gitlab/httparty' diff --git a/spec/initializers/secret_token_spec.rb b/spec/initializers/secret_token_spec.rb index 6366be30079..726ce07a2d1 100644 --- a/spec/initializers/secret_token_spec.rb +++ b/spec/initializers/secret_token_spec.rb @@ -6,8 +6,8 @@ describe 'create_tokens' do let(:secrets) { ActiveSupport::OrderedOptions.new } - HEX_KEY = /\h{128}/ - RSA_KEY = /\A-----BEGIN RSA PRIVATE KEY-----\n.+\n-----END RSA PRIVATE KEY-----\n\Z/m + HEX_KEY = /\h{128}/.freeze + RSA_KEY = /\A-----BEGIN RSA PRIVATE KEY-----\n.+\n-----END RSA PRIVATE KEY-----\n\Z/m.freeze before do allow(File).to receive(:write) diff --git a/spec/lib/gitlab/path_regex_spec.rb b/spec/lib/gitlab/path_regex_spec.rb index 857862a2abd..84b2e2dc823 100644 --- a/spec/lib/gitlab/path_regex_spec.rb +++ b/spec/lib/gitlab/path_regex_spec.rb @@ -120,10 +120,10 @@ describe Gitlab::PathRegex do # - Followed by one or more path-parts not starting with `:` or `*` # - Followed by a path-part that includes a wildcard parameter `*` # At the time of writing these routes match: http://rubular.com/r/Rv2pDE5Dvw - STARTING_WITH_NAMESPACE = %r{^/\*namespace_id/:(project_)?id} - NON_PARAM_PARTS = %r{[^:*][a-z\-_/]*} - ANY_OTHER_PATH_PART = %r{[a-z\-_/:]*} - WILDCARD_SEGMENT = /\*/ + STARTING_WITH_NAMESPACE = %r{^/\*namespace_id/:(project_)?id}.freeze + NON_PARAM_PARTS = %r{[^:*][a-z\-_/]*}.freeze + ANY_OTHER_PATH_PART = %r{[a-z\-_/:]*}.freeze + WILDCARD_SEGMENT = /\*/.freeze let(:namespaced_wildcard_routes) do routes_without_format.select do |p| p =~ %r{#{STARTING_WITH_NAMESPACE}/#{NON_PARAM_PARTS}/#{ANY_OTHER_PATH_PART}#{WILDCARD_SEGMENT}} @@ -144,7 +144,7 @@ describe Gitlab::PathRegex do end.uniq end - STARTING_WITH_GROUP = %r{^/groups/\*(group_)?id/} + STARTING_WITH_GROUP = %r{^/groups/\*(group_)?id/}.freeze let(:group_routes) do routes_without_format.select do |path| path =~ STARTING_WITH_GROUP |