Fix low-hanging rubocop gripes (#8458)
* rubocop: quit being so picky * rubocop: miscellany * rubocop: prefer present to blank
This commit is contained in:
parent
a791bac153
commit
da13fa5021
@ -62,6 +62,9 @@ Metrics/ParameterLists:
|
|||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Max: 20
|
Max: 20
|
||||||
|
|
||||||
|
Naming/MemoizedInstanceVariableName:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
Rails:
|
Rails:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
@ -71,6 +74,9 @@ Rails/HasAndBelongsToMany:
|
|||||||
Rails/SkipsModelValidations:
|
Rails/SkipsModelValidations:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
Rails/HttpStatus:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
Style/ClassAndModuleChildren:
|
Style/ClassAndModuleChildren:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Api::V1::Lists::AccountsController < Api::BaseController
|
class Api::V1::Lists::AccountsController < Api::BaseController
|
||||||
before_action -> { doorkeeper_authorize! :read, :'read:lists' }, only: [:show]
|
before_action -> { doorkeeper_authorize! :read, :'read:lists' }, only: [:show]
|
||||||
before_action -> { doorkeeper_authorize! :write, :'write:lists' }, except: [:show]
|
before_action -> { doorkeeper_authorize! :write, :'write:lists' }, except: [:show]
|
||||||
|
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Api::V1::ListsController < Api::BaseController
|
class Api::V1::ListsController < Api::BaseController
|
||||||
before_action -> { doorkeeper_authorize! :read, :'read:lists' }, only: [:index, :show]
|
before_action -> { doorkeeper_authorize! :read, :'read:lists' }, only: [:index, :show]
|
||||||
before_action -> { doorkeeper_authorize! :write, :'write:lists' }, except: [:index, :show]
|
before_action -> { doorkeeper_authorize! :write, :'write:lists' }, except: [:index, :show]
|
||||||
|
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
|
@ -288,7 +288,7 @@ class FeedManager
|
|||||||
# remains in the set. We could pick a random element, but this
|
# remains in the set. We could pick a random element, but this
|
||||||
# set should generally be small, and it seems ideal to show the
|
# set should generally be small, and it seems ideal to show the
|
||||||
# oldest potential such reblog.
|
# oldest potential such reblog.
|
||||||
other_reblog = redis.smembers(reblog_set_key).map(&:to_i).sort.first
|
other_reblog = redis.smembers(reblog_set_key).map(&:to_i).min
|
||||||
|
|
||||||
redis.zadd(timeline_key, other_reblog, other_reblog) if other_reblog
|
redis.zadd(timeline_key, other_reblog, other_reblog) if other_reblog
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ class UserMailer < Devise::Mailer
|
|||||||
return if @resource.disabled?
|
return if @resource.disabled?
|
||||||
|
|
||||||
I18n.with_locale(@resource.locale || I18n.default_locale) do
|
I18n.with_locale(@resource.locale || I18n.default_locale) do
|
||||||
mail to: @resource.unconfirmed_email.blank? ? @resource.email : @resource.unconfirmed_email,
|
mail to: @resource.unconfirmed_email.presence || @resource.email,
|
||||||
subject: I18n.t(@resource.pending_reconfirmation? ? 'devise.mailer.reconfirmation_instructions.subject' : 'devise.mailer.confirmation_instructions.subject', instance: @instance),
|
subject: I18n.t(@resource.pending_reconfirmation? ? 'devise.mailer.reconfirmation_instructions.subject' : 'devise.mailer.confirmation_instructions.subject', instance: @instance),
|
||||||
template_name: @resource.pending_reconfirmation? ? 'reconfirmation_instructions' : 'confirmation_instructions'
|
template_name: @resource.pending_reconfirmation? ? 'reconfirmation_instructions' : 'confirmation_instructions'
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,7 @@ module Expireable
|
|||||||
attr_reader :expires_in
|
attr_reader :expires_in
|
||||||
|
|
||||||
def expires_in=(interval)
|
def expires_in=(interval)
|
||||||
self.expires_at = interval.to_i.seconds.from_now unless interval.blank?
|
self.expires_at = interval.to_i.seconds.from_now if interval.present?
|
||||||
@expires_in = interval
|
@expires_in = interval
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ class User < ApplicationRecord
|
|||||||
:reduce_motion, :system_font_ui, :noindex, :theme, :display_sensitive_media, :hide_network,
|
:reduce_motion, :system_font_ui, :noindex, :theme, :display_sensitive_media, :hide_network,
|
||||||
:default_language, to: :settings, prefix: :setting, allow_nil: false
|
:default_language, to: :settings, prefix: :setting, allow_nil: false
|
||||||
|
|
||||||
attr_accessor :invite_code
|
attr_reader :invite_code
|
||||||
|
|
||||||
def pam_conflict(_)
|
def pam_conflict(_)
|
||||||
# block pam login tries on traditional account
|
# block pam login tries on traditional account
|
||||||
@ -258,7 +258,7 @@ class User < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def invite_code=(code)
|
def invite_code=(code)
|
||||||
self.invite = Invite.find_by(code: code) unless code.blank?
|
self.invite = Invite.find_by(code: code) if code.present?
|
||||||
@invite_code = code
|
@invite_code = code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ def each_schema_load_environment
|
|||||||
# needing to do the same, and we can't even use the same method
|
# needing to do the same, and we can't even use the same method
|
||||||
# to do it.
|
# to do it.
|
||||||
|
|
||||||
if Rails.env == 'development'
|
if Rails.env.development?
|
||||||
test_conf = ActiveRecord::Base.configurations['test']
|
test_conf = ActiveRecord::Base.configurations['test']
|
||||||
|
|
||||||
if test_conf['database']&.present?
|
if test_conf['database']&.present?
|
||||||
|
@ -280,14 +280,14 @@ namespace :mastodon do
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
ActionMailer::Base.smtp_settings = {
|
ActionMailer::Base.smtp_settings = {
|
||||||
:port => env['SMTP_PORT'],
|
port: env['SMTP_PORT'],
|
||||||
:address => env['SMTP_SERVER'],
|
address: env['SMTP_SERVER'],
|
||||||
:user_name => env['SMTP_LOGIN'].presence,
|
user_name: env['SMTP_LOGIN'].presence,
|
||||||
:password => env['SMTP_PASSWORD'].presence,
|
password: env['SMTP_PASSWORD'].presence,
|
||||||
:domain => env['LOCAL_DOMAIN'],
|
domain: env['LOCAL_DOMAIN'],
|
||||||
:authentication => env['SMTP_AUTH_METHOD'] == 'none' ? nil : env['SMTP_AUTH_METHOD'] || :plain,
|
authentication: env['SMTP_AUTH_METHOD'] == 'none' ? nil : env['SMTP_AUTH_METHOD'] || :plain,
|
||||||
:openssl_verify_mode => env['SMTP_OPENSSL_VERIFY_MODE'],
|
openssl_verify_mode: env['SMTP_OPENSSL_VERIFY_MODE'],
|
||||||
:enable_starttls_auto => true,
|
enable_starttls_auto: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionMailer::Base.default_options = {
|
ActionMailer::Base.default_options = {
|
||||||
@ -326,13 +326,11 @@ namespace :mastodon do
|
|||||||
|
|
||||||
if prompt.yes?('Prepare the database now?')
|
if prompt.yes?('Prepare the database now?')
|
||||||
prompt.say 'Running `RAILS_ENV=production rails db:setup` ...'
|
prompt.say 'Running `RAILS_ENV=production rails db:setup` ...'
|
||||||
prompt.say "\n"
|
prompt.say "\n\n"
|
||||||
|
|
||||||
if cmd.run!({ RAILS_ENV: 'production', SAFETY_ASSURED: 1 }, :rails, 'db:setup').failure?
|
if cmd.run!({ RAILS_ENV: 'production', SAFETY_ASSURED: 1 }, :rails, 'db:setup').failure?
|
||||||
prompt.say "\n"
|
|
||||||
prompt.error 'That failed! Perhaps your configuration is not right'
|
prompt.error 'That failed! Perhaps your configuration is not right'
|
||||||
else
|
else
|
||||||
prompt.say "\n"
|
|
||||||
prompt.ok 'Done!'
|
prompt.ok 'Done!'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -343,13 +341,11 @@ namespace :mastodon do
|
|||||||
|
|
||||||
if prompt.yes?('Compile the assets now?')
|
if prompt.yes?('Compile the assets now?')
|
||||||
prompt.say 'Running `RAILS_ENV=production rails assets:precompile` ...'
|
prompt.say 'Running `RAILS_ENV=production rails assets:precompile` ...'
|
||||||
prompt.say "\n"
|
prompt.say "\n\n"
|
||||||
|
|
||||||
if cmd.run!({ RAILS_ENV: 'production' }, :rails, 'assets:precompile').failure?
|
if cmd.run!({ RAILS_ENV: 'production' }, :rails, 'assets:precompile').failure?
|
||||||
prompt.say "\n"
|
|
||||||
prompt.error 'That failed! Maybe you need swap space?'
|
prompt.error 'That failed! Maybe you need swap space?'
|
||||||
else
|
else
|
||||||
prompt.say "\n"
|
|
||||||
prompt.say 'Done!'
|
prompt.say 'Done!'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -715,10 +711,10 @@ namespace :mastodon do
|
|||||||
pastel = Pastel.new
|
pastel = Pastel.new
|
||||||
|
|
||||||
duplicate_masters.each do |account|
|
duplicate_masters.each do |account|
|
||||||
puts pastel.yellow("First of their name: ") + pastel.bold(account.username) + " (#{admin_account_url(account.id)})"
|
puts pastel.yellow('First of their name: ') + pastel.bold(account.username) + " (#{admin_account_url(account.id)})"
|
||||||
|
|
||||||
Account.where('lower(username) = ?', account.username.downcase).where.not(id: account.id).each do |duplicate|
|
Account.where('lower(username) = ?', account.username.downcase).where.not(id: account.id).each do |duplicate|
|
||||||
puts " " + pastel.red("Duplicate: ") + admin_account_url(duplicate.id)
|
puts ' ' + pastel.red('Duplicate: ') + admin_account_url(duplicate.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user