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