joekhoobyar/cardiac

View on GitHub

Showing 25 of 27 total issues

Method operation has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def operation(event)
      return unless logger.debug?

      payload   = event.payload
      name, url, verb, result = *payload.values_at(:name, :url, :verb, :result)
Severity: Minor
Found in lib/cardiac/log_subscriber.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 execute! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def execute! &response_handler
      run_callbacks :execute do
        clear_resource_cache unless request_is_safe?
          
        instrumenter.instrument "operation.cardiac", event=event_attributes do
Severity: Minor
Found in lib/cardiac/resource/adapter.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 initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def initialize(resource_or_uri, http_verb=nil)
            @macro, @http_verb = self.class.build_macro, http_verb

            resource_or_uri.to_resource if resource_or_uri.respond_to?(:to_resource)
                    
Severity: Minor
Found in lib/cardiac/reflections.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 net_http_request_klass has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def net_http_request_klass
      if method_value.present?
        verb = method_value.to_s.upcase
        if @request_klass && @request_klass::METHOD == verb
          @request_klass
Severity: Minor
Found in lib/cardiac/resource/request_methods.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 operation has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def operation(event)
      return unless logger.debug?

      payload   = event.payload
      name, url, verb, result = *payload.values_at(:name, :url, :verb, :result)
Severity: Minor
Found in lib/cardiac/log_subscriber.rb - About 1 hr to fix

    Method find_by_identity has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def find_by_identity(id, &evaluator)
              unless @_model_cache_control
                super
              else
                find_all if @model_cache.nil? || @_model_cache_control[:expires_at].past?
    Severity: Minor
    Found in lib/cardiac/model/cache_decoration.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 check_subresource has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_subresource name, implementation, extension_block
          raise ArgumentError unless Proc===implementation
          raise ArgumentError unless String===name || Symbol===name
          raise ArgumentError unless extension_block.nil? || extension_block.arity==0
          name = name.to_sym
    Severity: Minor
    Found in lib/cardiac/resource/extension_methods.rb - About 55 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 find_all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def find_all(*args, &evaluator)
              unless @_model_cache_control
                super
              else
                if @model_cache.nil? || @_model_cache_control[:expires_at].past?
    Severity: Minor
    Found in lib/cardiac/model/cache_decoration.rb - About 55 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 decode_remote_attributes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def decode_remote_attributes(data,options={})
            unless data.nil?
              data = Hash===data ? data.with_indifferent_access : {data: data}
              data = data.slice(*options[:only]) if options[:only]
              data = data.except(*options[:except]) if options[:except]
    Severity: Minor
    Found in lib/cardiac/model/attributes.rb - About 55 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 read_attribute_for_serialization has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def read_attribute_for_serialization(name)
            case value = read_attribute(name)
            when Array
              value.map{|item| item.respond_to?(:serializable_hash) ? item.serializable_hash : item }
            else
    Severity: Minor
    Found in lib/cardiac/model/attributes.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 check_operation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_operation name, implementation
          raise ArgumentError unless Proc===implementation
          raise ArgumentError unless String===name || Symbol===name
          name = name.to_sym
          return [name, implementation] unless subresources_values.any?{|v| v.first==name }
    Severity: Minor
    Found in lib/cardiac/resource/extension_methods.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 non_default_port has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def non_default_port(scheme,port)
          case scheme
          when /^http$/i  then port==80  ? nil : port
          when /^https$/i then port==443 ? nil : port
          else port
    Severity: Minor
    Found in lib/cardiac/resource/uri_methods.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 abort! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def abort! exception
          # Start out by assuming we will abort.
          @aborted = true
          
          # Now we can run the abort callbacks.
    Severity: Minor
    Found in lib/cardiac/operation_handler.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 attribute= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def attribute=(attr, value)
            attr = attr.to_s
    
            # The attribute already had an unsaved change, so check if it is changing back to the original.
            if attribute_changed?(attr)
    Severity: Minor
    Found in lib/cardiac/model/dirty.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 cache_resource has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def cache_resource url, headers, event=nil
          if @resource_cache[url].key?(headers)
            event[:name] = 'CACHE' if event
            result = @resource_cache[url][headers]
          else
    Severity: Minor
    Found in lib/cardiac/resource/cache.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 find_with_ids has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def find_with_ids(*ids, &evaluator)
              expects_array = ids.first.kind_of?(Array)
              return ids.first if expects_array && ids.first.empty?
              ids = ids.flatten.compact.uniq
              case ids.size
    Severity: Minor
    Found in lib/cardiac/model/querying.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 option has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def option(key, value)
          raise ArgumentError unless String===key or Symbol===key
          raise ArgumentError if TrueClass===value
          self.options_values << (FalseClass===value ? key : {key => value})
          self
    Severity: Minor
    Found in lib/cardiac/resource/request_methods.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 check_extensions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_extensions modules, extension_block
          raise ArgumentError unless modules.all?{|mod| Module===mod}
          raise ArgumentError unless extension_block.nil? || extension_block.arity==0
          modules << Module.new(&extension_block) if extension_block
          modules
    Severity: Minor
    Found in lib/cardiac/resource/extension_methods.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 init_with has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def init_with(coder)
            _remote = coder['remote']
            self.attributes = _remote ? {} : coder['attributes']
            init_internals
            @new_record = false
    Severity: Minor
    Found in lib/cardiac/model/base.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 _field_changed? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def _field_changed?(attr, old, value)
            if type = _attribute_type(attr)
              if Numeric === type && (changes_from_nil_to_empty_string?(old, value) || changes_from_zero_to_string?(old, value))
                value = nil
              else
    Severity: Minor
    Found in lib/cardiac/model/dirty.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

    Severity
    Category
    Status
    Source
    Language