Indent when
as deep as case
. Open
when TemplateDeclarationType::REMOTE_TEMPLATE
- Read upRead up
- Exclude checks
This cop checks how the whens of a case expression are indented in relation to its case or end keyword.
It will register a separate offense for each misaligned when.
Example:
# If Layout/EndAlignment is set to keyword style (default)
# *case* and *end* should always be aligned to same depth,
# and therefore *when* should always be aligned to both -
# regardless of configuration.
# bad for all styles
case n
when 0
x * 2
else
y / 3
end
# good for all styles
case n
when 0
x * 2
else
y / 3
end
Example: EnforcedStyle: case (default)
# if EndAlignment is set to other style such as
# start_of_line (as shown below), then *when* alignment
# configuration does have an effect.
# bad
a = case n
when 0
x * 2
else
y / 3
end
# good
a = case n
when 0
x * 2
else
y / 3
end
Example: EnforcedStyle: end
# bad
a = case n
when 0
x * 2
else
y / 3
end
# good
a = case n
when 0
x * 2
else
y / 3
end
Indent when
as deep as case
. Open
when TemplateDeclarationType::LOCAL_TEMPLATE
- Read upRead up
- Exclude checks
This cop checks how the whens of a case expression are indented in relation to its case or end keyword.
It will register a separate offense for each misaligned when.
Example:
# If Layout/EndAlignment is set to keyword style (default)
# *case* and *end* should always be aligned to same depth,
# and therefore *when* should always be aligned to both -
# regardless of configuration.
# bad for all styles
case n
when 0
x * 2
else
y / 3
end
# good for all styles
case n
when 0
x * 2
else
y / 3
end
Example: EnforcedStyle: case (default)
# if EndAlignment is set to other style such as
# start_of_line (as shown below), then *when* alignment
# configuration does have an effect.
# bad
a = case n
when 0
x * 2
else
y / 3
end
# good
a = case n
when 0
x * 2
else
y / 3
end
Example: EnforcedStyle: end
# bad
a = case n
when 0
x * 2
else
y / 3
end
# good
a = case n
when 0
x * 2
else
y / 3
end
Extra empty line detected at class body beginning. Open
# Provides the appropriate strategy for a given template type
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of classes match the configuration.
Example: EnforcedStyle: empty_lines
# good
class Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
class Foo
class Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
class Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
class Foo
def bar
# ...
end
end
Extra empty line detected at module body beginning. Open
# Factory that creates a proper installer for a given template type
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of modules match the configuration.
Example: EnforcedStyle: empty_lines
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
module Foo
module Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
module Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
module Foo
def bar
# ...
end
end
Redundant return
detected. Open
return Generamba::CatalogInstaller.new
- Read upRead up
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Redundant return
detected. Open
return nil
- Read upRead up
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Final newline missing. Open
end
- Exclude checks
Redundant return
detected. Open
return Generamba::RemoteInstaller.new
- Read upRead up
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Indent when
as deep as case
. Open
when TemplateDeclarationType::CATALOG_TEMPLATE
- Read upRead up
- Exclude checks
This cop checks how the whens of a case expression are indented in relation to its case or end keyword.
It will register a separate offense for each misaligned when.
Example:
# If Layout/EndAlignment is set to keyword style (default)
# *case* and *end* should always be aligned to same depth,
# and therefore *when* should always be aligned to both -
# regardless of configuration.
# bad for all styles
case n
when 0
x * 2
else
y / 3
end
# good for all styles
case n
when 0
x * 2
else
y / 3
end
Example: EnforcedStyle: case (default)
# if EndAlignment is set to other style such as
# start_of_line (as shown below), then *when* alignment
# configuration does have an effect.
# bad
a = case n
when 0
x * 2
else
y / 3
end
# good
a = case n
when 0
x * 2
else
y / 3
end
Example: EnforcedStyle: end
# bad
a = case n
when 0
x * 2
else
y / 3
end
# good
a = case n
when 0
x * 2
else
y / 3
end
Redundant return
detected. Open
return Generamba::LocalInstaller.new
- Read upRead up
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.