Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config/contents/bundler/gem_comment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Add a comment describing each gem in your Gemfile.

### Example:
# bad

gem 'foo'

# good

# Helpers for the foo things.
gem 'foo'
2 changes: 1 addition & 1 deletion config/contents/bundler/insecure_protocol_source.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The symbol argument `:gemcutter`, `:rubygems` and `:rubyforge`
The symbol argument `:gemcutter`, `:rubygems`, and `:rubyforge`
are deprecated. So please change your source to URL string that
'https://rubygems.org' if possible, or 'http://rubygems.org' if not.

Expand Down
2 changes: 1 addition & 1 deletion config/contents/gemspec/duplicated_assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ in a gemspec.

Assigning to an attribute with the same name using `spec.foo =` will be
an unintended usage. On the other hand, duplication of methods such
as `spec.requirements`, `spec.add_runtime_dependency` and others are
as `spec.requirements`, `spec.add_runtime_dependency`, and others are
permitted because it is the intended use of appending values.

### Example:
Expand Down
12 changes: 6 additions & 6 deletions config/contents/gemspec/required_ruby_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ Thereby, RuboCop to perform static analysis working on the version
required by gemspec.

### Example:
# When `TargetRubyVersion` of .rubocop.yml is `2.3`.
# When `TargetRubyVersion` of .rubocop.yml is `2.5`.

# bad
Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.2.0'
spec.required_ruby_version = '>= 2.4.0'
end

# bad
Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.4.0'
spec.required_ruby_version = '>= 2.6.0'
end

# good
Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.3.0'
spec.required_ruby_version = '>= 2.5.0'
end

# good
Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.3'
spec.required_ruby_version = '>= 2.5'
end

# good
Gem::Specification.new do |spec|
spec.required_ruby_version = ['>= 2.3.0', '< 2.5.0']
spec.required_ruby_version = ['>= 2.5.0', '< 2.7.0']
end
5 changes: 3 additions & 2 deletions config/contents/layout/access_modifier_indentation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Modifiers should be indented as deep as method definitions, or as deep
as the class/module keyword, depending on configuration.
Bare access modifiers (those not applying to specific methods) should be
indented as deep as method definitions, or as deep as the class/module
keyword, depending on configuration.

### Example: EnforcedStyle: indent (default)
# bad
Expand Down
34 changes: 34 additions & 0 deletions config/contents/layout/align_arguments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Here we check if the arguments on a multi-line method
definition are aligned.

### Example: EnforcedStyle: with_first_argument (default)
# good

foo :bar,
:baz

foo(
:bar,
:baz
)

# bad

foo :bar,
:baz

foo(
:bar,
:baz
)

### Example: EnforcedStyle: with_fixed_indentation
# good

foo :bar,
:baz

# bad

foo :bar,
:baz
155 changes: 116 additions & 39 deletions config/contents/layout/align_hash.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Check that the keys, separators, and values of a multi-line hash
literal are aligned according to configuration. The configuration
options are:

- key (left align keys)
- key (left align keys, one space before hash rockets and values)
- separator (align hash rockets and colons, right align keys)
- table (left align keys, hash rockets, and values)

Expand All @@ -12,83 +12,160 @@ can also be configured. The options are:
- always_inspect
- always_ignore
- ignore_implicit (without curly braces)
- ignore_explicit (with curly braces)

### Example:
Alternatively you can specify multiple allowed styles. That's done by
passing a list of styles to EnforcedStyles.

# EnforcedHashRocketStyle: key (default)
# EnforcedColonStyle: key (default)

# good
### Example: EnforcedHashRocketStyle: key (default)
# bad
{
foo: bar,
ba: baz
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}

# good
{
:foo => bar,
:ba => baz
}

### Example: EnforcedHashRocketStyle: separator
# bad
{
foo: bar,
ba: baz
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
:ba => baz
}

### Example:

# EnforcedHashRocketStyle: separator
# EnforcedColonStyle: separator

#good
{
foo: bar,
ba: baz
}
# good
{
:foo => bar,
:ba => baz
}

#bad
{
foo: bar,
ba: baz
}
### Example: EnforcedHashRocketStyle: table
# bad
{
:foo => bar,
:ba => baz
:ba => baz
}

# good
{
:foo => bar,
:ba => baz
}

### Example:
### Example: EnforcedColonStyle: key (default)
# bad
{
foo: bar,
ba: baz
}
{
foo: bar,
ba: baz
}

# EnforcedHashRocketStyle: table
# EnforcedColonStyle: table
# good
{
foo: bar,
ba: baz
}

#good
### Example: EnforcedColonStyle: separator
# bad
{
foo: bar,
ba: baz
ba: baz
}

# good
{
:foo => bar,
:ba => baz
foo: bar,
ba: baz
}

#bad
### Example: EnforcedColonStyle: table
# bad
{
foo: bar,
ba: baz
}

# good
{
:foo => bar,
:ba => baz
}
foo: bar,
ba: baz
}

### Example: EnforcedLastArgumentHashStyle: always_inspect (default)
# Inspect both implicit and explicit hashes.

# bad
do_something(foo: 1,
bar: 2)

# bad
do_something({foo: 1,
bar: 2})

# good
do_something(foo: 1,
bar: 2)

# good
do_something(
foo: 1,
bar: 2
)

# good
do_something({foo: 1,
bar: 2})

# good
do_something({
foo: 1,
bar: 2
})

### Example: EnforcedLastArgumentHashStyle: always_ignore
# Ignore both implicit and explicit hashes.

# good
do_something(foo: 1,
bar: 2)

# good
do_something({foo: 1,
bar: 2})

### Example: EnforcedLastArgumentHashStyle: ignore_implicit
# Ignore only implicit hashes.

# bad
do_something({foo: 1,
bar: 2})

# good
do_something(foo: 1,
bar: 2)

### Example: EnforcedLastArgumentHashStyle: ignore_explicit
# Ignore only explicit hashes.

# bad
do_something(foo: 1,
bar: 2)

# good
do_something({foo: 1,
bar: 2})
57 changes: 49 additions & 8 deletions config/contents/layout/align_parameters.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,65 @@
Here we check if the parameters on a multi-line method call or
definition are aligned.

To set the alignment of the first argument, use the cop
FirstParameterIndentation.

### Example: EnforcedStyle: with_first_parameter (default)
# good

foo :bar,
:baz
def foo(bar,
baz)
123
end

def foo(
bar,
baz
)
123
end

# bad

def foo(bar,
baz)
123
end

# bad

foo :bar,
:baz
def foo(
bar,
baz)
123
end

### Example: EnforcedStyle: with_fixed_indentation
# good

foo :bar,
:baz
def foo(bar,
baz)
123
end

def foo(
bar,
baz
)
123
end

# bad

def foo(bar,
baz)
123
end

# bad

foo :bar,
:baz
def foo(
bar,
baz)
123
end
Loading