Apply rubocop rules to freeze constants
Added by popular demand among our team members.
This commit is contained in:
@@ -391,12 +391,18 @@ Style/IdenticalConditionalBranches:
|
||||
Style/MethodDefParentheses:
|
||||
Enabled: true
|
||||
|
||||
Style/MutableConstant:
|
||||
Enabled: true
|
||||
|
||||
Style/Not:
|
||||
Enabled: true
|
||||
|
||||
Style/PercentLiteralDelimiters:
|
||||
Enabled: true
|
||||
|
||||
Style/RedundantFreeze:
|
||||
Enabled: true
|
||||
|
||||
Style/SafeNavigation:
|
||||
Enabled: true
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module EmbedVideosHelper
|
||||
VIMEO_REGEX = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/
|
||||
YOUTUBE_REGEX = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
|
||||
VIMEO_REGEX = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/.freeze
|
||||
YOUTUBE_REGEX = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/.freeze
|
||||
|
||||
def embedded_video_code(resource)
|
||||
link = resource.video_url
|
||||
|
||||
@@ -2,7 +2,7 @@ class Activity < ApplicationRecord
|
||||
belongs_to :actionable, -> { with_hidden }, polymorphic: true
|
||||
belongs_to :user, -> { with_hidden }, inverse_of: :activities
|
||||
|
||||
VALID_ACTIONS = %w[hide block restore valuate email]
|
||||
VALID_ACTIONS = %w[hide block restore valuate email].freeze
|
||||
|
||||
validates :action, inclusion: { in: VALID_ACTIONS }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Budget
|
||||
class Heading < ApplicationRecord
|
||||
OSM_DISTRICT_LEVEL_ZOOM = 12.freeze
|
||||
OSM_DISTRICT_LEVEL_ZOOM = 12
|
||||
|
||||
include Sluggable
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Budget
|
||||
class ReclassifiedVote < ApplicationRecord
|
||||
REASONS = %w[heading_changed unfeasible]
|
||||
REASONS = %w[heading_changed unfeasible].freeze
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :investment
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module Statisticable
|
||||
extend ActiveSupport::Concern
|
||||
PARTICIPATIONS = %w[gender age geozone]
|
||||
PARTICIPATIONS = %w[gender age geozone].freeze
|
||||
|
||||
included do
|
||||
attr_reader :resource
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Legislation::DraftVersion < ApplicationRecord
|
||||
VALID_STATUSES = %w[draft published]
|
||||
VALID_STATUSES = %w[draft published].freeze
|
||||
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
@@ -23,7 +23,7 @@ class Legislation::Process < ApplicationRecord
|
||||
proposals_phase people_proposals_phase draft_publication
|
||||
result_publication].freeze
|
||||
|
||||
CSS_HEX_COLOR = /\A#?(?:[A-F0-9]{3}){1,2}\z/i
|
||||
CSS_HEX_COLOR = /\A#?(?:[A-F0-9]{3}){1,2}\z/i.freeze
|
||||
|
||||
has_many :draft_versions, -> { order(:id) },
|
||||
foreign_key: "legislation_process_id",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Poll::PartialResult < ApplicationRecord
|
||||
VALID_ORIGINS = %w[web booth]
|
||||
VALID_ORIGINS = %w[web booth].freeze
|
||||
|
||||
belongs_to :question, -> { with_hidden }, inverse_of: :partial_results
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", inverse_of: :poll_partial_results
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class Poll::Question::Answer::Video < ApplicationRecord
|
||||
belongs_to :answer, class_name: "Poll::Question::Answer"
|
||||
|
||||
VIMEO_REGEX = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/
|
||||
YOUTUBE_REGEX = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
|
||||
VIMEO_REGEX = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/.freeze
|
||||
YOUTUBE_REGEX = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/.freeze
|
||||
|
||||
validates :title, presence: true
|
||||
validate :valid_url?
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class ProgressBar < ApplicationRecord
|
||||
self.inheritance_column = nil
|
||||
RANGE = 0..100
|
||||
RANGE = (0..100).freeze
|
||||
|
||||
enum kind: %i[primary secondary]
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class Proposal < ApplicationRecord
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
RETIRE_OPTIONS = %w[duplicated started unfeasible done other]
|
||||
RETIRE_OPTIONS = %w[duplicated started unfeasible done other].freeze
|
||||
|
||||
translates :title, touch: true
|
||||
translates :description, touch: true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Report < ApplicationRecord
|
||||
KINDS = %i[results stats advanced_stats]
|
||||
KINDS = %i[results stats advanced_stats].freeze
|
||||
|
||||
belongs_to :process, polymorphic: true
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class SignatureSheet < ApplicationRecord
|
||||
belongs_to :signable, polymorphic: true
|
||||
belongs_to :author, class_name: "User"
|
||||
|
||||
VALID_SIGNABLES = %w[Proposal Budget::Investment]
|
||||
VALID_SIGNABLES = %w[Proposal Budget::Investment].freeze
|
||||
|
||||
has_many :signatures
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class SiteCustomization::ContentBlock < ApplicationRecord
|
||||
VALID_BLOCKS = %w[top_links footer subnavigation_left subnavigation_right]
|
||||
VALID_BLOCKS = %w[top_links footer subnavigation_left subnavigation_right].freeze
|
||||
|
||||
validates :locale, presence: true, inclusion: { in: I18n.available_locales.map(&:to_s) }
|
||||
validates :name, presence: true, uniqueness: { scope: :locale }, inclusion: { in: VALID_BLOCKS }
|
||||
|
||||
@@ -7,7 +7,7 @@ class SiteCustomization::Image < ApplicationRecord
|
||||
"budget_execution_no_image" => [800, 600],
|
||||
"map" => [420, 500],
|
||||
"logo_email" => [400, 80]
|
||||
}
|
||||
}.freeze
|
||||
|
||||
has_attached_file :image
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class SiteCustomization::Page < ApplicationRecord
|
||||
VALID_STATUSES = %w[draft published]
|
||||
VALID_STATUSES = %w[draft published].freeze
|
||||
has_many :cards,
|
||||
class_name: "Widget::Card",
|
||||
foreign_key: "site_customization_page_id",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Widget::Feed < ApplicationRecord
|
||||
self.table_name = "widget_feeds"
|
||||
|
||||
KINDS = %w[proposals debates processes]
|
||||
KINDS = %w[proposals debates processes].freeze
|
||||
|
||||
def active?
|
||||
setting.value.present?
|
||||
|
||||
@@ -8,7 +8,7 @@ module GraphQL
|
||||
float: GraphQL::FLOAT_TYPE,
|
||||
double: GraphQL::FLOAT_TYPE,
|
||||
string: GraphQL::STRING_TYPE
|
||||
}
|
||||
}.freeze
|
||||
|
||||
def self.create(api_types_definitions)
|
||||
created_types = {}
|
||||
|
||||
@@ -3,7 +3,7 @@ include RemoteTranslations::Microsoft::SentencesParser
|
||||
|
||||
class RemoteTranslations::Microsoft::Client
|
||||
CHARACTERS_LIMIT_PER_REQUEST = 5000
|
||||
PREVENTING_TRANSLATION_KEY = "notranslate"
|
||||
PREVENTING_TRANSLATION_KEY = "notranslate".freeze
|
||||
|
||||
def initialize
|
||||
api_key = Rails.application.secrets.microsoft_api_key
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class TagSanitizer
|
||||
DISALLOWED_STRINGS = %w[? < > = /]
|
||||
DISALLOWED_STRINGS = %w[? < > = /].freeze
|
||||
|
||||
def sanitize_tag(tag)
|
||||
tag = tag.dup
|
||||
|
||||
@@ -7,7 +7,7 @@ class UserSegments
|
||||
feasible_and_undecided_investment_authors
|
||||
selected_investment_authors
|
||||
winner_investment_authors
|
||||
not_supported_on_current_budget]
|
||||
not_supported_on_current_budget].freeze
|
||||
|
||||
def self.all_users
|
||||
User.active
|
||||
|
||||
Reference in New Issue
Block a user