From 488c192286ead874fcdfe04b6acf52e52e5cf9fc Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 18 Dec 2009 14:22:18 +0000 Subject: [PATCH] Removes "xxx and return" calls (#4446). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3185 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/account_controller.rb | 4 ++-- app/controllers/application_controller.rb | 6 ++++-- app/controllers/custom_fields_controller.rb | 2 +- app/controllers/issues_controller.rb | 3 ++- app/controllers/journals_controller.rb | 2 +- app/controllers/messages_controller.rb | 4 ++-- app/controllers/my_controller.rb | 8 ++++++-- app/controllers/repositories_controller.rb | 22 ++++++++++----------- app/controllers/timelog_controller.rb | 6 +++--- app/controllers/wiki_controller.rb | 3 ++- 10 files changed, 34 insertions(+), 26 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 17d113887..674045f73 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -67,9 +67,9 @@ class AccountController < ApplicationController if request.post? user = User.find_by_mail(params[:mail]) # user not found in db - flash.now[:error] = l(:notice_account_unknown_email) and return unless user + (flash.now[:error] = l(:notice_account_unknown_email); return) unless user # user uses an external authentification - flash.now[:error] = l(:notice_can_t_change_password) and return if user.auth_source_id + (flash.now[:error] = l(:notice_can_t_change_password); return) if user.auth_source_id # create a new token for password recovery token = Token.new(:user => user, :action => "recovery") if token.save diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 144ccdd57..75f7121f2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -30,7 +30,8 @@ class ApplicationController < ActionController::Base def delete_broken_cookies if cookies['_redmine_session'] && cookies['_redmine_session'] !~ /--/ cookies.delete '_redmine_session' - redirect_to home_path and return false + redirect_to home_path + return false end end @@ -166,7 +167,8 @@ class ApplicationController < ActionController::Base uri = URI.parse(back_url) # do not redirect user to another host or to the login or register page if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) - redirect_to(back_url) and return + redirect_to(back_url) + return end rescue URI::InvalidURIError # redirect to default diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb index ec16be566..e8e9e4947 100644 --- a/app/controllers/custom_fields_controller.rb +++ b/app/controllers/custom_fields_controller.rb @@ -32,7 +32,7 @@ class CustomFieldsController < ApplicationController end rescue end - redirect_to(:action => 'index') and return unless @custom_field.is_a?(CustomField) + (redirect_to(:action => 'index'); return) unless @custom_field.is_a?(CustomField) if request.post? and @custom_field.save flash[:notice] = l(:notice_successful_create) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 512293428..0cb815bec 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -475,7 +475,8 @@ private @project = projects.first else # TODO: let users bulk edit/move/destroy issues from different projects - render_error 'Can not bulk edit/move/destroy issues from different projects' and return false + render_error 'Can not bulk edit/move/destroy issues from different projects' + return false end rescue ActiveRecord::RecordNotFound render_404 diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index d479855f2..e9fe9099d 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -33,7 +33,7 @@ class JournalsController < ApplicationController private def find_journal @journal = Journal.find(params[:id]) - render_403 and return false unless @journal.editable_by?(User.current) + (render_403; return false) unless @journal.editable_by?(User.current) @project = @journal.journalized.project rescue ActiveRecord::RecordNotFound render_404 diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 437d1a291..fe5451944 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -68,7 +68,7 @@ class MessagesController < ApplicationController # Edit a message def edit - render_403 and return false unless @message.editable_by?(User.current) + (render_403; return false) unless @message.editable_by?(User.current) if params[:message] @message.locked = params[:message]['locked'] @message.sticky = params[:message]['sticky'] @@ -83,7 +83,7 @@ class MessagesController < ApplicationController # Delete a messages def destroy - render_403 and return false unless @message.destroyable_by?(User.current) + (render_403; return false) unless @message.destroyable_by?(User.current) @message.destroy redirect_to @message.parent.nil? ? { :controller => 'boards', :action => 'show', :project_id => @project, :id => @board } : diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index fdf509544..8d1405b87 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -78,7 +78,11 @@ class MyController < ApplicationController # Manage user's password def password @user = User.current - flash[:error] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id + if @user.auth_source_id + flash[:error] = l(:notice_can_t_change_password) + redirect_to :action => 'account' + return + end if request.post? if @user.check_password?(params[:password]) @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] @@ -116,7 +120,7 @@ class MyController < ApplicationController # params[:block] : id of the block to add def add_block block = params[:block].to_s.underscore - render(:nothing => true) and return unless block && (BLOCKS.keys.include? block) + (render :nothing => true; return) unless block && (BLOCKS.keys.include? block) @user = User.current # remove if already present in a group %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block } diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 8e39d42c7..745159ec7 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -73,7 +73,7 @@ class RepositoriesController < ApplicationController if request.xhr? @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) else - show_error_not_found and return unless @entries + (show_error_not_found; return) unless @entries @changesets = @repository.latest_changesets(@path, @rev) @properties = @repository.properties(@path, @rev) render :action => 'show' @@ -84,7 +84,7 @@ class RepositoriesController < ApplicationController def changes @entry = @repository.entry(@path, @rev) - show_error_not_found and return unless @entry + (show_error_not_found; return) unless @entry @changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) @properties = @repository.properties(@path, @rev) end @@ -107,13 +107,13 @@ class RepositoriesController < ApplicationController def entry @entry = @repository.entry(@path, @rev) - show_error_not_found and return unless @entry - + (show_error_not_found; return) unless @entry + # If the entry is a dir, show the browser - show and return if @entry.is_dir? - + (show; return) if @entry.is_dir? + @content = @repository.cat(@path, @rev) - show_error_not_found and return unless @content + (show_error_not_found; return) unless @content if 'raw' == params[:format] || @content.is_binary_data? || (@entry.size && @entry.size > Setting.file_max_size_displayed.to_i.kilobyte) # Force the download send_data @content, :filename => @path.split('/').last @@ -125,10 +125,10 @@ class RepositoriesController < ApplicationController def annotate @entry = @repository.entry(@path, @rev) - show_error_not_found and return unless @entry + (show_error_not_found; return) unless @entry @annotate = @repository.scm.annotate(@path, @rev) - render_error l(:error_scm_annotate) and return if @annotate.nil? || @annotate.empty? + (render_error l(:error_scm_annotate); return) if @annotate.nil? || @annotate.empty? end def revision @@ -146,7 +146,7 @@ class RepositoriesController < ApplicationController def diff if params[:format] == 'diff' @diff = @repository.diff(@path, @rev, @rev_to) - show_error_not_found and return unless @diff + (show_error_not_found; return) unless @diff filename = "changeset_r#{@rev}" filename << "_r#{@rev_to}" if @rev_to send_data @diff.join, :filename => "#{filename}.diff", @@ -199,7 +199,7 @@ private def find_repository @project = Project.find(params[:id]) @repository = @project.repository - render_404 and return false unless @repository + (render_404; return false) unless @repository @path = params[:path].join('/') unless params[:path].nil? @path ||= '' @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].strip diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index 4355141c7..c08815890 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -209,7 +209,7 @@ class TimelogController < ApplicationController end def edit - render_403 and return if @time_entry && !@time_entry.editable_by?(User.current) + (render_403; return) if @time_entry && !@time_entry.editable_by?(User.current) @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today) @time_entry.attributes = params[:time_entry] @@ -223,8 +223,8 @@ class TimelogController < ApplicationController end def destroy - render_404 and return unless @time_entry - render_403 and return unless @time_entry.editable_by?(User.current) + (render_404; return) unless @time_entry + (render_403; return) unless @time_entry.editable_by?(User.current) @time_entry.destroy flash[:notice] = l(:notice_successful_delete) redirect_to :back diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 63382f81c..782f939d6 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -183,7 +183,8 @@ class WikiController < ApplicationController return else # requested special page doesn't exist, redirect to default page - redirect_to :action => 'index', :id => @project, :page => nil and return + redirect_to :action => 'index', :id => @project, :page => nil + return end render :action => "special_#{page_title}" end -- 2.39.5