Rubocop fixes (#15892)
* Add missing spaces * Use filter_map over map + reject/compact * Simplify FactoryBot calls * Use to_h with block instead of map + to_h * Use guard clause
This commit is contained in:
parent
c460cce85e
commit
5da625cadb
13 changed files with 20 additions and 20 deletions
|
|
@ -74,12 +74,12 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def not_authorized
|
||||
render json: {error: "Error: not authorized"}, status: :unauthorized
|
||||
render json: { error: "Error: not authorized" }, status: :unauthorized
|
||||
raise NotAuthorizedError, "Unauthorized"
|
||||
end
|
||||
|
||||
def bad_request
|
||||
render json: {error: "Error: Bad Request"}, status: :bad_request
|
||||
render json: { error: "Error: Bad Request" }, status: :bad_request
|
||||
end
|
||||
|
||||
def error_too_many_requests(exc)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class CodepenTag < LiquidTagBase
|
|||
_, *options = stripped_link.split
|
||||
|
||||
# Validation
|
||||
validated_options = options.map { |option| valid_option(option) }.reject(&:nil?)
|
||||
validated_options = options.filter_map { |option| valid_option(option) }
|
||||
raise StandardError, "Invalid Options" unless options.empty? || !validated_options.empty?
|
||||
|
||||
option = validated_options.join("&")
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class GlitchTag < LiquidTagBase
|
|||
options -= %w[app code] if (options & %w[app code]) == %w[app code]
|
||||
|
||||
# Validation
|
||||
validated_options = options.map { |option| valid_option(option) }.reject(&:nil?)
|
||||
validated_options = options.filter_map { |option| valid_option(option) }
|
||||
raise StandardError, "Invalid Options" unless options.empty? || !validated_options.empty?
|
||||
|
||||
build_options(options)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class JsFiddleTag < LiquidTagBase
|
|||
_, *options = stripped_link.split
|
||||
|
||||
# Validation
|
||||
validated_options = options.map { |option| valid_option(option) }.reject(&:nil?)
|
||||
validated_options = options.filter_map { |option| valid_option(option) }
|
||||
raise StandardError, "Invalid Options" unless options.empty? || !validated_options.empty?
|
||||
|
||||
validated_options.length.zero? ? "" : validated_options.join(",").concat("/")
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class StackblitzTag < LiquidTagBase
|
|||
inputs = input.split
|
||||
|
||||
# Validation
|
||||
validated_views = inputs.map { |input_option| validator.call(input_option) }.reject(&:nil?)
|
||||
validated_views = inputs.filter_map { |input_option| validator.call(input_option) }
|
||||
raise StandardError, "Invalid Options" unless validated_views.length.between?(0, 1)
|
||||
|
||||
validated_views.length.zero? ? "" : validated_views.join.to_s
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ module Articles
|
|||
|
||||
Notification.remove_all_without_delay(notifiable_ids: article.id, notifiable_type: "Article")
|
||||
|
||||
if article_comments_ids.present?
|
||||
Notification.remove_all(notifiable_ids: article_comments_ids, notifiable_type: "Comment")
|
||||
end
|
||||
return if article_comments_ids.blank?
|
||||
|
||||
Notification.remove_all(notifiable_ids: article_comments_ids, notifiable_type: "Comment")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ module Color
|
|||
private
|
||||
|
||||
def hex_to_rgb_hash(hex)
|
||||
hex.match(RGB_REGEX).named_captures.map do |key, color|
|
||||
hex.match(RGB_REGEX).named_captures.to_h do |key, color|
|
||||
[key.to_sym, color.hex]
|
||||
end.to_h
|
||||
end
|
||||
end
|
||||
|
||||
attr_accessor :hexes
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ module Loggers
|
|||
end
|
||||
|
||||
def record_queue_stats(queues)
|
||||
queue_hash = queues.map do |queue|
|
||||
queue_hash = queues.to_h do |queue|
|
||||
[queue.name, { size: queue.size, latency: queue.latency }]
|
||||
end.to_h
|
||||
end
|
||||
queue_hash.each do |queue_name, queue_values|
|
||||
latency = queue_values.fetch(:latency, 0)
|
||||
size = queue_values.fetch(:size, 0)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ RSpec.describe "Admin bans user", type: :system do
|
|||
end
|
||||
|
||||
def add_tag_moderator_role
|
||||
tag = FactoryBot.create(:tag)
|
||||
tag = create(:tag)
|
||||
user.add_role(:tag_moderator, tag)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ require "rails_helper"
|
|||
|
||||
RSpec.describe Organizations::BustCacheWorker, type: :worker do
|
||||
describe "#perform" do
|
||||
let!(:organization) { FactoryBot.create(:organization) }
|
||||
let!(:organization) { create(:organization) }
|
||||
let(:worker) { subject }
|
||||
|
||||
before do
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ RSpec.describe PodcastEpisodes::BustCacheWorker, type: :worker do
|
|||
|
||||
context "when a path is not provided" do
|
||||
let(:podcast) { create(:podcast) }
|
||||
let(:podcast_episode) { FactoryBot.create(:podcast_episode, podcast_id: podcast.id) }
|
||||
let(:podcast_episode) { create(:podcast_episode, podcast_id: podcast.id) }
|
||||
|
||||
it "does not call the service" do
|
||||
worker.perform(podcast_episode.id, nil, "SlUg")
|
||||
|
|
@ -27,7 +27,7 @@ RSpec.describe PodcastEpisodes::BustCacheWorker, type: :worker do
|
|||
|
||||
context "when a slug is not provided" do
|
||||
let(:podcast) { create(:podcast) }
|
||||
let(:podcast_episode) { FactoryBot.create(:podcast_episode, podcast_id: podcast.id) }
|
||||
let(:podcast_episode) { create(:podcast_episode, podcast_id: podcast.id) }
|
||||
|
||||
it "does not call the service" do
|
||||
worker.perform(podcast_episode.id, "/PodCAst/SlUg", nil)
|
||||
|
|
@ -37,7 +37,7 @@ RSpec.describe PodcastEpisodes::BustCacheWorker, type: :worker do
|
|||
|
||||
context "when podcast episode is found" do
|
||||
let(:podcast) { create(:podcast) }
|
||||
let(:podcast_episode) { FactoryBot.create(:podcast_episode, podcast_id: podcast.id) }
|
||||
let(:podcast_episode) { create(:podcast_episode, podcast_id: podcast.id) }
|
||||
|
||||
it "busts cache" do
|
||||
worker.perform(podcast_episode.id, "/PodCAst/SlUg", "SlUg")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ require "rails_helper"
|
|||
|
||||
RSpec.describe Users::BustCacheWorker, type: :worker do
|
||||
describe "#perform" do
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
let(:user) { create(:user) }
|
||||
let(:worker) { subject }
|
||||
|
||||
it "busts cache" do
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ RSpec.describe Users::SubscribeToMailchimpNewsletterWorker, type: :worker do
|
|||
|
||||
describe "#perform_now" do
|
||||
let(:worker) { subject }
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
it "subscribes user to mailchimp newsletter" do
|
||||
mailchimp_bot = double
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue