znamenica/dneslov

View on GitHub
app/controllers/admin/memory_names_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Block body expression is on the same line as the block start.
Open

         format.json { render :index, json: @names.limit(500),
                                      locales: @locales,
                                      serializer: Admin::AutocompleteSerializer,
                                      total: @names.count,
                                      each_serializer: Admin::ShortNameSerializer }

This cop checks whether the multiline do end blocks have a newline after the start of the block. Additionally, it checks whether the block arguments, if any, are on the same line as the start of the block.

Example:

# bad
blah do |i| foo(i)
  bar(i)
end

# bad
blah do
  |i| foo(i)
  bar(i)
end

# good
blah do |i|
  foo(i)
  bar(i)
end

# bad
blah { |i| foo(i)
  bar(i)
}

# good
blah { |i|
  foo(i)
  bar(i)
}

Avoid using {...} for multi-line blocks.
Open

         format.json { render :index, json: @names.limit(500),

Check for uses of braces or do/end around single line or multi-line blocks.

Example: EnforcedStyle: linecountbased (default)

# bad - single line block
items.each do |item| item / 5 end

# good - single line block
items.each { |item| item / 5 }

# bad - multi-line block
things.map { |thing|
  something = thing.some_method
  process(something)
}

# good - multi-line block
things.map do |thing|
  something = thing.some_method
  process(something)
end

Example: EnforcedStyle: semantic

# Prefer `do...end` over `{...}` for procedural blocks.

# return value is used/assigned
# bad
foo = map do |x|
  x
end
puts (map do |x|
  x
end)

# return value is not used out of scope
# good
map do |x|
  x
end

# Prefer `{...}` over `do...end` for functional blocks.

# return value is not used out of scope
# bad
each { |x|
  x
}

# return value is used/assigned
# good
foo = map { |x|
  x
}
map { |x|
  x
}.inspect

Example: EnforcedStyle: bracesforchaining

# bad
words.each do |word|
  word.flip.flop
end.join("-")

# good
words.each { |word|
  word.flip.flop
}.join("-")

Expression at 10, 83 should be on its own line.
Open

                                      each_serializer: Admin::ShortNameSerializer }

This cop checks whether the end statement of a do..end block is on its own line.

Example:

# bad
blah do |i|
  foo(i) end

# good
blah do |i|
  foo(i)
end

# bad
blah { |i|
  foo(i) }

# good
blah { |i|
  foo(i)
}

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

class Admin::MemoryNamesController < Admin::CommonController

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.

Missing top-level class documentation comment.
Open

class Admin::MemoryNamesController < Admin::CommonController

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Do not use space inside reference brackets.
Open

      @names = model.by_token(params[ :t ])

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Do not use space inside reference brackets.
Open

      @names = model.by_token(params[ :t ])

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

There are no issues that match your filters.

Category
Status