Read about our upcoming Code of Conduct on this issue

Commit b7d8df50 authored by Douwe Maan's avatar Douwe Maan
Browse files

Enable Style/MutableConstant

parent ad222f96ec59
...@@ -308,6 +308,9 @@ Style/MultilineOperationIndentation: ...@@ -308,6 +308,9 @@ Style/MultilineOperationIndentation:
Style/MultilineTernaryOperator: Style/MultilineTernaryOperator:
Enabled: true Enabled: true
Style/MutableConstant:
Enabled: true
# Favor unless over if for negative conditions (or control flow or). # Favor unless over if for negative conditions (or control flow or).
Style/NegatedIf: Style/NegatedIf:
Enabled: true Enabled: true
......
...@@ -471,11 +471,6 @@ Style/MultilineIfModifier: ...@@ -471,11 +471,6 @@ Style/MultilineIfModifier:
- 'app/models/project_wiki.rb' - 'app/models/project_wiki.rb'
- 'lib/gitlab/workhorse.rb' - 'lib/gitlab/workhorse.rb'
# Offense count: 187
# Cop supports --auto-correct.
Style/MutableConstant:
Enabled: false
# Offense count: 8 # Offense count: 8
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/NestedParenthesizedCalls: Style/NestedParenthesizedCalls:
......
...@@ -3,7 +3,7 @@ class Admin::SystemInfoController < Admin::ApplicationController ...@@ -3,7 +3,7 @@ class Admin::SystemInfoController < Admin::ApplicationController
'nobrowse', 'nobrowse',
'read-only', 'read-only',
'ro' 'ro'
] ].freeze
EXCLUDED_MOUNT_TYPES = [ EXCLUDED_MOUNT_TYPES = [
'autofs', 'autofs',
...@@ -27,7 +27,7 @@ class Admin::SystemInfoController < Admin::ApplicationController ...@@ -27,7 +27,7 @@ class Admin::SystemInfoController < Admin::ApplicationController
'tmpfs', 'tmpfs',
'tracefs', 'tracefs',
'vfat' 'vfat'
] ].freeze
def show def show
@cpus = Vmstat.cpu rescue nil @cpus = Vmstat.cpu rescue nil
......
...@@ -59,10 +59,10 @@ module ServiceParams ...@@ -59,10 +59,10 @@ module ServiceParams
:user_key, :user_key,
:username, :username,
:webhook :webhook
] ].freeze
# Parameters to ignore if no value is specified # Parameters to ignore if no value is specified
FILTER_BLANK_PARAMS = [:password] FILTER_BLANK_PARAMS = [:password].freeze
def service_params def service_params
dynamic_params = @service.event_channel_names + @service.event_names dynamic_params = @service.event_channel_names + @service.event_names
......
...@@ -5,7 +5,7 @@ class JwtController < ApplicationController ...@@ -5,7 +5,7 @@ class JwtController < ApplicationController
SERVICES = { SERVICES = {
Auth::ContainerRegistryAuthenticationService::AUDIENCE => Auth::ContainerRegistryAuthenticationService, Auth::ContainerRegistryAuthenticationService::AUDIENCE => Auth::ContainerRegistryAuthenticationService,
} }.freeze
def auth def auth
service = SERVICES[params[:service]] service = SERVICES[params[:service]]
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
# iids: integer[] # iids: integer[]
# #
class IssuableFinder class IssuableFinder
NONE = '0' NONE = '0'.freeze
attr_accessor :current_user, :params attr_accessor :current_user, :params
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# #
class TodosFinder class TodosFinder
NONE = '0' NONE = '0'.freeze
attr_accessor :current_user, :params attr_accessor :current_user, :params
......
...@@ -198,7 +198,7 @@ def issuables_count_for_state(issuable_type, state) ...@@ -198,7 +198,7 @@ def issuables_count_for_state(issuable_type, state)
@counts[issuable_type][state] @counts[issuable_type][state]
end end
IRRELEVANT_PARAMS_FOR_CACHE_KEY = %i[utf8 sort page] IRRELEVANT_PARAMS_FOR_CACHE_KEY = %i[utf8 sort page].freeze
private_constant :IRRELEVANT_PARAMS_FOR_CACHE_KEY private_constant :IRRELEVANT_PARAMS_FOR_CACHE_KEY
def issuables_state_counter_cache_key(issuable_type, state) def issuables_state_counter_cache_key(issuable_type, state)
......
...@@ -5,7 +5,7 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -5,7 +5,7 @@ class ApplicationSetting < ActiveRecord::Base
add_authentication_token_field :runners_registration_token add_authentication_token_field :runners_registration_token
add_authentication_token_field :health_check_access_token add_authentication_token_field :health_check_access_token
CACHE_KEY = 'application_setting.last' CACHE_KEY = 'application_setting.last'.freeze
DOMAIN_LIST_SEPARATOR = %r{\s*[,;]\s* # comma or semicolon, optionally surrounded by whitespace DOMAIN_LIST_SEPARATOR = %r{\s*[,;]\s* # comma or semicolon, optionally surrounded by whitespace
| # or | # or
\s # any whitespace character \s # any whitespace character
......
...@@ -4,8 +4,8 @@ class Runner < ActiveRecord::Base ...@@ -4,8 +4,8 @@ class Runner < ActiveRecord::Base
RUNNER_QUEUE_EXPIRY_TIME = 60.minutes RUNNER_QUEUE_EXPIRY_TIME = 60.minutes
LAST_CONTACT_TIME = 1.hour.ago LAST_CONTACT_TIME = 1.hour.ago
AVAILABLE_SCOPES = %w[specific shared active paused online] AVAILABLE_SCOPES = %w[specific shared active paused online].freeze
FORM_EDITABLE = %i[description tag_list active run_untagged locked] FORM_EDITABLE = %i[description tag_list active run_untagged locked].freeze
has_many :builds has_many :builds
has_many :runner_projects, dependent: :destroy has_many :runner_projects, dependent: :destroy
......
...@@ -22,7 +22,7 @@ class Commit ...@@ -22,7 +22,7 @@ class Commit
DIFF_HARD_LIMIT_LINES = 50000 DIFF_HARD_LIMIT_LINES = 50000
# The SHA can be between 7 and 40 hex characters. # The SHA can be between 7 and 40 hex characters.
COMMIT_SHA_PATTERN = '\h{7,40}' COMMIT_SHA_PATTERN = '\h{7,40}'.freeze
class << self class << self
def decorate(commits, project) def decorate(commits, project)
......
...@@ -45,7 +45,7 @@ def html_fields ...@@ -45,7 +45,7 @@ def html_fields
Project Project
Release Release
Snippet Snippet
] ].freeze
def self.caching_classes def self.caching_classes
CACHING_CLASSES.map(&:constantize) CACHING_CLASSES.map(&:constantize)
......
module HasStatus module HasStatus
extend ActiveSupport::Concern extend ActiveSupport::Concern
DEFAULT_STATUS = 'created' DEFAULT_STATUS = 'created'.freeze
AVAILABLE_STATUSES = %w[created pending running success failed canceled skipped] AVAILABLE_STATUSES = %w[created pending running success failed canceled skipped].freeze
STARTED_STATUSES = %w[running success failed skipped] STARTED_STATUSES = %w[running success failed skipped].freeze
ACTIVE_STATUSES = %w[pending running] ACTIVE_STATUSES = %w[pending running].freeze
COMPLETED_STATUSES = %w[success failed canceled skipped] COMPLETED_STATUSES = %w[success failed canceled skipped].freeze
ORDERED_STATUSES = %w[failed pending running canceled success skipped] ORDERED_STATUSES = %w[failed pending running canceled success skipped].freeze
class_methods do class_methods do
def status_sql def status_sql
......
...@@ -11,7 +11,7 @@ class Label < ActiveRecord::Base ...@@ -11,7 +11,7 @@ class Label < ActiveRecord::Base
cache_markdown_field :description, pipeline: :single_line cache_markdown_field :description, pipeline: :single_line
DEFAULT_COLOR = '#428BCA' DEFAULT_COLOR = '#428BCA'.freeze
default_value_for :color, DEFAULT_COLOR default_value_for :color, DEFAULT_COLOR
......
class GroupMember < Member class GroupMember < Member
SOURCE_TYPE = 'Namespace' SOURCE_TYPE = 'Namespace'.freeze
belongs_to :group, foreign_key: 'source_id' belongs_to :group, foreign_key: 'source_id'
......
class ProjectMember < Member class ProjectMember < Member
SOURCE_TYPE = 'Project' SOURCE_TYPE = 'Project'.freeze
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
......
...@@ -7,7 +7,7 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -7,7 +7,7 @@ class MergeRequestDiff < ActiveRecord::Base
COMMITS_SAFE_SIZE = 100 COMMITS_SAFE_SIZE = 100
# Valid types of serialized diffs allowed by Gitlab::Git::Diff # Valid types of serialized diffs allowed by Gitlab::Git::Diff
VALID_CLASSES = [Hash, Rugged::Patch, Rugged::Diff::Delta] VALID_CLASSES = [Hash, Rugged::Patch, Rugged::Diff::Delta].freeze
belongs_to :merge_request belongs_to :merge_request
......
...@@ -35,11 +35,11 @@ class NotificationSetting < ActiveRecord::Base ...@@ -35,11 +35,11 @@ class NotificationSetting < ActiveRecord::Base
:merge_merge_request, :merge_merge_request,
:failed_pipeline, :failed_pipeline,
:success_pipeline :success_pipeline
] ].freeze
EXCLUDED_WATCHER_EVENTS = [ EXCLUDED_WATCHER_EVENTS = [
:success_pipeline :success_pipeline
] ].freeze
store :events, accessors: EMAIL_EVENTS, coder: JSON store :events, accessors: EMAIL_EVENTS, coder: JSON
......
...@@ -22,7 +22,7 @@ class Project < ActiveRecord::Base ...@@ -22,7 +22,7 @@ class Project < ActiveRecord::Base
class BoardLimitExceeded < StandardError; end class BoardLimitExceeded < StandardError; end
NUMBER_OF_PERMITTED_BOARDS = 1 NUMBER_OF_PERMITTED_BOARDS = 1
UNKNOWN_IMPORT_URL = 'http://unknown.git' UNKNOWN_IMPORT_URL = 'http://unknown.git'.freeze
cache_markdown_field :description, pipeline: :description cache_markdown_field :description, pipeline: :description
......
...@@ -18,7 +18,7 @@ class ProjectFeature < ActiveRecord::Base ...@@ -18,7 +18,7 @@ class ProjectFeature < ActiveRecord::Base
PRIVATE = 10 PRIVATE = 10
ENABLED = 20 ENABLED = 20
FEATURES = %i(issues merge_requests wiki snippets builds repository) FEATURES = %i(issues merge_requests wiki snippets builds repository).freeze
class << self class << self
def access_level_attribute(feature) def access_level_attribute(feature)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment