Skip to content

Commit b7d8df5

Browse files
committed
Enable Style/MutableConstant
1 parent 3dadf30 commit b7d8df5

File tree

118 files changed

+190
-192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+190
-192
lines changed

.rubocop.yml

+3
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ Style/MultilineOperationIndentation:
308308
Style/MultilineTernaryOperator:
309309
Enabled: true
310310

311+
Style/MutableConstant:
312+
Enabled: true
313+
311314
# Favor unless over if for negative conditions (or control flow or).
312315
Style/NegatedIf:
313316
Enabled: true

.rubocop_todo.yml

-5
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,6 @@ Style/MultilineIfModifier:
471471
- 'app/models/project_wiki.rb'
472472
- 'lib/gitlab/workhorse.rb'
473473

474-
# Offense count: 187
475-
# Cop supports --auto-correct.
476-
Style/MutableConstant:
477-
Enabled: false
478-
479474
# Offense count: 8
480475
# Cop supports --auto-correct.
481476
Style/NestedParenthesizedCalls:

app/controllers/admin/system_info_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Admin::SystemInfoController < Admin::ApplicationController
33
'nobrowse',
44
'read-only',
55
'ro'
6-
]
6+
].freeze
77

88
EXCLUDED_MOUNT_TYPES = [
99
'autofs',
@@ -27,7 +27,7 @@ class Admin::SystemInfoController < Admin::ApplicationController
2727
'tmpfs',
2828
'tracefs',
2929
'vfat'
30-
]
30+
].freeze
3131

3232
def show
3333
@cpus = Vmstat.cpu rescue nil

app/controllers/concerns/service_params.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ module ServiceParams
5959
:user_key,
6060
:username,
6161
:webhook
62-
]
62+
].freeze
6363

6464
# Parameters to ignore if no value is specified
65-
FILTER_BLANK_PARAMS = [:password]
65+
FILTER_BLANK_PARAMS = [:password].freeze
6666

6767
def service_params
6868
dynamic_params = @service.event_channel_names + @service.event_names

app/controllers/jwt_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class JwtController < ApplicationController
55

66
SERVICES = {
77
Auth::ContainerRegistryAuthenticationService::AUDIENCE => Auth::ContainerRegistryAuthenticationService,
8-
}
8+
}.freeze
99

1010
def auth
1111
service = SERVICES[params[:service]]

app/finders/issuable_finder.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# iids: integer[]
2020
#
2121
class IssuableFinder
22-
NONE = '0'
22+
NONE = '0'.freeze
2323

2424
attr_accessor :current_user, :params
2525

app/finders/todos_finder.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#
1414

1515
class TodosFinder
16-
NONE = '0'
16+
NONE = '0'.freeze
1717

1818
attr_accessor :current_user, :params
1919

app/helpers/issuables_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def issuables_count_for_state(issuable_type, state)
198198
@counts[issuable_type][state]
199199
end
200200

201-
IRRELEVANT_PARAMS_FOR_CACHE_KEY = %i[utf8 sort page]
201+
IRRELEVANT_PARAMS_FOR_CACHE_KEY = %i[utf8 sort page].freeze
202202
private_constant :IRRELEVANT_PARAMS_FOR_CACHE_KEY
203203

204204
def issuables_state_counter_cache_key(issuable_type, state)

app/models/application_setting.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class ApplicationSetting < ActiveRecord::Base
55
add_authentication_token_field :runners_registration_token
66
add_authentication_token_field :health_check_access_token
77

8-
CACHE_KEY = 'application_setting.last'
8+
CACHE_KEY = 'application_setting.last'.freeze
99
DOMAIN_LIST_SEPARATOR = %r{\s*[,;]\s* # comma or semicolon, optionally surrounded by whitespace
1010
| # or
1111
\s # any whitespace character

app/models/ci/runner.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ class Runner < ActiveRecord::Base
44

55
RUNNER_QUEUE_EXPIRY_TIME = 60.minutes
66
LAST_CONTACT_TIME = 1.hour.ago
7-
AVAILABLE_SCOPES = %w[specific shared active paused online]
8-
FORM_EDITABLE = %i[description tag_list active run_untagged locked]
7+
AVAILABLE_SCOPES = %w[specific shared active paused online].freeze
8+
FORM_EDITABLE = %i[description tag_list active run_untagged locked].freeze
99

1010
has_many :builds
1111
has_many :runner_projects, dependent: :destroy

app/models/commit.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Commit
2222
DIFF_HARD_LIMIT_LINES = 50000
2323

2424
# The SHA can be between 7 and 40 hex characters.
25-
COMMIT_SHA_PATTERN = '\h{7,40}'
25+
COMMIT_SHA_PATTERN = '\h{7,40}'.freeze
2626

2727
class << self
2828
def decorate(commits, project)

app/models/concerns/cache_markdown_field.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def html_fields
4545
Project
4646
Release
4747
Snippet
48-
]
48+
].freeze
4949

5050
def self.caching_classes
5151
CACHING_CLASSES.map(&:constantize)

app/models/concerns/has_status.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module HasStatus
22
extend ActiveSupport::Concern
33

4-
DEFAULT_STATUS = 'created'
5-
AVAILABLE_STATUSES = %w[created pending running success failed canceled skipped]
6-
STARTED_STATUSES = %w[running success failed skipped]
7-
ACTIVE_STATUSES = %w[pending running]
8-
COMPLETED_STATUSES = %w[success failed canceled skipped]
9-
ORDERED_STATUSES = %w[failed pending running canceled success skipped]
4+
DEFAULT_STATUS = 'created'.freeze
5+
AVAILABLE_STATUSES = %w[created pending running success failed canceled skipped].freeze
6+
STARTED_STATUSES = %w[running success failed skipped].freeze
7+
ACTIVE_STATUSES = %w[pending running].freeze
8+
COMPLETED_STATUSES = %w[success failed canceled skipped].freeze
9+
ORDERED_STATUSES = %w[failed pending running canceled success skipped].freeze
1010

1111
class_methods do
1212
def status_sql

app/models/label.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Label < ActiveRecord::Base
1111

1212
cache_markdown_field :description, pipeline: :single_line
1313

14-
DEFAULT_COLOR = '#428BCA'
14+
DEFAULT_COLOR = '#428BCA'.freeze
1515

1616
default_value_for :color, DEFAULT_COLOR
1717

app/models/members/group_member.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class GroupMember < Member
2-
SOURCE_TYPE = 'Namespace'
2+
SOURCE_TYPE = 'Namespace'.freeze
33

44
belongs_to :group, foreign_key: 'source_id'
55

app/models/members/project_member.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class ProjectMember < Member
2-
SOURCE_TYPE = 'Project'
2+
SOURCE_TYPE = 'Project'.freeze
33

44
include Gitlab::ShellAdapter
55

app/models/merge_request_diff.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class MergeRequestDiff < ActiveRecord::Base
77
COMMITS_SAFE_SIZE = 100
88

99
# Valid types of serialized diffs allowed by Gitlab::Git::Diff
10-
VALID_CLASSES = [Hash, Rugged::Patch, Rugged::Diff::Delta]
10+
VALID_CLASSES = [Hash, Rugged::Patch, Rugged::Diff::Delta].freeze
1111

1212
belongs_to :merge_request
1313

app/models/notification_setting.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ class NotificationSetting < ActiveRecord::Base
3535
:merge_merge_request,
3636
:failed_pipeline,
3737
:success_pipeline
38-
]
38+
].freeze
3939

4040
EXCLUDED_WATCHER_EVENTS = [
4141
:success_pipeline
42-
]
42+
].freeze
4343

4444
store :events, accessors: EMAIL_EVENTS, coder: JSON
4545

app/models/project.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Project < ActiveRecord::Base
2222
class BoardLimitExceeded < StandardError; end
2323

2424
NUMBER_OF_PERMITTED_BOARDS = 1
25-
UNKNOWN_IMPORT_URL = 'http://unknown.git/'
25+
UNKNOWN_IMPORT_URL = 'http://unknown.git/'.freeze
2626

2727
cache_markdown_field :description, pipeline: :description
2828

app/models/project_feature.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ProjectFeature < ActiveRecord::Base
1818
PRIVATE = 10
1919
ENABLED = 20
2020

21-
FEATURES = %i(issues merge_requests wiki snippets builds repository)
21+
FEATURES = %i(issues merge_requests wiki snippets builds repository).freeze
2222

2323
class << self
2424
def access_level_attribute(feature)

app/models/project_services/buildkite_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class BuildkiteService < CiService
44
include ReactiveService
55

6-
ENDPOINT = "https://buildkite.com/"
6+
ENDPOINT = "https://buildkite.com/".freeze
77

88
prop_accessor :project_url, :token
99
boolean_accessor :enable_ssl_verification

app/models/project_services/hipchat_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class HipchatService < Service
66
a b i strong em br img pre code
77
table th tr td caption colgroup col thead tbody tfoot
88
ul ol li dl dt dd
9-
]
9+
].freeze
1010

1111
prop_accessor :token, :room, :server, :color, :api_version
1212
boolean_accessor :notify_only_broken_builds, :notify

app/models/project_services/pivotaltracker_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class PivotaltrackerService < Service
22
include HTTParty
33

4-
API_ENDPOINT = 'https://www.pivotaltracker.com/services/v5/source_commits'
4+
API_ENDPOINT = 'https://www.pivotaltracker.com/services/v5/source_commits'.freeze
55

66
prop_accessor :token, :restrict_to_branch
77
validates :token, presence: true, if: :activated?

app/models/project_statistics.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class ProjectStatistics < ActiveRecord::Base
44

55
before_save :update_storage_size
66

7-
STORAGE_COLUMNS = [:repository_size, :lfs_objects_size, :build_artifacts_size]
7+
STORAGE_COLUMNS = [:repository_size, :lfs_objects_size, :build_artifacts_size].freeze
88
STATISTICS_COLUMNS = [:commit_count] + STORAGE_COLUMNS
99

1010
def total_repository_size

app/models/project_wiki.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class ProjectWiki
55
'Markdown' => :markdown,
66
'RDoc' => :rdoc,
77
'AsciiDoc' => :asciidoc
8-
} unless defined?(MARKUPS)
8+
}.freeze unless defined?(MARKUPS)
99

1010
class CouldNotCreateWikiError < StandardError; end
1111

app/models/repository.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Repository
1818
CACHED_METHODS = %i(size commit_count readme version contribution_guide
1919
changelog license_blob license_key gitignore koding_yml
2020
gitlab_ci_yml branch_names tag_names branch_count
21-
tag_count avatar exists? empty? root_ref)
21+
tag_count avatar exists? empty? root_ref).freeze
2222

2323
# Certain method caches should be refreshed when certain types of files are
2424
# changed. This Hash maps file types (as returned by Gitlab::FileDetector) to
@@ -33,7 +33,7 @@ class Repository
3333
koding: :koding_yml,
3434
gitlab_ci: :gitlab_ci_yml,
3535
avatar: :avatar
36-
}
36+
}.freeze
3737

3838
# Wraps around the given method and caches its output in Redis and an instance
3939
# variable.

app/models/todo.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Todo < ActiveRecord::Base
1717
APPROVAL_REQUIRED => :approval_required,
1818
UNMERGEABLE => :unmergeable,
1919
DIRECTLY_ADDRESSED => :directly_addressed
20-
}
20+
}.freeze
2121

2222
belongs_to :author, class_name: "User"
2323
belongs_to :note

app/services/auth/container_registry_authentication_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Auth
22
class ContainerRegistryAuthenticationService < BaseService
33
include Gitlab::CurrentSettings
44

5-
AUDIENCE = 'container_registry'
5+
AUDIENCE = 'container_registry'.freeze
66

77
def execute(authentication_abilities:)
88
@authentication_abilities = authentication_abilities

app/services/members/destroy_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class DestroyService < BaseService
44

55
attr_accessor :source
66

7-
ALLOWED_SCOPES = %i[members requesters all]
7+
ALLOWED_SCOPES = %i[members requesters all].freeze
88

99
def initialize(source, current_user, params = {})
1010
@source = source

app/services/notes/slash_commands_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class SlashCommandsService < BaseService
33
UPDATE_SERVICES = {
44
'Issue' => Issues::UpdateService,
55
'MergeRequest' => MergeRequests::UpdateService
6-
}
6+
}.freeze
77

88
def self.noteable_update_service(note)
99
UPDATE_SERVICES[note.noteable_type]

app/services/projects/destroy_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class DestroyService < BaseService
44

55
class DestroyError < StandardError; end
66

7-
DELETED_FLAG = '+deleted'
7+
DELETED_FLAG = '+deleted'.freeze
88

99
def async_execute
1010
project.transaction do

app/services/projects/download_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Projects
22
class DownloadService < BaseService
33
WHITELIST = [
44
/^[^.]+\.fogbugz.com$/
5-
]
5+
].freeze
66

77
def initialize(project, url)
88
@project, @url = project, url

app/services/projects/update_pages_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Projects
22
class UpdatePagesService < BaseService
33
BLOCK_SIZE = 32.kilobytes
44
MAX_SIZE = 1.terabyte
5-
SITE_PATH = 'public/'
5+
SITE_PATH = 'public/'.freeze
66

77
attr_reader :build
88

app/uploaders/uploader_helper.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Extra methods for uploader
22
module UploaderHelper
3-
IMAGE_EXT = %w[png jpg jpeg gif bmp tiff]
3+
IMAGE_EXT = %w[png jpg jpeg gif bmp tiff].freeze
44
# We recommend using the .mp4 format over .mov. Videos in .mov format can
55
# still be used but you really need to make sure they are served with the
66
# proper MIME type video/mp4 and not video/quicktime or your videos won't play
77
# on IE >= 9.
88
# http://archive.sublimevideo.info/20150912/docs.sublimevideo.net/troubleshooting.html
9-
VIDEO_EXT = %w[mp4 m4v mov webm ogv]
9+
VIDEO_EXT = %w[mp4 m4v mov webm ogv].freeze
1010
# These extension types can contain dangerous code and should only be embedded inline with
1111
# proper filtering. They should always be tagged as "Content-Disposition: attachment", not "inline".
12-
DANGEROUS_EXT = %w[svg]
12+
DANGEROUS_EXT = %w[svg].freeze
1313

1414
def image?
1515
extension_match?(IMAGE_EXT)

app/validators/addressable_url_validator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# end
1919
#
2020
class AddressableUrlValidator < ActiveModel::EachValidator
21-
DEFAULT_OPTIONS = { protocols: %w(http https ssh git) }
21+
DEFAULT_OPTIONS = { protocols: %w(http https ssh git) }.freeze
2222

2323
def validate_each(record, attribute, value)
2424
unless valid_url?(value)

config/initializers/gollum.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Gollum
2-
GIT_ADAPTER = "rugged"
2+
GIT_ADAPTER = "rugged".freeze
33
end
44
require "gollum-lib"
55

config/initializers/workhorse_multipart.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
module Gitlab
1212
module StrongParameterScalars
13-
GITLAB_PERMITTED_SCALAR_TYPES = [::UploadedFile]
13+
GITLAB_PERMITTED_SCALAR_TYPES = [::UploadedFile].freeze
1414

1515
def permitted_scalar?(value)
1616
super || GITLAB_PERMITTED_SCALAR_TYPES.any? { |type| value.is_a?(type) }

config/routes/wiki.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
WIKI_SLUG_ID = { id: /\S+/ } unless defined? WIKI_SLUG_ID
1+
WIKI_SLUG_ID = { id: /\S+/ }.freeze unless defined? WIKI_SLUG_ID
22

33
scope(controller: :wikis) do
44
scope(path: 'wikis', as: :wikis) do

db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class MoveFromDevelopersCanMergeToProtectedBranchesMergeAccess < ActiveRecord::Migration
55
DOWNTIME = true
6-
DOWNTIME_REASON = <<-HEREDOC
6+
DOWNTIME_REASON = <<-HEREDOC.freeze
77
We're creating a `merge_access_level` for each `protected_branch`. If a user creates a `protected_branch` while this
88
is running, we might be left with a `protected_branch` _without_ an associated `merge_access_level`. The `protected_branches`
99
table must not change while this is running, so downtime is required.

0 commit comments

Comments
 (0)