pezra/hal-client

View on GitHub
lib/hal_client.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Class HalClient has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class HalClient
  autoload :Interpreter, 'hal_client/interpreter'
  autoload :Representation, 'hal_client/representation'
  autoload :RepresentationFuture, 'hal_client/representation_future'
  autoload :RepresentationSet, 'hal_client/representation_set'
Severity: Minor
Found in lib/hal_client.rb - About 2 hrs to fix

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

      def initialize(options={})
        @default_message_request_headers = HTTP::Headers.new
        @default_entity_request_headers = HTTP::Headers.new
        @auth_helper = as_callable(options.fetch(:authorization, NullAuthHelper))
        @base_client ||= options[:base_client]
    Severity: Minor
    Found in lib/hal_client.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

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

      def interpret_response(resp)
        case resp.status
        when 200...300
          location = resp.headers["Location"]
    
    
    Severity: Minor
    Found in lib/hal_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

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

        def def_unsafe_request(method)
          verb = method.to_s.upcase
    
          define_method(method) do |url, data, headers={}|
            headers = auth_headers(url).merge(headers)
    Severity: Minor
    Found in lib/hal_client.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

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

        def def_idempotent_unsafe_request(method)
          verb = method.to_s.upcase
    
          define_method(method) do |url, data, headers={}|
            headers = auth_headers(url).merge(headers)
    Severity: Minor
    Found in lib/hal_client.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