m3talsmith/arkenstone

View on GitHub

Showing 4 of 22 total issues

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

      def validate_presence(attr, options)
        message = options[:message] || "can't be blank"
        test = options[:presence]
        method_not_defined = test != self.class.method_defined?(attr)
        if method_not_defined
Severity: Minor
Found in lib/arkenstone/validation/validations.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 saveable_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def saveable_attributes
        return attributes unless Arkenstone::Hook.has_hooks? self.class

        attrs = {}
        Arkenstone::Hook.all_hooks_for_class(self.class).each do |hook|
Severity: Minor
Found in lib/arkenstone/document.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 has_one has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def has_one(child_model_name, options = {})
        setup_arkenstone_data
        child_url_fragment = options[:model_name] || child_model_name

        # The method for accessing the cached single resource is `cached_[name]`. If the value is nil it creates a request to pull the value from the server.
Severity: Minor
Found in lib/arkenstone/associations.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 has_and_belongs_to_many has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def has_and_belongs_to_many(model_klass_name)
        # Gather the namespace
        namespace             = to_s.split(/::/)
        model_klass_name      = model_klass_name.to_s.singularize.underscore.to_sym
        current_klass_name    = namespace.pop.underscore.to_sym
Severity: Minor
Found in lib/arkenstone/associations.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