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|
- 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
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
- 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
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"
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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|
- Create a ticketCreate a ticket
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"
- 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
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|
- 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
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|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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