ManageIQ/manageiq-ui-classic

View on GitHub
app/helpers/textual_mixins/textual_vmm_info.rb

Summary

Maintainability
A
2 hrs
Test Coverage
D
66%

Method vm_vendor_details has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def vm_vendor_details
    {:vendor_display => _("Vendor"), :format => _("Format"), :version => _("Version"),
     :annotation => _("Notes")}.map do |method, title|
      if method == :annotation
        if @record.hardware
Severity: Minor
Found in app/helpers/textual_mixins/textual_vmm_info.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

Use :vmm_vendor_display instead of "vmm_vendor_display".
Open

    if @record.respond_to?("vmm_vendor_display")

Use filter_map instead.
Open

     :vmm_buildnumber => _("Build Number")}.map do |method, title|
      value = @record.send(method)
      value ? VmmInfo.new(title, value) : next
    end.compact

Use :vendor_display instead of "vendor_display".
Open

    if @record.respond_to?("vendor_display")

Use filter_map instead.
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>"))

There are no issues that match your filters.

Category
Status