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
- Read upRead up
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)
- Read upRead up
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
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)
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")
- Read upRead up
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)
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")
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?)
- Read upRead up
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
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
- Read upRead up
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?)
Avoid deeply nested control flow statements. Open
if d.nil?
dh = 1.hours
else
dh = d.hours
end
Avoid deeply nested control flow statements. Open
str_data_probable.nil? ? nil : (dev = str_data_probable[element.id])
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)
Avoid deeply nested control flow statements. Open
rescue
is_ok = false
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
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
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)]
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76