mvidner/ruby-dbus

View on GitHub

Showing 51 of 56 total issues

File data.rb has 496 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module DBus
  # FIXME: in general, when an API gives me, a user, a choice,
  # remember to make it easy for the case of:
  # "I don't CARE, I don't WANT to care, WHY should I care?"

Severity: Minor
Found in lib/dbus/data.rb - About 7 hrs to fix

    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 process has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def process(msg)
          return if msg.nil? # check if somethings wrong
    
          case msg.message_type
          when Message::ERROR, Message::METHOD_RETURN
    Severity: Minor
    Found in lib/dbus/connection.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 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

    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

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

      def my_class_attribute(*attrs)
        instance_reader    = true
        instance_writer    = true
    
        attrs.each do |name|
    Severity: Minor
    Found in lib/dbus/core_ext/class/attribute.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

    Class Object has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Object
        # @return [ObjectPath] The path of the object.
        attr_reader :path
    
        # The interfaces that the object supports. Hash: String => Interface
    Severity: Minor
    Found in lib/dbus/object.rb - About 2 hrs to fix

      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 run has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def run
              # before blocking, empty the buffers
              # https://bugzilla.novell.com/show_bug.cgi?id=537401
              @buses.each_value do |b|
                while (m = b.message_queue.message_from_buffer_nonblock)
        Severity: Minor
        Found in lib/dbus/main.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

        Method next_state has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def next_state(received_words)
                msg = received_words
        
                case @state
                when :WaitingForData
        Severity: Major
        Found in lib/dbus/auth.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

            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 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 process has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def process(msg)
                      return if msg.nil? # check if somethings wrong
                
                      case msg.message_type
                      when Message::ERROR, Message::METHOD_RETURN
                Severity: Minor
                Found in lib/dbus/connection.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 my_class_attribute has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def my_class_attribute(*attrs)
                      instance_reader    = true
                      instance_writer    = true
                  
                      attrs.each do |name|
                  Severity: Minor
                  Found in lib/dbus/core_ext/class/attribute.rb - About 1 hr to fix

                    Method define_shortcut_methods has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def define_shortcut_methods
                          # builds a list of duplicated methods
                          dup_meths = []
                          univocal_meths = {}
                          @interfaces.each_value do |intf|
                    Severity: Minor
                    Found in lib/dbus/proxy_object.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 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
                        Severity
                        Category
                        Status
                        Source
                        Language