varvet/godmin

View on GitHub

Showing 116 of 116 total issues

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

        unless options[:collection].is_a? Proc
Severity: Minor
Found in lib/godmin/helpers/filters.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?

Indent the first parameter one step more than apply_filters(.
Open

              params[:filter], apply_scope(

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)

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

    It is generated by running `rake sandbox:deploy` inside the Godmin repo.
Severity: Minor
Found in template.rb by rubocop

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

<% if namespaced? -%>

Avoid the use of Perl-style backrefs.
Open

                $1 == "desc" ? "asc" : "desc"
Severity: Minor
Found in lib/godmin/helpers/tables.rb by rubocop

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)

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

            data: { behavior: "select-box" }
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)

unexpected token tRPAREN (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

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

    It is generated by running `rake sandbox:deploy` inside the Godmin repo.
Severity: Minor
Found in template.rb by rubocop

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

<% module_namespacing do -%>

unterminated string meets end of file (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

require_dependency "<%= File.join(namespaced_path, "application_controller") %>"

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

Avoid the use of Perl-style backrefs.
Open

                $1
Severity: Minor
Found in lib/godmin/helpers/tables.rb by rubocop

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)

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

        if resource_parents.present?

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?

unexpected token tIDENTIFIER (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 %r around regular expression.
Open

      prefix.sub(/\A#{File.join(@engine_wrapper.namespaced_path)}/, "").sub(/\A\//, "")
Severity: Minor
Found in lib/godmin/resolver.rb by rubocop

This cop enforces using // or %r around regular expressions.

Example: EnforcedStyle: slashes (default)

# bad
snake_case = %r{^[\dA-Z_]+$}

# bad
regex = %r{
  foo
  (bar)
  (baz)
}x

# good
snake_case = /^[\dA-Z_]+$/

# good
regex = /
  foo
  (bar)
  (baz)
/x

Example: EnforcedStyle: percent_r

# bad
snake_case = /^[\dA-Z_]+$/

# bad
regex = /
  foo
  (bar)
  (baz)
/x

# good
snake_case = %r{^[\dA-Z_]+$}

# good
regex = %r{
  foo
  (bar)
  (baz)
}x

Example: EnforcedStyle: mixed

# bad
snake_case = %r{^[\dA-Z_]+$}

# bad
regex = /
  foo
  (bar)
  (baz)
/x

# good
snake_case = /^[\dA-Z_]+$/

# good
regex = %r{
  foo
  (bar)
  (baz)
}x

Example: AllowInnerSlashes: false (default)

# If `false`, the cop will always recommend using `%r` if one or more
# slashes are found in the regexp string.

# bad
x =~ /home\//

# good
x =~ %r{home/}

Example: AllowInnerSlashes: true

# good
x =~ /home\//

Freeze mutable objects assigned to constants.
Open

  VERSION = "2.3.0"
Severity: Minor
Found in lib/godmin/version.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

Indent the first parameter one step more than apply_order(.
Open

            params[:order], apply_filters(

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)

Use find_by instead of dynamic find_by_login.
Open

        @admin_user = admin_user_class.find_by_login(admin_user_login)

This cop checks dynamic find_by_* methods. Use find_by instead of dynamic method. See. https://github.com/bbatsov/rails-style-guide#find_by

Example:

# bad
User.find_by_name(name)

# bad
User.find_by_name_and_email(name)

# bad
User.find_by_email!(name)

# good
User.find_by(name: name)

# good
User.find_by(name: name, email: email)

# good
User.find_by!(email: email)

Line is too long. [133/120]
Open

    inject_into_file File.join("app/controllers", namespaced_path, "application_controller.rb"), after: "ActionController::Base\n" do

Use %r around regular expression.
Open

    gsub_file application_js, /\/\/= require turbolinks\n/, ""

This cop enforces using // or %r around regular expressions.

Example: EnforcedStyle: slashes (default)

# bad
snake_case = %r{^[\dA-Z_]+$}

# bad
regex = %r{
  foo
  (bar)
  (baz)
}x

# good
snake_case = /^[\dA-Z_]+$/

# good
regex = /
  foo
  (bar)
  (baz)
/x

Example: EnforcedStyle: percent_r

# bad
snake_case = /^[\dA-Z_]+$/

# bad
regex = /
  foo
  (bar)
  (baz)
/x

# good
snake_case = %r{^[\dA-Z_]+$}

# good
regex = %r{
  foo
  (bar)
  (baz)
}x

Example: EnforcedStyle: mixed

# bad
snake_case = %r{^[\dA-Z_]+$}

# bad
regex = /
  foo
  (bar)
  (baz)
/x

# good
snake_case = /^[\dA-Z_]+$/

# good
regex = %r{
  foo
  (bar)
  (baz)
}x

Example: AllowInnerSlashes: false (default)

# If `false`, the cop will always recommend using `%r` if one or more
# slashes are found in the regexp string.

# bad
x =~ /home\//

# good
x =~ %r{home/}

Example: AllowInnerSlashes: true

# good
x =~ /home\//
Severity
Category
Status
Source
Language