app/models/miq_report/formatters/graph.rb
Method to_chart
has a Cognitive Complexity of 16 (exceeds 11 allowed). Consider refactoring. Open
Open
def to_chart(theme = nil, show_title = false, graph_options = nil)
ManageIQ::Reporting::Formatter::ReportRenderer.render(ManageIQ::Reporting::Charting.format) do |e|
if col_formats
# NOTE: This code intentionally does not use number_to_human_size to create a human-readable
# chart summary, because we want to match the unit of the column, regardless of the size.
- Read upRead up
- Create a ticketCreate a ticket
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 immutable Array literals in loops. It is better to extract it into a local variable or a constant. Open
Open
next unless [:bytes_human_precision_2, :kilobytes_human, :megabytes_human, :megabytes_human_precision_2, :gigabytes_human, :gigabytes_human_precision_2].include?(format)
- Create a ticketCreate a ticket
- Exclude checks