Improve RuboCop rules (compatibility to Code Climate) (#3636)
08f8de84eb/Gemfile.lock (L38)
Code Climate is using RuboCop v0.46.0.
Change several rules to maintain compatibility.
shrike
parent
7d2b4186c3
commit
0a0b9a271a
18
.rubocop.yml
18
.rubocop.yml
|
@ -17,12 +17,19 @@ Bundler/OrderedGems:
|
||||||
Layout/AccessModifierIndentation:
|
Layout/AccessModifierIndentation:
|
||||||
EnforcedStyle: indent
|
EnforcedStyle: indent
|
||||||
|
|
||||||
|
Layout/EmptyLineAfterMagicComment:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
Layout/SpaceInsideHashLiteralBraces:
|
Layout/SpaceInsideHashLiteralBraces:
|
||||||
EnforcedStyle: space
|
EnforcedStyle: space
|
||||||
|
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 100
|
Max: 100
|
||||||
|
|
||||||
|
Metrics/BlockLength:
|
||||||
|
Exclude:
|
||||||
|
- 'lib/tasks/**/*'
|
||||||
|
|
||||||
Metrics/BlockNesting:
|
Metrics/BlockNesting:
|
||||||
Max: 3
|
Max: 3
|
||||||
|
|
||||||
|
@ -58,6 +65,9 @@ Rails:
|
||||||
Rails/HasAndBelongsToMany:
|
Rails/HasAndBelongsToMany:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
Rails/SkipsModelValidations:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
Style/ClassAndModuleChildren:
|
Style/ClassAndModuleChildren:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
@ -81,11 +91,19 @@ Style/GuardClause:
|
||||||
Style/Lambda:
|
Style/Lambda:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
Style/PercentLiteralDelimiters:
|
||||||
|
PreferredDelimiters:
|
||||||
|
'%i': '()'
|
||||||
|
'%w': '()'
|
||||||
|
|
||||||
Style/PerlBackrefs:
|
Style/PerlBackrefs:
|
||||||
AutoCorrect: false
|
AutoCorrect: false
|
||||||
|
|
||||||
Style/RegexpLiteral:
|
Style/RegexpLiteral:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
Style/SymbolArray:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
Style/TrailingCommaInLiteral:
|
Style/TrailingCommaInLiteral:
|
||||||
EnforcedStyleForMultiline: 'comma'
|
EnforcedStyleForMultiline: 'comma'
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Api::V1::NotificationsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def target_statuses_from_notifications
|
def target_statuses_from_notifications
|
||||||
@notifications.select { |notification| !notification.target_status.nil? }.map(&:target_status)
|
@notifications.reject { |notification| notification.target_status.nil? }.map(&:target_status)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
def insert_pagination_headers
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module StreamEntriesHelper
|
module StreamEntriesHelper
|
||||||
EMBEDDED_CONTROLLER = 'stream_entries'.freeze
|
EMBEDDED_CONTROLLER = 'stream_entries'
|
||||||
EMBEDDED_ACTION = 'embed'.freeze
|
EMBEDDED_ACTION = 'embed'
|
||||||
|
|
||||||
def display_name(account)
|
def display_name(account)
|
||||||
account.display_name.presence || account.username
|
account.display_name.presence || account.username
|
||||||
|
|
|
@ -109,8 +109,8 @@ class FeedManager
|
||||||
|
|
||||||
if status.reply? && !status.in_reply_to_account_id.nil? # Filter out if it's a reply
|
if status.reply? && !status.in_reply_to_account_id.nil? # Filter out if it's a reply
|
||||||
should_filter = !Follow.where(account_id: receiver_id, target_account_id: status.in_reply_to_account_id).exists? # and I'm not following the person it's a reply to
|
should_filter = !Follow.where(account_id: receiver_id, target_account_id: status.in_reply_to_account_id).exists? # and I'm not following the person it's a reply to
|
||||||
should_filter &&= !(receiver_id == status.in_reply_to_account_id) # and it's not a reply to me
|
should_filter &&= receiver_id != status.in_reply_to_account_id # and it's not a reply to me
|
||||||
should_filter &&= !(status.account_id == status.in_reply_to_account_id) # and it's not a self-reply
|
should_filter &&= status.account_id != status.in_reply_to_account_id # and it's not a self-reply
|
||||||
return should_filter
|
return should_filter
|
||||||
elsif status.reblog? # Filter out a reblog
|
elsif status.reblog? # Filter out a reblog
|
||||||
should_filter = Block.where(account_id: status.reblog.account_id, target_account_id: receiver_id).exists? # or if the author of the reblogged status is blocking me
|
should_filter = Block.where(account_id: status.reblog.account_id, target_account_id: receiver_id).exists? # or if the author of the reblogged status is blocking me
|
||||||
|
|
|
@ -6,8 +6,8 @@ module Paginable
|
||||||
included do
|
included do
|
||||||
scope :paginate_by_max_id, ->(limit, max_id = nil, since_id = nil) {
|
scope :paginate_by_max_id, ->(limit, max_id = nil, since_id = nil) {
|
||||||
query = order(arel_table[:id].desc).limit(limit)
|
query = order(arel_table[:id].desc).limit(limit)
|
||||||
query = query.where(arel_table[:id].lt(max_id)) unless max_id.blank?
|
query = query.where(arel_table[:id].lt(max_id)) if max_id.present?
|
||||||
query = query.where(arel_table[:id].gt(since_id)) unless since_id.blank?
|
query = query.where(arel_table[:id].gt(since_id)) if since_id.present?
|
||||||
query
|
query
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
class Setting < RailsSettings::Base
|
class Setting < RailsSettings::Base
|
||||||
source Rails.root.join('config/settings.yml')
|
source Rails.root.join('config', 'settings.yml')
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
var
|
var
|
||||||
|
|
|
@ -16,7 +16,7 @@ class FetchAtomService < BaseService
|
||||||
|
|
||||||
return nil if response.code != 200
|
return nil if response.code != 200
|
||||||
return [url, fetch(url)] if response.mime_type == 'application/atom+xml'
|
return [url, fetch(url)] if response.mime_type == 'application/atom+xml'
|
||||||
return process_headers(url, response) unless response['Link'].blank?
|
return process_headers(url, response) if response['Link'].present?
|
||||||
process_html(fetch(url))
|
process_html(fetch(url))
|
||||||
rescue OpenSSL::SSL::SSLError => e
|
rescue OpenSSL::SSL::SSLError => e
|
||||||
Rails.logger.debug "SSL error: #{e}"
|
Rails.logger.debug "SSL error: #{e}"
|
||||||
|
|
|
@ -23,7 +23,7 @@ class SuspendAccountService < BaseService
|
||||||
@account.notifications,
|
@account.notifications,
|
||||||
@account.favourites,
|
@account.favourites,
|
||||||
@account.active_relationships,
|
@account.active_relationships,
|
||||||
@account.passive_relationships
|
@account.passive_relationships,
|
||||||
].each do |association|
|
].each do |association|
|
||||||
destroy_all(association)
|
destroy_all(association)
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ class UpdateRemoteProfileService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
old_hub_url = account.hub_url
|
old_hub_url = account.hub_url
|
||||||
account.hub_url = hub_link['href'] if !hub_link.nil? && !hub_link['href'].blank? && (hub_link['href'] != old_hub_url)
|
account.hub_url = hub_link['href'] if !hub_link.nil? && hub_link['href'].present? && (hub_link['href'] != old_hub_url)
|
||||||
|
|
||||||
account.save_with_optional_media!
|
account.save_with_optional_media!
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
if Rails.env.development?
|
if Rails.env.development?
|
||||||
task :set_annotation_options do
|
task :set_annotation_options do
|
||||||
Annotate.set_defaults(
|
Annotate.set_defaults(
|
||||||
|
|
|
@ -150,7 +150,7 @@ RSpec.describe User, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'saves cleared otp_backup_codes' do
|
it 'saves cleared otp_backup_codes' do
|
||||||
user = Fabricate.build(:user, otp_backup_codes: %w[dummy dummy])
|
user = Fabricate.build(:user, otp_backup_codes: %w(dummy dummy))
|
||||||
user.disable_two_factor!
|
user.disable_two_factor!
|
||||||
expect(user.reload.otp_backup_codes.empty?).to be true
|
expect(user.reload.otp_backup_codes.empty?).to be true
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,14 +14,14 @@ describe 'Link headers' do
|
||||||
link_header = link_header_with_type('application/xrd+xml')
|
link_header = link_header_with_type('application/xrd+xml')
|
||||||
|
|
||||||
expect(link_header.href).to match 'http://www.example.com/.well-known/webfinger?resource=acct%3Atest%40cb6e6126.ngrok.io'
|
expect(link_header.href).to match 'http://www.example.com/.well-known/webfinger?resource=acct%3Atest%40cb6e6126.ngrok.io'
|
||||||
expect(link_header.attr_pairs.first).to eq %w[rel lrdd]
|
expect(link_header.attr_pairs.first).to eq %w(rel lrdd)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'contains atom url in link header' do
|
it 'contains atom url in link header' do
|
||||||
link_header = link_header_with_type('application/atom+xml')
|
link_header = link_header_with_type('application/atom+xml')
|
||||||
|
|
||||||
expect(link_header.href).to eq 'http://www.example.com/users/test.atom'
|
expect(link_header.href).to eq 'http://www.example.com/users/test.atom'
|
||||||
expect(link_header.attr_pairs.first).to eq %w[rel alternate]
|
expect(link_header.attr_pairs.first).to eq %w(rel alternate)
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_header_with_type(type)
|
def link_header_with_type(type)
|
||||||
|
|
Loading…
Reference in New Issue