rauversion/rauversion-ror

View on GitHub
app/services/fetch_link_card_service.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method attempt_oembed has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def attempt_oembed(card, url)
    response = OEmbed::Providers.get(url)
    card.type = response.type
    card.title = response.respond_to?(:title) ? response.title : ""
    card.author_name = response.respond_to?(:author_name) ? response.author_name : ""
Severity: Minor
Found in app/services/fetch_link_card_service.rb - About 2 hrs 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 attempt_opengraph has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def attempt_opengraph(card, url)
    response = http_client.get(url)

    return if response.code != 200 || response.mime_type != "text/html"

Severity: Minor
Found in app/services/fetch_link_card_service.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 parse_urls has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_urls(status)
    if status.local?
      urls = status.text.match(URL_PATTERN).to_a.map { |uri| Addressable::URI.parse(uri).normalize }
    else
      html = Nokogiri::HTML(status.text)
Severity: Minor
Found in app/services/fetch_link_card_service.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(url)
    # Get first http/https URL that isn't local
    # url = parse_urls(status)
    return if url.nil?

Severity: Minor
Found in app/services/fetch_link_card_service.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

There are no issues that match your filters.

Category
Status