davidesantangelo/webinspector

View on GitHub

Showing 7 of 7 total issues

Class Page has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Page
    attr_reader :url, :scheme, :host, :port, :title, :description, :body, :meta, :links, :domain_links, :domain_images, :images, :response

    def initialize(url, options = {})
      @url = url
Severity: Minor
Found in lib/web_inspector/page.rb - About 2 hrs to fix

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

        def domain_images(user_domain, host)
          @host ||= host
    
          validated_domain_uri = validate_url_domain("http://#{user_domain.downcase.gsub(/\s+/, '')}")
          raise "Invalid domain provided" unless validated_domain_uri
    Severity: Minor
    Found in lib/web_inspector/inspector.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 domain_links has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def domain_links(user_domain, host)
          @host ||= host
    
          validated_domain_uri = validate_url_domain("http://#{user_domain.downcase.gsub(/\s+/, '')}")
          raise "Invalid domain provided" unless validated_domain_uri
    Severity: Minor
    Found in lib/web_inspector/inspector.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 validate_url_domain has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_url_domain(u)
          # Enforce a few bare standards before proceeding
          u = "#{u}"
          u = "/" if u.empty?
    
    
    Severity: Minor
    Found in lib/web_inspector/inspector.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 meta_tags_by has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def meta_tags_by(attribute)
          hash = {}
          @page.css("meta[@#{attribute}]").map do |tag|
            name    = tag.attributes[attribute].value.downcase rescue nil
            content = tag.attributes['content'].value rescue nil
    Severity: Minor
    Found in lib/web_inspector/meta.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 get_new_images has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_new_images
          @images = []
          @page.css("img").each do |img|
            @images.push((img[:src].to_s.start_with? @url.to_s) ? img[:src] : URI.join(url, img[:src]).to_s) if (img and img[:src])
          end
    Severity: Minor
    Found in lib/web_inspector/inspector.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 get_new_links has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_new_links
          @links = []
          @page.css("a").each do |a|
            @links.push((a[:href].to_s.start_with? @url.to_s) ? a[:href] : URI.join(@url, a[:href]).to_s) if (a and a[:href])
          end
    Severity: Minor
    Found in lib/web_inspector/inspector.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

    Severity
    Category
    Status
    Source
    Language