aboutsummaryrefslogtreecommitdiffstats
path: root/.rubocop.yml
Commit message (Collapse)AuthorAgeFilesLines
* Bump rubocop to 0.71Abhay Nikam2019-06-061-7/+6
|
* Bump RuboCop to 0.67.2Koichi ITO2019-04-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Performance cops will be extracted from RuboCop to RuboCop Performance when next RuboCop 0.68 will be released. https://github.com/rubocop-hq/rubocop/issues/5977 RuboCop 0.67 is its transition period. Since rails/rails repository uses Performance cops, This PR added rubocop-performance gem to Gemfile. And this PR fixes some offenses using the following auto-correct. ```console % bundle exec rubocop -a Offenses: activerecord/test/cases/connection_adapters/connection_handlers_multi_db_test.rb:212:26: C: [Corrected] Layout/SpaceAroundOperators: Operator = > should be surrounded by a single space. "primary" => { adapter: "sqlite3", database: "db/primary.sqlite3" } ^^ activerecord/test/cases/connection_adapters/connection_handlers_multi_db_test.rb:239:26: C: [Corrected] Layout/SpaceAroundOperators: Operator => should be surrounded by a single space. "primary" => { adapter: "sqlite3", database: "db/primary.sqlite3" } ^^ actionview/test/template/resolver_shared_tests.rb:1:1: C: [Corrected] Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true. module ResolverSharedTests ^ actionview/test/template/resolver_shared_tests.rb:10:33: C: [Corrected] Layout/SpaceAroundEqualsInParameterDefault: Surrounding space missing in default value assignment. def with_file(filename, source="File at #{filename}") ^ actionview/test/template/resolver_shared_tests.rb:106:5: C: [Corrected] Rails/RefuteMethods: Prefer assert_not_same over refute_same. refute_same a, b ^^^^^^^^^^^ 2760 files inspected, 5 offenses detected, 5 offenses corrected ```
* Layout/SpaceBeforeComment Enabled: truekei2019-04-121-0/+3
|
* Exclude all `node_modules` from the RuboCop checkyuuji.yaginuma2019-04-101-1/+1
| | | | For avoiding check against `node_modules` in railties's test dir.
* Enable `Lint/AmbiguousOperator` and `Lint/AmbiguousRegexpLiteral` copsRyuta Kamizono2019-03-061-0/+6
| | | | | | | | | | | To avoid newly adding the warnings, which are frequently addressed. ac721c855203ac7570545c0e85fe086f8e94d94a 951383bd9afa4a71c17e56d1d4eb5866da851483 8a0f235fd3bd3f3c813fa7034c6d741831e55c3e c33c03e80cbe9f27274b45fe55f93bad3af988fb 424b2019830ea4c08e86ba9ff9600aa23a54cb4f
* Enable `Performance/ReverseEach` cop to avoid newly adding `reverse.each`Ryuta Kamizono2019-03-061-0/+3
| | | | https://github.com/rails/rails/pull/35451#discussion_r262746834
* Enable `Lint/ErbNewArguments` cop to avoid the deprecated arguments warningRyuta Kamizono2019-02-011-0/+3
| | | | | | Related 5754a29a974d31cab2b4392716b9825a3d910a69. And follows Ruby standard library style https://github.com/ruby/ruby/commit/3406c5d.
* Add foreign key to active_storage_attachments for `blob_id` via new migrationbogdanvlviv2019-01-161-0/+1
| | | | | | | | | | | | | | | | | | We need this in order to be able to add this migration for users that use ActiveStorage during update their apps from Rails 5.2 to Rails 6.0. Related to #33405 `rake app:update` should update active_storage `rake app:update` should execute `rake active_storage:update` if it is used in the app that is being updated. It will add new active_storage's migrations to users' apps during update Rails. Context https://github.com/rails/rails/pull/33405#discussion_r204239399 Also, see a related discussion in the Campfire: https://3.basecamp.com/3076981/buckets/24956/chats/12416418@1236713081
* Enable `Lint/UselessAssignment` cop to avoid unused variable warnings (#34904)Ryuta Kamizono2019-01-091-0/+3
| | | | | | | | | | | | | | * Enable `Lint/UselessAssignment` cop to avoid unused variable warnings Since we've addressed the warning "assigned but unused variable" frequently. 370537de05092aeea552146b42042833212a1acc 3040446cece8e7a6d9e29219e636e13f180a1e03 5ed618e192e9788094bd92c51255dda1c4fd0eae 76ebafe594fc23abc3764acc7a3758ca473799e5 And also, I've found the unused args in c1b14ad which raises no warnings by the cop, it shows the value of the cop.
* Enable `Lint/DeprecatedClassMethods` cop to avoid using deprecated methodsyuuji.yaginuma2019-01-091-0/+3
|
* Import Action TextGeorge Claghorn2019-01-041-0/+2
|
* Enable `Lint/ShadowingOuterLocalVariable` cop to avoid newly adding the warningRyuta Kamizono2018-12-281-0/+3
| | | | | | | | | | | Since we've addressed the warning "warning: shadowing outer local variable" frequently. 2c325182b84ea4c75855c777b25de0f15fd218e5 df76eaa4f1619dfbc024235f444c602eb6d6775a b86c2a6767b939c420687db7df078625c702dc7a b658743ac2a69d196d283e780816f5ad4a305753 b18f2fe96debdcd0744f99101d1a1e0d42c41eaa
* Import Action MailboxGeorge Claghorn2018-12-251-0/+2
|
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-211-0/+3
| | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* Require Ruby 2.5 for Rails 6.Kasper Timm Hansen2018-12-191-1/+1
| | | | | | | | | | Generally followed the pattern for https://github.com/rails/rails/pull/32034 * Removes needless CI configs for 2.4 * Targets 2.5 in rubocop * Updates existing CHANGELOG entries for fewer merge conflicts * Removes Hash#slice extension as that's inlined on Ruby 2.5. * Removes the need for send on define_method in MethodCallAssertions.
* Enable `Layout/SpaceAfterSemicolon` cop to avoid newly adding odd spacingRyuta Kamizono2018-12-131-2/+5
| | | | Ref https://github.com/rails/rails/commit/59ff1ba30d9f4d34b4d478104cc3f453e553c67a#diff-38fb97fba84b1ef0f311c4110a597c44R35
* Use RuboCop 0.60.0 and remove exclude files for `Style/RedundantFreeze`Yasuo Honda2018-11-081-3/+0
| | | | | Since https://github.com/rubocop-hq/rubocop/pull/6333 has been included into RuboCop 0.60.0.
* Skip node_modules dir in the rubocop checkPrathamesh Sonpatki2018-10-051-0/+1
| | | | - Otherwise it is running the check against all files in node_modules
* Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-291-0/+6
| | | | | | | | | | | | | | | | | | | | | Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'
* Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-251-0/+1
|
* Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Enable Style/ParenthesesAroundCondition copRyuta Kamizono2018-08-191-0/+3
| | | | To prevent style check in review like https://github.com/rails/rails/pull/33608#discussion_r211087605.
* Enable Lint/UriEscapeUnescape cop not to allow using obsolete methods in the ↵Ryuta Kamizono2018-08-161-0/+3
| | | | | | future Follow up #33627.
* Enable Start/EndWith and RegexpMatch copsBart de Water2018-07-281-0/+9
| | | | | In cases where the MatchData object is not used, this provides a speed-up: https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
* Remove Rubocop's comments from Rails code basebogdanvlviv2018-07-261-0/+4
| | | | | | | | | | PR#32381 added Rubocop's comments to some tests files in order to exclude `Performance/RedundantMerge`. Turn off `Performance` cops for tests files via `Exclude` in `.rubocop.yml`. Context https://github.com/rails/rails/pull/32381#discussion_r205212331
* Bump RuboCop to 0.58.2Koichi ITO2018-07-261-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## Summary RuboCop 0.58.2 was released. https://github.com/rubocop-hq/rubocop/releases/tag/v0.58.2 And rubocop-0-58 channel is available in Code Climate. https://github.com/codeclimate/codeclimate/releases/tag/v0.76.0 https://github.com/codeclimate/codeclimate/commit/38f21f0 In addition, the following changes are made in this PR. - Replace Custom cops with Rails cops - Add jaro_winkler gem to Gemfile.lock ### Replace Custom cops with Rails cops These are compatible replacements. - Replace `CustomCops/AssertNot` cop with `Rails/AssertNot` cop. - Replace `CustomCops/RefuteNot` cop with `Rails/RefuteMethods` cop. With this replacement, it was decided to use cop of RuboCop itself. It removes the code related to CustomCops accordingly. ### Add jaro_winkler gem to Gemfile.lock Since RuboCop 0.57.0 depends on jaro_winkler gem, it has been added to Gemfile.lock.
* Turn on performance based copsDillon Welch2018-07-231-0/+9
| | | | | | | | | | | | | | | | Use attr_reader/attr_writer instead of methods method is 12% slower Use flat_map over map.flatten(1) flatten is 66% slower Use hash[]= instead of hash.merge! with single arguments merge! is 166% slower See https://github.com/rails/rails/pull/32337 for more conversation
* Enable `Layout/EmptyLinesAroundBlockBody` to reduce review cost in the futureRyuta Kamizono2018-07-121-0/+3
| | | | | | | We sometimes ask "✂️ extra blank lines" to a contributor in reviews like https://github.com/rails/rails/pull/33337#discussion_r201509738. It is preferable to deal automatically without depending on manpower.
* Enable `Lint/StringConversionInInterpolation` rubocop ruleRyuta Kamizono2018-05-211-0/+3
| | | | | To prevent redundant `to_s` like https://github.com/rails/rails/pull/32923#discussion_r189460008 automatically in the future.
* Rubocop 0.54Bart de Water2018-04-211-7/+7
| | | | Fix `.rubocop.yml: Lint/EndAlignment has the wrong namespace - should be Layout` warning
* Allow rubocop check more filesbogdanvlviv2018-04-191-2/+2
| | | | | | | | | This commit fix pattern of filenames for `CustomCops/AssertNot` and `CustomCops/RefuteNot`. rubocop should check every file under `test/`. Related to #32441, #32605
* Merge pull request #32605 from composerinteralia/assert-notRafael França2018-04-191-0/+5
|\ | | | | Add RuboCop for `assert_not` over `assert !`
| * Add RuboCop for `assert_not` over `assert !`Daniel Colson2018-04-191-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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?
* | Add exculude condition in rubocop.ymlYoshiyuki Hirano2018-04-201-0/+1
|/ | | | | * Excluded `railties/test/fixtures/tmp/**/*` from rubocop inspect files * These files are generated after running test in railties
* Add custom RuboCop for `assert_not` over `refute`Daniel Colson2018-04-031-0/+7
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Add cop for preferring 'Foo.method' over 'Foo::method'Andrew White2018-02-221-0/+4
|
* Rails 6 requires Ruby 2.4.1+Jeremy Daer2018-02-171-1/+1
| | | | | | Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug. References #32028
* Remove usage of strip_heredoc in the framework in favor of <<~Rafael Mendonça França2018-02-161-1/+1
| | | | | 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.
* Enable autocorrect for `Lint/EndAlignment` copKoichi ITO2018-01-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### 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.
* Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-141-0/+3
| | | | Follow up of #31432.
* Enable `Layout/SpaceBeforeComma` rubocop rule, and fixed moreRyuta Kamizono2017-12-121-0/+3
| | | | Follow up of #31390.
* Enable `Style/DefWithParentheses` rubocop ruleRyuta Kamizono2017-11-271-0/+3
| | | | | | | 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.
* Enable `Style/RedundantReturn` rubocop rule, and fixed a couple moreRyuta Kamizono2017-11-011-0/+4
| | | | Follow up of #31004.
* Merge pull request #31005 from shuheiktgw/remove_unnecessary_semicolonsMatthew Draper2017-10-281-0/+4
| | | | Removed unnecessary semicolons
* Remove frozen_string_literal comment from activestorage's migrationbogdanvlviv2017-08-221-0/+1
| | | | | The activestorage's migration is used as template for apps Related to #30348
* Fix RuboCop offensesKoichi ITO2017-08-161-0/+1
| | | | And enable `context_dependent` of Style/BracesAroundHashParameters cop.
* Adding frozen_string_literal pragma to Railties.Pat Allan2017-08-141-1/+0
|
* Remove unnecessary Include parameter in rubocop.ymlKoichi ITO2017-08-141-1/+0
|
* Use frozen string literal in root filesKoichi ITO2017-08-131-13/+1
|
* Use frozen string literal in ci/Koichi ITO2017-08-131-0/+1
|