Commit c1362b0210defb8ee7461d7b06db23af7f5fb611

Authored by Rafael Manzo
1 parent 869ef774

RepositoriesController#show simplified

Showing 1 changed file with 11 additions and 7 deletions   Show diff stats
app/controllers/repositories_controller.rb
... ... @@ -13,13 +13,7 @@ class RepositoriesController < ApplicationController
13 13 def show
14 14 @configuration = KalibroEntities::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this!
15 15 @processing = @repository.last_processing
16   - if @processing.ready?
17   - if params[:module_result_id].nil?
18   - @root_module_result = @processing.root_module_result
19   - else
20   - @root_module_result = ModuleResult.find(params[:module_result_id].to_i)
21   - end
22   - end
  16 + set_root_module_result if @processing.ready?
23 17 end
24 18  
25 19 # GET projects/1/repositories/new
... ... @@ -78,6 +72,16 @@ class RepositoriesController < ApplicationController
78 72 end
79 73  
80 74 private
  75 + # Reducing show action cyclomatic complexity
  76 + def set_root_module_result
  77 + if params[:module_result_id].nil?
  78 + @root_module_result = @processing.root_module_result
  79 + else
  80 + @root_module_result = ModuleResult.find(params[:module_result_id].to_i)
  81 + end
  82 + end
  83 +
  84 + # Duplicated code on create and update actions extracted here
81 85 def failed_action(format, destiny_action)
82 86 @project_id = params[:project_id]
83 87 @repository_types = Repository.repository_types
... ...