mvidner/ruby-dbus

View on GitHub
lib/dbus/marshall.rb

Summary

Maintainability
D
2 days
Test Coverage

Method append has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def append(type, val)
      raise TypeException, "Cannot send nil" if val.nil?

      type = type.chr if type.is_a?(Integer)
      type = Type::Parser.new(type).parse[0] if type.is_a?(String)
Severity: Minor
Found in lib/dbus/marshall.rb - About 4 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

Method do_parse has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def do_parse(signature, mode: :plain)
      # FIXME: better naming for packet vs value
      packet = nil
      data_class = Data::BY_TYPE_CODE[signature.sigtype]

Severity: Minor
Found in lib/dbus/marshall.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

Method make_variant has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def self.make_variant(value)
      # TODO: mix in _make_variant to String, Integer...
      if value == true
        ["b", true]
      elsif value == false
Severity: Minor
Found in lib/dbus/marshall.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

File marshall.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "socket"

require_relative "../dbus/type"

# = D-Bus main module
Severity: Minor
Found in lib/dbus/marshall.rb - About 2 hrs to fix

    Method do_parse has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def do_parse(signature, mode: :plain)
          # FIXME: better naming for packet vs value
          packet = nil
          data_class = Data::BY_TYPE_CODE[signature.sigtype]
    
    
    Severity: Major
    Found in lib/dbus/marshall.rb - About 2 hrs to fix

      Method append has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def append(type, val)
            raise TypeException, "Cannot send nil" if val.nil?
      
            type = type.chr if type.is_a?(Integer)
            type = Type::Parser.new(type).parse[0] if type.is_a?(String)
      Severity: Minor
      Found in lib/dbus/marshall.rb - About 1 hr to fix

        Method append_variant has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def append_variant(val)
              vartype = nil
              if val.is_a?(DBus::Data::Variant)
                vartype = val.member_type
                vardata = val.exact_value
        Severity: Minor
        Found in lib/dbus/marshall.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 make_variant has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.make_variant(value)
              # TODO: mix in _make_variant to String, Integer...
              if value == true
                ["b", true]
              elsif value == false
        Severity: Minor
        Found in lib/dbus/marshall.rb - About 1 hr to fix

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

              def append_variant(val)
                vartype = nil
                if val.is_a?(DBus::Data::Variant)
                  vartype = val.member_type
                  vardata = val.exact_value
          Severity: Minor
          Found in lib/dbus/marshall.rb - About 1 hr to fix

            Method append_array has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def append_array(child_type, val)
                  if val.is_a?(Hash)
                    raise TypeException, "Expected an Array but got a Hash" if child_type.sigtype != Type::DICT_ENTRY
            
                    # Damn ruby rocks here
            Severity: Minor
            Found in lib/dbus/marshall.rb - About 25 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