Rubocop: Enable and fix Style/OptionalBooleanParameter cop (#9711)
* Enable and fix Style/OptionalBooleanParameter cop * Keep regular parameters for workers * Keep regular parameters for workers * Fix spec * Trigger Travis correctly
This commit is contained in:
parent
0c08918307
commit
085c60992b
17 changed files with 29 additions and 27 deletions
|
|
@ -433,7 +433,7 @@ Style/ClassAndModuleChildren:
|
|||
Style/OptionalBooleanParameter:
|
||||
Description: 'Use keyword arguments when defining method with boolean argument.'
|
||||
StyleGuide: '#boolean-keyword-arguments'
|
||||
Enabled: pending
|
||||
Enabled: true
|
||||
|
||||
Style/OptionHash:
|
||||
Description: "Don't use option hashes when you can use keyword arguments."
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ class FollowsController < ApplicationController
|
|||
|
||||
def unfollow(followable, need_notification: false)
|
||||
user_follow = current_user.stop_following(followable)
|
||||
Notification.send_new_follower_notification_without_delay(user_follow, true) if need_notification
|
||||
Notification.send_new_follower_notification_without_delay(user_follow, is_read: true) if need_notification
|
||||
|
||||
"unfollowed"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
module CommentsHelper
|
||||
def comment_class(comment, is_view_root = false)
|
||||
def comment_class(comment, is_view_root: false)
|
||||
if comment.root? || is_view_root
|
||||
"root"
|
||||
else
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class Notification < ApplicationRecord
|
|||
scope :unread, -> { where(read: false) }
|
||||
|
||||
class << self
|
||||
def send_new_follower_notification(follow, is_read = false)
|
||||
def send_new_follower_notification(follow, is_read: false)
|
||||
return unless follow && Follow.need_new_follower_notification_for?(follow.followable_type)
|
||||
return if follow.followable_type == "User" && UserBlock.blocking?(follow.followable_id, follow.follower_id)
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ class Notification < ApplicationRecord
|
|||
Notifications::NewFollowerWorker.perform_async(follow_data, is_read)
|
||||
end
|
||||
|
||||
def send_new_follower_notification_without_delay(follow, is_read = false)
|
||||
def send_new_follower_notification_without_delay(follow, is_read: false)
|
||||
return unless follow && Follow.need_new_follower_notification_for?(follow.followable_type)
|
||||
return if follow.followable_type == "User" && UserBlock.blocking?(follow.followable_id, follow.follower_id)
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ module Github
|
|||
end
|
||||
|
||||
# adapted from https://api.rubyonrails.org/classes/Module.html#method-i-delegate_missing_to
|
||||
def respond_to_missing?(method, _include_all = false)
|
||||
def respond_to_missing?(method, _include_all = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||
target.respond_to?(method, false) || super
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ module Notifications
|
|||
# * :followable_id [Integer]
|
||||
# * :followable_type [String] - "User" or "Organization"
|
||||
# * :follower_id [Integer] - user id
|
||||
def initialize(follow_data, is_read = false)
|
||||
def initialize(follow_data, is_read: false)
|
||||
# we explicitly symbolize_keys because FollowData.new will fail otherwise with an error of
|
||||
# ":followable_id is missing in Hash input". FollowData expects a symbol, not a string.
|
||||
follow_data.symbolize_keys!
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ module Podcasts
|
|||
rss = HTTParty.get(podcast.feed_url, limit: 7).body
|
||||
feed = RSS::Parser.parse(rss, false)
|
||||
|
||||
set_unreachable(:unparsable, force_update) && return unless feed
|
||||
set_unreachable(status: :unparsable, force_update: force_update) && return unless feed
|
||||
|
||||
get_episode = Podcasts::GetEpisode.new(podcast)
|
||||
feed.items.first(limit).each do |item|
|
||||
|
|
@ -21,18 +21,18 @@ module Podcasts
|
|||
podcast.update_columns(reachable: true, status_notice: "")
|
||||
feed.items.size
|
||||
rescue Net::OpenTimeout, Errno::ECONNREFUSED, SocketError, HTTParty::RedirectionTooDeep
|
||||
set_unreachable(:unreachable, force_update)
|
||||
set_unreachable(status: :unreachable, force_update: force_update)
|
||||
rescue OpenSSL::SSL::SSLError
|
||||
set_unreachable(:ssl_failed, force_update)
|
||||
set_unreachable(status: :ssl_failed, force_update: force_update)
|
||||
rescue RSS::NotWellFormedError
|
||||
set_unreachable(:unparsable, force_update)
|
||||
set_unreachable(status: :unparsable, force_update: force_update)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :podcast
|
||||
|
||||
def set_unreachable(status = :unreachable, force_update = false)
|
||||
def set_unreachable(status: :unreachable, force_update: false)
|
||||
# don't recheck if the podcast was already unreachable or force update is required
|
||||
need_refetching = podcast.reachable || force_update
|
||||
podcast.update_columns(reachable: false, status_notice: I18n.t(status, scope: "podcasts.statuses"))
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
class RssReader
|
||||
def self.get_all_articles(force = true)
|
||||
new.get_all_articles(force)
|
||||
def self.get_all_articles(force: true)
|
||||
new.get_all_articles(force: force)
|
||||
end
|
||||
|
||||
def get_all_articles(force = true)
|
||||
def get_all_articles(force: true)
|
||||
articles = []
|
||||
|
||||
User.where.not(feed_url: [nil, ""]).find_each do |user|
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ module Search
|
|||
end
|
||||
|
||||
# adapted from https://api.rubyonrails.org/classes/Module.html#method-i-delegate_missing_to
|
||||
def respond_to_missing?(method, _include_all = false)
|
||||
def respond_to_missing?(method, _include_all = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||
target.respond_to?(method, false) || super
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ module TwitterClient
|
|||
end
|
||||
|
||||
# adapted from https://api.rubyonrails.org/classes/Module.html#method-i-delegate_missing_to
|
||||
def respond_to_missing?(method, _include_all = false)
|
||||
def respond_to_missing?(method, _include_all = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||
target.respond_to?(method, false) || super
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<div class="comment-hash-marker" id="<%= comment.id_code_generated %>"></div>
|
||||
<div id="comment-node-<%= comment.id %>" class="single-comment-node <%= comment_class(comment, is_view_root) %> <%= "flat-node" if comment.depth > 3 %> comment-deep-<%= comment.depth %>" data-comment-id="<%= comment.id %>" data-comment-author-id="<%= comment_user_id_unless_deleted comment %>" data-content-user-id="<%= comment_user_id_unless_deleted comment %>">
|
||||
<div id="comment-node-<%= comment.id %>"
|
||||
class="single-comment-node <%= comment_class(comment, is_view_root: is_view_root) %> <%= "flat-node" if comment.depth > 3 %> comment-deep-<%= comment.depth %>" data-comment-id="<%= comment.id %>" data-comment-author-id="<%= comment_user_id_unless_deleted comment %>" data-content-user-id="<%= comment_user_id_unless_deleted comment %>">
|
||||
<% if comment.deleted %>
|
||||
<div class="inner-comment">
|
||||
<div class="body" style="padding-bottom:32px;opacity:0.3;user-select:none;cursor:default">
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ module Notifications
|
|||
|
||||
sidekiq_options queue: :medium_priority, retry: 10
|
||||
|
||||
def perform(follow_data, is_read = false)
|
||||
Notifications::NewFollower::Send.call(follow_data, is_read)
|
||||
def perform(follow_data, is_read = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||
Notifications::NewFollower::Send.call(follow_data, is_read: is_read)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ module Users
|
|||
|
||||
sidekiq_options queue: :high_priority, retry: 10
|
||||
|
||||
def perform(user_id, admin_delete = false)
|
||||
def perform(user_id, admin_delete = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||
user = User.find_by(id: user_id)
|
||||
return unless user
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ end
|
|||
|
||||
task fetch_all_rss: :environment do
|
||||
Rails.application.eager_load!
|
||||
RssReader.get_all_articles(false) # False means don't force fetch. Fetch "random" subset instead of all of them.
|
||||
|
||||
RssReader.get_all_articles(force: false) # don't force fetch. Fetch "random" subset instead of all of them.
|
||||
end
|
||||
|
||||
task resave_supported_tags: :environment do
|
||||
|
|
|
|||
|
|
@ -244,9 +244,9 @@ RSpec.describe "UserSettings", type: :request do
|
|||
end
|
||||
|
||||
context "when requesting an export of the articles" do
|
||||
def send_request(flag = true)
|
||||
def send_request(export_requested: true)
|
||||
put "/users/#{user.id}", params: {
|
||||
user: { tab: "misc", export_requested: flag }
|
||||
user: { tab: "misc", export_requested: export_requested }
|
||||
}
|
||||
end
|
||||
|
||||
|
|
@ -282,7 +282,7 @@ RSpec.describe "UserSettings", type: :request do
|
|||
|
||||
it "does not send an email if there was no request" do
|
||||
sidekiq_perform_enqueued_jobs do
|
||||
expect { send_request(false) }.not_to(change { ActionMailer::Base.deliveries.count })
|
||||
expect { send_request(export_requested: false) }.not_to(change { ActionMailer::Base.deliveries.count })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ RSpec.describe Notifications::NewFollower::Send, type: :service do
|
|||
end
|
||||
|
||||
it "creates a read notification" do
|
||||
notification = described_class.call(follow_data(follow), true)
|
||||
notification = described_class.call(follow_data(follow), is_read: true)
|
||||
expect(notification.read).to be_truthy
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ RSpec.describe "Notifications page", type: :system, js: true do
|
|||
|
||||
it "allows user to follow other users back" do
|
||||
follow = leslie.follow(alex)
|
||||
Notification.send_new_follower_notification_without_delay(follow, "Published")
|
||||
Notification.send_new_follower_notification_without_delay(follow, is_read: true)
|
||||
visit "/notifications"
|
||||
expect(page).to have_css("div.single-notification")
|
||||
click_button("Follow back")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue