kevinrutherford/event_bus

View on GitHub

Showing 2 of 2 total issues

Method subscribe_pattern has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def subscribe_pattern(pattern, listener, method_name, &blk)
      if listener
        raise ArgumentError.new('You cannot give both a listener and a block') if block_given?
        raise ArgumentError.new('You must supply a method name') unless method_name
        registrations.add_method(pattern, listener, method_name)
Severity: Minor
Found in lib/event_bus.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 subscribe has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def subscribe(pattern, listener = nil, method_name = nil, &blk)
      case pattern
      when Regexp, String, Symbol
        subscribe_pattern(pattern, listener, method_name, &blk)
      else
Severity: Minor
Found in lib/event_bus.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