bkotu6717/brilliant_web_scraper

View on GitHub

Showing 6 of 6 total issues

Method get_processed_phone_numbers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def get_processed_phone_numbers(phone_numbers)
    return [] if phone_numbers.nil? || phone_numbers.empty?

    unescaped_contacts = phone_numbers.map { |phone_number| unescape_html(phone_number) }
    good_phone_numbers = []
Severity: Minor
Found in lib/parsers/phone_numbers.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 perform_scrape has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def perform_scrape(url, read_timeout, open_timeout)
    timeout_in_sec = scraper_timeout(read_timeout, open_timeout)
    Timeout::timeout(timeout_in_sec) do
      response = ScrapeRequest.new(url, read_timeout, open_timeout)
      retry_count = 0
Severity: Minor
Found in lib/scraper/scrape_helper.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 scrape_profile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def scrape_profile(response, regexes)
    return if response.to_s.empty? || regexes.empty?

    profiles = []
    regexes.each do |regex|
Severity: Minor
Found in lib/parsers/youtube_channel.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 scrape_description has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def scrape_description(response, regexes)
    return if response.to_s.empty? || regexes.empty?

    description = nil
    regexes.each do |regex|
Severity: Minor
Found in lib/parsers/description_helper.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 grep_title has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def grep_title(response)
        return if !response.is_a?(String) || response.empty?

        title_regex =  /<\s*title.*?>(.*?)<?\s*\/?title\s*?>/im
    title = response.match(title_regex).captures[0].strip rescue nil
Severity: Minor
Found in lib/parsers/title.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 grep_redirected_to_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def grep_redirected_to_url(response)
    return if response.nil? || response.empty?

    patterns = [
      %r{(?im)<link\s+[\s\w="'-]*rel\s*=\s*(?:"|')canonical(?:"|')[\s\w='"-]*?\s+href\s*=\s*(?:"|')([^"']*)(?:"|')[\s\w='"-]*?(?:>|\/>)},
Severity: Minor
Found in lib/parsers/redirected_to.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