estimancy/projestimate

View on GitHub
app/controllers/projects_controller.rb

Summary

Maintainability
F
3 wks
Test Coverage

File projects_controller.rb has 1532 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class ProjectsController < ApplicationController
  include WbsActivityElementsHelper
  include ModuleProjectsHelper
  include ProjectsHelper
  include PemoduleEstimationMethods
Severity: Major
Found in app/controllers/projects_controller.rb - About 4 days to fix

    Method update has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring.
    Open

      def update
        set_page_title 'Edit estimation'
        @project = Project.find(params[:id])
        @organization = @project.organization
    
    
    Severity: Minor
    Found in app/controllers/projects_controller.rb - About 1 day to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method duplicate has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
    Open

      def duplicate
        # To duplicate a project user need to have the "show_project" and "create_project_from_scratch" authorizations
        if params[:action_name] == "duplication"
          authorize! :create_project_from_scratch, Project
          # To Create a project from a template user need to have "create_project_from_template" authorization
    Severity: Minor
    Found in app/controllers/projects_controller.rb - About 1 day to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Class ProjectsController has 59 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class ProjectsController < ApplicationController
      include WbsActivityElementsHelper
      include ModuleProjectsHelper
      include ProjectsHelper
      include PemoduleEstimationMethods
    Severity: Major
    Found in app/controllers/projects_controller.rb - About 1 day to fix

      Method checkout has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

        def checkout
          old_prj = Project.find(params[:project_id])
      
          authorize! :commit_project, old_prj
      
      
      Severity: Minor
      Found in app/controllers/projects_controller.rb - About 6 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method save_estimation_results has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
      Open

        def save_estimation_results(start_module_project, input_attributes, output_data)
          #@project = current_project
          authorize! :execute_estimation_plan, @project
      
          @pbs_project_element = current_component
      Severity: Minor
      Found in app/controllers/projects_controller.rb - About 6 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method update has 138 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def update
          set_page_title 'Edit estimation'
          @project = Project.find(params[:id])
          @organization = @project.organization
      
      
      Severity: Major
      Found in app/controllers/projects_controller.rb - About 5 hrs to fix

        Method create has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            @is_model = params[:project][:is_model]
            if @is_model == "true"
              authorize! :manage_estimation_models, Project
            else
        Severity: Minor
        Found in app/controllers/projects_controller.rb - About 5 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method update_views_and_widgets has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

          def update_views_and_widgets(new_prj, old_mp, new_mp)
            #For initialization module level
            if old_mp.pemodule.alias == Projestimate::Application::INITIALIZATION
              #Copy the views and widgets for the new project
              new_view = View.create(organization_id: new_prj.organization_id, name: "#{new_prj.to_s} : view for #{new_mp.to_s}", description: "Please rename the view's name and description if needed.")
        Severity: Minor
        Found in app/controllers/projects_controller.rb - About 4 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method dashboard has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

          def dashboard
            authorize! :show_project, @project
        
            # return if user doesn't have the rigth to consult the estimation
            if !can_show_estimation?(@project)
        Severity: Minor
        Found in app/controllers/projects_controller.rb - About 4 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method duplicate has 109 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def duplicate
            # To duplicate a project user need to have the "show_project" and "create_project_from_scratch" authorizations
            if params[:action_name] == "duplication"
              authorize! :create_project_from_scratch, Project
              # To Create a project from a template user need to have "create_project_from_template" authorization
        Severity: Major
        Found in app/controllers/projects_controller.rb - About 4 hrs to fix

          Method destroy has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

            def destroy
              @project = Project.find(params[:id])
              authorize! :delete_project, @project
          
              is_model = @project.is_model
          Severity: Minor
          Found in app/controllers/projects_controller.rb - About 4 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method dashboard has 104 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def dashboard
              authorize! :show_project, @project
          
              # return if user doesn't have the rigth to consult the estimation
              if !can_show_estimation?(@project)
          Severity: Major
          Found in app/controllers/projects_controller.rb - About 4 hrs to fix

            Method checkout has 90 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def checkout
                old_prj = Project.find(params[:project_id])
            
                authorize! :commit_project, old_prj
            
            
            Severity: Major
            Found in app/controllers/projects_controller.rb - About 3 hrs to fix

              Method append_pemodule has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                def append_pemodule
                  @project = Project.find(params[:project_id])
                  @pemodule = Pemodule.find(params[:module_selected].split(',').last.to_i)
              
                  authorize! :alter_estimation_plan, @project
              Severity: Minor
              Found in app/controllers/projects_controller.rb - About 3 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method create has 76 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def create
                  @is_model = params[:project][:is_model]
                  if @is_model == "true"
                    authorize! :manage_estimation_models, Project
                  else
              Severity: Major
              Found in app/controllers/projects_controller.rb - About 3 hrs to fix

                Method save_estimation_results has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def save_estimation_results(start_module_project, input_attributes, output_data)
                    #@project = current_project
                    authorize! :execute_estimation_plan, @project
                
                    @pbs_project_element = current_component
                Severity: Major
                Found in app/controllers/projects_controller.rb - About 2 hrs to fix

                  Method append_pemodule has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def append_pemodule
                      @project = Project.find(params[:project_id])
                      @pemodule = Pemodule.find(params[:module_selected].split(',').last.to_i)
                  
                      authorize! :alter_estimation_plan, @project
                  Severity: Major
                  Found in app/controllers/projects_controller.rb - About 2 hrs to fix

                    Method edit has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def edit
                        set_page_title 'Edit estimation'
                    
                        @project = Project.find(params[:id])
                        @organization = @project.organization
                    Severity: Minor
                    Found in app/controllers/projects_controller.rb - About 2 hrs to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method edit has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def edit
                        set_page_title 'Edit estimation'
                    
                        @project = Project.find(params[:id])
                        @organization = @project.organization
                    Severity: Minor
                    Found in app/controllers/projects_controller.rb - About 1 hr to fix

                      Method collapse_project_version has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def collapse_project_version
                          projects = Project.find_all_by_id(params[:project_ids])
                          flash_error = ""
                          Project.transaction do
                            projects.each do |project|
                      Severity: Minor
                      Found in app/controllers/projects_controller.rb - About 1 hr to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Method add_wbs_activity_to_project has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def add_wbs_activity_to_project
                          @project = Project.find(params[:project_id])
                      
                          @pe_wbs_project_activity = @project.pe_wbs_projects.activities_wbs.first
                          @wbs_project_elements_root = @project.wbs_project_element_root
                      Severity: Minor
                      Found in app/controllers/projects_controller.rb - About 1 hr to fix

                        Method set_element_value_with_activities has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def set_element_value_with_activities(estimation_result, module_project)
                            authorize! :execute_estimation_plan, @project
                        
                            result_with_consistency = Hash.new
                            consistency = true
                        Severity: Minor
                        Found in app/controllers/projects_controller.rb - About 1 hr to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Method add_wbs_activity_to_project has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def add_wbs_activity_to_project
                            @project = Project.find(params[:project_id])
                        
                            @pe_wbs_project_activity = @project.pe_wbs_projects.activities_wbs.first
                            @wbs_project_elements_root = @project.wbs_project_element_root
                        Severity: Minor
                        Found in app/controllers/projects_controller.rb - About 1 hr to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Method collapse_project_version has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def collapse_project_version
                            projects = Project.find_all_by_id(params[:project_ids])
                            flash_error = ""
                            Project.transaction do
                              projects.each do |project|
                        Severity: Minor
                        Found in app/controllers/projects_controller.rb - About 1 hr to fix

                          Method set_project_version has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def set_project_version(project_to_checkout)
                              #No authorize is required as method is private and could not be accessed by any route
                              new_version = ''
                              parent_version = project_to_checkout.version
                          
                          
                          Severity: Minor
                          Found in app/controllers/projects_controller.rb - About 1 hr to fix

                            Method show_project_history has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def show_project_history
                                #No authorize required as authorizations are manage  in each called function...
                                @counter = params['counter']
                                checked_node_ids = params['checked_node_ids']
                                action_id = params['action_id']
                            Severity: Minor
                            Found in app/controllers/projects_controller.rb - About 1 hr to fix

                              Method add_filter_on_project_version has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def add_filter_on_project_version
                                  #No authorize required
                                  selected_filter_version = params[:filter_selected]
                                  #"Display leaves projects only",1], ["Display all versions",2], ["Display root version only",3], ["Most recent version",4]
                              
                              
                              Severity: Minor
                              Found in app/controllers/projects_controller.rb - About 1 hr to fix

                                Method find_use_project has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def find_use_project
                                    @project = Project.find(params[:project_id])
                                    authorize! :show_project, @project
                                
                                    @related_projects = Array.new
                                Severity: Minor
                                Found in app/controllers/projects_controller.rb - About 1 hr to fix

                                Cognitive Complexity

                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                A method's cognitive complexity is based on a few simple rules:

                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                • Code is considered more complex for each "break in the linear flow of the code"
                                • Code is considered more complex when "flow breaking structures are nested"

                                Further reading

                                Method show has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def show
                                    @project = Project.find(params[:id])
                                
                                    @organization = @project.organization
                                
                                
                                Severity: Minor
                                Found in app/controllers/projects_controller.rb - About 1 hr to fix

                                  Method update_views_and_widgets has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    def update_views_and_widgets(new_prj, old_mp, new_mp)
                                      #For initialization module level
                                      if old_mp.pemodule.alias == Projestimate::Application::INITIALIZATION
                                        #Copy the views and widgets for the new project
                                        new_view = View.create(organization_id: new_prj.organization_id, name: "#{new_prj.to_s} : view for #{new_mp.to_s}", description: "Please rename the view's name and description if needed.")
                                  Severity: Minor
                                  Found in app/controllers/projects_controller.rb - About 1 hr to fix

                                    Method destroy has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      def destroy
                                        @project = Project.find(params[:id])
                                        authorize! :delete_project, @project
                                    
                                        is_model = @project.is_model
                                    Severity: Minor
                                    Found in app/controllers/projects_controller.rb - About 1 hr to fix

                                      Method update_organization_estimation_statuses has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                        def update_organization_estimation_statuses
                                          @estimation_statuses = []
                                      
                                          unless params[:project_organization_id].nil? || params[:project_organization_id].blank?
                                            @organization = Organization.find(params[:project_organization_id])
                                      Severity: Minor
                                      Found in app/controllers/projects_controller.rb - About 1 hr to fix

                                      Cognitive Complexity

                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                      A method's cognitive complexity is based on a few simple rules:

                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                      • Code is considered more complex for each "break in the linear flow of the code"
                                      • Code is considered more complex when "flow breaking structures are nested"

                                      Further reading

                                      Method set_project_version has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                        def set_project_version(project_to_checkout)
                                          #No authorize is required as method is private and could not be accessed by any route
                                          new_version = ''
                                          parent_version = project_to_checkout.version
                                      
                                      
                                      Severity: Minor
                                      Found in app/controllers/projects_controller.rb - About 1 hr to fix

                                      Cognitive Complexity

                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                      A method's cognitive complexity is based on a few simple rules:

                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                      • Code is considered more complex for each "break in the linear flow of the code"
                                      • Code is considered more complex when "flow breaking structures are nested"

                                      Further reading

                                      Method render_selected_wbs_activity_elements has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        def render_selected_wbs_activity_elements
                                          @project = Project.find(params[:project_id])
                                          authorize! :edit_project, @project
                                      
                                          @pe_wbs_project_activity = @project.pe_wbs_projects.activities_wbs.first
                                      Severity: Minor
                                      Found in app/controllers/projects_controller.rb - About 1 hr to fix

                                        Method confirm_deletion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          def confirm_deletion
                                            @project = Project.find(params[:project_id])
                                            authorize! :delete_project, @project
                                        
                                            @from_tree_history_view = params[:from_tree_history_view]
                                        Severity: Minor
                                        Found in app/controllers/projects_controller.rb - About 45 mins to fix

                                        Cognitive Complexity

                                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                        A method's cognitive complexity is based on a few simple rules:

                                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                        • Code is considered more complex for each "break in the linear flow of the code"
                                        • Code is considered more complex when "flow breaking structures are nested"

                                        Further reading

                                        Avoid deeply nested control flow statements.
                                        Open

                                                      redirect_to (is_model ? organization_setting_path(@current_organization, anchor: "tabs-estimation-models") : organization_estimations_path(@current_organization))
                                        Severity: Major
                                        Found in app/controllers/projects_controller.rb - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                      unless @project.organization.attribute_organizations.nil?
                                                        @project.organization.attribute_organizations.each do |am|
                                                          ['input', 'output'].each do |in_out|
                                                            mpa = EstimationValue.create(:pe_attribute_id => am.pe_attribute.id, :module_project_id => cap_module_project.id, :in_out => in_out,
                                                                                         :is_mandatory => am.is_mandatory, :description => am.pe_attribute.description, :display_order => nil,
                                          Severity: Major
                                          Found in app/controllers/projects_controller.rb - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                          estimation_value_id = new_estimation_value.nil? ? nil : new_estimation_value.id
                                            Severity: Major
                                            Found in app/controllers/projects_controller.rb - About 45 mins to fix

                                              Avoid deeply nested control flow statements.
                                              Open

                                                            unless pf.nil?
                                                              pf.views_widget_id = new_view_widget.id
                                                              pf.save
                                                            end
                                              Severity: Major
                                              Found in app/controllers/projects_controller.rb - About 45 mins to fix

                                                Method add_filter_on_project_version has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                Open

                                                  def add_filter_on_project_version
                                                    #No authorize required
                                                    selected_filter_version = params[:filter_selected]
                                                    #"Display leaves projects only",1], ["Display all versions",2], ["Display root version only",3], ["Most recent version",4]
                                                
                                                
                                                Severity: Minor
                                                Found in app/controllers/projects_controller.rb - About 45 mins to fix

                                                Cognitive Complexity

                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                A method's cognitive complexity is based on a few simple rules:

                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                • Code is considered more complex when "flow breaking structures are nested"

                                                Further reading

                                                Avoid deeply nested control flow statements.
                                                Open

                                                          elsif !project_organization.nil?
                                                
                                                            # project's organization is deleted and none one is selected
                                                            if @project.organization.nil?
                                                              cap_module_project.estimation_values.delete_all
                                                Severity: Major
                                                Found in app/controllers/projects_controller.rb - About 45 mins to fix

                                                  Consider simplifying this complex logical expression.
                                                  Open

                                                      if (@project.is_model && can?(:manage_estimation_models, Project)) || (!@project.is_model && (can?(:edit_project, @project) || can_alter_estimation?(@project))) # Have the write access to project
                                                  
                                                        @product_name = params[:project][:product_name]
                                                        project_root = @project.root_component
                                                        project_root_name = "#{@product_name.blank? ? @project.title : @product_name}"
                                                  Severity: Major
                                                  Found in app/controllers/projects_controller.rb - About 40 mins to fix

                                                    Method run_estimation_plan has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                    Open

                                                      def run_estimation_plan(input_data, pbs_project_element_id, level, project, current_mp_to_execute)
                                                    Severity: Minor
                                                    Found in app/controllers/projects_controller.rb - About 35 mins to fix

                                                      Method enable_update_in_local? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                        def enable_update_in_local?
                                                          #No authorize required since this method is protected and won't be call from route
                                                          if is_master_instance?
                                                            true
                                                          else
                                                      Severity: Minor
                                                      Found in app/controllers/projects_controller.rb - About 35 mins to fix

                                                      Cognitive Complexity

                                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                      A method's cognitive complexity is based on a few simple rules:

                                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                      • Code is considered more complex for each "break in the linear flow of the code"
                                                      • Code is considered more complex when "flow breaking structures are nested"

                                                      Further reading

                                                      Method update_comments_status_change has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                        def update_comments_status_change
                                                          @project = Project.find(params[:project_id])
                                                      
                                                          new_comments = ""
                                                          auto_updated_comments = ""
                                                      Severity: Minor
                                                      Found in app/controllers/projects_controller.rb - About 35 mins to fix

                                                      Cognitive Complexity

                                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                      A method's cognitive complexity is based on a few simple rules:

                                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                      • Code is considered more complex for each "break in the linear flow of the code"
                                                      • Code is considered more complex when "flow breaking structures are nested"

                                                      Further reading

                                                      Method is_collapsible? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                        def is_collapsible?(project)
                                                          #No authorize is required
                                                          begin
                                                            if project.checkpoint?
                                                              if !project.is_root? && project.child_ids.length==1
                                                      Severity: Minor
                                                      Found in app/controllers/projects_controller.rb - About 35 mins to fix

                                                      Cognitive Complexity

                                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                      A method's cognitive complexity is based on a few simple rules:

                                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                      • Code is considered more complex for each "break in the linear flow of the code"
                                                      • Code is considered more complex when "flow breaking structures are nested"

                                                      Further reading

                                                      Method auto_update_status_comment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                        def auto_update_status_comment(project_id, new_status_id)
                                                          project = Project.find(project_id)
                                                          if project
                                                            # Get the project status before updating the value
                                                            last_estimation_status_name = project.estimation_status_id.nil? ? "" : project.estimation_status.name
                                                      Severity: Minor
                                                      Found in app/controllers/projects_controller.rb - About 35 mins to fix

                                                      Cognitive Complexity

                                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                      A method's cognitive complexity is based on a few simple rules:

                                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                      • Code is considered more complex for each "break in the linear flow of the code"
                                                      • Code is considered more complex when "flow breaking structures are nested"

                                                      Further reading

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                redirect_to redirect_apply(edit_project_path(@project, :anchor => session[:anchor]), nil, organization_estimations_path(@project.organization)) and return
                                                      Severity: Major
                                                      Found in app/controllers/projects_controller.rb - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                  redirect_to redirect_apply(edit_project_path(@project, :anchor => session[:anchor]), nil, organization_setting_path(@project.organization, anchor: "tabs-estimation-models")) and return
                                                        Severity: Major
                                                        Found in app/controllers/projects_controller.rb - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                redirect_to organization_estimations_path(@current_organization), :flash => {:error => I18n.t(:error_project_checkout_failed)} and return
                                                          Severity: Major
                                                          Found in app/controllers/projects_controller.rb - About 30 mins to fix

                                                            Method select_pbs_project_elements has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              def select_pbs_project_elements
                                                                #No authorize required
                                                                @project = Project.find(params[:project_id])
                                                                @module_projects = @project.module_projects
                                                                @initialization_module_project = @initialization_module.nil? ? nil : @module_projects.find_by_pemodule_id(@initialization_module.id)
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb - About 25 mins to fix

                                                            Cognitive Complexity

                                                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                            A method's cognitive complexity is based on a few simple rules:

                                                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                            • Code is considered more complex for each "break in the linear flow of the code"
                                                            • Code is considered more complex when "flow breaking structures are nested"

                                                            Further reading

                                                            Method load_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              def load_data
                                                                #No authorize required since this method protected and is used to load data and shared by the other one.
                                                                if params[:id]
                                                                  @project = Project.find(params[:id])
                                                                else
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb - About 25 mins to fix

                                                            Cognitive Complexity

                                                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                            A method's cognitive complexity is based on a few simple rules:

                                                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                            • Code is considered more complex for each "break in the linear flow of the code"
                                                            • Code is considered more complex when "flow breaking structures are nested"

                                                            Further reading

                                                            Method run_estimation_plan has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              def run_estimation_plan(input_data, pbs_project_element_id, level, project, current_mp_to_execute)
                                                                @project = project #current_project
                                                                authorize! :execute_estimation_plan, @project
                                                            
                                                                @result_hash = Hash.new
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb - About 25 mins to fix

                                                            Cognitive Complexity

                                                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                            A method's cognitive complexity is based on a few simple rules:

                                                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                            • Code is considered more complex for each "break in the linear flow of the code"
                                                            • Code is considered more complex when "flow breaking structures are nested"

                                                            Further reading

                                                            Method render_selected_wbs_activity_elements has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              def render_selected_wbs_activity_elements
                                                                @project = Project.find(params[:project_id])
                                                                authorize! :edit_project, @project
                                                            
                                                                @pe_wbs_project_activity = @project.pe_wbs_projects.activities_wbs.first
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb - About 25 mins to fix

                                                            Cognitive Complexity

                                                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                            A method's cognitive complexity is based on a few simple rules:

                                                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                            • Code is considered more complex for each "break in the linear flow of the code"
                                                            • Code is considered more complex when "flow breaking structures are nested"

                                                            Further reading

                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                            Open

                                                                  if old_mp.view
                                                                    old_mp_view_widgets = old_mp.view.views_widgets.all
                                                                    old_mp_view_widgets.each do |old_view_widget|
                                                                      new_view_widget_mp = ModuleProject.find_by_project_id_and_copy_id(new_prj.id, old_view_widget.module_project_id)
                                                                      new_view_widget_mp_id = new_view_widget_mp.nil? ? nil : new_view_widget_mp.id
                                                            Severity: Major
                                                            Found in app/controllers/projects_controller.rb and 1 other location - About 3 hrs to fix
                                                            app/models/project.rb on lines 348..368

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 125.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Identical blocks of code found in 6 locations. Consider refactoring.
                                                            Open

                                                                      ["input", "output"].each do |io|
                                                                        new_mp.pemodule.pe_attributes.each do |attr|
                                                                          old_prj.pbs_project_elements.each do |old_component|
                                                                            new_prj_components.each do |new_component|
                                                                              ev = new_mp.estimation_values.where(pe_attribute_id: attr.id, in_out: io).first
                                                            Severity: Major
                                                            Found in app/controllers/projects_controller.rb and 5 other locations - About 2 hrs to fix
                                                            app/controllers/organizations_controller.rb on lines 410..420
                                                            app/controllers/projects_controller.rb on lines 1580..1590
                                                            app/models/project.rb on lines 402..412
                                                            app/workers/organization_duplicate_project_worker.rb on lines 248..258
                                                            app/workers/organization_duplicate_project_worker.rb on lines 423..433

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 83.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Identical blocks of code found in 6 locations. Consider refactoring.
                                                            Open

                                                                    ["input", "output"].each do |io|
                                                                      new_mp.pemodule.pe_attributes.each do |attr|
                                                                        old_prj.pbs_project_elements.each do |old_component|
                                                                          new_prj_components.each do |new_component|
                                                                            ev = new_mp.estimation_values.where(pe_attribute_id: attr.id, in_out: io).first
                                                            Severity: Major
                                                            Found in app/controllers/projects_controller.rb and 5 other locations - About 2 hrs to fix
                                                            app/controllers/organizations_controller.rb on lines 410..420
                                                            app/controllers/projects_controller.rb on lines 1956..1966
                                                            app/models/project.rb on lines 402..412
                                                            app/workers/organization_duplicate_project_worker.rb on lines 248..258
                                                            app/workers/organization_duplicate_project_worker.rb on lines 423..433

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 83.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Identical blocks of code found in 4 locations. Consider refactoring.
                                                            Open

                                                                      new_mp.guw_unit_of_work_groups.each do |guw_group|
                                                                        new_pbs_project_element = new_prj_components.find_by_copy_id(guw_group.pbs_project_element_id)
                                                                        new_pbs_project_element_id = new_pbs_project_element.nil? ? nil : new_pbs_project_element.id
                                                                        guw_group.update_attribute(:pbs_project_element_id, new_pbs_project_element_id)
                                                            
                                                            
                                                            Severity: Major
                                                            Found in app/controllers/projects_controller.rb and 3 other locations - About 1 hr to fix
                                                            app/controllers/projects_controller.rb on lines 1557..1569
                                                            app/models/project.rb on lines 379..391
                                                            app/workers/organization_duplicate_project_worker.rb on lines 400..412

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 61.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Identical blocks of code found in 4 locations. Consider refactoring.
                                                            Open

                                                                    new_mp.guw_unit_of_work_groups.each do |guw_group|
                                                                      new_pbs_project_element = new_prj_components.find_by_copy_id(guw_group.pbs_project_element_id)
                                                                      new_pbs_project_element_id = new_pbs_project_element.nil? ? nil : new_pbs_project_element.id
                                                                      guw_group.update_attribute(:pbs_project_element_id, new_pbs_project_element_id)
                                                            
                                                            
                                                            Severity: Major
                                                            Found in app/controllers/projects_controller.rb and 3 other locations - About 1 hr to fix
                                                            app/controllers/projects_controller.rb on lines 1933..1945
                                                            app/models/project.rb on lines 379..391
                                                            app/workers/organization_duplicate_project_worker.rb on lines 400..412

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 61.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Identical blocks of code found in 3 locations. Consider refactoring.
                                                            Open

                                                                          @project.organization.attribute_organizations.each do |am|
                                                                            ['input', 'output'].each do |in_out|
                                                                              mpa = EstimationValue.create(:pe_attribute_id => am.pe_attribute.id,
                                                                                                           :module_project_id => cap_module_project.id,
                                                                                                           :in_out => in_out, :is_mandatory => am.is_mandatory,
                                                            Severity: Major
                                                            Found in app/controllers/projects_controller.rb and 2 other locations - About 1 hr to fix
                                                            app/controllers/projects_controller.rb on lines 361..371
                                                            app/controllers/projects_controller.rb on lines 605..611

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 58.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Identical blocks of code found in 3 locations. Consider refactoring.
                                                            Open

                                                                            @project.organization.attribute_organizations.each do |am|
                                                                              ['input', 'output'].each do |in_out|
                                                                                mpa = EstimationValue.create(:pe_attribute_id => am.pe_attribute.id,
                                                                                                             :module_project_id => cap_module_project.id,
                                                                                                             :in_out => in_out,
                                                            Severity: Major
                                                            Found in app/controllers/projects_controller.rb and 2 other locations - About 1 hr to fix
                                                            app/controllers/projects_controller.rb on lines 605..611
                                                            app/controllers/projects_controller.rb on lines 629..637

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 58.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Identical blocks of code found in 3 locations. Consider refactoring.
                                                            Open

                                                                          @project.organization.attribute_organizations.each do |am|
                                                                            ['input', 'output'].each do |in_out|
                                                                              mpa = EstimationValue.create(:pe_attribute_id => am.pe_attribute.id, :module_project_id => cap_module_project.id, :in_out => in_out,
                                                                                                           :is_mandatory => am.is_mandatory, :description => am.pe_attribute.description, :display_order => nil,
                                                                                                           :string_data_low => {:pe_attribute_name => am.pe_attribute.name, :default_low => ''},
                                                            Severity: Major
                                                            Found in app/controllers/projects_controller.rb and 2 other locations - About 1 hr to fix
                                                            app/controllers/projects_controller.rb on lines 361..371
                                                            app/controllers/projects_controller.rb on lines 629..637

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 58.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                            Open

                                                                  set_breadcrumbs "#{I18n.t(:estimation_models)}" => organization_setting_path(@organization, anchor: "tabs-estimation-models"), "#{@project} <span class='badge' style='background-color: #{@project.status_background_color}'>#{@project.status_name}</span>" => edit_project_path(@project)
                                                            
                                                                  if cannot?(:manage_estimation_models, Project)    # No write access to project
                                                                    if can_show_estimation?(@project)
                                                                      redirect_to(:action => 'show') and return
                                                            Severity: Major
                                                            Found in app/controllers/projects_controller.rb and 1 other location - About 1 hr to fix
                                                            app/controllers/projects_controller.rb on lines 473..480

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 52.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                            Open

                                                                  set_breadcrumbs "#{I18n.t(:estimation_models)}" => organization_setting_path(@organization, anchor: "tabs-estimation-models"), "#{@project} <span class='badge' style='background-color: #{@project.status_background_color}'>#{@project.status_name}</span>" => edit_project_path(@project)
                                                            
                                                                  if cannot?(:manage_estimation_models, Project)    # No write access to project
                                                                    if can_show_estimation?(@project)
                                                                      redirect_to(:action => 'show') and return
                                                            Severity: Major
                                                            Found in app/controllers/projects_controller.rb and 1 other location - About 1 hr to fix
                                                            app/controllers/projects_controller.rb on lines 406..413

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 52.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                            Open

                                                              def load_security_for_selected_user
                                                                #No authorize required
                                                                set_page_title 'Project securities'
                                                                @user = User.find(params[:user_id])
                                                                @project = Project.find(params[:project_id])
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb and 1 other location - About 55 mins to fix
                                                            app/controllers/projects_controller.rb on lines 819..830

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 46.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                            Open

                                                              def load_security_for_selected_group
                                                                #No authorize required
                                                                set_page_title 'Project securities'
                                                                @group = Group.find(params[:group_id])
                                                                @project = Project.find(params[:project_id])
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb and 1 other location - About 55 mins to fix
                                                            app/controllers/projects_controller.rb on lines 802..813

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 46.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                            Open

                                                                    unless params["user_securities_from_model"].nil?
                                                                      params["user_securities_from_model"].each do |psl|
                                                                        params["user_securities_from_model"][psl.first].each do |group|
                                                                          ProjectSecurity.create(user_id: group.first.to_i,
                                                                                                 project_id: @project.id,
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb and 1 other location - About 35 mins to fix
                                                            app/controllers/projects_controller.rb on lines 543..549

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 35.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                            Open

                                                                    unless params["group_securities_from_model"].nil?
                                                                      params["group_securities_from_model"].each do |psl|
                                                                        params["group_securities_from_model"][psl.first].each do |group|
                                                                          ProjectSecurity.create(group_id: group.first.to_i,
                                                                                                 project_id: @project.id,
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb and 1 other location - About 35 mins to fix
                                                            app/controllers/projects_controller.rb on lines 554..560

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 35.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                            Open

                                                              def update_project_security_level_group
                                                                #TODO check if No authorize is required
                                                                set_page_title 'Project securities'
                                                                @group = Group.find(params[:group_id].to_i)
                                                                @prj_scrt = ProjectSecurity.find_by_group_id_and_project_id(@group.id, @project.id)
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb and 1 other location - About 35 mins to fix
                                                            app/controllers/projects_controller.rb on lines 836..844

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 34.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                            Open

                                                              def update_project_security_level
                                                                #TODO check if No authorize is required
                                                                set_page_title 'Project securities'
                                                                @user = User.find(params[:user_id].to_i)
                                                                @prj_scrt = ProjectSecurity.find_by_user_id_and_project_id(@user.id, @project.id)
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb and 1 other location - About 35 mins to fix
                                                            app/controllers/projects_controller.rb on lines 849..857

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 34.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 3 locations. Consider refactoring.
                                                            Open

                                                              def enable_update_in_local?
                                                                #No authorize required since this method is protected and won't be call from route
                                                                if is_master_instance?
                                                                  true
                                                                else
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb and 2 other locations - About 30 mins to fix
                                                            app/controllers/wbs_activities_controller.rb on lines 447..462
                                                            app/controllers/wbs_activity_ratios_controller.rb on lines 174..188

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 33.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                            Open

                                                                      @result_hash["#{est_val.pe_attribute.alias}_#{current_mp_to_execute.id}".to_sym] = cm.send("get_#{est_val.pe_attribute.alias}", project.id, current_mp_to_execute.id, pbs_project_element_id, level)
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb and 1 other location - About 15 mins to fix
                                                            app/controllers/projects_controller.rb on lines 1397..1397

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 25.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                            Open

                                                                  @result_hash["#{balancing_attr_est_values.pe_attribute.alias}_#{current_mp_to_execute.id}".to_sym] = cm.send("get_#{balancing_attr_est_values.pe_attribute.alias}", project.id, current_mp_to_execute.id, pbs_project_element_id, level)
                                                            Severity: Minor
                                                            Found in app/controllers/projects_controller.rb and 1 other location - About 15 mins to fix
                                                            app/controllers/projects_controller.rb on lines 1412..1412

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 25.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            There are no issues that match your filters.

                                                            Category
                                                            Status