jdantonio/functional-ruby

View on GitHub
lib/functional/pattern_matching.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method __pattern_arity__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def __pattern_arity__(pat)
        r = pat.reduce(0) do |acc, v|
          if v.is_a?(Hash) 
            ub = v.values.count { |e| e == UNBOUND }
            # if hash have UNBOUND then treat each unbound as separate arg
Severity: Minor
Found in lib/functional/pattern_matching.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 __unbound_args__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def __unbound_args__(match, args)
      argv = []
      match.args.each_with_index do |p, i|
        if p == ALL && i == match.args.length-1
          # when got ALL, then push all to the end to the list of args,
Severity: Minor
Found in lib/functional/pattern_matching.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 defn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def defn(function, *args, &block)
        unless block_given?
          raise ArgumentError.new("block missing for definition of function `#{function}` on class #{self}")
        end

Severity: Minor
Found in lib/functional/pattern_matching.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