sinisterchipmunk/gravatar

View on GitHub

Showing 5 of 5 total issues

Class Gravatar has 33 methods (exceeds 20 allowed). Consider refactoring.
Open

class Gravatar
  API_METHODS = [
    :exists?, :addresses, :user_images, :save_data!, :save_image!, :save_url!, :use_image!, :use_user_image!,
    :remove_image!, :delete_user_image!, :test, :image_url, :image_data, :signup_url
  ]
Severity: Minor
Found in lib/gravatar.rb - About 4 hrs to fix

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

      def mock_response(name = :__unassigned)
        if name == :__unassigned
          @mock_response
        else
          if name.nil?
    Severity: Minor
    Found in lib/gravatar/test_case.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 query_for_image has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def query_for_image(options)
        query = ''
        [:rating, :size, :default, :forcedefault, :r, :s, :d, :f].each do |key|
          if options.key?(key)
            query.blank? ? query.concat("?") : query.concat("&")
    Severity: Minor
    Found in lib/gravatar.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

    Method initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def initialize(email, options = {})
        raise ArgumentError, "Expected :email" unless email
        @options = options || {}
        @email = email
        
    Severity: Minor
    Found in lib/gravatar.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

    Method call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def call(*key, &block)
          cached_copy = read_cache(*key)
          cached_copy &&= cached_copy[:object]
          
          if expired?(*key) && block_given?
    Severity: Minor
    Found in lib/gravatar/cache.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