mvidner/ruby-dbus

View on GitHub
lib/dbus/type.rb

Summary

Maintainability
C
1 day
Test Coverage

Method parse_one has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_one(char, for_array: false)
        res = nil
        case char
        when "a"
          res = Type.new(ARRAY)
Severity: Minor
Found in lib/dbus/type.rb - About 3 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

File type.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module DBus
  # Like a {Signature} but containing only a single complete type.
  #
  # For documentation purposes only.
  class SingleCompleteType < String; end
Severity: Minor
Found in lib/dbus/type.rb - About 2 hrs to fix

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

          def parse_one(char, for_array: false)
            res = nil
            case char
            when "a"
              res = Type.new(ARRAY)
    Severity: Minor
    Found in lib/dbus/type.rb - About 1 hr to fix

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

          def <<(item)
            raise ArgumentError unless item.is_a?(Type)
      
            if ![STRUCT, ARRAY, DICT_ENTRY].member?(@sigtype)
              raise SignatureException
      Severity: Minor
      Found in lib/dbus/type.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(sigtype, abstract: false)
            if !TYPE_MAPPING.keys.member?(sigtype)
              case sigtype
              when ")"
                raise SignatureException, "STRUCT unexpectedly closed: )"
      Severity: Minor
      Found in lib/dbus/type.rb - About 35 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

      There are no issues that match your filters.

      Category
      Status