lib/core/coap/client.rb

Summary

Maintainability
C
1 day
Test Coverage

Method client has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

      def client(method, path, host = nil, port = nil, payload = nil, options = {}, observe_callback = nil)
        # Set host and port only one time on multiple requests
        host.nil? ? (host = @host unless @host.nil?) : @host = host
        port.nil? ? (port = @port unless @port.nil?) : @port = port

Severity: Minor
Found in lib/core/coap/client.rb - About 5 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 client has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def client(method, path, host = nil, port = nil, payload = nil, options = {}, observe_callback = nil)
        # Set host and port only one time on multiple requests
        host.nil? ? (host = @host unless @host.nil?) : @host = host
        port.nil? ? (port = @port unless @port.nil?) : @port = port

Severity: Major
Found in lib/core/coap/client.rb - About 2 hrs to fix

    Method client has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def client(method, path, host = nil, port = nil, payload = nil, options = {}, observe_callback = nil)
    Severity: Major
    Found in lib/core/coap/client.rb - About 50 mins to fix

      Method observe has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def observe(path, host, port, callback, payload = nil, options = {})
      Severity: Minor
      Found in lib/core/coap/client.rb - About 45 mins to fix

        Method validate_arguments! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def validate_arguments!(host, port, path, payload)
                if host.nil? || host.empty?
                  fail ArgumentError, 'Argument «host» missing.'
                end
        
        
        Severity: Minor
        Found in lib/core/coap/client.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