karlfreeman/multi_mime

View on GitHub

Showing 4 of 4 total issues

Method load_adapter has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def load_adapter(new_adapter)
    case new_adapter
    when String, Symbol
      adapter_clazz = nil
      REQUIREMENT_MAP.each do |adapter, library, clazz|
Severity: Minor
Found in lib/multi_mime.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 load_adapter has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def load_adapter(new_adapter)
    case new_adapter
    when String, Symbol
      adapter_clazz = nil
      REQUIREMENT_MAP.each do |adapter, library, clazz|
Severity: Minor
Found in lib/multi_mime.rb - About 1 hr to fix

    Method default_adapter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def default_adapter
        return :mime_types if defined?(::MIME::Types)
        return :mimemagic if defined?(::MimeMagic)
        return :mime_type if defined?(::Mime::Type)
        return :rack_mime if defined?(::Rack::Mime)
    Severity: Minor
    Found in lib/multi_mime.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 adapter
    Severity: Major
    Found in lib/multi_mime.rb - About 30 mins to fix
      Severity
      Category
      Status
      Source
      Language