diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index e45bf83..00269b2 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -13,13 +13,7 @@ class RepositoriesController < ApplicationController def show @configuration = KalibroEntities::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this! @processing = @repository.last_processing - if @processing.ready? - if params[:module_result_id].nil? - @root_module_result = @processing.root_module_result - else - @root_module_result = ModuleResult.find(params[:module_result_id].to_i) - end - end + set_root_module_result if @processing.ready? end # GET projects/1/repositories/new @@ -78,6 +72,16 @@ class RepositoriesController < ApplicationController end private + # Reducing show action cyclomatic complexity + def set_root_module_result + if params[:module_result_id].nil? + @root_module_result = @processing.root_module_result + else + @root_module_result = ModuleResult.find(params[:module_result_id].to_i) + end + end + + # Duplicated code on create and update actions extracted here def failed_action(format, destiny_action) @project_id = params[:project_id] @repository_types = Repository.repository_types -- libgit2 0.21.2