gottfrois/link_thumbnailer

View on GitHub

Showing 7 of 7 total issues

Class Processor has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Processor < ::SimpleDelegator

    attr_accessor :url
    attr_reader   :config, :http, :redirect_count

Severity: Minor
Found in lib/link_thumbnailer/processor.rb - About 2 hrs to fix

    Method initialize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize
          @redirect_limit         = 3
          @user_agent             = 'link_thumbnailer'
          @verify_ssl             = true
          @http_open_timeout      = 5
    Severity: Minor
    Found in lib/link_thumbnailer/configuration.rb - About 1 hr to fix

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

          def valid_response_format?(response)
            return true unless config.raise_on_invalid_format
            return true if response['Content-Type'] =~ /text\/html/
            return true if response['Content-Type'] =~ /application\/html/
            return true if response['Content-Type'] =~ /application\/xhtml\+xml/
      Severity: Minor
      Found in lib/link_thumbnailer/processor.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

      Avoid too many return statements within this method.
      Open

            return true if response['Content-Type'] =~ /text\/plain/
      Severity: Major
      Found in lib/link_thumbnailer/processor.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return true if response['Content-Type'] =~ /text\/xml/
        Severity: Major
        Found in lib/link_thumbnailer/processor.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return true if response['Content-Type'] =~ /application\/xml/
          Severity: Major
          Found in lib/link_thumbnailer/processor.rb - About 30 mins to fix

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

                    def abs_urls
                      urls.map do |url|
                        uri = validate_url(url)
            
                        next unless uri
            Severity: Minor
            Found in lib/link_thumbnailer/scrapers/default/images.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