Fix RuboCop Style/RedundantCondition (#41884).

git-svn-id: https://svn.redmine.org/redmine/trunk@23627 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2025-04-11 09:21:17 +00:00
parent 5668aa651f
commit 08ea4e0323
4 changed files with 5 additions and 16 deletions

View File

@@ -1106,13 +1106,6 @@ Style/RedundantBegin:
- 'test/unit/project_nested_set_concurrency_test.rb' - 'test/unit/project_nested_set_concurrency_test.rb'
- 'test/unit/query_test.rb' - 'test/unit/query_test.rb'
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantCondition:
Exclude:
- 'app/controllers/messages_controller.rb'
- 'app/controllers/previews_controller.rb'
- 'app/models/issue.rb'
# This cop supports safe autocorrection (--autocorrect). # This cop supports safe autocorrection (--autocorrect).
Style/RedundantConditional: Style/RedundantConditional:
Exclude: Exclude:

View File

@@ -134,7 +134,7 @@ class MessagesController < ApplicationController
def preview def preview
message = @board.messages.find_by_id(params[:id]) message = @board.messages.find_by_id(params[:id])
@text = params[:text] ? params[:text] : nil @text = params[:text] || nil
@previewed = message @previewed = message
render :partial => 'common/preview' render :partial => 'common/preview'
end end

View File

@@ -26,7 +26,7 @@ class PreviewsController < ApplicationController
if @issue if @issue
@previewed = @issue @previewed = @issue
end end
@text = params[:text] ? params[:text] : nil @text = params[:text] || nil
render :partial => 'common/preview' render :partial => 'common/preview'
end end
@@ -34,12 +34,12 @@ class PreviewsController < ApplicationController
if params[:id].present? && news = News.visible.find_by_id(params[:id]) if params[:id].present? && news = News.visible.find_by_id(params[:id])
@previewed = news @previewed = news
end end
@text = params[:text] ? params[:text] : nil @text = params[:text] || nil
render :partial => 'common/preview' render :partial => 'common/preview'
end end
def text def text
@text = params[:text] ? params[:text] : nil @text = params[:text] || nil
render :partial => 'common/preview' render :partial => 'common/preview'
end end

View File

@@ -1203,11 +1203,7 @@ class Issue < ApplicationRecord
end end
def last_notes def last_notes
if @last_notes @last_notes || journals.visible.where.not(notes: '').reorder(:id => :desc).first.try(:notes)
@last_notes
else
journals.visible.where.not(notes: '').reorder(:id => :desc).first.try(:notes)
end
end end
# Preloads relations for a collection of issues # Preloads relations for a collection of issues