ManageIQ/binary_struct

View on GitHub

Showing 4 of 16 total issues

Class BinaryStruct has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

class BinaryStruct
  SIZES = {
    'A'   => 1,   # String with trailing NULs and spaces removed
    'a'   => 1,   # String
    'B'   => 1,   # Extract bits from each character (MSB first)
Severity: Minor
Found in lib/binary_struct.rb - About 2 hrs to fix

    Method encode_hash has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def encode_hash(hash)
        data = ""
        @definition.each_slice(2) do |format, name|
          raise "member not found: #{name}" unless name.nil? || hash.has_key?(name)
          value = unless name.nil?
    Severity: Minor
    Found in lib/binary_struct.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 get_size has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.get_size(definition)
        size = 0
        definition.each_slice(2) do |format, _|
          type, count        = format[0, 1], format[1..-1]
          modifier, modcount = count[0, 1], count[1..-1]
    Severity: Minor
    Found in lib/binary_struct.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

    Method offset has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def offset(attr)
        offset = 0
        self.definition.each_slice(2) do |format, name|
          return offset if name == attr
    
    
    Severity: Minor
    Found in lib/binary_struct.rb - About 45 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

    Severity
    Category
    Status
    Source
    Language