kalifs/state_store

View on GitHub

Showing 2 of 2 total issues

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

      def has_states *states
        states_stores_options = states && states.last.is_a?(Hash) && states.pop || {}
        raise ArgumentError.new("No states given") if states.empty? 
        raise ArgumentError.new(":in is required") unless states_stores_options[:in]

Severity: Minor
Found in lib/state_store/extension.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 method_missing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def method_missing(method_name, *args)
          state_method_name = method_name.to_s.match(/^has_(\w+)\?$/)
          state_method_name = state_method_name && state_method_name[1].to_sym
          if state_method_name
            options = self.class.states_stores_options.detect{|key,value| value[:in].to_sym == state_method_name}
Severity: Minor
Found in lib/state_store/extension.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