app/jobs/company_relationships_job.rb

Summary

Maintainability
D
1 day
Test Coverage

Method add_cb_investors has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

  def add_cb_investors
    @cb_org.investors.each do |competitor|
      next if competitor.type == 'Person'
      ignore_invalid do
        competitor = Competitor.from_crunchbase! competitor.permalink, competitor.name
Severity: Minor
Found in app/jobs/company_relationships_job.rb - About 5 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 has too many lines. [41/30]
Open

  def add_cb_investors
    @cb_org.investors.each do |competitor|
      next if competitor.type == 'Person'
      ignore_invalid do
        competitor = Competitor.from_crunchbase! competitor.permalink, competitor.name

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for add_cb_investors is too high. [14/6]
Open

  def add_cb_investors
    @cb_org.investors.each do |competitor|
      next if competitor.type == 'Person'
      ignore_invalid do
        competitor = Competitor.from_crunchbase! competitor.permalink, competitor.name

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method add_al_founders has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def add_al_founders
    @al_startup.roles.each do |person|
      next unless person['role'] == 'founder'
      user = Http::AngelList::User.new person['tagged']['id']
      social = Founder::SOCIAL_KEYS.map { |k| [k, user.public_send(k)] }.to_h
Severity: Minor
Found in app/jobs/company_relationships_job.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 has too many lines. [32/30]
Open

  def perform_with_timeout(company_id)
    @company = Company.find(company_id)

    @company.al_id ||= Http::AngelList::Startup.find_id(@company.name)
    @al_startup = @company.angelist_startup(TIMEOUT)

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for perform_with_timeout is too high. [8/6]
Open

  def perform_with_timeout(company_id)
    @company = Company.find(company_id)

    @company.al_id ||= Http::AngelList::Startup.find_id(@company.name)
    @al_startup = @company.angelist_startup(TIMEOUT)

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method import_news has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def import_news(url, body, published_at)
    @company.investments.where(investor_id: nil).find_each do |cc|
      destroy_invalid_investments!(cc.competitor_id) and next unless (competitor = cc.competitor).present?
      competitor.investors.find_each do |investor|
        if body.include?(investor.name)
Severity: Minor
Found in app/jobs/company_relationships_job.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 add_cb_investors has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def add_cb_investors
    @cb_org.investors.each do |competitor|
      next if competitor.type == 'Person'
      ignore_invalid do
        competitor = Competitor.from_crunchbase! competitor.permalink, competitor.name
Severity: Minor
Found in app/jobs/company_relationships_job.rb - About 1 hr to fix

Method perform_with_timeout has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def perform_with_timeout(company_id)
    @company = Company.find(company_id)

    @company.al_id ||= Http::AngelList::Startup.find_id(@company.name)
    @al_startup = @company.angelist_startup(TIMEOUT)
Severity: Minor
Found in app/jobs/company_relationships_job.rb - About 1 hr to fix

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

  def add_cb_founders
    return unless (founders = @cb_org.founders).present?
    founders.each do |founder|
      person = Http::Crunchbase::Person.new(founder.permalink, TIMEOUT)
      next unless person.found?
Severity: Minor
Found in app/jobs/company_relationships_job.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_with_timeout has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def perform_with_timeout(company_id)
    @company = Company.find(company_id)

    @company.al_id ||= Http::AngelList::Startup.find_id(@company.name)
    @al_startup = @company.angelist_startup(TIMEOUT)
Severity: Minor
Found in app/jobs/company_relationships_job.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

There are no issues that match your filters.

Category
Status