varvet/godmin

View on GitHub

Showing 116 of 116 total issues

unexpected token tFID (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

<% if namespaced? -%>

-' interpreted as argument prefix (Using Ruby 2.1 parser; configure usingTargetRubyVersionparameter, underAllCops`)
Open

<% if namespaced? -%>

unexpected token tLT (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

<% module_namespacing do -%>

Use if params[:batch_action].blank? instead of unless params[:batch_action].present?.
Open

          return unless params[:batch_action].present?

This cops checks for code that can be changed to blank?. Settings: NilOrEmpty: Convert checks for nil or empty? to blank? NotPresent: Convert usages of not present? to blank? UnlessPresent: Convert usages of unless present? to blank?

Example:

# NilOrEmpty: true
  # bad
  foo.nil? || foo.empty?
  foo == nil || foo.empty?

  # good
  foo.blank?

# NotPresent: true
  # bad
  !foo.present?

  # good
  foo.blank?

# UnlessPresent: true
  # bad
  something unless foo.present?
  unless foo.present?
    something
  end

  # good
  something if foo.blank?
  if foo.blank?
    something
  end

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

          if scope && scope_map.key?(scope.to_sym)

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

Use scope.presence || default_scope instead of scope.blank? ? default_scope : scope.
Open

          @scope = scope.blank? ? default_scope : scope

This cop checks code that can be written more easily using Object#presence defined by Active Support.

Example:

# bad
a.present? ? a : nil

# bad
!a.present? ? nil : a

# bad
a.blank? ? nil : a

# bad
!a.blank? ? a : nil

# good
a.presence

Example:

# bad
a.present? ? a : b

# bad
!a.present? ? b : a

# bad
a.blank? ? b : a

# bad
!a.blank? ? a : b

# good
a.presence || b

unexpected token tLPAREN2 (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

    This is the source code for a demo application of the [Godmin](https://github.com/varvet/godmin) admin framework for Rails.
Severity: Minor
Found in template.rb by rubocop

Use nested module/class definitions instead of compact style.
Open

class Godmin::ResourceGenerator < Godmin::Generators::NamedBase

This cop checks the style of children definitions at classes and modules. Basically there are two different styles:

Example: EnforcedStyle: nested (default)

# good
# have each child on its own line
class Foo
  class Bar
  end
end

Example: EnforcedStyle: compact

# good
# combine definitions as much as possible
class Foo::Bar
end

The compact style is only forced for classes/modules with one child.

Favor modifier unless usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

        unless @_partial_override.key?(partial)
Severity: Minor
Found in lib/godmin/helpers/application.rb by rubocop

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

Use =~ in places where the MatchData returned by #match will not be used.
Open

              elsif params[:order].match(/\A\w+_(asc|desc)\z/)
Severity: Minor
Found in lib/godmin/helpers/tables.rb by rubocop

This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

Example:

# bad
do_something if str.match(/regex/)
while regex.match('str')
  do_something
end

# good
method(str =~ /regex/)
return value unless regex =~ 'str'

unexpected token tLSHFT (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

  readme_text = <<~README
Severity: Minor
Found in template.rb by rubocop

Line is too long. [125/120]
Open

    inject_into_file File.join("app/assets/stylesheets", namespaced_path, "application.css"), before: " *= require_tree ." do

Use meaningful heredoc delimiters.
Open

      END

This cop checks that your heredocs are using meaningful delimiters. By default it disallows END and EO*, and can be configured through blacklisting additional delimiters.

Example:

# good
<<-SQL
  SELECT * FROM foo
SQL

# bad
<<-END
  SELECT * FROM foo
END

# bad
<<-EOS
  SELECT * FROM foo
EOS

Indent the first parameter one step more than options.deep_merge(.
Open

          value: datetime_value(attribute, options, :datepicker),
          data: { behavior: "datepicker" }
Severity: Minor
Found in lib/godmin/helpers/forms.rb by rubocop

This cop checks the indentation of the first parameter in a method call. Parameters after the first one are checked by Style/AlignParameters, not by this cop.

Example:

# bad
some_method(
first_param,
second_param)

# good
some_method(
  first_param,
second_param)

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

          if name =~ /(.+)_id$/

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

Avoid the use of Perl-style backrefs.
Open

            parents << $1.classify.constantize.find(value)

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)
Severity
Category
Status
Source
Language