app/helpers/textual_mixins/textual_vmm_info.rb
Method vm_vendor_details
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
def vm_vendor_details
{:vendor_display => _("Vendor"), :format => _("Format"), :version => _("Version"),
:annotation => _("Notes")}.map do |method, title|
if method == :annotation
if @record.hardware
- 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
Use :vmm_vendor_display
instead of "vmm_vendor_display"
. Open
Open
if @record.respond_to?("vmm_vendor_display")
- Create a ticketCreate a ticket
- Exclude checks
Use filter_map
instead. Open
Open
:vmm_buildnumber => _("Build Number")}.map do |method, title|
value = @record.send(method)
value ? VmmInfo.new(title, value) : next
end.compact
- Create a ticketCreate a ticket
- Exclude checks
Use :vendor_display
instead of "vendor_display"
. Open
Open
if @record.respond_to?("vendor_display")
- Create a ticketCreate a ticket
- Exclude checks
Use filter_map
instead. Open
Open
:annotation => _("Notes")}.map do |method, title|
if method == :annotation
if @record.hardware
value = @record.hardware.send(method)
value ? VmmInfo.new(title, value) : VmmInfo.new(title, _("<No notes have been entered for this VM>"))
- Create a ticketCreate a ticket
- Exclude checks