estimancy/projestimate

View on GitHub
app/helpers/views_widgets_helper.rb

Summary

Maintainability
F
1 wk
Test Coverage

Method get_view_widget_data has a Cognitive Complexity of 188 (exceeds 5 allowed). Consider refactoring.
Open

  def get_view_widget_data(module_project_id, view_widget_id)

    # General data
    view_widget = ViewsWidget.find(view_widget_id)
    pbs_project_elt = current_component
Severity: Minor
Found in app/helpers/views_widgets_helper.rb - About 3 days 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 display_effort_or_cost_per_phase has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

  def display_effort_or_cost_per_phase(pbs_project_element, module_project_id, estimation_value, view_widget_id)
    res = String.new
    view_widget = ViewsWidget.find(view_widget_id)

    module_project = ModuleProject.find(module_project_id)
Severity: Minor
Found in app/helpers/views_widgets_helper.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 get_view_widget_data has 214 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def get_view_widget_data(module_project_id, view_widget_id)

    # General data
    view_widget = ViewsWidget.find(view_widget_id)
    pbs_project_elt = current_component
Severity: Major
Found in app/helpers/views_widgets_helper.rb - About 1 day to fix

    File views_widgets_helper.rb has 478 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ViewsWidgetsHelper
    
      # Get the label widget data
      def get_label_widget_data(view_widget_id)
        view_widget = ViewsWidget.find(view_widget_id)
    Severity: Minor
    Found in app/helpers/views_widgets_helper.rb - About 7 hrs to fix

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

        def get_chart_data_by_phase_and_profile(pbs_project_element, module_project, estimation_value, view_widget)
          result = String.new
          stacked_data = Array.new
          profiles_wbs_data = Hash.new
          probable_est_value = estimation_value.send("string_data_probable")
      Severity: Minor
      Found in app/helpers/views_widgets_helper.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 display_effort_or_cost_per_phase has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def display_effort_or_cost_per_phase(pbs_project_element, module_project_id, estimation_value, view_widget_id)
          res = String.new
          view_widget = ViewsWidget.find(view_widget_id)
      
          module_project = ModuleProject.find(module_project_id)
      Severity: Major
      Found in app/helpers/views_widgets_helper.rb - About 3 hrs to fix

        Method get_chart_data_by_phase_and_profile has 82 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def get_chart_data_by_phase_and_profile(pbs_project_element, module_project, estimation_value, view_widget)
            result = String.new
            stacked_data = Array.new
            profiles_wbs_data = Hash.new
            probable_est_value = estimation_value.send("string_data_probable")
        Severity: Major
        Found in app/helpers/views_widgets_helper.rb - About 3 hrs to fix

          Method get_chart_data_effort_and_cost has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_chart_data_effort_and_cost(pbs_project_element, module_project, estimation_value, view_widget)
              chart_data = []
              effort_breakdown_stacked_bar_dataset = {}
          
              return chart_data if (!module_project.pemodule.alias.eql?(Projestimate::Application::EFFORT_BREAKDOWN) || estimation_value.nil?)
          Severity: Minor
          Found in app/helpers/views_widgets_helper.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 get_label_widget_data has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def get_label_widget_data(view_widget_id)
              view_widget = ViewsWidget.find(view_widget_id)
              widget_data = {}
              initial_width = 60;  initial_height = 60
              value_to_show = nil # according to the widget type
          Severity: Minor
          Found in app/helpers/views_widgets_helper.rb - About 1 hr to fix

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

              def get_label_widget_data(view_widget_id)
                view_widget = ViewsWidget.find(view_widget_id)
                widget_data = {}
                initial_width = 60;  initial_height = 60
                value_to_show = nil # according to the widget type
            Severity: Minor
            Found in app/helpers/views_widgets_helper.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 get_chart_data_effort_and_cost has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def get_chart_data_effort_and_cost(pbs_project_element, module_project, estimation_value, view_widget)
                chart_data = []
                effort_breakdown_stacked_bar_dataset = {}
            
                return chart_data if (!module_project.pemodule.alias.eql?(Projestimate::Application::EFFORT_BREAKDOWN) || estimation_value.nil?)
            Severity: Minor
            Found in app/helpers/views_widgets_helper.rb - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                              if d.nil?
                                dh = 1.hours
                              else
                                dh = d.hours
                              end
              Severity: Major
              Found in app/helpers/views_widgets_helper.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                str_data_probable.nil? ? nil : (dev = str_data_probable[element.id])
                Severity: Major
                Found in app/helpers/views_widgets_helper.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                value_to_show =  raw estimation_value.nil? ? "#{ content_tag(:div, I18n.t(:notice_no_estimation_saved), :class => 'no_estimation_value')}" : display_effort_or_cost_per_phase(pbs_project_elt, module_project, estimation_value, view_widget_id)
                  Severity: Major
                  Found in app/helpers/views_widgets_helper.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                    rescue
                                      is_ok = false
                    Severity: Major
                    Found in app/helpers/views_widgets_helper.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                        if wbs_profiles_value.nil?
                                          profiles_wbs_data["profile_id_#{profile.id}"]["#{wbs_activity_elt.name}"] = 0
                                        else
                                          value = number_with_delimiter(wbs_profiles_value.round(estimation_value.pe_attribute.precision.nil? ? user_number_precision : estimation_value.pe_attribute.precision))
                                          profiles_wbs_data["profile_id_#{profile.id}"]["#{wbs_activity_elt.name}"] = value
                      Severity: Major
                      Found in app/helpers/views_widgets_helper.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                    unless estimation_value.pe_attribute.alias == "ratio" || estimation_value.pe_attribute.alias == "ratio_name"
                                      wbs_activity_elt_root = module_project.wbs_activity.wbs_activity_elements.first.root
                        
                                      wbs_data_low = data_low.nil? ? nil : data_low
                                      wbs_data_high = data_high.nil? ? nil : data_high
                        Severity: Major
                        Found in app/helpers/views_widgets_helper.rb - About 45 mins to fix

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

                                    if level_estimation_values.nil? || level_estimation_values[pbs_project_element.id].nil? || level_estimation_values[pbs_project_element.id][wbs_activity_elt.id].nil? || level_estimation_values[pbs_project_element.id][wbs_activity_elt.id][:value].nil?
                                      chart_data << ["#{wbs_activity_elt.name}", 0]
                                    else
                                      wbs_value = level_estimation_values[pbs_project_element.id][wbs_activity_elt.id][:value]
                                      chart_data << ["#{wbs_activity_elt.name}", wbs_value.round(user_number_precision)]
                          Severity: Minor
                          Found in app/helpers/views_widgets_helper.rb and 2 other locations - About 20 mins to fix
                          app/helpers/projects_helper.rb on lines 290..294
                          app/helpers/projects_helper.rb on lines 316..320

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

                          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 2 locations. Consider refactoring.
                          Open

                                  icon_font_size = ((height+width)/2) * 0.025
                                  if icon_font_size > 3 && icon_font_size < 6
                                    icon_font_size = 3 #4
                                  elsif icon_font_size > 6
                                    icon_font_size = 4 #5
                          Severity: Minor
                          Found in app/helpers/views_widgets_helper.rb and 1 other location - About 15 mins to fix
                          app/helpers/views_widgets_helper.rb on lines 57..62

                          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

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

                                  icon_font_size = ((height+width)/2) * 0.025
                                  if icon_font_size > 3 && icon_font_size < 6
                                    icon_font_size = 3
                                  elsif icon_font_size > 6
                                    icon_font_size = 4
                          Severity: Minor
                          Found in app/helpers/views_widgets_helper.rb and 1 other location - About 15 mins to fix
                          app/helpers/views_widgets_helper.rb on lines 127..132

                          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

                                unless level.eql?("probable")
                                  pbs_data_level = estimation_value.send("string_data_#{level}")
                                  pbs_data_level.nil? ? pbs_level_data_for_consistency[level] = nil : pbs_level_data_for_consistency[level] = pbs_data_level[pbs_project_element.id]
                                end
                          Severity: Minor
                          Found in app/helpers/views_widgets_helper.rb and 1 other location - About 15 mins to fix
                          app/helpers/projects_helper.rb on lines 231..234

                          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