Skip to content
Snippets Groups Projects
Commit f93b2e02 authored by Stan Hu's avatar Stan Hu
Browse files

Run rubocop -a on CE files

parent a5620a0d
No related branches found
No related tags found
No related merge requests found
Showing
with 33 additions and 34 deletions
Loading
@@ -7,7 +7,7 @@ class HelpController < ApplicationController
Loading
@@ -7,7 +7,7 @@ class HelpController < ApplicationController
   
# Taken from Jekyll # Taken from Jekyll
# https://github.com/jekyll/jekyll/blob/3.5-stable/lib/jekyll/document.rb#L13 # 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 def index
# Remove YAML frontmatter so that it doesn't look weird # Remove YAML frontmatter so that it doesn't look weird
Loading
Loading
Loading
@@ -15,8 +15,8 @@ class Import::BitbucketServerController < Import::BaseController
Loading
@@ -15,8 +15,8 @@ class Import::BitbucketServerController < Import::BaseController
# (https://community.atlassian.com/t5/Answers-Developer-Questions/stash-repository-names/qaq-p/499054) # (https://community.atlassian.com/t5/Answers-Developer-Questions/stash-repository-names/qaq-p/499054)
# #
# Bitbucket Server starts personal project names with a tilde. # Bitbucket Server starts personal project names with a tilde.
VALID_BITBUCKET_PROJECT_CHARS = /\A~?[\w\-\.\s]+\z/ VALID_BITBUCKET_PROJECT_CHARS = /\A~?[\w\-\.\s]+\z/.freeze
VALID_BITBUCKET_CHARS = /\A[\w\-\.\s]+\z/ VALID_BITBUCKET_CHARS = /\A[\w\-\.\s]+\z/.freeze
   
def new def new
end end
Loading
Loading
Loading
@@ -2,7 +2,7 @@
Loading
@@ -2,7 +2,7 @@
   
module AuthHelper module AuthHelper
PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq).freeze 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? def ldap_enabled?
Gitlab::Auth::LDAP::Config.enabled? Gitlab::Auth::LDAP::Config.enabled?
Loading
Loading
Loading
@@ -8,7 +8,7 @@ module SidekiqHelper
Loading
@@ -8,7 +8,7 @@ module SidekiqHelper
(?<state>[DIEKNRSTVWXZNLpsl\+<>/\d]+)\s+ (?<state>[DIEKNRSTVWXZNLpsl\+<>/\d]+)\s+
(?<start>.+?)\s+ (?<start>.+?)\s+
(?<command>(?:ruby\d+:\s+)?sidekiq.*\].*) (?<command>(?:ruby\d+:\s+)?sidekiq.*\].*)
\z}x \z}x.freeze
   
def parse_sidekiq_ps(line) def parse_sidekiq_ps(line)
match = line.strip.match(SIDEKIQ_PS_REGEXP) match = line.strip.match(SIDEKIQ_PS_REGEXP)
Loading
Loading
Loading
@@ -8,7 +8,7 @@ module ApplicationSettingImplementation
Loading
@@ -8,7 +8,7 @@ module ApplicationSettingImplementation
\s # any whitespace character \s # any whitespace character
| # or | # or
[\r\n] # any number of newline characters [\r\n] # any number of newline characters
}x }x.freeze
   
# Setting a key restriction to `-1` means that all keys of this type are # Setting a key restriction to `-1` means that all keys of this type are
# forbidden. # forbidden.
Loading
Loading
Loading
@@ -28,12 +28,12 @@ class CommitRange
Loading
@@ -28,12 +28,12 @@ class CommitRange
   
# The beginning and ending refs can be named or SHAs, and # The beginning and ending refs can be named or SHAs, and
# the range notation can be double- or triple-dot. # the range notation can be double- or triple-dot.
REF_PATTERN = /[0-9a-zA-Z][0-9a-zA-Z_.-]*[0-9a-zA-Z\^]/ REF_PATTERN = /[0-9a-zA-Z][0-9a-zA-Z_.-]*[0-9a-zA-Z\^]/.freeze
PATTERN = /#{REF_PATTERN}\.{2,3}#{REF_PATTERN}/ PATTERN = /#{REF_PATTERN}\.{2,3}#{REF_PATTERN}/.freeze
   
# In text references, the beginning and ending refs can only be SHAs # In text references, the beginning and ending refs can only be SHAs
# between 7 and 40 hex characters. # 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 def self.reference_prefix
'@' '@'
Loading
Loading
Loading
@@ -9,7 +9,7 @@ module Maskable
Loading
@@ -9,7 +9,7 @@ module Maskable
# * No spaces # * No spaces
# * Minimal length of 8 characters # * Minimal length of 8 characters
# * Absolutely no fun is allowed # * Absolutely no fun is allowed
REGEX = /\A\w{8,}\z/ REGEX = /\A\w{8,}\z/.freeze
   
included do included do
validates :masked, inclusion: { in: [true, false] } validates :masked, inclusion: { in: [true, false] }
Loading
Loading
Loading
@@ -10,7 +10,7 @@
Loading
@@ -10,7 +10,7 @@
module Redactable module Redactable
extend ActiveSupport::Concern extend ActiveSupport::Concern
   
UNSUBSCRIBE_PATTERN = %r{/sent_notifications/\h{32}/unsubscribe} UNSUBSCRIBE_PATTERN = %r{/sent_notifications/\h{32}/unsubscribe}.freeze
   
class_methods do class_methods do
def redact_field(field) def redact_field(field)
Loading
Loading
Loading
@@ -19,7 +19,7 @@ module Taskable
Loading
@@ -19,7 +19,7 @@ module Taskable
\s+ # whitespace prefix has to be always presented for a list item \s+ # whitespace prefix has to be always presented for a list item
(\[\s\]|\[[xX]\]) # checkbox (\[\s\]|\[[xX]\]) # checkbox
(\s.+) # followed by whitespace and some text. (\s.+) # followed by whitespace and some text.
}x }x.freeze
   
def self.get_tasks(content) def self.get_tasks(content)
content.to_s.scan(ITEM_PATTERN).map do |checkbox, label| content.to_s.scan(ITEM_PATTERN).map do |checkbox, label|
Loading
Loading
Loading
@@ -3,8 +3,8 @@
Loading
@@ -3,8 +3,8 @@
class Environment < ApplicationRecord class Environment < ApplicationRecord
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
# Used to generate random suffixes for the slug # Used to generate random suffixes for the slug
LETTERS = 'a'..'z' LETTERS = ('a'..'z').freeze
NUMBERS = '0'..'9' NUMBERS = ('0'..'9').freeze
SUFFIX_CHARS = LETTERS.to_a + NUMBERS.to_a SUFFIX_CHARS = LETTERS.to_a + NUMBERS.to_a
   
belongs_to :project, required: true belongs_to :project, required: true
Loading
Loading
Loading
@@ -16,7 +16,7 @@ module ErrorTracking
Loading
@@ -16,7 +16,7 @@ module ErrorTracking
(?<project>[^/]+)/* (?<project>[^/]+)/*
)? )?
\z \z
}x }x.freeze
   
self.reactive_cache_key = ->(setting) { [setting.class.model_name.singular, setting.project_id] } self.reactive_cache_key = ->(setting) { [setting.class.model_name.singular, setting.project_id] }
   
Loading
Loading
Loading
@@ -4,7 +4,7 @@ module Projects
Loading
@@ -4,7 +4,7 @@ module Projects
# Used by project imports, it removes any potential paths # Used by project imports, it removes any potential paths
# included in an error message that could be stored in the DB # included in an error message that could be stored in the DB
class ImportErrorFilter class ImportErrorFilter
ERROR_MESSAGE_FILTER = /[^\s]*#{File::SEPARATOR}[^\s]*(?=(\s|\z))/ ERROR_MESSAGE_FILTER = /[^\s]*#{File::SEPARATOR}[^\s]*(?=(\s|\z))/.freeze
FILTER_MESSAGE = '[FILTERED]' FILTER_MESSAGE = '[FILTERED]'
   
def self.filter_message(message) def self.filter_message(message)
Loading
Loading
Loading
@@ -14,8 +14,8 @@ class FileUploader < GitlabUploader
Loading
@@ -14,8 +14,8 @@ class FileUploader < GitlabUploader
include ObjectStorage::Concern include ObjectStorage::Concern
prepend ObjectStorage::Extension::RecordsUploads prepend ObjectStorage::Extension::RecordsUploads
   
MARKDOWN_PATTERN = %r{\!?\[.*?\]\(/uploads/(?<secret>[0-9a-f]{32})/(?<file>.*?)\)} MARKDOWN_PATTERN = %r{\!?\[.*?\]\(/uploads/(?<secret>[0-9a-f]{32})/(?<file>.*?)\)}.freeze
DYNAMIC_PATH_PATTERN = %r{.*(?<secret>\h{32})/(?<identifier>.*)} DYNAMIC_PATH_PATTERN = %r{.*(?<secret>\h{32})/(?<identifier>.*)}.freeze
   
after :remove, :prune_store_dir after :remove, :prune_store_dir
   
Loading
Loading
Loading
@@ -2,7 +2,7 @@ require 'gettext_i18n_rails/haml_parser'
Loading
@@ -2,7 +2,7 @@ require 'gettext_i18n_rails/haml_parser'
require 'gettext_i18n_rails_js/parser/javascript' require 'gettext_i18n_rails_js/parser/javascript'
require 'json' require 'json'
   
VUE_TRANSLATE_REGEX = /((%[\w.-]+)(?:\s))?{{ (N|n|s)?__\((.*)\) }}/ VUE_TRANSLATE_REGEX = /((%[\w.-]+)(?:\s))?{{ (N|n|s)?__\((.*)\) }}/.freeze
   
module GettextI18nRails module GettextI18nRails
class HamlParser class HamlParser
Loading
Loading
Loading
@@ -21,7 +21,7 @@ class EmojiChecker
Loading
@@ -21,7 +21,7 @@ class EmojiChecker
# alone is not enough, as we'd match `:foo:bar:baz`. Instead, we use this # 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 # regex to save us from having to check for all possible emoji names when we
# know one definitely is not included. # know one definitely is not included.
LIKELY_EMOJI = /:[\+a-z0-9_\-]+:/ LIKELY_EMOJI = /:[\+a-z0-9_\-]+:/.freeze
   
def initialize def initialize
names = JSON.parse(File.read(DIGESTS)).keys + names = JSON.parse(File.read(DIGESTS)).keys +
Loading
Loading
# rubocop:disable all
class ChangeStateToAllowEmptyMergeRequestDiffs < ActiveRecord::Migration[4.2] class ChangeStateToAllowEmptyMergeRequestDiffs < ActiveRecord::Migration[4.2]
def up def up
change_column :merge_request_diffs, :state, :string, null: true, change_column :merge_request_diffs, :state, :string, null: true,
Loading
Loading
Loading
@@ -6,7 +6,7 @@ module API
Loading
@@ -6,7 +6,7 @@ module API
   
LOG_FILENAME = Rails.root.join("log", "api_json.log") 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 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 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 USER_REQUIREMENTS = { user_id: NO_SLASH_URL_PART_REGEX }.freeze
Loading
Loading
Loading
@@ -2,13 +2,13 @@
Loading
@@ -2,13 +2,13 @@
   
module Banzai module Banzai
module ColorParser module ColorParser
ALPHA = /0(?:\.\d+)?|\.\d+|1(?:\.0+)?/ # 0.0..1.0 ALPHA = /0(?:\.\d+)?|\.\d+|1(?:\.0+)?/.freeze # 0.0..1.0
PERCENTS = /(?:\d{1,2}|100)%/ # 00%..100% PERCENTS = /(?:\d{1,2}|100)%/.freeze # 00%..100%
ALPHA_CHANNEL = /(?:,\s*(?:#{ALPHA}|#{PERCENTS}))?/ ALPHA_CHANNEL = /(?:,\s*(?:#{ALPHA}|#{PERCENTS}))?/.freeze
BITS = /\d{1,2}|1\d\d|2(?:[0-4]\d|5[0-5])/ # 00..255 BITS = /\d{1,2}|1\d\d|2(?:[0-4]\d|5[0-5])/.freeze # 00..255
DEGS = /-?\d+(?:deg)?/i # [-]digits[deg] DEGS = /-?\d+(?:deg)?/i.freeze # [-]digits[deg]
RADS = /-?(?:\d+(?:\.\d+)?|\.\d+)rad/i # [-](digits[.digits] OR .digits)rad RADS = /-?(?:\d+(?:\.\d+)?|\.\d+)rad/i.freeze # [-](digits[.digits] OR .digits)rad
HEX_FORMAT = /\#(?:\h{3}|\h{4}|\h{6}|\h{8})/ HEX_FORMAT = /\#(?:\h{3}|\h{4}|\h{6}|\h{8})/.freeze
RGB_FORMAT = %r{ RGB_FORMAT = %r{
(?:rgba? (?:rgba?
\( \(
Loading
@@ -20,7 +20,7 @@ module Banzai
Loading
@@ -20,7 +20,7 @@ module Banzai
#{ALPHA_CHANNEL} #{ALPHA_CHANNEL}
\) \)
) )
}xi }xi.freeze
HSL_FORMAT = %r{ HSL_FORMAT = %r{
(?:hsla? (?:hsla?
\( \(
Loading
@@ -28,11 +28,11 @@ module Banzai
Loading
@@ -28,11 +28,11 @@ module Banzai
#{ALPHA_CHANNEL} #{ALPHA_CHANNEL}
\) \)
) )
}xi }xi.freeze
   
FORMATS = [HEX_FORMAT, RGB_FORMAT, HSL_FORMAT].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. # Public: Analyzes whether the String is a color code.
# #
Loading
Loading
Loading
@@ -33,7 +33,7 @@ module Banzai
Loading
@@ -33,7 +33,7 @@ module Banzai
# https://github.com/vmg/rinku/blob/v2.0.1/ext/rinku/autolink.c#L65 # https://github.com/vmg/rinku/blob/v2.0.1/ext/rinku/autolink.c#L65
# #
# Rubular: http://rubular.com/r/nrL3r9yUiq # 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 # Text matching LINK_PATTERN inside these elements will not be linked
IGNORE_PARENTS = %w(a code kbd pre script style).to_set IGNORE_PARENTS = %w(a code kbd pre script style).to_set
Loading
Loading
Loading
@@ -20,7 +20,7 @@ module Banzai
Loading
@@ -20,7 +20,7 @@ module Banzai
\s* \s*
^\k<delim> # closing front matter marker ^\k<delim> # closing front matter marker
\s* \s*
}mx }mx.freeze
   
def call def call
html.sub(PATTERN) do |_match| html.sub(PATTERN) do |_match|
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment