Showing 116 of 116 total issues
Class has too many lines. [142/100] Open
class Search
# Keys for fields scraped on RateBeer
def self.data_keys
[:query,
:beers,
- Read upRead up
- Exclude checks
This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for scrape_breweries is too high. [36.26/15] Open
def scrape_breweries
brewery_info = doc.css('#tabs table')
@breweries = brewery_info.flat_map.with_index do |tbl, i|
status = i == 0 ? 'Active' : 'Out of Business'
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [23/10] Open
def scrape_breweries
brewery_info = doc.css('#tabs table')
@breweries = brewery_info.flat_map.with_index do |tbl, i|
status = i == 0 ? 'Active' : 'Out of Business'
- Read upRead up
- Exclude checks
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.
Assignment Branch Condition size for process_beer_row is too high. [27.68/15] Open
def process_beer_row(row)
result = [:id, :name, :score, :ratings, :url].zip([nil]).to_h
content = row.element_children.map { |x| fix_characters(x.text) }
result[:name] = row.element_children.first.at_css('a').text
result[:score], result[:ratings] = content.values_at(3, 4)
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for run_search is too high. [24.7/15] Open
def run_search
@beers, @breweries = nil
tables = doc.css('h2').map(&:text).zip(doc.css('table'))
beers, breweries = nil
tables.each do |(heading, table)|
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [17/10] Open
def run_search
@beers, @breweries = nil
tables = doc.css('h2').map(&:text).zip(doc.css('table'))
beers, breweries = nil
tables.each do |(heading, table)|
- Read upRead up
- Exclude checks
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.
Method has too many lines. [17/10] Open
def all_styles(include_hidden = false)
doc = Scraping.noko_doc(URI.join(BASE_URL, '/beerstyles/'))
root = doc.at_css('div.container-fluid')
categories = root.css('h3').map(&:text)
- Read upRead up
- Exclude checks
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.
Assignment Branch Condition size for all_styles is too high. [21.21/15] Open
def all_styles(include_hidden = false)
doc = Scraping.noko_doc(URI.join(BASE_URL, '/beerstyles/'))
root = doc.at_css('div.container-fluid')
categories = root.css('h3').map(&:text)
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for scrape_rating is too high. [19.1/15] Open
def scrape_rating
raw_rating = [:overall,
:style].zip(doc.css('#_aggregateRating6 div')
.select { |d| d['title'] =~ /This figure/ }
.map { |d| d['title'].split(':').first.to_f }).to_h
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [13/10] Open
def strip_generic_terms(query)
generic_words = ["Brew",
"Brewers",
"Brewery",
"Brewing",
- Read upRead up
- Exclude checks
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.
Assignment Branch Condition size for scrape_misc is too high. [18.03/15] Open
def scrape_misc
doc.at_css('.stats-container')
.children
.map(&:text)
.flat_map { |x| x.gsub(nbsp, ' ').strip.split(':') }
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for scrape_beers is too high. [18.25/15] Open
def scrape_beers
@beers = beer_list.css('tr').drop(1).map do |row|
cells = row.css('td')
url = cells[1].at_css('a')['href']
[cells[0].text.to_i, Beer::Beer.new(url.split('/').last,
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for process_breweries_table is too high. [18.03/15] Open
def process_breweries_table(table)
table.css('tr').map do |row|
result = [:id, :name, :location, :url].zip([nil]).to_h
result[:name], result[:location] = row.element_children.map do |x|
fix_characters(x.text)
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [12/10] Open
def process_beer_row(row)
result = [:id, :name, :score, :ratings, :url].zip([nil]).to_h
content = row.element_children.map { |x| fix_characters(x.text) }
result[:name] = row.element_children.first.at_css('a').text
result[:score], result[:ratings] = content.values_at(3, 4)
- Read upRead up
- Exclude checks
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.
Method has too many lines. [11/10] Open
def process_beers_table(table)
beers = []
threads = []
mutex = Mutex.new
table.css('tr').drop(1).map do |r|
- Read upRead up
- Exclude checks
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.
Method has too many lines. [11/10] Open
def process_brewed_at_for(node)
brewed_at_for_node = node.at_css('div.small em')
return {} if brewed_at_for_node.nil?
node_text = brewed_at_for_node.children.first.text
key = if node_text.include?('Brewed at')
- Read upRead up
- Exclude checks
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 inspect is too high. [7/6] Open
def inspect
num_beers = @beers && @beers.count || 0
num_breweries = @breweries && @breweries.count || 0
val = "#<#{self.class} - #{@query}"
val << " - #{num_beers} beers / #{num_breweries} breweries" if @beers || @breweries
- Read upRead up
- Exclude checks
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.
Assignment Branch Condition size for process_beer_row is too high. [15.3/15] Open
def process_beer_row(row)
beer = process_beer_name_cell(row.css('td').first)
beer[:abv] = row.css('td')[1].text.to_f
beer[:date_added] = Date.strptime(row.css('td')[2].text, '%m/%d/%Y')
Beer::Beer.new(id, beer.merge(process_rating_info(row)))
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for review_chunks is too high. [15.13/15] Open
def review_chunks
doc.flat_map do |page|
page.css('div div')
.children
.select { |x| x.name == 'div' || x.name == 'small' }
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method scrape_breweries
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def scrape_breweries
brewery_info = doc.css('#tabs table')
@breweries = brewery_info.flat_map.with_index do |tbl, i|
status = i == 0 ? 'Active' : 'Out of Business'
- Read upRead up
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"