joekhoobyar/cardiac

View on GitHub

Showing 27 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

    Similar blocks of code found in 2 locations. 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 and 1 other location - About 25 mins to fix
    lib/cardiac/resource/request_methods.rb on lines 17..21

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

    Severity
    Category
    Status
    Source
    Language