disclosed/disclosed_app

View on GitHub

Showing 5 of 23 total issues

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

  def parse
    return if !self.raw_date?
    date_range_match = raw_date.match(/(.*)\sto\s(.*)/i)
    date_range_match ||= raw_date.match(/(\d{4}\-\d{2}\-\d{2})\s*to\s*(\d{4}\-\d{2}\-\d{2})/)
    date_range_match ||= raw_date.match(/(\d{4}\-\d{2}\-\d{2})\s*\-\s*(\d{4}\-\d{2}\-\d{2})/)
Severity: Minor
Found in lib/contract_period_parser.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 extract has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def extract
    @row_mappings.each do |mapping|
      @result[mapping.field] = @page.xpath('//tr[regex(., "' + mapping.label + '")]//td[regex(., "^(?!.*' + mapping.label + ').*$")]', NokogiriXpathExtensions.new).text.strip
      @result[mapping.field] = clean_nbsp(@result[mapping.field])
      @result[mapping.field] = clean_dash(@result[mapping.field])
Severity: Minor
Found in lib/scrapers/table_extractor.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 scrape_contract has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def scrape_contract(url)
    mappings = [
      Scrapers::TableMapping.new(:vendor_name),
      Scrapers::TableMapping.new(:reference_number),
      Scrapers::TableMapping.new(:raw_contract_period, "contract period"),
Severity: Minor
Found in lib/scrapers/nafta/scraper.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 extract has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def extract
    @row_mappings.each do |mapping|
      @result[mapping.field] = @page.xpath('//dl/dt[regex(., "' + mapping.label + '")]/following-sibling::dd[position()=1]', NokogiriXpathExtensions.new).text.strip
      @result[mapping.field] = clean_nbsp(@result[mapping.field])
      @result[mapping.field] = clean_dash(@result[mapping.field])
Severity: Minor
Found in lib/scrapers/dl_extractor.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 upsert_into_db! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def upsert_into_db!(&callback)
    @contracts.each_with_index do |contract, i|
      attributes = build_attributes(contract)
      context = SaveContractFromScraper.call(attributes: attributes, agency: attributes[:agency])
      if context.success?
Severity: Minor
Found in lib/contract_loader.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