af83/chouette-core

View on GitHub
app/models/concerns/options_support.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method handle_serialize_option has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

      def handle_serialize_option attribute_name, opts
        serializer = opts[:serialize]
    
        define_method attribute_name do
          return nil unless respond_to?(:options)
Severity: Minor
Found in app/models/concerns/options_support.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 handle_default_value_option has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def handle_default_value_option attribute_name, opts
        if opts.key?(:default_value)
          after_initialize do
            if self.new_record? && self.send(attribute_name).nil?
              self.send("#{attribute_name}=", opts[:default_value])
Severity: Minor
Found in app/models/concerns/options_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 handle_enumerize_option has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def handle_enumerize_option attribute_name, opts
        if opts.key?(:enumerize)
          collection = opts[:enumerize] == :collection ? opts[:collection] : opts[:enumerize]
          enumerize attribute_name, in: collection, default: opts[:default_value]
        end
Severity: Minor
Found in app/models/concerns/options_support.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