datacite/levriero

View on GitHub
app/controllers/application_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage

Line is too long. [166/120]
Open

               when "ActiveModel::ForbiddenAttributesError", "ActionController::ParameterMissing", "ActionController::UnpermittedParameters", "NoMethodError" then 422

Checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop. It also ignores a shebang line by default.

This cop has some autocorrection capabilities. It can programmatically shorten certain long lines by inserting line breaks into expressions that can be safely split across lines. These include arrays, hashes, and method calls with argument lists.

If autocorrection is enabled, the following Layout cops are recommended to further format the broken lines. (Many of these are enabled by default.)

  • ArgumentAlignment
  • ArrayAlignment
  • BlockAlignment
  • BlockDelimiters
  • BlockEndNewline
  • ClosingParenthesisIndentation
  • FirstArgumentIndentation
  • FirstArrayElementIndentation
  • FirstHashElementIndentation
  • FirstParameterIndentation
  • HashAlignment
  • IndentationWidth
  • MultilineArrayLineBreaks
  • MultilineBlockLayout
  • MultilineHashBraceLayout
  • MultilineHashKeyLineBreaks
  • MultilineMethodArgumentLineBreaks
  • MultilineMethodParameterLineBreaks
  • ParameterAlignment

Together, these cops will pretty print hashes, arrays, method calls, etc. For example, let's say the max columns is 25:

Example:

# bad
{foo: "0000000000", bar: "0000000000", baz: "0000000000"}

# good
{foo: "0000000000",
bar: "0000000000", baz: "0000000000"}

# good (with recommended cops enabled)
{
  foo: "0000000000",
  bar: "0000000000",
  baz: "0000000000",
}

Line is too long. [156/120]
Open

               when "Elasticsearch::Transport::Transport::Errors::NotFound", "AbstractController::ActionNotFound", "ActionController::RoutingError" then 404

Checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop. It also ignores a shebang line by default.

This cop has some autocorrection capabilities. It can programmatically shorten certain long lines by inserting line breaks into expressions that can be safely split across lines. These include arrays, hashes, and method calls with argument lists.

If autocorrection is enabled, the following Layout cops are recommended to further format the broken lines. (Many of these are enabled by default.)

  • ArgumentAlignment
  • ArrayAlignment
  • BlockAlignment
  • BlockDelimiters
  • BlockEndNewline
  • ClosingParenthesisIndentation
  • FirstArgumentIndentation
  • FirstArrayElementIndentation
  • FirstHashElementIndentation
  • FirstParameterIndentation
  • HashAlignment
  • IndentationWidth
  • MultilineArrayLineBreaks
  • MultilineBlockLayout
  • MultilineHashBraceLayout
  • MultilineHashKeyLineBreaks
  • MultilineMethodArgumentLineBreaks
  • MultilineMethodParameterLineBreaks
  • ParameterAlignment

Together, these cops will pretty print hashes, arrays, method calls, etc. For example, let's say the max columns is 25:

Example:

# bad
{foo: "0000000000", bar: "0000000000", baz: "0000000000"}

# good
{foo: "0000000000",
bar: "0000000000", baz: "0000000000"}

# good (with recommended cops enabled)
{
  foo: "0000000000",
  bar: "0000000000",
  baz: "0000000000",
}

Rename is_admin_or_staff? to admin_or_staff?.
Open

  def is_admin_or_staff?

Checks that predicate methods names end with a question mark and do not start with a forbidden prefix.

A method is determined to be a predicate method if its name starts with one of the prefixes defined in the NamePrefix configuration. You can change what prefixes are considered by changing this option. Any method name that starts with one of these prefixes is required by the cop to end with a ?. Other methods can be allowed by adding to the AllowedMethods configuration.

NOTE: The is_a? method is allowed by default.

If ForbiddenPrefixes is set, methods that start with the configured prefixes will not be allowed and will be removed by autocorrection.

In other words, if ForbiddenPrefixes is empty, a method named is_foo will register an offense only due to the lack of question mark (and will be autocorrected to is_foo?). If ForbiddenPrefixes contains is_, is_foo will register an offense both because the ? is missing and because of the is_ prefix, and will be corrected to foo?.

NOTE: ForbiddenPrefixes is only applied to prefixes in NamePrefix; a prefix in the former but not the latter will not be considered by this cop.

Example:

# bad
def is_even(value)
end

def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value
end

def has_value?
end

# good
def value?
end

Example: AllowedMethods: ['is_a?'] (default)

# good
def is_a?(value)
end

There are no issues that match your filters.

Category
Status