efreesen/active_repository

View on GitHub

Showing 10 of 10 total issues

Class Base has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Base < ActiveHash::Base
    extend ActiveModel::Callbacks
    extend ActiveRepository::Finders
    extend ActiveRepository::Writers
    include ActiveModel::Validations
Severity: Minor
Found in lib/active_repository/base.rb - About 3 hrs to fix

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

        def create(attributes={})
          attributes = attributes.symbolize_keys if attributes.respond_to?(:symbolize_keys)
          object = self.new(attributes)
    
          if object.present? && object.valid?
    Severity: Minor
    Found in lib/active_repository/writers.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 save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def save(force=false)
          execute_callbacks(before_save_methods)
          result = true
    
          if self.class == persistence_class
    Severity: Minor
    Found in lib/active_repository/base.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 serialize! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def serialize!(attributes)
          unless attributes.nil?
            attributes.each do |key, value|
              key = "id" if key == "_id"
              self.send("#{key}=", (value.dup rescue value))
    Severity: Minor
    Found in lib/active_repository/base.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 validate_each has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def validate_each(record, attribute, value)
            query  = (record.id ? "id <> #{record.id}" : 'id is not null')
            
            if(options[:scope])
              value = record.send(options[:scope])
    Severity: Minor
    Found in lib/active_repository/uniqueness.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 update_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def update_attributes(attributes)
            attributes  = attributes.symbolize_keys if attributes.respond_to?(:symbolize_keys)
            klass       = self.class
            model_class = persistence_class
    
    
    Severity: Minor
    Found in lib/active_repository/writers.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 save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def save(*args)
          if self.valid?
            record = self.class.find_by(id: self.id)
    
            self.class.insert(self) if record.nil? && record != self
    Severity: Minor
    Found in lib/active_repository/write_support.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 execute_callbacks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def execute_callbacks(callbacks)
            Array(callbacks).each do |callback|
              method = callback[:method]
              options = callback[:options]
    
    
    Severity: Minor
    Found in lib/active_repository/base.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 set_timestamps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def set_timestamps
            if self.errors.empty?
              self.created_at = DateTime.now.utc if self.respond_to?(:created_at=) && self.created_at.nil?
              self.updated_at = DateTime.now.utc if self.respond_to?(:updated_at=)
            end
    Severity: Minor
    Found in lib/active_repository/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 can_run? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def can_run?
            return @can_run if @can_run
    
            if_option = @options[:if].nil? ? true : @object.send(@options[:if])
            unless_option = @options[:unless].nil? ? false : @object.send(@options[:unless])
    Severity: Minor
    Found in lib/active_repository/callback/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