estimancy/projestimate

View on GitHub
app/models/project.rb

Summary

Maintainability
F
3 days
Test Coverage

Method execute_duplication_SAVE_NOT_WORKING has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
Open

  def self.execute_duplication_SAVE_NOT_WORKING(project_id, parameters, create_from_template = nil)
    #Project.transaction do
      begin
        old_prj = Project.find(project_id)

Severity: Minor
Found in app/models/project.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 execute_duplication_SAVE_NOT_WORKING has 107 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.execute_duplication_SAVE_NOT_WORKING(project_id, parameters, create_from_template = nil)
    #Project.transaction do
      begin
        old_prj = Project.find(project_id)

Severity: Major
Found in app/models/project.rb - About 4 hrs to fix

    File project.rb has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Project < ActiveRecord::Base
      attr_accessible :title, :description, :version, :alias, :state, :estimation_status_id, :status_comment,
                      :start_date, :is_model, :organization_id, :project_area_id, :project_category_id,
                      :acquisition_category_id, :platform_category_id, :parent_id
    
    
    Severity: Minor
    Found in app/models/project.rb - About 2 hrs to fix

      Avoid deeply nested control flow statements.
      Open

                          unless pf.nil?
                            pf.views_widget_id = widget_copy.id
                            pf.save
                          end
      Severity: Major
      Found in app/models/project.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/models/project.rb - About 45 mins to fix

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

            def project_estimation_statuses(organization=nil)
              if new_record? || self.estimation_status.nil? #|| !self.organization.estimation_statuses.include?(self.estimation_status)
                # For new record
                if organization.nil?
                  nil
          Severity: Minor
          Found in app/models/project.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 |view_widget|
                          new_view_widget_mp = ModuleProject.find_by_project_id_and_copy_id(new_prj.id, 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/models/project.rb and 1 other location - About 3 hrs to fix
          app/controllers/projects_controller.rb on lines 1427..1447

          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/models/project.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/controllers/projects_controller.rb on lines 1956..1966
          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/models/project.rb and 3 other locations - About 1 hr to fix
          app/controllers/projects_controller.rb on lines 1557..1569
          app/controllers/projects_controller.rb on lines 1933..1945
          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_prj_components.each do |new_c|
                      new_ancestor_ids_list = []
                      new_c.ancestor_ids.each do |ancestor_id|
                        ancestor_id = PbsProjectElement.find_by_pe_wbs_project_id_and_copy_id(new_c.pe_wbs_project_id, ancestor_id).id
                        new_ancestor_ids_list.push(ancestor_id)
          Severity: Minor
          Found in app/models/project.rb and 3 other locations - About 25 mins to fix
          app/controllers/organizations_controller.rb on lines 234..241
          app/workers/organization_duplicate_project_worker.rb on lines 73..80
          app/workers/organization_duplicate_project_worker.rb on lines 305..312

          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 30.

          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