| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
To prevent redundant `to_s` like https://github.com/rails/rails/pull/32923#discussion_r189460008
automatically in the future.
|
|
|
|
| |
Fix `.rubocop.yml: Lint/EndAlignment has the wrong namespace - should be Layout` warning
|
|
|
|
|
|
|
|
|
| |
This commit fix pattern of filenames for `CustomCops/AssertNot` and
`CustomCops/RefuteNot`.
rubocop should check every file under `test/`.
Related to #32441, #32605
|
|\
| |
| | |
Add RuboCop for `assert_not` over `assert !`
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We added `assert_not` in f75addd "to replace warty 'assert !foo'".
fa8d35b agrees that it is warty, and so do I. This custom Rubocop rule
turns the wart into a violation.
As with my last custom cop, https://github.com/rails/rails/pull/32441,
I want to make sure this looks right on code climate before pushing
another commit to autocorrect everything.
@toshimaru I just noticed
https://github.com/toshimaru/rubocop-rails/pull/26
Is there a better way to add these custom cops, or were you saying we
shouldn't have custom cops at all?
|
|/
|
|
|
| |
* Excluded `railties/test/fixtures/tmp/**/*` from rubocop inspect files
* These files are generated after running test in railties
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since at least cf4afc4 we have preferred `assert_not` methods over
`refute` methods. I have seen plenty of comments in PRs about this,
and we have tried to fix it a few times (5294ad8, e45f176, 8910f12,
41f50be, d4cfd54, 48a183e, and 211adb4), but the `refute` methods
keep sneaking back in.
This custom RuboCop will take care of enforcing this preference, so we
don't have to think about it again. I suspect there are other similar
stylistic preferences that could be solved with some custom RuboCops, so
I will definitely keep my eyes open. `assert_not` over `assert !` might
be a good candidate, for example.
I wasn't totally sure if `ci/custom_cops` was the best place to put
this, but nothing else seemed quite right. At one point I had it set up
as a gem, but I think custom cops like this would have limited value
in another context.
I want to see how code climate handles the new cops before
autocorrecting the existing violations. If things go as expected, I will
push another commit with those corrections.
|
| |
|
|
|
|
|
|
| |
Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug.
References #32028
|
|
|
|
|
| |
Some places we can't remove because Ruby still don't have a method
equivalent to strip_heredoc to be called in an already existent string.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
### Summary
This PR changes .rubocop.yml.
Regarding the code using `if ... else ... end`, I think the coding style
that Rails expects is as follows.
```ruby
var = if cond
a
else
b
end
```
However, the current .rubocop.yml setting does not offense for the
following code.
```ruby
var = if cond
a
else
b
end
```
I think that the above code expects offense to be warned.
Moreover, the layout by autocorrect is unnatural.
```ruby
var = if cond
a
else
b
end
```
This PR adds a setting to .rubocop.yml to make an offense warning and
autocorrect as expected by the coding style.
And this change also fixes `case ... when ... end` together.
Also this PR itself is an example that arranges the layout using
`rubocop -a`.
### Other Information
Autocorrect of `Lint/EndAlignment` cop is `false` by default.
https://github.com/bbatsov/rubocop/blob/v0.51.0/config/default.yml#L1443
This PR changes this value to `true`.
Also this PR has changed it together as it is necessary to enable
`Layout/ElseAlignment` cop to make this behavior.
|
|
|
|
| |
Follow up of #31432.
|
|
|
|
| |
Follow up of #31390.
|
|
|
|
|
|
|
| |
The def with blank `()` was newly added in #31176, but we have not used
the blank `()` style in most part of our code base.
So I've enabled `Style/DefWithParentheses` to prevent to newly added the
code.
|
|
|
|
| |
Follow up of #31004.
|
|
|
|
| |
Removed unnecessary semicolons
|
|
|
|
|
| |
The activestorage's migration is used as template for apps
Related to #30348
|
|
|
|
| |
And enable `context_dependent` of Style/BracesAroundHashParameters cop.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
We are already removing the braces around hash parameters in the last
argument in other places so we should not change the entire codebase
because of two places.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
We have some indentation cops. But now there is a little inconsistent
params indentations. Enable `Layout/FirstParameterIndentation` cop to
prevent newly inconsistent indentation added and auto-correct to
existing violations.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Refer https://github.com/bbatsov/rubocop/pull/4278/commits/54166bf76ba76b14f1bbc8a34165f175dbc3f227
for the commit
```
/path/to/rails/.rubocop.yml: Style/CaseIndentation has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/CommentIndentation has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/EmptyLines has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/EmptyLinesAroundClassBody has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/EmptyLinesAroundMethodBody has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/EmptyLinesAroundModuleBody has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/IndentationConsistency has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/IndentationWidth has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/SpaceAfterColon has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/SpaceAfterComma has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/SpaceAroundEqualsInParameterDefault has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/SpaceAroundKeyword has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/SpaceAroundOperators has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/SpaceBeforeFirstArg has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/SpaceBeforeBlockBraces has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/SpaceInsideBlockBraces has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/SpaceInsideHashLiteralBraces has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/SpaceInsideParens has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/Tab has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/TrailingBlankLines has the wrong namespace - should be Layout
/path/to/rails/.rubocop.yml: Style/TrailingWhitespace has the wrong namespace - should be Layout
```
|
|
|
|
| |
empty lines
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change will help to catch ruby 2.3+ syntax in code base. Right now, minimal ruby version set to 2.2.2 in gemspecs.
Rubocop output before:
$ rubocop
Inspecting 2133 files
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................CC.........................................................................................................................................................................................................................................................
Offenses:
activerecord/test/cases/schema_dumper_test.rb:454:32: C: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
output = dump_table_schema('infinity_defaults')
^^^^^^^^^^^^^^^^^^^
guides/bug_report_templates/active_record_migrations_gem.rb:65:4: C: Final newline missing.
end
guides/bug_report_templates/active_record_migrations_master.rb:64:4: C: Final newline missing.
end
2133 files inspected, 3 offenses detected
$
After:
$ rubocop
Inspecting 2133 files
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................CC.........................................................................................................................................................................................................................................................
Offenses:
activerecord/test/cases/schema_dumper_test.rb:454:32: C: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
output = dump_table_schema('infinity_defaults')
^^^^^^^^^^^^^^^^^^^
guides/bug_report_templates/active_record_migrations_gem.rb:65:4: C: Final newline missing.
end
guides/bug_report_templates/active_record_migrations_master.rb:64:4: C: Final newline missing.
end
2133 files inspected, 3 offenses detected
$
|
|
|
|
|
|
| |
All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772.
But comments was still kept absolute position. This commit aligns
comments with method definitions for consistency.
|
|
|
|
|
|
|
|
| |
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces
Fix all violations in the repository.
|
| |
|
| |
|