Skip to content

Commit

Permalink
style(rubocop): Style/MutableConstant
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed Feb 10, 2024
1 parent d508772 commit 129dffa
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/models/credential.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Credential < ApplicationRecord

belongs_to :server

TYPES = ["SMTP", "API", "SMTP-IP"]
TYPES = ["SMTP", "API", "SMTP-IP"].freeze

validates :key, presence: true, uniqueness: { case_sensitive: false }
validates :type, inclusion: { in: TYPES }
Expand Down
5 changes: 2 additions & 3 deletions app/models/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@ class Domain < ApplicationRecord

include HasDNSChecks

VERIFICATION_EMAIL_ALIASES = ["webmaster", "postmaster", "admin", "administrator", "hostmaster"]
VERIFICATION_EMAIL_ALIASES = ["webmaster", "postmaster", "admin", "administrator", "hostmaster"].freeze
VERIFICATION_METHODS = ["DNS", "Email"].freeze

belongs_to :server, optional: true
belongs_to :owner, optional: true, polymorphic: true
has_many :routes, dependent: :destroy
has_many :track_domains, dependent: :destroy

VERIFICATION_METHODS = ["DNS", "Email"]

validates :name, presence: true, format: { with: /\A[a-z0-9\-.]*\z/ }, uniqueness: { case_sensitive: false, scope: [:owner_type, :owner_id], message: "is already added" }
validates :verification_method, inclusion: { in: VERIFICATION_METHODS }

Expand Down
4 changes: 2 additions & 2 deletions app/models/http_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class HTTPEndpoint < ApplicationRecord
has_many :routes, as: :endpoint
has_many :additional_route_endpoints, dependent: :destroy, as: :endpoint

ENCODINGS = ["BodyAsJSON", "FormData"]
FORMATS = ["Hash", "RawMessage"]
ENCODINGS = ["BodyAsJSON", "FormData"].freeze
FORMATS = ["Hash", "RawMessage"].freeze

before_destroy :update_routes

Expand Down
2 changes: 1 addition & 1 deletion app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

class Organization < ApplicationRecord

RESERVED_PERMALINKS = ["new", "edit", "remove", "delete", "destroy", "admin", "mail", "org", "server"]
RESERVED_PERMALINKS = ["new", "edit", "remove", "delete", "destroy", "admin", "mail", "org", "server"].freeze

INITIAL_QUOTA = 10
INITIAL_SUPER_QUOTA = 10_000
Expand Down
7 changes: 3 additions & 4 deletions app/models/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

class Route < ApplicationRecord

MODES = ["Endpoint", "Accept", "Hold", "Bounce", "Reject"]
MODES = ["Endpoint", "Accept", "Hold", "Bounce", "Reject"].freeze
SPAM_MODES = ["Mark", "Quarantine", "Fail"].freeze
ENDPOINT_TYPES = ["SMTPEndpoint", "HTTPEndpoint", "AddressEndpoint"].freeze

include HasUUID

Expand All @@ -33,9 +35,6 @@ class Route < ApplicationRecord
belongs_to :endpoint, polymorphic: true, optional: true
has_many :additional_route_endpoints, dependent: :destroy

SPAM_MODES = ["Mark", "Quarantine", "Fail"]
ENDPOINT_TYPES = ["SMTPEndpoint", "HTTPEndpoint", "AddressEndpoint"]

validates :name, presence: true, format: /\A(([a-z0-9\-.]*)|(\*)|(__returnpath__))\z/
validates :spam_mode, inclusion: { in: SPAM_MODES }
validates :endpoint, presence: { if: proc { mode == "Endpoint" } }
Expand Down
5 changes: 2 additions & 3 deletions app/models/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@

class Server < ApplicationRecord

RESERVED_PERMALINKS = ["new", "all", "search", "stats", "edit", "manage", "delete", "destroy", "remove"]
RESERVED_PERMALINKS = ["new", "all", "search", "stats", "edit", "manage", "delete", "destroy", "remove"].freeze
MODES = ["Live", "Development"].freeze

include HasUUID
include HasSoftDestroy
Expand All @@ -64,8 +65,6 @@ class Server < ApplicationRecord
has_many :track_domains, dependent: :destroy
has_many :ip_pool_rules, dependent: :destroy, as: :owner

MODES = ["Live", "Development"]

random_string :token, type: :chars, length: 6, unique: true, upper_letters_only: true
default_value :permalink, -> { name ? name.parameterize : nil }
default_value :raw_message_retention_days, -> { 30 }
Expand Down
2 changes: 1 addition & 1 deletion app/models/smtp_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SMTPEndpoint < ApplicationRecord
has_many :routes, as: :endpoint
has_many :additional_route_endpoints, dependent: :destroy, as: :endpoint

SSL_MODES = ["None", "Auto", "STARTTLS", "TLS"]
SSL_MODES = ["None", "Auto", "STARTTLS", "TLS"].freeze

before_destroy :update_routes

Expand Down
2 changes: 1 addition & 1 deletion app/models/webhook_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class WebhookEvent < ApplicationRecord
"MessageLinkClicked",
"MessageLoaded",
"DomainDNSError"
]
].freeze

belongs_to :webhook

Expand Down
2 changes: 1 addition & 1 deletion app/models/webhook_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class WebhookRequest < ApplicationRecord

include HasUUID

RETRIES = { 1 => 2.minutes, 2 => 3.minutes, 3 => 6.minutes, 4 => 10.minutes, 5 => 15.minutes }
RETRIES = { 1 => 2.minutes, 2 => 3.minutes, 3 => 6.minutes, 4 => 10.minutes, 5 => 15.minutes }.freeze

belongs_to :server
belongs_to :webhook, optional: true
Expand Down
4 changes: 2 additions & 2 deletions lib/postal/app_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def self.graylog_notifier

class LogFormatter

TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%3N".freeze
COLORS = [32, 34, 35, 31, 32, 33]
TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%3N"
COLORS = [32, 34, 35, 31, 32, 33].freeze

def call(severity, datetime, progname, msg)
time = datetime.strftime(TIME_FORMAT)
Expand Down
4 changes: 2 additions & 2 deletions lib/postal/message_db/statistics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def initialize(database)
@database = database
end

STATS_GAPS = { hourly: :hour, daily: :day, monthly: :month, yearly: :year }
COUNTERS = [:incoming, :outgoing, :spam, :bounces, :held]
STATS_GAPS = { hourly: :hour, daily: :day, monthly: :month, yearly: :year }.freeze
COUNTERS = [:incoming, :outgoing, :spam, :bounces, :held].freeze

#
# Increment an appropriate counter
Expand Down
2 changes: 1 addition & 1 deletion lib/postal/message_inspectors/spam_assassin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SpamAssassin < MessageInspector
EXCLUSIONS = {
outgoing: ["NO_RECEIVED", "NO_RELAYS", "ALL_TRUSTED", "FREEMAIL_FORGED_REPLYTO", "RDNS_DYNAMIC", "CK_HELO_GENERIC", /^SPF_/, /^HELO_/, /DKIM_/, /^RCVD_IN_/],
incoming: []
}
}.freeze

def inspect_message(inspection)
data = nil
Expand Down
2 changes: 1 addition & 1 deletion lib/postal/received_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ReceivedHeader
OUR_HOSTNAMES = {
smtp: Postal.config.dns.smtp_server_hostname,
http: Postal.config.web.host
}
}.freeze

class << self

Expand Down
2 changes: 1 addition & 1 deletion lib/postal/reply_separator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ReplySeparator
/^>*\s*Sent from my.*/m,
/^>*\s*=== Please reply above this line ===.*/m,
/(^>.*\n?){10,}/
]
].freeze

def self.separate(text)
return "" unless text.is_a?(String)
Expand Down

0 comments on commit 129dffa

Please sign in to comment.