about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2017-06-08 20:24:28 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-06-08 13:24:28 +0200
commit0a0b9a271a8de84272ff2dafc96ef53db224bb21 (patch)
tree39a325adf00bb3f57d65510029d9b85d1d4b5de1 /app
parent7d2b4186c37ec81ae896eb57168cb0374de2c656 (diff)
Improve RuboCop rules (compatibility to Code Climate) (#3636)
https://github.com/codeclimate/codeclimate-rubocop/blob/08f8de84ebfb39caa96391e23816877278f6441c/Gemfile.lock#L38
Code Climate is using RuboCop v0.46.0.

Change several rules to maintain compatibility.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api/v1/notifications_controller.rb2
-rw-r--r--app/helpers/stream_entries_helper.rb4
-rw-r--r--app/lib/feed_manager.rb4
-rw-r--r--app/models/concerns/paginable.rb4
-rw-r--r--app/models/setting.rb2
-rw-r--r--app/services/fetch_atom_service.rb2
-rw-r--r--app/services/suspend_account_service.rb2
-rw-r--r--app/services/update_remote_profile_service.rb2
8 files changed, 11 insertions, 11 deletions
diff --git a/app/controllers/api/v1/notifications_controller.rb b/app/controllers/api/v1/notifications_controller.rb
index 20b28776d..a28e99f2f 100644
--- a/app/controllers/api/v1/notifications_controller.rb
+++ b/app/controllers/api/v1/notifications_controller.rb
@@ -51,7 +51,7 @@ class Api::V1::NotificationsController < Api::BaseController
   end
 
   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
 
   def insert_pagination_headers
diff --git a/app/helpers/stream_entries_helper.rb b/app/helpers/stream_entries_helper.rb
index ba989a84d..275762c87 100644
--- a/app/helpers/stream_entries_helper.rb
+++ b/app/helpers/stream_entries_helper.rb
@@ -1,8 +1,8 @@
 # frozen_string_literal: true
 
 module StreamEntriesHelper
-  EMBEDDED_CONTROLLER = 'stream_entries'.freeze
-  EMBEDDED_ACTION = 'embed'.freeze
+  EMBEDDED_CONTROLLER = 'stream_entries'
+  EMBEDDED_ACTION = 'embed'
 
   def display_name(account)
     account.display_name.presence || account.username
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 86928fa36..90a1441f2 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -109,8 +109,8 @@ class FeedManager
 
     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 &&= !(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 &&= 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
       return should_filter
     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
diff --git a/app/models/concerns/paginable.rb b/app/models/concerns/paginable.rb
index 9e95cd649..6061bf9bd 100644
--- a/app/models/concerns/paginable.rb
+++ b/app/models/concerns/paginable.rb
@@ -6,8 +6,8 @@ module Paginable
   included do
     scope :paginate_by_max_id, ->(limit, max_id = nil, since_id = nil) {
       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].gt(since_id)) unless since_id.blank?
+      query = query.where(arel_table[:id].lt(max_id)) if max_id.present?
+      query = query.where(arel_table[:id].gt(since_id)) if since_id.present?
       query
     }
   end
diff --git a/app/models/setting.rb b/app/models/setting.rb
index e0107dd83..340552581 100644
--- a/app/models/setting.rb
+++ b/app/models/setting.rb
@@ -13,7 +13,7 @@
 #
 
 class Setting < RailsSettings::Base
-  source Rails.root.join('config/settings.yml')
+  source Rails.root.join('config', 'settings.yml')
 
   def to_param
     var
diff --git a/app/services/fetch_atom_service.rb b/app/services/fetch_atom_service.rb
index 9c514aa9f..8f42db0aa 100644
--- a/app/services/fetch_atom_service.rb
+++ b/app/services/fetch_atom_service.rb
@@ -16,7 +16,7 @@ class FetchAtomService < BaseService
 
     return nil if response.code != 200
     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))
   rescue OpenSSL::SSL::SSLError => e
     Rails.logger.debug "SSL error: #{e}"
diff --git a/app/services/suspend_account_service.rb b/app/services/suspend_account_service.rb
index 0cf574ca2..4a4f23b80 100644
--- a/app/services/suspend_account_service.rb
+++ b/app/services/suspend_account_service.rb
@@ -23,7 +23,7 @@ class SuspendAccountService < BaseService
       @account.notifications,
       @account.favourites,
       @account.active_relationships,
-      @account.passive_relationships
+      @account.passive_relationships,
     ].each do |association|
       destroy_all(association)
     end
diff --git a/app/services/update_remote_profile_service.rb b/app/services/update_remote_profile_service.rb
index 6607bc84e..8a553bb36 100644
--- a/app/services/update_remote_profile_service.rb
+++ b/app/services/update_remote_profile_service.rb
@@ -24,7 +24,7 @@ class UpdateRemoteProfileService < BaseService
     end
 
     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!