Commit 792056e8 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'frozen-string-enable-app-models-even-more-still' into 'master'

Enable frozen string in rest of app/models/**/*.rb

See merge request gitlab-org/gitlab-ce!21129
parents c732433d 32af384a
# frozen_string_literal: true
class ProgrammingLanguage < ActiveRecord::Base class ProgrammingLanguage < ActiveRecord::Base
validates :name, presence: true validates :name, presence: true
validates :color, allow_blank: false, color: true validates :color, allow_blank: false, color: true
......
# frozen_string_literal: true
require 'asana' require 'asana'
class AsanaService < Service class AsanaService < Service
......
# frozen_string_literal: true
class AssemblaService < Service class AssemblaService < Service
prop_accessor :token, :subdomain prop_accessor :token, :subdomain
validates :token, presence: true, if: :activated? validates :token, presence: true, if: :activated?
......
# frozen_string_literal: true
class BambooService < CiService class BambooService < CiService
include ReactiveService include ReactiveService
......
# frozen_string_literal: true
class BugzillaService < IssueTrackerService class BugzillaService < IssueTrackerService
validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated? validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated?
......
# frozen_string_literal: true
require "addressable/uri" require "addressable/uri"
class BuildkiteService < CiService class BuildkiteService < CiService
......
# frozen_string_literal: true
# This class is to be removed with 9.1 # This class is to be removed with 9.1
# We should also by then remove BuildsEmailService from database # We should also by then remove BuildsEmailService from database
class BuildsEmailService < Service class BuildsEmailService < Service
......
# frozen_string_literal: true
class CampfireService < Service class CampfireService < Service
prop_accessor :token, :subdomain, :room prop_accessor :token, :subdomain, :room
validates :token, presence: true, if: :activated? validates :token, presence: true, if: :activated?
...@@ -82,7 +84,7 @@ class CampfireService < Service ...@@ -82,7 +84,7 @@ class CampfireService < Service
before = push[:before] before = push[:before]
after = push[:after] after = push[:after]
message = "" message = []
message << "[#{project.full_name}] " message << "[#{project.full_name}] "
message << "#{push[:user_name]} " message << "#{push[:user_name]} "
...@@ -95,6 +97,6 @@ class CampfireService < Service ...@@ -95,6 +97,6 @@ class CampfireService < Service
message << "#{project.web_url}/compare/#{before}...#{after}" message << "#{project.web_url}/compare/#{before}...#{after}"
end end
message message.join
end end
end end
# frozen_string_literal: true
require 'slack-notifier' require 'slack-notifier'
module ChatMessage module ChatMessage
......
# frozen_string_literal: true
module ChatMessage module ChatMessage
class IssueMessage < BaseMessage class IssueMessage < BaseMessage
attr_reader :title attr_reader :title
......
# frozen_string_literal: true
module ChatMessage module ChatMessage
class MergeMessage < BaseMessage class MergeMessage < BaseMessage
attr_reader :merge_request_iid attr_reader :merge_request_iid
......
# frozen_string_literal: true
module ChatMessage module ChatMessage
class NoteMessage < BaseMessage class NoteMessage < BaseMessage
attr_reader :note attr_reader :note
......
# frozen_string_literal: true
module ChatMessage module ChatMessage
class PipelineMessage < BaseMessage class PipelineMessage < BaseMessage
attr_reader :ref_type attr_reader :ref_type
......
# frozen_string_literal: true
module ChatMessage module ChatMessage
class PushMessage < BaseMessage class PushMessage < BaseMessage
attr_reader :after attr_reader :after
......
# frozen_string_literal: true
module ChatMessage module ChatMessage
class WikiPageMessage < BaseMessage class WikiPageMessage < BaseMessage
attr_reader :title attr_reader :title
......
# frozen_string_literal: true
# Base class for Chat notifications services # Base class for Chat notifications services
# This class is not meant to be used directly, but only to inherit from. # This class is not meant to be used directly, but only to inherit from.
class ChatNotificationService < Service class ChatNotificationService < Service
......
# frozen_string_literal: true
# Base class for CI services # Base class for CI services
# List methods you need to implement to get your CI service # List methods you need to implement to get your CI service
# working with GitLab Merge Requests # working with GitLab Merge Requests
......
# frozen_string_literal: true
class CustomIssueTrackerService < IssueTrackerService class CustomIssueTrackerService < IssueTrackerService
validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated? validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated?
......
# frozen_string_literal: true
# Base class for deployment services # Base class for deployment services
# #
# These services integrate with a deployment solution like Kubernetes/OpenShift, # These services integrate with a deployment solution like Kubernetes/OpenShift,
......
# frozen_string_literal: true
class DroneCiService < CiService class DroneCiService < CiService
include ReactiveService include ReactiveService
......
# frozen_string_literal: true
class EmailsOnPushService < Service class EmailsOnPushService < Service
boolean_accessor :send_from_committer_email boolean_accessor :send_from_committer_email
boolean_accessor :disable_diffs boolean_accessor :disable_diffs
......
# frozen_string_literal: true
class ExternalWikiService < Service class ExternalWikiService < Service
prop_accessor :external_wiki_url prop_accessor :external_wiki_url
......
# frozen_string_literal: true
require "flowdock-git-hook" require "flowdock-git-hook"
# Flow dock depends on Grit to compute the number of commits between two given # Flow dock depends on Grit to compute the number of commits between two given
......
# frozen_string_literal: true
require "gemnasium/gitlab_service" require "gemnasium/gitlab_service"
class GemnasiumService < Service class GemnasiumService < Service
......
# frozen_string_literal: true
class GitlabIssueTrackerService < IssueTrackerService class GitlabIssueTrackerService < IssueTrackerService
include Gitlab::Routing include Gitlab::Routing
......
# frozen_string_literal: true
require 'hangouts_chat' require 'hangouts_chat'
class HangoutsChatService < ChatNotificationService class HangoutsChatService < ChatNotificationService
......
# frozen_string_literal: true
class HipchatService < Service class HipchatService < Service
include ActionView::Helpers::SanitizeHelper include ActionView::Helpers::SanitizeHelper
...@@ -108,7 +110,7 @@ class HipchatService < Service ...@@ -108,7 +110,7 @@ class HipchatService < Service
before = push[:before] before = push[:before]
after = push[:after] after = push[:after]
message = "" message = []
message << "#{push[:user_name]} " message << "#{push[:user_name]} "
if Gitlab::Git.blank_ref?(before) if Gitlab::Git.blank_ref?(before)
...@@ -132,7 +134,7 @@ class HipchatService < Service ...@@ -132,7 +134,7 @@ class HipchatService < Service
end end
end end
message message.join
end end
def markdown(text, options = {}) def markdown(text, options = {})
...@@ -165,11 +167,11 @@ class HipchatService < Service ...@@ -165,11 +167,11 @@ class HipchatService < Service
description = obj_attr[:description] description = obj_attr[:description]
issue_link = "<a href=\"#{issue_url}\">issue ##{issue_iid}</a>" issue_link = "<a href=\"#{issue_url}\">issue ##{issue_iid}</a>"
message = "#{user_name} #{state} #{issue_link} in #{project_link}: <b>#{title}</b>"
message = ["#{user_name} #{state} #{issue_link} in #{project_link}: <b>#{title}</b>"]
message << "<pre>#{markdown(description)}</pre>" message << "<pre>#{markdown(description)}</pre>"
message message.join
end end
def create_merge_request_message(data) def create_merge_request_message(data)
...@@ -184,12 +186,11 @@ class HipchatService < Service ...@@ -184,12 +186,11 @@ class HipchatService < Service
merge_request_url = "#{project_url}/merge_requests/#{merge_request_id}" merge_request_url = "#{project_url}/merge_requests/#{merge_request_id}"
merge_request_link = "<a href=\"#{merge_request_url}\">merge request !#{merge_request_id}</a>" merge_request_link = "<a href=\"#{merge_request_url}\">merge request !#{merge_request_id}</a>"
message = "#{user_name} #{state} #{merge_request_link} in " \ message = ["#{user_name} #{state} #{merge_request_link} in " \
"#{project_link}: <b>#{title}</b>" "#{project_link}: <b>#{title}</b>"]
message << "<pre>#{markdown(description)}</pre>" message << "<pre>#{markdown(description)}</pre>"
message.join
message
end end
def format_title(title) def format_title(title)
...@@ -235,12 +236,11 @@ class HipchatService < Service ...@@ -235,12 +236,11 @@ class HipchatService < Service
end end
subject_html = "<a href=\"#{note_url}\">#{subject_type} #{subject_desc}</a>" subject_html = "<a href=\"#{note_url}\">#{subject_type} #{subject_desc}</a>"
message = "#{user_name} commented on #{subject_html} in #{project_link}: " message = ["#{user_name} commented on #{subject_html} in #{project_link}: "]
message << title message << title
message << "<pre>#{markdown(note, ref: commit_id)}</pre>" message << "<pre>#{markdown(note, ref: commit_id)}</pre>"
message.join
message
end end
def create_pipeline_message(data) def create_pipeline_message(data)
......
# frozen_string_literal: true
require 'uri' require 'uri'
class IrkerService < Service class IrkerService < Service
......
# frozen_string_literal: true
class IssueTrackerService < Service class IssueTrackerService < Service
validate :one_issue_tracker, if: :activated?, on: :manual_change validate :one_issue_tracker, if: :activated?, on: :manual_change
......
# frozen_string_literal: true
class JiraService < IssueTrackerService class JiraService < IssueTrackerService
include Gitlab::Routing include Gitlab::Routing
include ApplicationHelper include ApplicationHelper
......
# frozen_string_literal: true
## ##
# NOTE: # NOTE:
# We'll move this class to Clusters::Platforms::Kubernetes, which contains exactly the same logic. # We'll move this class to Clusters::Platforms::Kubernetes, which contains exactly the same logic.
......
# frozen_string_literal: true
class MattermostService < ChatNotificationService class MattermostService < ChatNotificationService
def title def title
'Mattermost notifications' 'Mattermost notifications'
......
# frozen_string_literal: true
class MattermostSlashCommandsService < SlashCommandsService class MattermostSlashCommandsService < SlashCommandsService
include TriggersHelper include TriggersHelper
......
# frozen_string_literal: true
class MicrosoftTeamsService < ChatNotificationService class MicrosoftTeamsService < ChatNotificationService
def title def title
'Microsoft Teams Notification' 'Microsoft Teams Notification'
......
# frozen_string_literal: true
# For an example companion mocking service, see https://gitlab.com/gitlab-org/gitlab-mock-ci-service # For an example companion mocking service, see https://gitlab.com/gitlab-org/gitlab-mock-ci-service
class MockCiService < CiService class MockCiService < CiService
ALLOWED_STATES = %w[failed canceled running pending success success_with_warnings skipped not_found].freeze ALLOWED_STATES = %w[failed canceled running pending success success_with_warnings skipped not_found].freeze
......
# frozen_string_literal: true
class MockDeploymentService < DeploymentService class MockDeploymentService < DeploymentService
def title def title
'Mock deployment' 'Mock deployment'
......
# frozen_string_literal: true
class MockMonitoringService < MonitoringService class MockMonitoringService < MonitoringService
def title def title
'Mock monitoring' 'Mock monitoring'
......
# frozen_string_literal: true
# Base class for monitoring services # Base class for monitoring services
# #
# These services integrate with a deployment solution like Prometheus # These services integrate with a deployment solution like Prometheus
......
# frozen_string_literal: true
class PackagistService < Service class PackagistService < Service
prop_accessor :username, :token, :server prop_accessor :username, :token, :server
......
# frozen_string_literal: true
class PipelinesEmailService < Service class PipelinesEmailService < Service
prop_accessor :recipients prop_accessor :recipients
boolean_accessor :notify_only_broken_pipelines boolean_accessor :notify_only_broken_pipelines
......
# frozen_string_literal: true
class PivotaltrackerService < Service class PivotaltrackerService < Service
API_ENDPOINT = 'https://www.pivotaltracker.com/services/v5/source_commits'.freeze API_ENDPOINT = 'https://www.pivotaltracker.com/services/v5/source_commits'.freeze
......
# frozen_string_literal: true
class PrometheusService < MonitoringService class PrometheusService < MonitoringService
include PrometheusAdapter include PrometheusAdapter
......
# frozen_string_literal: true
class PushoverService < Service class PushoverService < Service
BASE_URI = 'https://api.pushover.net/1'.freeze BASE_URI = 'https://api.pushover.net/1'.freeze
...@@ -79,7 +81,7 @@ class PushoverService < Service ...@@ -79,7 +81,7 @@ class PushoverService < Service
end end
if data[:total_commits_count] > 0 if data[:total_commits_count] > 0
message << "\nTotal commits count: #{data[:total_commits_count]}" message = [message, "Total commits count: #{data[:total_commits_count]}"].join("\n")
end end
pushover_data = { pushover_data = {
......
# frozen_string_literal: true
class RedmineService < IssueTrackerService class RedmineService < IssueTrackerService
validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated? validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated?
......
# frozen_string_literal: true
class SlackService < ChatNotificationService class SlackService < ChatNotificationService
def title def title
'Slack notifications' 'Slack notifications'
......
# frozen_string_literal: true
class SlackSlashCommandsService < SlashCommandsService class SlackSlashCommandsService < SlashCommandsService
include TriggersHelper include TriggersHelper
......
# frozen_string_literal: true
# Base class for Chat services # Base class for Chat services
# This class is not meant to be used directly, but only to inherrit from. # This class is not meant to be used directly, but only to inherrit from.
class SlashCommandsService < Service class SlashCommandsService < Service
......
# frozen_string_literal: true
class TeamcityService < CiService class TeamcityService < CiService
include ReactiveService include ReactiveService
......
# frozen_string_literal: true
class ProtectedBranch::MergeAccessLevel < ActiveRecord::Base class ProtectedBranch::MergeAccessLevel < ActiveRecord::Base
include ProtectedBranchAccess include ProtectedBranchAccess
end end
# frozen_string_literal: true
class ProtectedBranch::PushAccessLevel < ActiveRecord::Base class ProtectedBranch::PushAccessLevel < ActiveRecord::Base
include ProtectedBranchAccess include ProtectedBranchAccess
end end
# frozen_string_literal: true
class ProtectedTag::CreateAccessLevel < ActiveRecord::Base class ProtectedTag::CreateAccessLevel < ActiveRecord::Base
include ProtectedTagAccess include ProtectedTagAccess
......
# frozen_string_literal: true
class RepositoryLanguage < ActiveRecord::Base class RepositoryLanguage < ActiveRecord::Base
belongs_to :project belongs_to :project
belongs_to :programming_language belongs_to :programming_language
......
# frozen_string_literal: true
class SiteStatistic < ActiveRecord::Base class SiteStatistic < ActiveRecord::Base
# prevents the creation of multiple rows # prevents the creation of multiple rows
default_value_for :id, 1 default_value_for :id, 1
......
# frozen_string_literal: true
module Storage module Storage
class HashedProject class HashedProject
attr_accessor :project attr_accessor :project
......
# frozen_string_literal: true
module Storage module Storage
class LegacyProject class LegacyProject
attr_accessor :project attr_accessor :project
......
---
title: Enable frozen string in rest of app/models/**/*.rb
merge_request: gfyoung
author:
type: performance
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