diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1c229d303..776a87e6b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-auto-gen-timestamp` -# using RuboCop version 0.92.0. +# using RuboCop version 0.93.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new diff --git a/app/controllers/moderations_controller.rb b/app/controllers/moderations_controller.rb index 09204cfcf..3344bc92b 100644 --- a/app/controllers/moderations_controller.rb +++ b/app/controllers/moderations_controller.rb @@ -62,7 +62,7 @@ class ModerationsController < ApplicationController @tag_moderator_tags = Tag.with_role(:tag_moderator, current_user) @adjustments = TagAdjustment.where(article_id: @moderatable.id) @already_adjusted_tags = @adjustments.map(&:tag_name).join(", ") - @allowed_to_adjust = @moderatable.class.name == "Article" && ( + @allowed_to_adjust = @moderatable.instance_of?(Article) && ( current_user.has_role?(:super_admin) || @tag_moderator_tags.any?) @hidden_comments = @moderatable.comments.where(hidden_by_commentable_user: true) end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 3adc6f487..ddd1429ae 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -74,7 +74,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController username: @user.username, user_id: @user.id, auth_data: request.env["omniauth.auth"], - auth_error: request.env["omniauth.error"]&.inspect, + auth_error: request.env["omniauth.error"].inspect, user_errors: user_errors }) Honeybadger.notify("Omniauth log in error") diff --git a/app/controllers/tag_adjustments_controller.rb b/app/controllers/tag_adjustments_controller.rb index 50953f8f3..8f8b29bc4 100644 --- a/app/controllers/tag_adjustments_controller.rb +++ b/app/controllers/tag_adjustments_controller.rb @@ -33,7 +33,7 @@ class TagAdjustmentsController < ApplicationController @tag_moderator_tags = Tag.with_role(:tag_moderator, current_user) @adjustments = TagAdjustment.where(article_id: article.id) @already_adjusted_tags = @adjustments.map(&:tag_name).join(", ") - @allowed_to_adjust = @moderatable.class.name == "Article" && (current_user.any_admin? || @tag_moderator_tags.any?) + @allowed_to_adjust = @moderatable.instance_of?(Article) && (current_user.any_admin? || @tag_moderator_tags.any?) respond_to do |format| format.json { render json: { error: "Failure: #{tag_adjustment.errors.full_messages.to_sentence}" } } format.html { render template: "moderations/mod" } diff --git a/app/labor/generated_image.rb b/app/labor/generated_image.rb index 10915d7b4..cc8d2d0b4 100644 --- a/app/labor/generated_image.rb +++ b/app/labor/generated_image.rb @@ -8,9 +8,9 @@ class GeneratedImage def social_image if resource.class.name.include?("Article") article_image - elsif resource.class.name == "User" + elsif resource.instance_of?(User) optimize_image "/user/#{resource.id}?bust=#{resource.profile_image_url}" - elsif resource.class.name == "Organization" + elsif resource.instance_of?(Organization) optimize_image "/organization/#{resource.id}?bust=#{resource.profile_image_url}" elsif resource.class.name.include?("Tag") optimize_image "/tag/#{@resource.id}?bust=#{@resource.pretty_name}" diff --git a/app/models/follow.rb b/app/models/follow.rb index 9140231f7..f911a5796 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -57,7 +57,7 @@ class Follow < ApplicationRecord end def send_email_notification - return unless followable.class.name == "User" && followable.email? + return unless followable.instance_of?(User) && followable.email? Follows::SendEmailNotificationWorker.perform_async(id) end diff --git a/app/models/reaction.rb b/app/models/reaction.rb index 4969d0dc0..67ae171e8 100644 --- a/app/models/reaction.rb +++ b/app/models/reaction.rb @@ -53,7 +53,7 @@ class Reaction < ApplicationRecord end def cached_any_reactions_for?(reactable, user, category) - class_name = reactable.class.name == "ArticleDecorator" ? "Article" : reactable.class.name + class_name = reactable.instance_of?(ArticleDecorator) ? "Article" : reactable.class.name cache_name = "any_reactions_for-#{class_name}-#{reactable.id}-" \ "#{user.reactions_count}-#{user.public_reactions_count}-#{category}" Rails.cache.fetch(cache_name, expires_in: 24.hours) do diff --git a/app/views/articles/feed.rss.builder b/app/views/articles/feed.rss.builder index 6cd9f27cc..fc39bc847 100644 --- a/app/views/articles/feed.rss.builder +++ b/app/views/articles/feed.rss.builder @@ -12,7 +12,7 @@ xml.rss version: "2.0" do articles.each do |article| xml.item do xml.title article.title - xml.author(user && user.class.name == "User" ? user.name : article.user.name) + xml.author(user.instance_of?(User) ? user.name : article.user.name) xml.pubDate article.published_at.to_s(:rfc822) if article.published_at xml.link app_url(article.path) xml.guid app_url(article.path) diff --git a/spec/models/article_spec.rb b/spec/models/article_spec.rb index 138c0b65e..994165f64 100644 --- a/spec/models/article_spec.rb +++ b/spec/models/article_spec.rb @@ -779,7 +779,9 @@ RSpec.describe Article, type: :model do describe "spam" do before do allow(SiteConfig).to receive(:mascot_user_id).and_return(user.id) - allow(SiteConfig).to receive(:spam_trigger_terms).and_return(["yahoomagoo gogo", "testtestetest", "magoo.+magee"]) + allow(SiteConfig).to receive(:spam_trigger_terms).and_return( + ["yahoomagoo gogo", "testtestetest", "magoo.+magee"], + ) end it "creates vomit reaction if possible spam" do