slack-ruby/slack-shellbot

View on GitHub
lib/commands/base.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method invoke has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

        def invoke(client, data)
          finalize_routes!

          expression = data.text

Severity: Minor
Found in lib/commands/base.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 call has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        def call(client, data)
          Thread.current[:stdout] = []
          if data.key?(:text)
            data.text = Slack::Messages::Formatting.unescape(data.text)
            command, redirect_to = split_redirect(data.text)
Severity: Minor
Found in lib/commands/base.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 match_attachments has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def match_attachments(data, route, fields_to_scan = nil)
          fields_to_scan ||= %i[pretext text title]
          data.attachments.each do |attachment|
            fields_to_scan.each do |field|
              next unless attachment[field]
Severity: Minor
Found in lib/commands/base.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 call_command has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def call_command(client, data, match, block)
          if block
            block.call(client, data, match) if permitted?(client, data, match)
          elsif respond_to?(:call)
            send(:call, client, data, match) if permitted?(client, data, match)
Severity: Minor
Found in lib/commands/base.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 split_redirect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def split_redirect(text)
          parts = Shellwords.split(text)
          command = []
          while parts.any?
            part = parts.shift
Severity: Minor
Found in lib/commands/base.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

There are no issues that match your filters.

Category
Status