]> source.dussan.org Git - redmine.git/commitdiff
Removes "xxx and return" calls (#4446).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 18 Dec 2009 14:22:18 +0000 (14:22 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 18 Dec 2009 14:22:18 +0000 (14:22 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3185 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/account_controller.rb
app/controllers/application_controller.rb
app/controllers/custom_fields_controller.rb
app/controllers/issues_controller.rb
app/controllers/journals_controller.rb
app/controllers/messages_controller.rb
app/controllers/my_controller.rb
app/controllers/repositories_controller.rb
app/controllers/timelog_controller.rb
app/controllers/wiki_controller.rb

index 17d113887373cb8cc5daa50d06df6e7542f3fbcc..674045f73c21416f0effa40d157ab4093e507e42 100644 (file)
@@ -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
index 144ccdd573898ada31e41dc156458d7c67840eae..75f7121f2897e7b94fe1861523b84db256cfd099 100644 (file)
@@ -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
index ec16be566f142e4643a36b334227459247a00784..e8e9e49479da0143b53b472aadd09f5010674622 100644 (file)
@@ -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)
index 512293428602f9f3bc83cbdd43f0368c61daba70..0cb815bec39a3a630a6c8e40f197d90a265186c5 100644 (file)
@@ -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
index d479855f2c4455a6802e2bc02364c6c71cc25c1d..e9fe9099de2e536751f506ad38ce76763d9d7bfc 100644 (file)
@@ -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
index 437d1a291cce6b0c5439668f62829dc73ad26d12..fe545194462feea0b04f7a28b1e75eeaf7953cde 100644 (file)
@@ -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 } :
index fdf509544c65771f97a084b9af6380075fb926cf..8d1405b87da2fc15fb24e522b738b71e4dc26de3 100644 (file)
@@ -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 }
index 8e39d42c7fd892595d7ca1fde2997be938b96890..745159ec71a466c987fc74981ce2a6dbc571e787 100644 (file)
@@ -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
index 4355141c7b89c5efac25a93413b16c3abb71cf2e..c08815890d06cea21e6131afbda7998b2530edb2 100644 (file)
@@ -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
index 63382f81c015214db005ce9d3848904f6e90fd6e..782f939d641629163d2b59629d3d2858281a3178 100644 (file)
@@ -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