Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated channel and documentation to Rubocop v0.80.0 #225

8 changes: 4 additions & 4 deletions .rubocop.yml
Expand Up @@ -2,7 +2,10 @@ inherit_from: base_rubocop.yml

require: rubocop-rspec

Style/FileName:
Layout/MultilineOperationIndentation:
Enabled: false

Naming/FileName:
Exclude:
- 'bin/codeclimate-rubocop'

Expand All @@ -17,6 +20,3 @@ Style/TrailingCommaInHashLiteral:

Style/TrailingCommaInArguments:
Enabled: false

Style/MultilineOperationIndentation:
Enabled: false
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -6,7 +6,7 @@ gem "activesupport", require: false
gem "mry", require: false
gem "parser"
gem "pry", require: false
gem "rubocop", "0.78.0", require: false
gem "rubocop", "0.80.0", require: false
gem "rubocop-i18n", require: false
gem "rubocop-migrations", require: false
gem "rubocop-minitest", require: false
Expand Down
10 changes: 6 additions & 4 deletions Gemfile.lock
Expand Up @@ -27,6 +27,7 @@ GEM
rack (2.0.7)
rainbow (3.0.0)
rake (13.0.1)
rexml (3.2.4)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
Expand All @@ -40,11 +41,12 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.0)
rubocop (0.78.0)
rubocop (0.80.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.6)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
rexml
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-i18n (2.0.1)
Expand Down Expand Up @@ -81,7 +83,7 @@ DEPENDENCIES
pry
rake
rspec
rubocop (= 0.78.0)
rubocop (= 0.80.0)
rubocop-i18n
rubocop-migrations
rubocop-minitest
Expand All @@ -93,4 +95,4 @@ DEPENDENCIES
test-prof

BUNDLED WITH
2.1.2
2.1.4
41 changes: 27 additions & 14 deletions base_rubocop.yml
Expand Up @@ -5,6 +5,13 @@
Layout/LineLength:
Enabled: false

# Disallow extra spacing for token alignment
Layout/ExtraSpacing:
AllowForAlignment: false

Layout/DotPosition:
EnforcedStyle: trailing

################################################################################
# Metrics
################################################################################
Expand All @@ -13,14 +20,24 @@ Metrics/AbcSize:
Enabled: false

################################################################################
# Style
# Naming
################################################################################

# Executables are conventionally named bin/foo-bar
Style/FileName:
Naming/FileName:
Exclude:
- bin/**/*

# We have common cases where has_ and have_ make sense
Naming/PredicateName:
Enabled: true
ForbiddenPrefixes:
- is_

################################################################################
# Style
################################################################################

# We don't (currently) document our code
Style/Documentation:
Enabled: false
Expand Down Expand Up @@ -54,9 +71,6 @@ Style/IfUnlessModifier:
Style/SignalException:
EnforcedStyle: only_raise

Style/DotPosition:
EnforcedStyle: trailing

# Common globals we allow
Style/GlobalVars:
AllowedVariables:
Expand All @@ -69,12 +83,6 @@ Style/GlobalVars:
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names

# We have common cases where has_ and have_ make sense
Style/PredicateName:
Enabled: true
ForbiddenPrefixes:
- is_

# We use %w[ ], not %w( ) because the former looks like an array
Style/PercentLiteralDelimiters:
PreferredDelimiters:
Expand All @@ -94,9 +102,14 @@ Style/Next:
Style/ModuleFunction:
Enabled: false

# Disallow extra spacing for token alignment
Style/ExtraSpacing:
AllowForAlignment: false
Style/HashEachMethods:
Enabled: false

Style/HashTransformKeys:
Enabled: false

Style/HashTransformValues:
Enabled: false

################################################################################
# Specs - be more lenient on length checks and block styles
Expand Down
14 changes: 14 additions & 0 deletions config/contents/layout/leading_comment_space.md
Expand Up @@ -29,3 +29,17 @@ or rackup options.
# Some comment
# Another line of comment
#*

### Example: AllowGemfileRubyComment: false (default)

# bad

#ruby=2.7.0
#ruby-gemset=myproject

### Example: AllowGemfileRubyComment: true

# good

#ruby=2.7.0
#ruby-gemset=myproject
8 changes: 7 additions & 1 deletion config/contents/layout/line_length.md
Expand Up @@ -12,19 +12,25 @@ 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.)

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

Together, these cops will pretty print hashes, arrays,
method calls, etc. For example, let's say the max columns
Expand Down
18 changes: 18 additions & 0 deletions config/contents/layout/space_around_operators.md
@@ -1,6 +1,10 @@
Checks that operators have space around them, except for ** which
should or shouldn't have surrounding space depending on configuration.

This cop has `AllowForAlignment` option. When `true`, allows most
uses of extra spacing if the intent is to align with an operator on
the previous or next line, not counting empty lines or comment lines.

### Example:
# bad
total = 3*4
Expand All @@ -12,6 +16,20 @@ should or shouldn't have surrounding space depending on configuration.
"apple" + "juice"
my_number = 38 / 4

### Example: AllowForAlignment: true (default)
# good
{
1 => 2,
11 => 3
}

### Example: AllowForAlignment: false
# bad
{
1 => 2,
11 => 3
}

### Example: EnforcedStyleForExponentOperator: no_space (default)
# bad
a ** b
Expand Down
37 changes: 37 additions & 0 deletions config/contents/lint/missing_cop_enable_directive.md
@@ -0,0 +1,37 @@
This cop checks that there is an `# rubocop:enable ...` statement
after a `# rubocop:disable ...` statement. This will prevent leaving
cop disables on wide ranges of code, that latter contributors to
a file wouldn't be aware of.

### Example:
# Lint/MissingCopEnableDirective:
# MaximumRangeSize: .inf

# good
# rubocop:disable Layout/SpaceAroundOperators
x= 0
# rubocop:enable Layout/SpaceAroundOperators
# y = 1
# EOF

# bad
# rubocop:disable Layout/SpaceAroundOperators
x= 0
# EOF

### Example:
# Lint/MissingCopEnableDirective:
# MaximumRangeSize: 2

# good
# rubocop:disable Layout/SpaceAroundOperators
x= 0
# With the previous, there are 2 lines on which cop is disabled.
# rubocop:enable Layout/SpaceAroundOperators

# bad
# rubocop:disable Layout/SpaceAroundOperators
x= 0
x += 1
# Including this, that's 3 lines on which the cop is disabled.
# rubocop:enable Layout/SpaceAroundOperators
21 changes: 20 additions & 1 deletion config/contents/lint/redundant_cop_disable_directive.md
@@ -1,3 +1,22 @@
# The Lint/RedundantCopDisableDirective cop needs to be disabled so as
# to be able to provide a (bad) example of a redundant disable.
# rubocop:disable Lint/RedundantCopDisableDirective
# rubocop:disable Lint/RedundantCopDisableDirective
This cop detects instances of rubocop:disable comments that can be
removed without causing any offenses to be reported. It's implemented
as a cop in that it inherits from the Cop base class and calls
add_offense. The unusual part of its implementation is that it doesn't
have any on_* methods or an investigate method. This means that it
doesn't take part in the investigation phase when the other cops do
their work. Instead, it waits until it's called in a later stage of the
execution. The reason it can't be implemented as a normal cop is that
it depends on the results of all other cops to do its work.


### Example:
# bad
# rubocop:disable Layout/LineLength
x += 1
# rubocop:enable Layout/LineLength

# good
x += 1
27 changes: 26 additions & 1 deletion config/contents/lint/redundant_cop_enable_directive.md
@@ -1,3 +1,28 @@
# The Lint/RedundantCopEnableDirective cop needs to be disabled so as
# to be able to provide a (bad) example of an unneeded enable.
# rubocop:disable Lint/RedundantCopEnableDirective
# rubocop:disable Lint/RedundantCopEnableDirective
This cop detects instances of rubocop:enable comments that can be
removed.

When comment enables all cops at once `rubocop:enable all`
that cop checks whether any cop was actually enabled.
### Example:
# bad
foo = 1
# rubocop:enable Layout/LineLength

# good
foo = 1
### Example:
# bad
# rubocop:disable Style/StringLiterals
foo = "1"
# rubocop:enable Style/StringLiterals
baz
# rubocop:enable all

# good
# rubocop:disable Style/StringLiterals
foo = "1"
# rubocop:enable all
baz
4 changes: 4 additions & 0 deletions config/contents/lint/useless_setter_call.md
@@ -1,6 +1,10 @@
This cop checks for setter call to local variable as the final
expression of a function definition.

Note: There are edge cases in which the local variable references a
value that is also accessible outside the local scope. This is not
detected by the cop, and it can yield a false positive.

### Example:

# bad
Expand Down
2 changes: 1 addition & 1 deletion config/contents/naming/memoized_instance_variable_name.md
Expand Up @@ -5,7 +5,7 @@ This cop can be configured with the EnforcedStyleForLeadingUnderscores
directive. It can be configured to allow for memoized instance variables
prefixed with an underscore. Prefixing ivars with an underscore is a
convention that is used to implicitly indicate that an ivar should not
be set or referencd outside of the memoization method.
be set or referenced outside of the memoization method.

### Example: EnforcedStyleForLeadingUnderscores: disallowed (default)
# bad
Expand Down
26 changes: 26 additions & 0 deletions config/contents/style/block_delimiters.md
Expand Up @@ -100,3 +100,29 @@ multi-line blocks.
words.each { |word|
word.flip.flop
}

### Example: BracesRequiredMethods: ['sig']

# Methods listed in the BracesRequiredMethods list, such as 'sig'
# in this example, will require `{...}` braces. This option takes
# precedence over all other configurations except IgnoredMethods.

# bad
sig do
params(
foo: string,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing comma, is this a deliberate choice?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be a choice made upstream, whether a typo or deliberate I cannot say.

).void
end
def bar(foo)
puts foo
end

# good
sig {
params(
foo: string,
).void
}
def bar(foo)
puts foo
end
17 changes: 17 additions & 0 deletions config/contents/style/double_cop_disable_directive.md
@@ -0,0 +1,17 @@
Detects double disable comments on one line. This is mostly to catch
automatically generated comments that need to be regenerated.

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

# good
# rubocop:disable Metrics/AbcSize
def f # rubocop:disable Style/For
end
# rubocop:enable Metrics/AbcSize

# if both fit on one line
def f # rubocop:disable Style/For, Metrics/AbcSize
end