mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Fix various rubocop lints (#24749)
These (21 + 3 from previous PRs) are soon to be enabled in rubocop-discourse: Capybara/VisibilityMatcher Lint/DeprecatedOpenSSLConstant Lint/DisjunctiveAssignmentInConstructor Lint/EmptyConditionalBody Lint/EmptyEnsure Lint/LiteralInInterpolation Lint/NonLocalExitFromIterator Lint/ParenthesesAsGroupedExpression Lint/RedundantCopDisableDirective Lint/RedundantRequireStatement Lint/RedundantSafeNavigation Lint/RedundantStringCoercion Lint/RedundantWithIndex Lint/RedundantWithObject Lint/SafeNavigationChain Lint/SafeNavigationConsistency Lint/SelfAssignment Lint/UnreachableCode Lint/UselessMethodDefinition Lint/Void Previous PRs: Lint/ShadowedArgument Lint/DuplicateMethods Lint/BooleanSymbol RSpec/SpecFilePathSuffix
This commit is contained in:
@@ -234,7 +234,7 @@ class Admin::SiteTextsController < Admin::AdminController
|
||||
translations.each do |key, value|
|
||||
next unless I18n.exists?(key, :en)
|
||||
|
||||
if value&.is_a?(Hash)
|
||||
if value.is_a?(Hash)
|
||||
fix_plural_keys(key, value, locale).each do |plural|
|
||||
plural_key = plural[0]
|
||||
plural_value = plural[1]
|
||||
|
||||
@@ -463,7 +463,7 @@ class ApplicationController < ActionController::Base
|
||||
return unless guardian.can_enable_safe_mode?
|
||||
|
||||
safe_mode = params[SAFE_MODE]
|
||||
if safe_mode&.is_a?(String)
|
||||
if safe_mode.is_a?(String)
|
||||
safe_mode = safe_mode.split(",")
|
||||
request.env[NO_THEMES] = safe_mode.include?(NO_THEMES) || safe_mode.include?(LEGACY_NO_THEMES)
|
||||
request.env[NO_PLUGINS] = safe_mode.include?(NO_PLUGINS)
|
||||
|
||||
@@ -92,7 +92,7 @@ class ListController < ApplicationController
|
||||
|
||||
# Note the first is the default and we don't add a title
|
||||
if (filter.to_s != current_homepage) && use_crawler_layout?
|
||||
filter_title = I18n.t("js.filters.#{filter.to_s}.title", count: 0)
|
||||
filter_title = I18n.t("js.filters.#{filter}.title", count: 0)
|
||||
|
||||
if list_opts[:category] && @category
|
||||
@title =
|
||||
|
||||
@@ -121,7 +121,7 @@ class TopicsController < ApplicationController
|
||||
|
||||
deleted =
|
||||
guardian.can_see_topic?(ex.obj, false) ||
|
||||
(!guardian.can_see_topic?(ex.obj) && ex.obj&.access_topic_via_group && ex.obj.deleted_at)
|
||||
(!guardian.can_see_topic?(ex.obj) && ex.obj&.access_topic_via_group && ex.obj&.deleted_at)
|
||||
|
||||
if SiteSetting.detailed_404
|
||||
if deleted
|
||||
@@ -975,7 +975,7 @@ class TopicsController < ApplicationController
|
||||
rescue Discourse::InvalidAccess => ex
|
||||
deleted =
|
||||
guardian.can_see_topic?(ex.obj, false) ||
|
||||
(!guardian.can_see_topic?(ex.obj) && ex.obj&.access_topic_via_group && ex.obj.deleted_at)
|
||||
(!guardian.can_see_topic?(ex.obj) && ex.obj&.access_topic_via_group && ex.obj&.deleted_at)
|
||||
|
||||
raise Discourse::NotFound.new(
|
||||
nil,
|
||||
|
||||
@@ -225,7 +225,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
if params[:external_ids]&.is_a?(ActionController::Parameters) && current_user&.admin? && is_api?
|
||||
if params[:external_ids].is_a?(ActionController::Parameters) && current_user&.admin? && is_api?
|
||||
attributes[:user_associated_accounts] = []
|
||||
|
||||
params[:external_ids].each do |provider_name, provider_uid|
|
||||
@@ -716,7 +716,7 @@ class UsersController < ApplicationController
|
||||
|
||||
# Handle associated accounts
|
||||
associations = []
|
||||
if params[:external_ids]&.is_a?(ActionController::Parameters) && current_user&.admin? && is_api?
|
||||
if params[:external_ids].is_a?(ActionController::Parameters) && current_user&.admin? && is_api?
|
||||
params[:external_ids].each do |provider_name, provider_uid|
|
||||
authenticator = Discourse.enabled_authenticators.find { |a| a.name == provider_name }
|
||||
raise Discourse::InvalidParameters.new(:external_ids) if !authenticator&.is_managed?
|
||||
|
||||
@@ -192,10 +192,10 @@ class UsersEmailController < ApplicationController
|
||||
if token
|
||||
if type == :old
|
||||
@change_request =
|
||||
token.user&.email_change_requests.where(old_email_token_id: token.id).first
|
||||
token.user&.email_change_requests&.where(old_email_token_id: token.id)&.first
|
||||
elsif type == :new
|
||||
@change_request =
|
||||
token.user&.email_change_requests.where(new_email_token_id: token.id).first
|
||||
token.user&.email_change_requests&.where(new_email_token_id: token.id)&.first
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user