jetrockets/attrio

View on GitHub

Showing 6 of 11 total issues

Method typecast has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def self.typecast(value, options = {})
        begin
          array = (!value.is_a?(::Array) && value.respond_to?(:split)) ? value.split(options[:split]): Attrio::Helpers.to_a(value).flatten
          if options[:element].present?

Severity: Minor
Found in lib/attrio/types/array.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 typecast has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def self.typecast(value, options = {})
        begin
          set = value.respond_to?(:split) ? value.split(options[:split]).to_set : Attrio::Helpers.to_a(value).to_set

          if options[:element].present?
Severity: Minor
Found in lib/attrio/types/set.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 define_typecasting_method has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def self.define_typecasting_method(klass, type, options)
        klass.send :define_method, options[:method_name] do |value|
          if !value.nil?
            value = if type.respond_to?(:typecast) && type.respond_to?(:typecasted?)
              type.typecasted?(value, options) ? value : type.typecast(*[value, options])
Severity: Minor
Found in lib/attrio/builders/writer_builder.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 typecast has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def self.typecast(value, options = {})
        true_values = options[:true] || options[:true_values] || ['yes', '1', 1, 'true']
        false_values = options[:false] || options[:false_values]

        if false_values.present?
Severity: Minor
Found in lib/attrio/types/boolean.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 cast_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.cast_type(constant)
      return constant if constant.is_a?(Class) && !!(constant < Attrio::Types::Base)

      string = constant.to_s
      string = string.camelize if (string =~ /\w_\w/ || string.chars.first.downcase == string.chars.first)
Severity: Minor
Found in lib/attrio/attributes_parser.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

Avoid too many return statements within this method.
Open

        return constant
Severity: Major
Found in lib/attrio/attributes_parser.rb - About 30 mins to fix
    Severity
    Category
    Status
    Source
    Language