DanMeakin/ratebeer

View on GitHub

Showing 116 of 116 total issues

Use %i or %I for an array of symbols.
Open

      [:rating,
       :rating_breakdown].each do |attr|
Severity: Minor
Found in lib/ratebeer/beer/review.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]

Trailing whitespace detected.
Open

    
Severity: Minor
Found in lib/ratebeer/search.rb by rubocop

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

      generic_words.each { |w| query.gsub!(w, " ") }
Severity: Minor
Found in lib/ratebeer/search.rb by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Freeze mutable objects assigned to constants.
Open

      INFO_SELECTOR = 'table'
Severity: Minor
Found in lib/ratebeer/beer.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Useless assignment to variable - beers. Use _ or _beers as a variable name to indicate that it won't be used.
Open

      beers, breweries   = nil
Severity: Minor
Found in lib/ratebeer/search.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Useless assignment to variable - breweries. Use _ or _breweries as a variable name to indicate that it won't be used.
Open

      beers, breweries   = nil
Severity: Minor
Found in lib/ratebeer/search.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Trailing whitespace detected.
Open

    
Severity: Minor
Found in lib/ratebeer/scraping.rb by rubocop

Line is too long. [81/80]
Open

                                            name: fix_characters(cells[1].text))]
Severity: Minor
Found in lib/ratebeer/style.rb by rubocop

Provide an exception class and message as arguments to raise.
Open

      raise PageNotFoundError.new("style not found - ##{id}") if root.nil?
Severity: Minor
Found in lib/ratebeer/style.rb by rubocop

This cop checks the args passed to fail and raise. For exploded style (default), it recommends passing the exception class and message to raise, rather than construct an instance of the error. It will still allow passing just a message, or the construction of an error with more than one argument.

The exploded style works identically, but with the addition that it will also suggest constructing error objects when the exception is passed multiple arguments.

Example: EnforcedStyle: exploded (default)

# bad
raise StandardError.new("message")

# good
raise StandardError, "message"
fail "message"
raise MyCustomError.new(arg1, arg2, arg3)
raise MyKwArgError.new(key1: val1, key2: val2)

Example: EnforcedStyle: compact

# bad
raise StandardError, "message"
raise RuntimeError, arg1, arg2, arg3

# good
raise StandardError.new("message")
raise MyCustomError.new(arg1, arg2, arg3)
fail "message"

When defining the == operator, name its argument other.
Open

    def ==(other_entity)
Severity: Minor
Found in lib/ratebeer/scraping.rb by rubocop

This cop makes sure that certain binary operator methods have their sole parameter named other.

Example:

# bad
def +(amount); end

# good
def +(other); end

Use %i or %I for an array of symbols.
Open

      [:name,
       :description,
       :glassware,
       :beers]
Severity: Minor
Found in lib/ratebeer/style.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]

Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem codeclimate-test-reporter should appear before simplecov.
Open

  gem 'codeclimate-test-reporter', '~> 1.0.0'
Severity: Minor
Found in Gemfile by rubocop

Gems should be alphabetically sorted within groups.

Example:

# bad
gem 'rubocop'
gem 'rspec'

# good
gem 'rspec'
gem 'rubocop'

# good
gem 'rubocop'

gem 'rspec'

# good only if TreatCommentsAsGroupSeparators is true
# For code quality
gem 'rubocop'
# For tests
gem 'rspec'

Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency i18n should appear before nokogiri.
Open

  s.add_runtime_dependency('i18n')
Severity: Minor
Found in ratebeer.gemspec by rubocop

Dependencies in the gemspec should be alphabetically sorted.

Example:

# bad
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'

# good
spec.add_dependency 'rspec'
spec.add_dependency 'rubocop'

# good
spec.add_dependency 'rubocop'

spec.add_dependency 'rspec'

# bad
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'

# good
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'

# good
spec.add_development_dependency 'rubocop'

spec.add_development_dependency 'rspec'

# bad
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'

# good
spec.add_runtime_dependency 'rspec'
spec.add_runtime_dependency 'rubocop'

# good
spec.add_runtime_dependency 'rubocop'

spec.add_runtime_dependency 'rspec'

# good only if TreatCommentsAsGroupSeparators is true
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

      ["@beers", "@breweries"].each { |v| remove_instance_variable(v) if instance_variable_defined?(v) }
Severity: Minor
Found in lib/ratebeer/search.rb by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Line is too long. [86/80]
Open

      string = string.encode('UTF-8', invalid: :replace, undef: :replace, replace: '')
Severity: Minor
Found in lib/ratebeer/scraping.rb by rubocop

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

                     "\u0096" => "–",
Severity: Minor
Found in lib/ratebeer/scraping.rb by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Trailing whitespace detected.
Open

    [:beer_url, 
Severity: Minor
Found in lib/ratebeer/urls.rb by rubocop

Freeze mutable objects assigned to constants.
Open

    BASE_URL   = 'https://www.ratebeer.com'
Severity: Minor
Found in lib/ratebeer/urls.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

        if options
Severity: Minor
Found in lib/ratebeer/brewery.rb by rubocop

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

Trailing whitespace detected.
Open

    end 
Severity: Minor
Found in lib/ratebeer/search.rb by rubocop
Severity
Category
Status
Source
Language