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
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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?
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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.
Loading
Loading
Loading
Loading
@@ -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
'@'
Loading
Loading
Loading
Loading
@@ -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] }
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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|
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -16,7 +16,7 @@ module ErrorTracking
(?<project>[^/]+)/*
)?
\z
}x
}x.freeze
 
self.reactive_cache_key = ->(setting) { [setting.class.model_name.singular, setting.project_id] }
 
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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 +
Loading
Loading
# rubocop:disable all
class ChangeStateToAllowEmptyMergeRequestDiffs < ActiveRecord::Migration[4.2]
def up
change_column :merge_request_diffs, :state, :string, null: true,
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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?
\(
Loading
Loading
@@ -20,7 +20,7 @@ module Banzai
#{ALPHA_CHANNEL}
\)
)
}xi
}xi.freeze
HSL_FORMAT = %r{
(?:hsla?
\(
Loading
Loading
@@ -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.
#
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ module Banzai
\s*
^\k<delim> # closing front matter marker
\s*
}mx
}mx.freeze
 
def call
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