serradura/kind

View on GitHub

Showing 25 of 25 total issues

Method resolve_value_to_assign has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

      def resolve_value_to_assign(kind, default, value)
        if kind == ::Proc
          UNDEFINED == default ? value : KIND.value(kind, value, default)
        else
          default_is_a_callable = default.respond_to?(:call)
Severity: Minor
Found in lib/kind/__lib__/attributes.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 get has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def get(data, key)
        return data[key] if ::Hash === data

        case data
        when ::Array
Severity: Minor
Found in lib/kind/dig.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 call has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def call(object)
      return if KIND.nil_or_undefined?(object)

      return object.blank? ? nil : object if object.respond_to?(:blank?)

Severity: Minor
Found in lib/kind/presence.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 kind_functional_action! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def kind_functional_action!
        return self if Kind.is?(Result::Methods, self)

        public_methods = self.public_instance_methods - ::Object.new.methods

Severity: Minor
Found in lib/kind/functional/action.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 kind_functional_action! has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def kind_functional_action!
        return self if Kind.is?(Result::Methods, self)

        public_methods = self.public_instance_methods - ::Object.new.methods

Severity: Minor
Found in lib/kind/functional/action.rb - About 1 hr to fix

    Method check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def check(method_name = UNDEFINED, &fn)
            result = if UNDEFINED != method_name
              if method_name.kind_of?(::Symbol)
                @value.respond_to?(method_name) ? @value.public_send(method_name) : NONE_INSTANCE
              else
    Severity: Minor
    Found in lib/kind/maybe/some.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 reject has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def reject(method_name = UNDEFINED, &fn)
            result = if UNDEFINED != method_name
              if method_name.kind_of?(::Symbol)
                @value.respond_to?(method_name) ? @value.public_send(method_name) : NONE_INSTANCE
              else
    Severity: Minor
    Found in lib/kind/maybe/some.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 wrap has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def wrap(arg = UNDEFINED)
            if block_given?
              begin
                return new(yield) if UNDEFINED == arg
    
    
    Severity: Minor
    Found in lib/kind/maybe/wrapper.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 kind_is_not has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def kind_is_not(expected, value)
          case expected
          when ::Class
            return if expected == Kind.of_class(value) || value < expected
    
    
    Severity: Minor
    Found in lib/kind/validator.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 result? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def result?(types, matcher)
          undef_t = Undefined == (t = types)
          undef_m = Undefined == (m = matcher)
    
          return true if undef_t && undef_m
    Severity: Minor
    Found in lib/kind/result/abstract.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 kind_of has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def kind_of(expected, value)
          if ::Array === expected
            return if expected.any? { |type| type === value }
    
            "must be a kind of #{expected.map { |type| type.name }.join(', ')}"
    Severity: Minor
    Found in lib/kind/validator.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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      class Either::Monad::Wrapper < Kind::Monad::Wrapper
        def left(matcher = UNDEFINED)
          return if @monad.right? || output?
    
          @output = yield(@monad.value) if @monad.either?(matcher)
    Severity: Minor
    Found in lib/kind/either/monad/wrapper.rb and 1 other location - About 50 mins to fix
    lib/kind/maybe/monad/wrapper.rb on lines 6..16

    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 43.

    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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      class Maybe::Monad::Wrapper < Kind::Monad::Wrapper
        def none(matcher = UNDEFINED)
          return if @monad.some? || output?
    
          @output = yield(@monad.value) if @monad.maybe?(matcher)
    Severity: Minor
    Found in lib/kind/maybe/monad/wrapper.rb and 1 other location - About 50 mins to fix
    lib/kind/either/monad/wrapper.rb on lines 6..16

    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 43.

    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 call_validation_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def call_validation_for(attribute, value)
          expected = options[:with] || options[:in]
    
          return validate_with_default_strategy(expected, value) if expected
    
    
    Severity: Minor
    Found in lib/kind/validator.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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def call(data, *input)
          args = input.size == 1 && input[0].kind_of?(::Array) ? input[0] : input
    
          result = call!(data, args)
    
    
    Severity: Minor
    Found in lib/kind/dig.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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def call(object, *input)
          args = input.size == 1 && input[0].kind_of?(::Array) ? input[0] : input
    
          result = call!(object, args.shift, args)
    
    
    Severity: Minor
    Found in lib/kind/try.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 a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def ===(m)
          return false unless Result::Abstract === m
          return false unless (self.success? && m.success?) || (self.failure? && m.failure?)
    
          self.type == m.type && self.value === m.value
    Severity: Minor
    Found in lib/kind/result/monad.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 a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.[](arg1 = UNDEFINED, arg2 = UNDEFINED, opt = Empty::HASH) # :nodoc:
          value_must_be_a = opt[:value_must_be_a]
    
          type = UNDEFINED == arg2 ? self::DEFAULT_TYPE : STRICT.kind_of(::Symbol, arg1)
    
    
    Severity: Minor
    Found in lib/kind/result/monad.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

    Avoid too many return statements within this method.
    Open

          return array_of(expected, value) if expected = options[:array_of]
    Severity: Major
    Found in lib/kind/validator.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return instance_of(expected, value) if expected = options[:instance_of]
      Severity: Major
      Found in lib/kind/validator.rb - About 30 mins to fix
        Severity
        Category
        Status
        Source
        Language