ManageIQ/manageiq-smartstate

View on GitHub
lib/VolumeManager/MiqVolumeManager.rb

Summary

Maintainability
C
1 day
Test Coverage
F
29%

Method parseLvmMetadata has a Cognitive Complexity of 18 (exceeds 8 allowed). Consider refactoring.
Open

  def parseLvmMetadata(pvHdrs)
    pvHdrs.each_value do |pvh|
      if pvh.lvm_type == "LVM2"
        $log.debug "MiqVolumeManager.parseLvmMetadata: parsing LVM2 metadata"
        pvh.mdList.each do |md|
Severity: Minor
Found in lib/VolumeManager/MiqVolumeManager.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 pvToXml has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring.
Open

  def pvToXml(doc = nil, hidden = false)
    doc = MiqXml.createDoc(nil) unless doc

    if hidden
      vols = @hiddenVolumes
Severity: Minor
Found in lib/VolumeManager/MiqVolumeManager.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 fromNativePvs has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.fromNativePvs
    return nil unless Sys::Platform::IMPL == :linux

    msg_pfx = "MiqVolumeManager.fromNativePvs"

Severity: Minor
Found in lib/VolumeManager/MiqVolumeManager.rb - About 1 hr to fix

Method initialize has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize(pVols)
    @logicalVolumes     = []         # visible logical volumes
    @physicalVolumes    = []         # visible physical volumes
    @hiddenVolumes      = []         # hidded volumes (in volume groups)
    @allPhysicalVolumes = []         # all physical volumes
Severity: Minor
Found in lib/VolumeManager/MiqVolumeManager.rb - About 1 hr to fix

Method pvToXml has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def pvToXml(doc = nil, hidden = false)
    doc = MiqXml.createDoc(nil) unless doc

    if hidden
      vols = @hiddenVolumes
Severity: Minor
Found in lib/VolumeManager/MiqVolumeManager.rb - About 1 hr to fix

Method vgToXml has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def vgToXml(doc = nil)
    doc = MiqXml.createDoc(nil) unless doc

    vgs = doc.add_element 'volume_groups'
    @vgHash.each do |vgn, vgo|
Severity: Minor
Found in lib/VolumeManager/MiqVolumeManager.rb - About 1 hr to fix

Method fromNativePvs has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
Open

  def self.fromNativePvs
    return nil unless Sys::Platform::IMPL == :linux

    msg_pfx = "MiqVolumeManager.fromNativePvs"

Severity: Minor
Found in lib/VolumeManager/MiqVolumeManager.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 lvToXml has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
Open

  def lvToXml(doc = nil)
    doc = MiqXml.createDoc(nil) unless doc

    lvs = doc.add_element 'logical'
    @logicalVolumes.each do |dobj|
Severity: Minor
Found in lib/VolumeManager/MiqVolumeManager.rb - About 55 mins 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

Unused block argument - vgname. If it's necessary, use _ or _vgname as an argument name to indicate that it won't be used.
Open

    @vgHash.each do |vgname, vg|

Checks for unused block arguments.

Example:

# bad
do_something do |used, unused|
  puts used
end

do_something do |bar|
  puts :foo
end

define_method(:foo) do |bar|
  puts :baz
end

# good
do_something do |used, _unused|
  puts used
end

do_something do
  puts :foo
end

define_method(:foo) do |_bar|
  puts :baz
end

Example: IgnoreEmptyBlocks: true (default)

# good
do_something { |unused| }

Example: IgnoreEmptyBlocks: false

# bad
do_something { |unused| }

Example: AllowUnusedKeywordArguments: false (default)

# bad
do_something do |unused: 42|
  foo
end

Example: AllowUnusedKeywordArguments: true

# good
do_something do |unused: 42|
  foo
end

There are no issues that match your filters.

Category
Status