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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem "activesupport", require: false
gem "mry", require: false
gem "parser"
gem "pry", require: false
gem "rubocop", "0.81.0", require: false
gem "rubocop", "0.82.0", require: false
gem "rubocop-i18n", require: false
gem "rubocop-migrations", require: false
gem "rubocop-minitest", require: false
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.0)
rubocop (0.81.0)
rubocop (0.82.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
Expand Down Expand Up @@ -83,7 +83,7 @@ DEPENDENCIES
pry
rake
rspec
rubocop (= 0.81.0)
rubocop (= 0.82.0)
rubocop-i18n
rubocop-migrations
rubocop-minitest
Expand Down
28 changes: 28 additions & 0 deletions config/contents/layout/indentation_style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
This cop checks that the indentation method is consistent.
Either tabs only or spaces only are used for indentation.

### Example: EnforcedStyle: spaces (default)
# bad
# This example uses a tab to indent bar.
def foo
bar
end

# good
# This example uses spaces to indent bar.
def foo
bar
end

### Example: EnforcedStyle: tabs
# bad
# This example uses spaces to indent bar.
def foo
bar
end

# good
# This example uses a tab to indent bar.
def foo
bar
end
2 changes: 1 addition & 1 deletion config/contents/layout/line_length.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This cop 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/Tab` cop.
of the `Layout/IndentationStyle` cop.
It also ignores a shebang line by default.

This cop has some autocorrection capabilities.
Expand Down
30 changes: 30 additions & 0 deletions config/contents/layout/space_around_method_call_operator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Checks method call operators to not have spaces around them.

### Example:
# bad
foo. bar
foo .bar
foo . bar
foo. bar .buzz
foo
. bar
. buzz
foo&. bar
foo &.bar
foo &. bar
foo &. bar&. buzz
RuboCop:: Cop
RuboCop:: Cop:: Cop
:: RuboCop::Cop

# good
foo.bar
foo.bar.buzz
foo
.bar
.buzz
foo&.bar
foo&.bar&.buzz
RuboCop::Cop
RuboCop::Cop::Cop
::RuboCop::Cop
17 changes: 16 additions & 1 deletion config/contents/lint/raise_exception.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
This cop checks for `raise` or `fail` statements which are
raising `Exception` class.

You can specify a module name that will be an implicit namespace
using `AllowedImplicitNamespaces` option. The cop cause a false positive
for namespaced `Exception` when a namespace is omitted. This option can
prevent the false positive by specifying a namespace to be omitted for
`Exception`. Alternatively, make `Exception` a fully qualified class
name with an explicit namespace.

### Example:
# bad
raise Exception, 'Error message here'

# good
raise StandardError, 'Error message here'
raise StandardError, 'Error message here'

### Example: AllowedImplicitNamespaces: ['Gem']
# good
module Gem
def self.foo
raise Exception # This exception means `Gem::Exception`.
end
end
13 changes: 13 additions & 0 deletions config/contents/style/case_equality.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,16 @@ This cop checks for uses of the case equality operator(===).
something.is_a?(Array)
(1..100).include?(7)
some_string =~ /something/

### Example: AllowOnConstant
# Style/CaseEquality:
# AllowOnConstant: true

# bad
(1..100) === 7
/something/ === some_string

# good
Array === something
(1..100).include?(7)
some_string =~ /something/
14 changes: 14 additions & 0 deletions config/contents/style/disable_cops_within_source_code_directive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Detects comments to enable/disable RuboCop.
This is useful if want to make sure that every RuboCop error gets fixed
and not quickly disabled with a comment.

### Example:
# bad
# rubocop:disable Metrics/AbcSize
def f
end
# rubocop:enable Metrics/AbcSize

# good
def fixed_method_name_and_no_rubocop_comments
end
54 changes: 54 additions & 0 deletions config/contents/style/exponential_notation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
This cop enforces consistency when using exponential notation
for numbers in the code (eg 1.2e4). Different styles are supported:
- `scientific` which enforces a mantissa between 1 (inclusive)
and 10 (exclusive).
- `engineering` which enforces the exponent to be a multiple of 3
and the mantissa to be between 0.1 (inclusive)
and 10 (exclusive).
- `integral` which enforces the mantissa to always be a whole number
without trailing zeroes.

### Example: EnforcedStyle: scientific (default)
# Enforces a mantissa between 1 (inclusive) and 10 (exclusive).

# bad
10e6
0.3e4
11.7e5
3.14e0

# good
1e7
3e3
1.17e6
3.14

### Example: EnforcedStyle: engineering
# Enforces using multiple of 3 exponents,
# mantissa should be between 0.1 (inclusive) and 1000 (exclusive)

# bad
3.2e7
0.1e5
12e5
1232e6

# good
32e6
10e3
1.2e6
1.232e9

### Example: EnforcedStyle: integral
# Enforces the mantissa to have no decimal part and no
# trailing zeroes.

# bad
3.2e7
0.1e5
120e4

# good
32e6
1e4
12e5
2 changes: 1 addition & 1 deletion config/contents/style/if_unless_modifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ written as modifier `if`/`unless`. The cop also checks for modifier

The maximum line length is configured in the `Layout/LineLength`
cop. The tab size is configured in the `IndentationWidth` of the
`Layout/Tab` cop.
`Layout/IndentationStyle` cop.

### Example:
# bad
Expand Down
3 changes: 2 additions & 1 deletion config/contents/style/trailing_comma_in_arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ The supported styles are:
for all parenthesized method calls with arguments.
- `comma`: Requires a comma after the last argument, but only for
parenthesized method calls where each argument is on its own line.
- `no_comma`: Does not requires a comma after the last argument.
- `no_comma`: Requires that there is no comma after the last
argument.

### Example: EnforcedStyleForMultiline: consistent_comma
# bad
Expand Down
12 changes: 8 additions & 4 deletions spec/cc/engine/config_upgrader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ def get_true
end
CODE
create_source_file(".rubocop.yml", <<~CONFIG)
Layout/SpaceAroundMethodCallOperator:
Enabled: false
Lint/RaiseException:
Enabled: false
Lint/StructNewOverride:
Enabled: false
Style/AccessorMethodName:
Enabled: false
Style/ExponentialNotation:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Style/HashEachMethods:
Expand All @@ -23,10 +31,6 @@ def get_true
Enabled: true
Style/HashTransformValues:
Enabled: true
Lint/RaiseException:
Enabled: false
Lint/StructNewOverride:
Enabled: false
CONFIG

# No warnings about obsolete cop name
Expand Down