diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 000000000000..cf385a135cf1 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,14 @@ +[codespell] +# Intentionally left empty, these are passed as command-line switches +check-hidden = +check-filenames = +ignore-words-list = ba, + creat, + enviromnent, + filetest, + fo, + irregardless, + mange, + ofo, + thi, + upto, diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 000000000000..e802241fffb0 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,13 @@ +;;; Directory Local Variables +;;; For more information see (info "(emacs) Directory Variables") + +((ruby-mode + (bug-reference-url-format . "https://github.com/rubocop/rubocop/issues/%s") + (bug-reference-bug-regexp . "#\\(?2:[[:digit:]]+\\)") + (indent-tabs-mode . nil) + (fill-column . 100) + (whitespace-line-column 100))) + +;; To use the bug-reference stuff, do: +;; (add-hook 'text-mode-hook #'bug-reference-mode) +;; (add-hook 'prog-mode-hook #'bug-reference-prog-mode) diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000000..4a7ea3036a20 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000000..a19ade077d36 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +CHANGELOG.md merge=union diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000000..826c9ea2455a --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,7 @@ +# These are supported funding model platforms + +github: [bbatsov, koic] +patreon: bbatsov +open_collective: rubocop +tidelift: "rubygems/rubocop" +custom: https://www.paypal.me/bbatsov diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000000..db943862c833 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,45 @@ +--- +name: Bug Report +about: Report an issue with RuboCop you've discovered. +labels: [bug] +--- + +*Be clear, concise and precise in your description of the problem. +Open an issue with a descriptive title and a summary in grammatically correct, +complete sentences.* + +*Use the template below when reporting bugs. Please, make sure that +you're running the latest stable RuboCop and that the problem you're reporting +hasn't been reported (and potentially fixed) already.* + +*Before filing the ticket you should replace all text above the horizontal +rule with your own words.* + +-------- + +## Expected behavior + +Describe here how you expected RuboCop to behave in this particular situation. + +## Actual behavior + +Describe here what actually happened. +Please use `rubocop --debug` when pasting rubocop output as it contains additional information. + +## Steps to reproduce the problem + +This is extremely important! Providing us with a reliable way to reproduce +a problem will expedite its solution. + +## RuboCop version + +Include the output of `rubocop -V` or `bundle exec rubocop -V` if using Bundler. +If you see extension cop versions (e.g. `rubocop-performance`, `rubocop-rspec`, and others) +output by `rubocop -V`, include them as well. Here's an example: + +``` +$ [bundle exec] rubocop -V +1.79.0 (using Parser 3.3.5.0, rubocop-ast 1.32.3, analyzing as Ruby 3.3, running on ruby 3.3.5) [x86_64-linux] + - rubocop-performance 1.22.1 + - rubocop-rspec 3.1.0 +``` diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000000..06a34bef1845 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: GitHub Discussions + url: https://github.com/rubocop/rubocop/discussions + about: For anything else. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000000..221ed5f73da8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,21 @@ +--- +name: Feature Request +about: Suggest new RuboCop features or improvements to existing features. +labels: [feature request] +--- + +## Is your feature request related to a problem? Please describe. + +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +## Describe the solution you'd like + +A clear and concise description of what you want to happen. + +## Describe alternatives you've considered + +A clear and concise description of any alternative solutions or features you've considered. + +## Additional context + +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/freeform.md b/.github/ISSUE_TEMPLATE/freeform.md new file mode 100644 index 000000000000..e2844add5a45 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/freeform.md @@ -0,0 +1,4 @@ +--- +name: Miscellaneous +about: For things that aren't quite feature requests or bugs but still relate to the issue tracker. +--- diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000000..226defb636a5 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ +**Replace this text with a summary of the changes in your PR. +The more detailed you are, the better.** + +----------------- + +Before submitting the PR make sure the following are checked: + +* [ ] The PR relates to *only* one subject with a clear title and description in grammatically correct, complete sentences. +* [ ] Wrote [good commit messages][1]. +* [ ] Commit message starts with `[Fix #issue-number]` (if the related issue exists). +* [ ] Feature branch is up-to-date with `master` (if not - rebase it). +* [ ] Squashed related commits together. +* [ ] Added tests. +* [ ] Ran `bundle exec rake default`. It executes all tests and runs RuboCop on its own code. +* [ ] Added an entry (file) to the [changelog folder](https://github.com/rubocop/rubocop/blob/master/changelog/) named `{change_type}_{change_description}.md` if the new code introduces user-observable changes. See [changelog entry format](https://github.com/rubocop/rubocop/blob/master/CONTRIBUTING.md#changelog-entry-format) for details. + +[1]: https://chris.beams.io/posts/git-commit/ diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000000..b18fd2935736 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'weekly' diff --git a/.github/workflows/github_release.yml b/.github/workflows/github_release.yml new file mode 100644 index 000000000000..2607babd6251 --- /dev/null +++ b/.github/workflows/github_release.yml @@ -0,0 +1,25 @@ +name: Create GitHub Release + +on: + push: + tags: + - "v*" # Trigger when a version tag is pushed (e.g., v1.0.0) + +jobs: + create-release: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Create GitHub Release + uses: ncipollo/release-action@v1 + with: + tag: ${{ github.ref_name }} + name: RuboCop ${{ github.ref_name }} + bodyFile: relnotes/${{ github.ref_name }}.md + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 000000000000..e9e651c899e8 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,64 @@ +name: Linting +on: + push: + branches: + - master + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + lint-ruby: + name: Ruby + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ruby # Latest stable CRuby version + bundler-cache: true + - name: internal_investigation + run: bundle exec rake internal_investigation + + lint-ruby-without-bundler: + name: Ruby without Bundler + runs-on: ubuntu-latest + steps: + # Install Ruby first so bundler installs no gems + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ruby # Latest stable CRuby version + - uses: actions/checkout@v4 + - name: Package and install RuboCop locally + run: | + gem build + gem install ./rubocop-*.gem --no-document + gem install rubocop-performance rubocop-rake rubocop-rspec --no-document + - name: internal_investigation + run: rubocop + # Regression test for https://github.com/rubocop/rubocop/issues/13867 + - name: internal_investigation with require + run: | + echo "require: rubocop-rspec" > .rubocop.yml + # This should never give any offense, just testing it doesn't error + rubocop Gemfile --only RSpec/AnyInstance + + lint-yaml: + permissions: + contents: read # for actions/checkout to fetch code + pull-requests: write # for karancode/yamllint-github-action to post comments on PRs + name: Yaml + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Yamllint + uses: karancode/yamllint-github-action@v3.0.0 + with: + yamllint_strict: true + yamllint_format: parsable + yamllint_comment: true + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml new file mode 100644 index 000000000000..ca700d5628b2 --- /dev/null +++ b/.github/workflows/rubocop.yml @@ -0,0 +1,174 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + workflow_dispatch: + +permissions: # added using https://github.com/step-security/secure-workflows + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + spec-ubuntu: + name: Spec - ubuntu ${{ matrix.ruby }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', 'head'] + + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Check requiring libraries successfully + # See https://github.com/rubocop/rubocop/pull/4523#issuecomment-309136113 + run: ruby -I lib -r bundler/setup -r rubocop -e 'exit 0' + - name: spec + env: + CI_RUBY_VERSION: ${{ matrix.ruby }} + CC_TEST_REPORTER_ID: dummy # Value doesn't matter, enables json formatter + STRICT_WARNINGS: 1 + run: COVERAGE=true bundle exec rake spec + - name: Upload Coverage Artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-ubuntu-${{ matrix.ruby }} + path: coverage/coverage.json + if-no-files-found: error + + spec-jruby: + name: Spec - JRuby + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 'jruby' # Latest stable JRuby version + bundler-cache: true + - name: spec + run: bundle exec rake spec + + spec-windows: + needs: spec-ubuntu # Don't spend CI resources on slow Windows specs if CI won't pass anyway. + name: Spec - windows ${{ matrix.ruby }} + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + ruby: + - '2.7' # Oldest supported version + - 'ruby' # Latest stable CRuby version + + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Check requiring libraries successfully + # See https://github.com/rubocop/rubocop/pull/4523#issuecomment-309136113 + run: ruby -I lib -r bundler/setup -r rubocop -e 'exit 0' + - name: spec + env: + CI_RUBY_VERSION: ${{ matrix.ruby }} + run: bundle exec rake spec + + upload_coverage: + name: Upload Coverage + needs: spec-ubuntu + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + name: Download Coverage Artifacts + with: + pattern: coverage-* + - uses: paambaati/codeclimate-action@v9 + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + if: ${{ env.CC_TEST_REPORTER_ID != '' }} + with: + coverageLocations: | + ${{github.workspace}}/coverage-*/coverage.json:simplecov + + ascii_spec: + name: Ascii Spec - ${{ matrix.os }} ${{ matrix.ruby }} + runs-on: ${{ matrix.os }}-latest + + strategy: + fail-fast: false + matrix: + os: [ubuntu, windows] + ruby: + - '2.7' # Oldest supported version + - 'ruby' # Latest stable CRuby version + + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: ascii_spec + env: + CI_RUBY_VERSION: ${{ matrix.ruby }} + run: bundle exec rake ascii_spec + + documentation_check: + name: Documentation Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ruby # Latest stable CRuby version + bundler-cache: true + - name: Check documentation syntax + run: bundle exec rake documentation_syntax_check + + prism: + runs-on: ubuntu-latest + name: Prism + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + # Specify the minimum Ruby version 2.7 required for Prism to run. + ruby-version: 2.7 + bundler-cache: true + - name: spec + env: + PARSER_ENGINE: parser_prism + run: bundle exec rake prism_spec + + rspec4: + runs-on: ubuntu-latest + name: RSpec 4 + steps: + - uses: actions/checkout@v4 + - name: Use latest RSpec 4 from `4-0-dev` branch + run: | + sed -e "/'rspec', '~> 3/d" -i Gemfile + cat << EOF > Gemfile.local + gem 'rspec', github: 'rspec/rspec', branch: '4-0-dev' + gem 'rspec-core', github: 'rspec/rspec', branch: '4-0-dev' + gem 'rspec-expectations', github: 'rspec/rspec', branch: '4-0-dev' + gem 'rspec-mocks', github: 'rspec/rspec', branch: '4-0-dev' + gem 'rspec-support', github: 'rspec/rspec', branch: '4-0-dev' + EOF + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + bundler-cache: true + - name: spec + run: bundle exec rake spec diff --git a/.github/workflows/spell_checking.yml b/.github/workflows/spell_checking.yml new file mode 100644 index 000000000000..ef255974413f --- /dev/null +++ b/.github/workflows/spell_checking.yml @@ -0,0 +1,28 @@ +name: Spell Checking + +on: [pull_request] + +permissions: # added using https://github.com/step-security/secure-workflows + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + codespell: + name: Check spelling of all files with codespell + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: codespell-project/actions-codespell@v2 + + misspell: + name: Check spelling of all files in commit with misspell + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install + run: wget -O - -q https://raw.githubusercontent.com/client9/misspell/master/install-misspell.sh | sh -s -- -b . + - name: Misspell + run: git ls-files --empty-directory | xargs ./misspell -i 'enviromnent' -error diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 000000000000..c1bd3ce8f433 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,38 @@ +name: Close inactive issues and pull requests +on: + schedule: + - cron: "30 1 * * *" + +jobs: + close-issues: + if: (github.repository == 'rubocop/rubocop') + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/stale@v9 + with: + days-before-issue-stale: 90 + days-before-issue-close: 30 + stale-issue-label: "stale" + exempt-all-milestones: true + exempt-issue-labels: "bug, high priority, good first issue, pinned" + stale-issue-message: >- + This issue has been automatically marked as stale because it has not + had any recent activity. It will be closed soon if no further + activity occurs. Thank you for your understanding! + close-issue-message: >- + This issue has been automatically closed due to lack of activity. Feel free to ask + for it to be re-opened if you ever come back to it. + days-before-pr-stale: 30 + days-before-pr-close: 30 + exempt-pr-labels: "high priority, good first issue, pinned" + stale-pr-message: >- + This pull request has been automatically marked as stale because it has not + had any recent activity. It will be closed soon if no further + activity occurs. Thank you for your contribution and understanding! + close-pr-message: >- + This pull request has been automatically closed due to lack of activity. Feel free to ask + for it to be re-opened if you ever come back to it. + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/unstale.yml b/.github/workflows/unstale.yml new file mode 100644 index 000000000000..c9165231b3ab --- /dev/null +++ b/.github/workflows/unstale.yml @@ -0,0 +1,19 @@ +name: Unmark issues and pull requests as stale on activity +on: + issue_comment: + types: [created] + +# actions/stale does this automatically, but only once a day. +# This immediately removes the label when the user creates a comment. +jobs: + remove-stale-label: + if: (github.repository == 'rubocop/rubocop') + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - name: Remove stale label + env: + GH_TOKEN: ${{ github.token }} + run: gh issue edit ${{ github.event.issue.number }} --remove-label "stale" -R ${{ github.repository }} diff --git a/.gitignore b/.gitignore index 880664a3a729..d6176a266c6f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,17 @@ doc .bundle Gemfile.lock Gemfile.local +vendor/ + +# rbenv +.ruby-version + +# rspec +/spec/examples.txt +/.test_queue_stats + +# RuboCop +.rubocop # jeweler generated pkg @@ -20,7 +31,10 @@ pkg # etags TAGS -# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore: +# byebug +.byebug_history + +# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore: # # * Create a file at ~/.gitignore # * Include files you want ignored @@ -45,10 +59,19 @@ TAGS #.\#* # For vim: -#*.swp +*.swp # For redcar: #.redcar # For rubinius: #*.rbc + +# For bundle binstubs +bin/* + +# For stackprof or others +tmp/* + +# For vscode: +.vscode diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 000000000000..cfd922ff167b --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,7 @@ +- id: rubocop + name: rubocop + description: Enforce the community Ruby Style Guide with RuboCop + entry: rubocop + language: ruby + types: ['ruby'] + args: ['--autocorrect', '--force-exclusion'] diff --git a/.rspec b/.rspec index 4e1e0d2f7224..c99d2e7396e1 100644 --- a/.rspec +++ b/.rspec @@ -1 +1 @@ ---color +--require spec_helper diff --git a/.rubocop.yml b/.rubocop.yml index d9ff92edeb2b..cce5397b8d03 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,10 +2,383 @@ inherit_from: .rubocop_todo.yml +plugins: + - rubocop-internal_affairs + - rubocop-performance + - rubocop-rake + - rubocop-rspec + AllCops: + NewCops: enable Exclude: - 'vendor/**/*' - 'spec/fixtures/**/*' + - 'tmp/**/*' + - '.git/**/*' + - 'bin/*' + TargetRubyVersion: 2.7 + SuggestExtensions: false + +Naming/PredicateMethod: + AllowedPatterns: + - !ruby/regexp /\Aon_/ # ignore Node#on_* methods + +Naming/PredicatePrefix: + # Method define macros for dynamically generated method. + MethodDefinitionMacros: + - define_method + - define_singleton_method + - def_node_matcher + - def_node_search + +Style/AccessorGrouping: + Exclude: + - lib/rubocop/formatter/base_formatter.rb + - lib/rubocop/cop/offense.rb + +Style/FormatStringToken: + # Because we parse a lot of source codes from strings. Percent arrays + # look like unannotated format string tokens to this cop. + Exclude: + - spec/**/* + +Style/IpAddresses: + # The test for this cop includes strings that would cause offenses + Exclude: + - spec/rubocop/cop/style/ip_addresses_spec.rb + +Style/ReturnNilInPredicateMethodDefinition: + AllowedMethods: + - on_defined? # rubocop-ast node handler + +Layout/EndOfLine: + EnforcedStyle: lf + +Layout/ClassStructure: + Enabled: true + +Layout/RedundantLineBreak: + Enabled: true + +Layout/TrailingWhitespace: + AllowInHeredoc: false + +Lint/AmbiguousBlockAssociation: + Exclude: + - 'spec/**/*.rb' + +Layout/HashAlignment: + EnforcedHashRocketStyle: + - key + - table + EnforcedColonStyle: + - key + - table + +Layout/LineLength: + Max: 100 + AllowedPatterns: + - !ruby/regexp /\A +(it|describe|context|shared_examples|include_examples|it_behaves_like) ["']/ + +Lint/InterpolationCheck: + Exclude: + - 'spec/**/*.rb' + +Lint/UselessAccessModifier: + MethodCreatingMethods: + - 'def_matcher' + - 'def_node_matcher' + +Lint/EmptyFile: + Exclude: + # This file is intentionally empty to catch rubocop cops failing on empty files. + - spec/rubocop/intentionally_empty_file.rb + +Metrics/BlockLength: + Exclude: + - 'Rakefile' + - '**/*.rake' + - 'spec/**/*.rb' + +Metrics/ClassLength: + Exclude: + - lib/rubocop/config_obsoletion.rb + - lib/rubocop/options.rb + +Metrics/ModuleLength: + Exclude: + - 'spec/**/*.rb' + +Naming/InclusiveLanguage: + Enabled: true + CheckStrings: true + FlaggedTerms: + ' a offense': + Suggestions: + - an offense + ' and offense': + Suggestions: + - ' an offense' + auto-correct: + Suggestions: + - autocorrect + auto_correct: + Suggestions: + - autocorrect + behaviour: + Suggestions: + - behavior + offence: + Suggestions: + - offense + 'does not registers': + Suggestions: + - does not register + 'register no offense': + Suggestions: + - registers no offense + 'register an error': + Suggestions: + - register an offense + 'registers an error': + Suggestions: + - registers an offense + 'does not register and corrects': + Suggestions: + does not register + 'does not register an offense and corrects': + Suggestions: + does not register an offense + Exclude: + - lib/rubocop/cop/naming/inclusive_language.rb + - lib/rubocop/cop/mixin/auto_corrector.rb + - spec/rubocop/cop/naming/inclusive_language_spec.rb + +RSpec: + Language: + Expectations: + - expect_autocorrect_options_for_autocorrect + - expect_autocorrect_options_for_autocorrect_all + - expect_autocorrect_options_for_fix_layout + - expect_correction + - expect_feature_loader + - expect_no_offenses + - expect_offense + +RSpec/Dialect: + Enabled: true + PreferredMethods: + shared_examples_for: shared_examples + +RSpec/ExampleWithoutDescription: + EnforcedStyle: single_line_only + +RSpec/PredicateMatcher: + # Also consider `be(true)` and `be(false)` as offenses, instead of only `be_truthy` and `be_falsy` + Strict: false + +RSpec/SpecFilePathFormat: + CustomTransform: + GitHubActionsFormatter: github_actions_formatter + JUnitFormatter: junit_formatter + OnSendWithoutOnCSend: on_send_without_on_csend + RedundantLetRuboCopConfigNew: redundant_let_rubocop_config_new + Exclude: + - spec/rubocop/cop/mixin/enforce_superclass_spec.rb + +RSpec/MessageSpies: + EnforcedStyle: receive + +RSpec/NestedGroups: + Max: 7 + +RSpec/MultipleMemoizedHelpers: + Enabled: false + +Performance/CollectionLiteralInLoop: + Exclude: + - 'Rakefile' + - 'spec/**/*.rb' + +Performance/EndWith: + SafeMultiline: false + +Performance/StartWith: + SafeMultiline: false -Style/Encoding: +RSpec/StubbedMock: + Enabled: false + +InternalAffairs/UndefinedConfig: + Exclude: + - 'lib/rubocop/cop/correctors/**/*.rb' + - 'lib/rubocop/cop/mixin/**/*.rb' + +InternalAffairs/StyleDetectedApiUse: + Exclude: + - 'lib/rubocop/cop/mixin/percent_array.rb' + +InternalAffairs/NumblockHandler: + Exclude: + - 'lib/rubocop/cop/internal_affairs/*.rb' + +InternalAffairs/OnSendWithoutOnCSend: + Exclude: + - 'lib/rubocop/cop/bundler/**/*.rb' + - 'lib/rubocop/cop/gemspec/**/*.rb' + - 'lib/rubocop/cop/mixin/**/*.rb' + + # `send` method is an operator call + - 'lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb' + - 'lib/rubocop/cop/internal_affairs/method_name_equal.rb' + - 'lib/rubocop/cop/internal_affairs/node_type_predicate.rb' + - 'lib/rubocop/cop/internal_affairs/single_line_comparison.rb' + - 'lib/rubocop/cop/layout/space_after_not.rb' + - 'lib/rubocop/cop/layout/space_around_operators.rb' + - 'lib/rubocop/cop/layout/space_before_brackets.rb' + - 'lib/rubocop/cop/layout/space_in_lambda_literal.rb' + - 'lib/rubocop/cop/layout/space_inside_reference_brackets.rb' + - 'lib/rubocop/cop/lint/ambiguous_operator_precedence.rb' + - 'lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb' + - 'lib/rubocop/cop/lint/identity_comparison.rb' + - 'lib/rubocop/cop/lint/literal_as_condition.rb' + - 'lib/rubocop/cop/lint/multiple_comparison.rb' + - 'lib/rubocop/cop/style/array_join.rb' + - 'lib/rubocop/cop/style/bitwise_predicate.rb' + - 'lib/rubocop/cop/style/case_equality.rb' + - 'lib/rubocop/cop/style/conditional_assignment.rb' + - 'lib/rubocop/cop/style/double_negation.rb' + - 'lib/rubocop/cop/style/even_odd.rb' + - 'lib/rubocop/cop/style/float_division.rb' + - 'lib/rubocop/cop/style/nil_comparison.rb' + - 'lib/rubocop/cop/style/non_nil_check.rb' + - 'lib/rubocop/cop/style/not.rb' + - 'lib/rubocop/cop/style/operator_method_call.rb' + - 'lib/rubocop/cop/style/stabby_lambda_parentheses.rb' + - 'lib/rubocop/cop/style/string_concatenation.rb' + - 'lib/rubocop/cop/style/yoda_condition.rb' + - 'lib/rubocop/cop/style/yoda_expression.rb' + + # `send` receiver is constant / self / literal + - 'lib/rubocop/cop/lint/big_decimal_new.rb' + - 'lib/rubocop/cop/lint/debugger.rb' + - 'lib/rubocop/cop/lint/deprecated_class_methods.rb' + - 'lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb' + - 'lib/rubocop/cop/lint/erb_new_arguments.rb' + - 'lib/rubocop/cop/lint/format_parameter_mismatch.rb' + - 'lib/rubocop/cop/lint/hash_new_with_keyword_arguments_as_default.rb' + - 'lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb' + - 'lib/rubocop/cop/lint/inherit_exception.rb' + - 'lib/rubocop/cop/lint/non_atomic_file_operation.rb' + - 'lib/rubocop/cop/lint/redundant_dir_glob_sort.rb' + - 'lib/rubocop/cop/lint/send_with_mixin_argument.rb' + - 'lib/rubocop/cop/lint/shared_mutable_default.rb' + - 'lib/rubocop/cop/lint/struct_new_override.rb' + - 'lib/rubocop/cop/lint/symbol_conversion.rb' + - 'lib/rubocop/cop/lint/to_enum_arguments.rb' + - 'lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb' + - 'lib/rubocop/cop/lint/uri_escape_unescape.rb' + - 'lib/rubocop/cop/lint/uri_regexp.rb' + - 'lib/rubocop/cop/metrics/collection_literal_length.rb' + - 'lib/rubocop/cop/security/io_methods.rb' + - 'lib/rubocop/cop/security/json_load.rb' + - 'lib/rubocop/cop/security/marshal_load.rb' + - 'lib/rubocop/cop/security/open.rb' + - 'lib/rubocop/cop/security/yaml_load.rb' + - 'lib/rubocop/cop/style/auto_resource_cleanup.rb' + - 'lib/rubocop/cop/style/class_equality_comparison.rb' + - 'lib/rubocop/cop/style/comparable_clamp.rb' + - 'lib/rubocop/cop/style/dir.rb' + - 'lib/rubocop/cop/style/dir_empty.rb' + - 'lib/rubocop/cop/style/empty_literal.rb' + - 'lib/rubocop/cop/style/env_home.rb' + - 'lib/rubocop/cop/style/expand_path_arguments.rb' + - 'lib/rubocop/cop/style/fetch_env_var.rb' + - 'lib/rubocop/cop/style/file_empty.rb' + - 'lib/rubocop/cop/style/file_read.rb' + - 'lib/rubocop/cop/style/file_touch.rb' + - 'lib/rubocop/cop/style/file_write.rb' + - 'lib/rubocop/cop/style/format_string.rb' + - 'lib/rubocop/cop/style/hash_conversion.rb' + - 'lib/rubocop/cop/style/nested_file_dirname.rb' + - 'lib/rubocop/cop/style/random_with_offset.rb' + - 'lib/rubocop/cop/style/redundant_array_constructor.rb' + - 'lib/rubocop/cop/style/redundant_format.rb' + - 'lib/rubocop/cop/style/redundant_freeze.rb' + - 'lib/rubocop/cop/style/redundant_interpolation_unfreeze.rb' + - 'lib/rubocop/cop/style/redundant_regexp_constructor.rb' + - 'lib/rubocop/cop/style/redundant_self.rb' + - 'lib/rubocop/cop/style/stderr_puts.rb' + - 'lib/rubocop/cop/style/yaml_file_read.rb' + + # `send` is a keyword / macro / has no receiver + - 'lib/rubocop/cop/internal_affairs/create_empty_file.rb' + - 'lib/rubocop/cop/internal_affairs/empty_line_between_expect_offense_and_correction.rb' + - 'lib/rubocop/cop/internal_affairs/example_description.rb' + - 'lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb' + - 'lib/rubocop/cop/internal_affairs/node_matcher_directive.rb' + - 'lib/rubocop/cop/internal_affairs/node_pattern_groups.rb' + - 'lib/rubocop/cop/internal_affairs/offense_location_keyword.rb' + - 'lib/rubocop/cop/internal_affairs/redundant_context_config_parameter.rb' + - 'lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb' + - 'lib/rubocop/cop/internal_affairs/redundant_location_argument.rb' + - 'lib/rubocop/cop/internal_affairs/redundant_message_argument.rb' + - 'lib/rubocop/cop/internal_affairs/style_detected_api_use.rb' + - 'lib/rubocop/cop/internal_affairs/undefined_config.rb' + - 'lib/rubocop/cop/layout/def_end_alignment.rb' + - 'lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb' + - 'lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb' + - 'lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb' + - 'lib/rubocop/cop/layout/space_around_keyword.rb' + - 'lib/rubocop/cop/lint/constant_reassignment.rb' + - 'lib/rubocop/cop/lint/duplicate_methods.rb' + - 'lib/rubocop/cop/lint/duplicate_require.rb' + - 'lib/rubocop/cop/lint/lambda_without_literal_block.rb' + - 'lib/rubocop/cop/lint/raise_exception.rb' + - 'lib/rubocop/cop/lint/rand_one.rb' + - 'lib/rubocop/cop/lint/redundant_require_statement.rb' + - 'lib/rubocop/cop/lint/redundant_string_coercion.rb' + - 'lib/rubocop/cop/lint/refinement_import_methods.rb' + - 'lib/rubocop/cop/lint/require_relative_self_path.rb' + - 'lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb' + - 'lib/rubocop/cop/lint/useless_ruby2_keywords.rb' + - 'lib/rubocop/cop/naming/method_name.rb' + - 'lib/rubocop/cop/naming/predicate_prefix.rb' + - 'lib/rubocop/cop/security/eval.rb' + - 'lib/rubocop/cop/style/access_modifier_declarations.rb' + - 'lib/rubocop/cop/style/alias.rb' + - 'lib/rubocop/cop/style/attr.rb' + - 'lib/rubocop/cop/style/class_vars.rb' + - 'lib/rubocop/cop/style/document_dynamic_eval_definition.rb' + - 'lib/rubocop/cop/style/eval_with_location.rb' + - 'lib/rubocop/cop/style/implicit_runtime_error.rb' + - 'lib/rubocop/cop/style/mixin_usage.rb' + - 'lib/rubocop/cop/style/raise_args.rb' + - 'lib/rubocop/cop/style/redundant_current_directory_in_path.rb' + - 'lib/rubocop/cop/style/redundant_exception.rb' + - 'lib/rubocop/cop/style/redundant_file_extension_in_require.rb' + - 'lib/rubocop/cop/style/redundant_return.rb' + - 'lib/rubocop/cop/style/require_order.rb' + - 'lib/rubocop/cop/style/signal_exception.rb' + - 'lib/rubocop/cop/style/top_level_method_definition.rb' + + # not valid or plausible for safe navigation + - 'lib/rubocop/cop/internal_affairs/cop_enabled.rb' + - 'lib/rubocop/cop/internal_affairs/processed_source_buffer_name.rb' + - 'lib/rubocop/cop/internal_affairs/redundant_method_dispatch_node.rb' + - 'lib/rubocop/cop/lint/it_without_arguments_in_block.rb' + - 'lib/rubocop/cop/lint/safe_navigation_chain.rb' + - 'lib/rubocop/cop/lint/useless_times.rb' + - 'lib/rubocop/cop/style/collection_querying.rb' + - 'lib/rubocop/cop/style/colon_method_call.rb' + - 'lib/rubocop/cop/style/numeric_predicate.rb' + - 'lib/rubocop/cop/style/single_argument_dig.rb' + +Gemspec/DependencyVersion: + Enabled: true + +Style/RequireOrder: Enabled: true + +RSpec/IncludeExamples: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9409c1b28d4c..b77d7d45bb70 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,34 +1,78 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2015-09-01 06:24:35 +0200 using RuboCop version 0.33.0. +# on 2025-03-20 15:23:03 UTC using RuboCop version 1.74.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 180 -Metrics/AbcSize: - Max: 32 +# Offense count: 4 +InternalAffairs/NodeDestructuring: + Exclude: + - 'lib/rubocop/cop/variable_force.rb' -# Offense count: 15 -# Configuration parameters: CountComments. +# Offense count: 79 +# Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 147 + Max: 193 -# Offense count: 51 -Metrics/CyclomaticComplexity: - Max: 10 - -# Offense count: 186 -# Configuration parameters: CountComments. +# Offense count: 328 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 20 + Max: 14 -# Offense count: 9 -# Configuration parameters: CountComments. +# Offense count: 7 +# Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: - Max: 164 + Max: 128 + +# Offense count: 3 +# Configuration parameters: Mode, AllowedMethods. +Naming/PredicateMethod: + Exclude: + - 'lib/rubocop/cop/lint/unreachable_code.rb' + - 'lib/rubocop/cop/metrics/utils/abc_size_calculator.rb' + - 'lib/rubocop/cop/style/super_arguments.rb' + +# Offense count: 13 +RSpec/AnyInstance: + Exclude: + - 'spec/rubocop/cli/suggest_extensions_spec.rb' + - 'spec/rubocop/cli_spec.rb' + - 'spec/rubocop/cop/lint/duplicate_methods_spec.rb' + - 'spec/rubocop/cop/team_spec.rb' + - 'spec/rubocop/target_finder_spec.rb' + +# Offense count: 1852 +# Configuration parameters: Prefixes, AllowedPatterns. +# Prefixes: when, with, without +RSpec/ContextWording: + Enabled: false + +# Offense count: 9273 +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 114 + +# Offense count: 9 +RSpec/ExpectOutput: + Exclude: + - 'spec/rubocop/cli/auto_gen_config_spec.rb' + - 'spec/rubocop/cli/options_spec.rb' + +# Offense count: 6445 +RSpec/MultipleExpectations: + Max: 25 + +# Offense count: 9 +RSpec/SubjectStub: + Exclude: + - 'spec/rubocop/config_spec.rb' + - 'spec/rubocop/formatter/json_formatter_spec.rb' + - 'spec/rubocop/formatter/pacman_formatter_spec.rb' + - 'spec/rubocop/formatter/progress_formatter_spec.rb' -# Offense count: 31 -Metrics/PerceivedComplexity: - Max: 11 +# Offense count: 12 +Rake/MethodDefinitionInTask: + Exclude: + - 'tasks/cut_release.rake' diff --git a/.simplecov b/.simplecov new file mode 100644 index 000000000000..43bb298cd962 --- /dev/null +++ b/.simplecov @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +SimpleCov.start do + add_filter '/spec/' + add_filter '/vendor/bundle/' + enable_coverage :branch +end diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a082dd1b49bc..000000000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -sudo: false -cache: bundler -language: ruby -rvm: - - 1.9.3 - - 2.0.0 - - 2.1 - - 2.2 - - ruby-head - - jruby-19mode - - jruby-9.0.1.0 - - rbx-2 -matrix: - allow_failures: - - rvm: ruby-head - - rvm: rbx-2 - fast_finish: true -before_install: gem update --remote bundler -install: - - bundle install --retry=3 -script: - - bundle exec rspec - - bundle exec rake coveralls:push - - bundle exec rubocop diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 000000000000..c7501a7be770 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,11 @@ +extends: default + +rules: + comments: + min-spaces-from-content: 1 + document-start: disable + empty-lines: + max: 1 + line-length: disable + truthy: + check-keys: false diff --git a/.yardopts b/.yardopts index d0ca88828ed7..7e2035420730 100644 --- a/.yardopts +++ b/.yardopts @@ -1,2 +1,3 @@ ---markup markdown +--markup asciidoc --hide-void-return +--tag safety:"Cop Safety Information" diff --git a/CHANGELOG.md b/CHANGELOG.md index aac65d3d310e..c273ffc056a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,1498 +1,3576 @@ # Change log + + ## master (unreleased) -### Bug Fixes - -* [#2232](https://github.com/bbatsov/rubocop/issues/2232): Fix false positive in `Lint/FormatParameterMismatch` for argument with splat operator. ([@dreyks][]) -* [#2237](https://github.com/bbatsov/rubocop/pull/2237): Allow `Lint/FormatParameterMismatch` to be called using `Kernel.format` and `Kernel.sprintf`. ([@rrosenblum][]) -* [#2234](https://github.com/bbatsov/rubocop/issues/2234): Do not register an offense for `Lint/FormatParameterMismatch` when the format string is a variable. ([@rrosenblum][]) -* [#2240](https://github.com/bbatsov/rubocop/pull/2240): `Lint/UnneededDisable` should not report non-`Lint` `rubocop:disable` comments when running `rubocop --lint`. ([@jonas054][]) -* [#2121](https://github.com/bbatsov/rubocop/issues/2121): Allow space before values in hash literals in `Style/ExtraSpacing` to avoid correction conflict. ([@jonas054][]) -* [#2241](https://github.com/bbatsov/rubocop/issues/2241): Read cache in binary format. ([@jonas054][]) - -### Changes - -* [#2248](https://github.com/bbatsov/rubocop/issues/2248): Allow block-pass in `Style/AutoResourceCleanup`. ([@lumeet][]) - -## 0.34.1 (09/09/2015) - -### Bug Fixes - -* [#2212](https://github.com/bbatsov/rubocop/issues/2212): Handle methods without parentheses in auto-correct. ([@karreiro][]) -* [#2214](https://github.com/bbatsov/rubocop/pull/2214): Fix `File name too long error` when `STDIN` option is provided. ([@mrfoto][]) -* [#2217](https://github.com/bbatsov/rubocop/issues/2217): Allow block arguments in `Style/SymbolProc`. ([@lumeet][]) -* [#2213](https://github.com/bbatsov/rubocop/issues/2213): Write to cache with binary encoding to avoid transcoding exceptions in some locales. ([@jonas054][]) -* [#2218](https://github.com/bbatsov/rubocop/issues/2218): Fix loading config error when safe yaml is only partially loaded. ([@maxjacobson][]) -* [#2161](https://github.com/bbatsov/rubocop/issues/2161): Allow an explicit receiver (except `Kernel`) in `Style/SignalException`. ([@lumeet][]) - -## 0.34.0 (05/09/2015) - -### New features - -* [#2143](https://github.com/bbatsov/rubocop/pull/2143): New cop `Performance/CaseWhenSplat` will identify and rearange `case` `when` statements that contain a `when` condition with a splat. ([@rrosenblum][]) -* New cop `Lint/DuplicatedKey` checks for duplicated keys in hashes, which Ruby 2.2 warns against. ([@sliuu][]) -* [#2106](https://github.com/bbatsov/rubocop/issues/2106): Add `SuspiciousParamNames` option to `Style/OptionHash`. ([@wli][]) -* [#2193](https://github.com/bbatsov/rubocop/pull/2193): `Style/Next` supports more `Enumerable` methods. ([@rrosenblum][]) -* [#2179](https://github.com/bbatsov/rubocop/issues/2179): Add `--list-target-files` option to CLI, which prints the files which will be inspected. ([@maxjacobson][]) -* New cop `Style/MutableConstant` checks for assignment of mutable objects to constants. ([@bbatsov][]) -* New cop `Style/RedudantFreeze` checks for usages of `Object#freeze` on immutable objects. ([@bbatsov][]) -* [#1924](https://github.com/bbatsov/rubocop/issues/1924): New option `--cache` and configuration parameter `AllCops: UseCache` turn result caching on (default) or off. ([@jonas054][]) -* [#2204](https://github.com/bbatsov/rubocop/pull/2204): New cop `Style/StringMethods` will check for preferred method `to_sym` over `intern`. ([@imtayadeway][]) - -### Changes - -* [#1351](https://github.com/bbatsov/rubocop/issues/1351): Allow class emitter methods in `Style/MethodName`. ([@jonas054][]) -* [#2126](https://github.com/bbatsov/rubocop/pull/2126): `Style/RescueModifier` can now auto-correct. ([@rrosenblum][]) -* [#2109](https://github.com/bbatsov/rubocop/issues/2109): Allow alignment with a token on the nearest line with same indentation in `Style/ExtraSpacing`. ([@jonas054][]) -* `Lint/EndAlignment` handles the `case` keyword. ([@lumeet][]) -* [#2146](https://github.com/bbatsov/rubocop/pull/2146): Add STDIN support. ([@caseywebdev][]) -* [#2175](https://github.com/bbatsov/rubocop/pull/2175): Files that are excluded from a cop (e.g. using the `Exclude:` config option) are no longer being processed by that cop. ([@bquorning][]) -* `Rails/ActionFilter` now handles complete list of methods found in the Rails 4.2 [release notes](https://github.com/rails/rails/blob/4115a12da1409c753c747fd4bab6e612c0c6e51a/guides/source/4_2_release_notes.md#notable-changes-1). ([@MGerrior][]) -* [*2138](https://github.com/bbatsov/rubocop/issues/2138): Change the offense in `Style/Next` to highlight the condition instead of the iteration. ([@rrosenblum][]) -* `Style/EmptyLineBetweenDefs` now handles class methods as well. ([@unmanbearpig][]) -* Improve handling of `super` in `Style/SymbolProc`. ([@lumeet][]) -* `Style/SymbolProc` is applied to methods receiving arguments. ([@lumeet][]) -* [#1839](https://github.com/bbatsov/rubocop/issues/1839): Remove Rainbow monkey patching of String which conflicts with other gems like colorize. ([@daviddavis][]) -* `Style/HashSyntax` is now a bit faster when checking Ruby 1.9 syntax hash keys. ([@bquorning][]) -* `Lint/DeprecatedClassMethods` is now a whole lot faster. ([@bquorning][]) -* `Lint/BlockAlignment`, `Style/IndentationWidth`, and `Style/MultilineOperationIndentation` are now quite a bit faster. ([@bquorning][]) +## 1.79.0 (2025-07-24) + +### New features + +* [#14348](https://github.com/rubocop/rubocop/pull/14348): Add new cop `Layout/EmptyLinesAfterModuleInclusion`. ([@lovro-bikic][]) +* [#14374](https://github.com/rubocop/rubocop/pull/14374): Enhance `Naming/MethodName` cop to detect offenses within `Data` members. ([@viralpraxis][]) + +### Bug fixes + +* [#14373](https://github.com/rubocop/rubocop/pull/14373): Fix an error for `Style/ParallelAssignment` when a lambda with parallel assignment is used on the RHS. ([@koic][]) +* [#14370](https://github.com/rubocop/rubocop/issues/14370): Fix comment duplication bug in `Style/AccessorGrouping` separated autocorrect. ([@r7kamura][]) +* [#14377](https://github.com/rubocop/rubocop/pull/14377): Fix a false positive for `Lint/UselessAssignment` when the assignment is inside a loop body. ([@5hun-s][]) +* [#14355](https://github.com/rubocop/rubocop/pull/14355): Fix a false negative for `Style/RedundantParentheses` when using parentheses around a `rescue` expression on a one-line. ([@koic][]) +* [#14354](https://github.com/rubocop/rubocop/pull/14354): Fix incorrect autocorrect for `Style/AccessModifierDeclarations` when using a grouped access modifier declaration. ([@girasquid][]) +* [#14367](https://github.com/rubocop/rubocop/issues/14367): Fix an incorrect autocorrect for `Style/SingleLineMethods` when defining a single-line singleton method. ([@koic][]) +* [#14344](https://github.com/rubocop/rubocop/issues/14344): Fix incorrect autocorrect for `Style/SingleLineMethods` when a single-line method definition contains a modifier. ([@koic][]) +* [#14350](https://github.com/rubocop/rubocop/issues/14350): Fix `Naming/MethodName` cop false positives with `define_method` and operator names. ([@viralpraxis][]) +* [#14333](https://github.com/rubocop/rubocop/issues/14333): Fix `Naming/PredicateMethod` ignoring the implicit `nil` from missing `else` branches. ([@earlopain][]) +* [#14356](https://github.com/rubocop/rubocop/pull/14356): Fix `Style/ItBlockParameter` cop error on `always` style and missing block body. ([@viralpraxis][]) +* [#14362](https://github.com/rubocop/rubocop/issues/14362): Update `Lint/RequireRangeParentheses` to not register false positives when range elements span multiple lines. ([@dvandersluis][]) +* [#14309](https://github.com/rubocop/rubocop/issues/14309): Update `Style/SoleNestedConditional` to properly correct assignments within `and`. ([@dvandersluis][]) + +### Changes + +* [#14358](https://github.com/rubocop/rubocop/pull/14358): Add `tsort` gem to runtime dependency for Ruby 3.5-dev. ([@koic][]) +* [#14322](https://github.com/rubocop/rubocop/issues/14322): Expand the scope of `Style/ItAssignment` to consider all local variable and method parameter names. ([@dvandersluis][]) +* [#14378](https://github.com/rubocop/rubocop/pull/14378): Change `Layout/SpaceAroundKeyword` to offend for missing whitespace between `return` and opening parenthesis. ([@lovro-bikic][]) +* [#14360](https://github.com/rubocop/rubocop/pull/14360): Make `Layout/SpaceAroundOperators` aware of alternative and as pattern matchings. ([@koic][]) +* [#14375](https://github.com/rubocop/rubocop/pull/14375): Make `Lint/RedundantSafeNavigation` aware of builtin convert methods `to_s`, `to_i`, `to_f`, `to_a`, and `to_h`. ([@koic][]) +* [#13835](https://github.com/rubocop/rubocop/issues/13835): Add `InferNonNilReceiver` config to `Lint/RedundantSafeNavigation` to check previous code paths if the receiver is non-nil. ([@fatkodima][]) +* [#14381](https://github.com/rubocop/rubocop/pull/14381): Offend `array1.any? { |elem| array2.member?(elem) }` and `array1.none? { |elem| array2.member?(elem) }` in `Style/ArrayIntersect`. ([@lovro-bikic][]) + +## 1.78.0 (2025-07-08) + +### New features + +* [#14331](https://github.com/rubocop/rubocop/pull/14331): Enhance `Naming/MethodName` cop to detect offenses within `define_method` calls. ([@viralpraxis][]) +* [#14325](https://github.com/rubocop/rubocop/pull/14325): Enhance `Naming/MethodName` cop to handle offenses within `Struct` members. ([@viralpraxis][]) +* [#14335](https://github.com/rubocop/rubocop/pull/14335): Enhance `Security/Eval` cop to detect `Kernel.eval` calls. ([@viralpraxis][]) + +### Bug fixes + +* [#14343](https://github.com/rubocop/rubocop/pull/14343): Fix autocorrect code for `Style/HashConversion` to avoid syntax error. ([@koic][]) +* [#14346](https://github.com/rubocop/rubocop/issues/14346): Avoid requiring parentheses for `Style/SingleLineMethods`. ([@koic][]) +* [#14339](https://github.com/rubocop/rubocop/pull/14339): Fix bug where specifying `--format` disables parallelization. ([@r7kamura][]) +* [#14300](https://github.com/rubocop/rubocop/pull/14300): Fix false positives for `Lint/DuplicateMethods` cop when self-alias trick is used. ([@viralpraxis][]) +* [#14329](https://github.com/rubocop/rubocop/issues/14329): Fix false positives for `Lint/LiteralAsCondition` when a literal is used inside `||` in `case` condition. ([@koic][]) +* [#14326](https://github.com/rubocop/rubocop/issues/14326): Fix additional autocorrection errors in `Style/HashConversion` for nested `Hash[]` calls. ([@dvandersluis][]) +* [#14031](https://github.com/rubocop/rubocop/issues/14031): Honor --config options on server mode. ([@steiley][]) +* [#14319](https://github.com/rubocop/rubocop/pull/14319): Fix the following incorrect autocorrect for `Lint/RedundantTypeConversion` when using parentheses with no arguments or any arguments. ([@koic][]) +* [#14336](https://github.com/rubocop/rubocop/issues/14336): Fix incorrect autocorrect for `Style/ItBlockParameter` when using a single numbered parameter after multiple numbered parameters in a method chain. ([@koic][]) +* [#11782](https://github.com/rubocop/rubocop/issues/11782): Move pending cops warning out of ConfigLoader. ([@nobuyo][]) + +### Changes + +* [#14318](https://github.com/rubocop/rubocop/issues/14318): Add `WaywardPredicates` config to `Naming/PredicateMethod` to handle methods that look like predicates but aren't. ([@dvandersluis][]) + +## 1.77.0 (2025-06-20) + +### New features + +* [#14223](https://github.com/rubocop/rubocop/pull/14223): Add new `Gemspec/AttributeAssignment` cop. ([@viralpraxis][]) +* [#14128](https://github.com/rubocop/rubocop/issues/14128): Allow long fully-qualified namespace strings to exceed max length. ([@niranjan-patil][]) +* [#14288](https://github.com/rubocop/rubocop/pull/14288): Add new cop `Style/CollectionQuerying`. ([@lovro-bikic][]) +* [#14165](https://github.com/rubocop/rubocop/issues/14165): Add new `DefaultToNil` option to `Style/FetchEnvVar` cop. ([@Yuhi-Sato][]) +* [#14314](https://github.com/rubocop/rubocop/pull/14314): Enhance `Gemspec/RequireMFA` cop autocorrect to insert MFA directive after last `metadata` assignment. ([@viralpraxis][]) +* [#14159](https://github.com/rubocop/rubocop/pull/14159): Enhance `Layout/SpaceInsideArrayLiteralBrackets` cop to analyze nested constant patterns. ([@viralpraxis][]) + +### Bug fixes + +* [#14306](https://github.com/rubocop/rubocop/issues/14306): Fix an error for `Style/HashConversion` when using nested `Hash[]`. ([@koic][]) +* [#14298](https://github.com/rubocop/rubocop/issues/14298): Fix an error for `Style/SoleNestedConditional` when autocorrecting nested if/unless/if. ([@ssagara00][]) +* [#14313](https://github.com/rubocop/rubocop/issues/14313): Fix a false positive for `Layout/SpaceBeforeBrackets` when call desugared `Hash#[]` to lvar receiver with a space around the dot. ([@koic][]) +* [#14292](https://github.com/rubocop/rubocop/issues/14292): Fix false positives for `Style/RedundantParentheses` when assigning a parenthesized one-line `in` pattern matching. ([@koic][]) +* [#14296](https://github.com/rubocop/rubocop/issues/14296): Fix false positives for `Style/RedundantSelf` when receiver and lvalue have the same name in or-assignment. ([@koic][]) +* [#14303](https://github.com/rubocop/rubocop/pull/14303): Fix `Lint/SelfAssignment` to allow inline RBS comments. ([@Morriar][]) +* [#14307](https://github.com/rubocop/rubocop/issues/14307): Fix `Style/MethodCallWithArgsParentheses` false positive on forwarded keyword argument with additional arguments. ([@viralpraxis][]) +* [#14301](https://github.com/rubocop/rubocop/issues/14301): Fix autocorrection syntax error for multiline expressions in `Style/RedundantParentheses`. ([@lovro-bikic][]) + +### Changes + +* [#14295](https://github.com/rubocop/rubocop/pull/14295): Update `Naming/PredicateMethod` to consider negation (`!`/`not`) as boolean values. ([@dvandersluis][]) +* [#14255](https://github.com/rubocop/rubocop/issues/14255): Update `Naming/PredicateMethod` to treat returned predicate method calls as boolean values. ([@dvandersluis][]) + +## 1.76.2 (2025-06-17) + +### Bug fixes + +* [#14273](https://github.com/rubocop/rubocop/issues/14273): Fix an error for `Lint/EmptyInterpolation` when using a boolean literal inside interpolation. ([@koic][]) +* [#14260](https://github.com/rubocop/rubocop/issues/14260): Fix an error for `Lint/UselessDefaultValueArgument` when `fetch` call without a receiver. ([@koic][]) +* [#14267](https://github.com/rubocop/rubocop/pull/14267): Fix an error for `Style/ConditionalAssignment` cop when using one-line branches. ([@viralpraxis][]) +* [#14275](https://github.com/rubocop/rubocop/issues/14275): Fix false positives for `Style/RedundantParentheses` when using parenthesized one-line pattern matching in endless method definition. ([@koic][]) +* [#14269](https://github.com/rubocop/rubocop/issues/14269): Fix false positives for `Style/RedundantSelf` when local variable assignment name is used in nested `if`. ([@koic][]) +* [#14286](https://github.com/rubocop/rubocop/issues/14286): Fix incorrect autocorrect for `Lint/SafeNavigationChain` when a safe navigation is used on the left-hand side of a `-` operator when inside an array. ([@koic][]) + +### Changes + +* [#14232](https://github.com/rubocop/rubocop/issues/14232): Add `AllowedPatterns` and `AllowBangMethods` configuration to `Naming/PredicateMethod`. ([@dvandersluis][]) +* [#14268](https://github.com/rubocop/rubocop/pull/14268): Register operator expression range boundaries as offenses in `Lint/AmbiguousRange`. ([@lovro-bikic][]) +* [#14264](https://github.com/rubocop/rubocop/pull/14264): Offend access modifiers used on top-level in `Lint/UselessAccessModifier`. ([@lovro-bikic][]) +* [#14278](https://github.com/rubocop/rubocop/pull/14278): Register conditions wrapped in parentheses as offenses in `Style/MinMaxComparison`. ([@lovro-bikic][]) + +## 1.76.1 (2025-06-09) + +### Bug fixes + +* [#14245](https://github.com/rubocop/rubocop/pull/14245): Fix an error for `Lint/EmptyInterpolation` when using primitives in interpolation. ([@ka8725][]) +* [#14233](https://github.com/rubocop/rubocop/issues/14233): Fix an error for `Style/SafeNavigation` when using ternary expression with index access call. ([@koic][]) +* [#14236](https://github.com/rubocop/rubocop/issues/14236): Fix an error for `Style/SafeNavigation` when using ternary expression with operator method call. ([@koic][]) +* [#14249](https://github.com/rubocop/rubocop/issues/14249): Fix false positives for `Style/RedundantArrayFlatten` when `Array#join` is used with an argument other than the default `nil`. ([@koic][]) +* [#14239](https://github.com/rubocop/rubocop/issues/14239): Fix false positives for `Style/RedundantParentheses` when using one-line `in` pattern matching in operator. ([@koic][]) +* [#14240](https://github.com/rubocop/rubocop/issues/14240): Fix `Naming/PredicateMethod` cop error on empty parentheses method body. ([@viralpraxis][]) +* [#14235](https://github.com/rubocop/rubocop/pull/14235): Fix `Style/SafeNavigation` cop error on indexed assignment in ternary expression. ([@viralpraxis][]) +* [#14247](https://github.com/rubocop/rubocop/pull/14247): Fix `Style/SafeNavigation` invalid autocorrection on double colon method call. ([@viralpraxis][]) + +## 1.76.0 (2025-06-04) + +### New features + +* [#12360](https://github.com/rubocop/rubocop/issues/12360): Add new `Naming/PredicateMethod` cop to check that predicate methods end with `?` and non-predicate methods do not. ([@dvandersluis][]) +* [#13121](https://github.com/rubocop/rubocop/issues/13121): Add new `Style/EmptyStringInsideInterpolation` cop. ([@zopolis4][]) +* [#14091](https://github.com/rubocop/rubocop/pull/14091): Add new cop `Style/RedundantArrayFlatten`. ([@lovro-bikic][]) +* [#14184](https://github.com/rubocop/rubocop/pull/14184): Add new cop `Lint/UselessOr`. ([@lovro-bikic][]) +* [#14221](https://github.com/rubocop/rubocop/pull/14221): Enhance `Gemspec` department cops to detect offenses if specification variable is `it` or a numbered parameter. ([@viralpraxis][]) +* [#14166](https://github.com/rubocop/rubocop/pull/14166): Add new cop `Lint/UselessDefaultValueArgument`. ([@lovro-bikic][]) + +### Bug fixes + +* [#14228](https://github.com/rubocop/rubocop/issues/14228): Fix a false positive for `Style/RedundantParentheses` when using a one-line `rescue` expression as a method argument. ([@koic][]) +* [#14224](https://github.com/rubocop/rubocop/pull/14224): Fix false negatives for `Style/RedundantParentheses` when using one-line pattern matching. ([@koic][]) +* [#14205](https://github.com/rubocop/rubocop/issues/14205): False negatives in `Style/SafeNavigation` when a ternary expression is used in a method argument. ([@steiley][]) +* [#14226](https://github.com/rubocop/rubocop/pull/14226): Fix `Lint/LiteralAsCondition` autocorrect when branches of a condition have comments. ([@zopolis4][]) + +### Changes + +* [#14066](https://github.com/rubocop/rubocop/pull/14066): Add `EnforcedStyle: allow_single_line` as the default to `Style/ItBlockParameter`. ([@koic][]) +* [#13788](https://github.com/rubocop/rubocop/pull/13788): Disable `Lint/ShadowingOuterLocalVariable` by default. ([@nekketsuuu][]) +* [#14215](https://github.com/rubocop/rubocop/pull/14215): Recognize inequation (`!=`) in `Lint/IdentityComparison`. ([@lovro-bikic][]) + +## 1.75.8 (2025-05-28) + +### Bug fixes + +* [#14191](https://github.com/rubocop/rubocop/pull/14191): Fix `Lint/FloatComparison` cop to detect floating-point number comparisons in `case` statements. ([@daisuke][]) +* [#14209](https://github.com/rubocop/rubocop/pull/14209): Fix an error for `Style/RedundantFormat` with invalid format arguments. ([@earlopain][]) +* [#14200](https://github.com/rubocop/rubocop/pull/14200): Fix false positives for `Style/DefWithParentheses` when using endless method definition with empty parentheses and a space before `=`. ([@koic][]) +* [#14197](https://github.com/rubocop/rubocop/issues/14197): Fix infinite loop error for `EnforcedStyle: with_fixed_indentation` of `Layout/ArgumentAlignment` and `EnforcedStyle: consistent` of `Layout/FirstArgumentIndentation` and `Layout/HashAlignment`. ([@koic][]) +* [#14204](https://github.com/rubocop/rubocop/pull/14204): Fix `Layout/EmptyLinesAroundAccessModifier` cop error on trailing access modifier. ([@viralpraxis][]) +* [#14198](https://github.com/rubocop/rubocop/pull/14198): Fix `Lint/DuplicateMethods` cop error on `to` option is dynamically generated and `prefix` is enabled. ([@viralpraxis][]) +* [#14199](https://github.com/rubocop/rubocop/pull/14199): Fix wrong autocorrection for `Style/MapToHash` with destructuring argument. ([@lovro-bikic][]) +* [#14050](https://github.com/rubocop/rubocop/issues/14050): Modify condition for `rubocop:todo` EOL comment. ([@jonas054][]) + +## 1.75.7 (2025-05-21) + +### Bug fixes + +* [#14185](https://github.com/rubocop/rubocop/pull/14185): Fix an error for `Style/IfUnlessModifierOfIfUnless` when using nested modifier. ([@koic][]) +* [#14192](https://github.com/rubocop/rubocop/pull/14192): Fix negatives for `Layout/SpaceBeforeBrackets` when using space between method argument parentheses and left bracket. ([@koic][]) +* [#14189](https://github.com/rubocop/rubocop/issues/14189): Fix incorrect autocorrect for `Layout/SpaceBeforeBrackets` when using space between receiver and left brackets, and a space inside left bracket. ([@koic][]) +* [#14170](https://github.com/rubocop/rubocop/pull/14170): Fix `Style/AccessModifierDeclarations` cop error on semicolon after modifier. ([@viralpraxis][]) +* [#14195](https://github.com/rubocop/rubocop/pull/14195): Fix `Style/AccessModifierDeclarations` cop error on symbol modifier without surrounding scope. ([@viralpraxis][]) +* [#14172](https://github.com/rubocop/rubocop/pull/14172): Fix `Style/AccessModifierDeclarations` cop false positives when there are no method definitions and style is `inline`. ([@viralpraxis][]) +* [#14193](https://github.com/rubocop/rubocop/issues/14193): Fix `Lint/UselessAssignment` cop error when using nested assignment with splat. ([@earlopain][]) + +### Changes + +* [#14188](https://github.com/rubocop/rubocop/pull/14188): Enhance `Gemspec/DuplicatedAssignment` cop to detect duplicated indexed assignment. ([@viralpraxis][]) +* [#14183](https://github.com/rubocop/rubocop/pull/14183): Recognize `prefix` argument for `delegate` method in `Lint/DuplicateMethods`. ([@lovro-bikic][]) + +## 1.75.6 (2025-05-15) + +### Bug fixes + +* [#14176](https://github.com/rubocop/rubocop/pull/14176): Fix an error for `Style/MultilineIfModifier` when using nested modifier. ([@koic][]) +* [#14077](https://github.com/rubocop/rubocop/issues/14077): Change `nil` representation in todo file comments. ([@jonas054][]) +* [#14164](https://github.com/rubocop/rubocop/pull/14164): Fix an error for `Lint/UselessAssignment` when variables are assigned using unary operator in chained assignment and remain unreferenced. ([@koic][]) +* [#14173](https://github.com/rubocop/rubocop/pull/14173): Fix an error for `Style/StringConcatenation` when using implicit concatenation with string interpolation. ([@koic][]) +* [#14177](https://github.com/rubocop/rubocop/issues/14177): Fix false positives for `Style/SoleNestedConditional` when using nested `if` and `not` in condition. ([@koic][]) +* [#14152](https://github.com/rubocop/rubocop/pull/14152): Fix `Layout/SpaceInsideArrayLiteralBrackets` cop error on array pattern without brackets. ([@viralpraxis][]) +* [#14153](https://github.com/rubocop/rubocop/pull/14153): Fix `Style/PercentQLiterals` cop error on Unicode escape sequence. ([@viralpraxis][]) + +### Changes + +* [#14082](https://github.com/rubocop/rubocop/issues/14082): Mark `Style/ComparableBetween` as unsafe. ([@earlopain][]) +* [#14181](https://github.com/rubocop/rubocop/issues/14181): Make `Lint/DuplicateMethods` aware of Active Support's `delegate` method. ([@lovro-bikic][]) +* [#14156](https://github.com/rubocop/rubocop/issues/14156): Make `Style/IfUnlessModifier` allow endless method definition in the `if` body. ([@koic][]) + +## 1.75.5 (2025-05-05) + +### Bug fixes + +* [#14148](https://github.com/rubocop/rubocop/pull/14148): Fix an infinite loop error for `Layout/SpaceAfterSemicolon` with `Layout/SpaceBeforeSemicolon` when a sequence of semicolons appears. ([@koic][]) +* [#14145](https://github.com/rubocop/rubocop/pull/14145): Fix `Lint/ArrayLiteralInRegexp` cop error on empty interpolation. ([@viralpraxis][]) +* [#14072](https://github.com/rubocop/rubocop/issues/14072): Fix autocorrect issue in `Layout/HashAlignment`. ([@jonas054][]) +* [#14131](https://github.com/rubocop/rubocop/issues/14131): Fix false positives for `Style/ArgumentsForwarding` when using anonymous block argument forwarding to a method with a block. ([@koic][]) +* [#14140](https://github.com/rubocop/rubocop/pull/14140): Fix `Layout/LeadingCommentSpace` to allow splitting long inline RBS comment signatures across multiple lines. ([@Morriar][]) +* [#14147](https://github.com/rubocop/rubocop/pull/14147): Fix `Lint/LiteralAsCondition` cop error on `if` without body. ([@viralpraxis][]) +* [#14151](https://github.com/rubocop/rubocop/pull/14151): Fix `Lint/Void` cop error on nested empty `begin`. ([@viralpraxis][]) +* [#13547](https://github.com/rubocop/rubocop/pull/13547): Fix `Style/IdenticalConditionalBranches` cop failure in case of `if` node with implicit `then`. ([@viralpraxis][]) +* [#14146](https://github.com/rubocop/rubocop/pull/14146): Fix `Style/MethodCallWithArgsParentheses` cop error on complex numbers when `EnforcedStyle` is set to `omit_parentheses`. ([@viralpraxis][]) +* [#14137](https://github.com/rubocop/rubocop/issues/14137): Fix `Style/TrailingCommaInArguments` cop error if `EnforcedStyleForMultiline` is set to `comma`. ([@viralpraxis][]) + +### Changes + +* [#14144](https://github.com/rubocop/rubocop/pull/14144): `Layout/SpaceInsideArrayLiteralBrackets` make aware of array pattern matching. ([@koic][]) +* [#14142](https://github.com/rubocop/rubocop/issues/14142): `Layout/SpaceInsideHashLiteralBraces` make aware of hash pattern matching. ([@koic][]) + +## 1.75.4 (2025-04-28) + +### Bug fixes + +* [#14123](https://github.com/rubocop/rubocop/issues/14123): Fix an infinite loop error for `Lint/BooleanSymbol` when using the rocket hash syntax with a boolean symbol key. ([@koic][]) +* [#14134](https://github.com/rubocop/rubocop/pull/14134): Fix an error for `Style/ComparableBetween` when comparing the value with itself. ([@earlopain][]) +* [#14111](https://github.com/rubocop/rubocop/issues/14111): Fix an error for `Style/SafeNavigation` when the RHS of `&&` is a complex `||` expression composed of `&&` conditions. ([@koic][]) +* [#14129](https://github.com/rubocop/rubocop/issues/14129): Fix false positives for `Style/ArgumentsForwarding` when using default positional arg, keyword arg, and block arg in Ruby 3.1. ([@koic][]) +* [#14110](https://github.com/rubocop/rubocop/pull/14110): Fix false positives for `Style/RedundantParentheses` when parens around basic conditional as the second argument of a parenthesized method call. ([@koic][]) +* [#14120](https://github.com/rubocop/rubocop/issues/14120): Fix false positives for `Style/RedundantParentheses` when parens around unparenthesized method call as the second argument of a parenthesized method call. ([@koic][]) +* [#14133](https://github.com/rubocop/rubocop/pull/14133): Fix `Lint/LiteralAsCondition` autocorrect when a literal is the condition of an elsif followed by an else. ([@zopolis4][]) +* [#14116](https://github.com/rubocop/rubocop/issues/14116): Make `Style/TrailingCommaInArguments` cop aware of trailing commas in `[]` method call. ([@viralpraxis][]) +* [#14114](https://github.com/rubocop/rubocop/pull/14114): Fix `Style/ClassAndModuleChildren` cop error on tab-intended compactable modules. ([@viralpraxis][]) + +### Changes + +* [#13611](https://github.com/rubocop/rubocop/issues/13611): Enable `Lint/CircularArgumentReference` on Ruby 3.4. ([@earlopain][]) + +## 1.75.3 (2025-04-22) + +### Bug fixes + +* [#13676](https://github.com/rubocop/rubocop/issues/13676): Allow RuboCop to inspect hidden directories if they are explicitly provided. ([@viralpraxis][]) +* [#14080](https://github.com/rubocop/rubocop/pull/14080): Allow writing RBS::Inline annotation `#:` after end keyword in `Style/CommentedKeyword`. ([@dak2][]) +* [#14075](https://github.com/rubocop/rubocop/issues/14075): Fix an error for `Layout/EmptyLineAfterGuardClause` when calling a method on the result of a single-line `if` with `return`. ([@koic][]) +* [#14067](https://github.com/rubocop/rubocop/pull/14067): Fix false negatives for `Style/RedundantParentheses` when using parens around singleton method body. ([@koic][]) +* [#14070](https://github.com/rubocop/rubocop/issues/14070): Fix false positives for `EnforcedStyleForMultiline: diff_comma` of `Style/TrailingCommaInArrayLiteral` and `Style/TrailingCommaInHashLiteral` when trailing comma with comment. ([@koic][]) +* [#14092](https://github.com/rubocop/rubocop/pull/14092): Fix false negative for `Style/RedundantParentheses` when using some operator methods with a parenthesized argument. ([@koic][]) +* [#14103](https://github.com/rubocop/rubocop/pull/14103): Fix `Layout/MultilineOperationIndentation` cop error on `indexasgn` node without arguments. ([@viralpraxis][]) +* [#14089](https://github.com/rubocop/rubocop/pull/14089): Fix redundant current directory prefix regexp. ([@sferik][]) +* [#14099](https://github.com/rubocop/rubocop/pull/14099): Fix `Style/ClassAndModuleChildren` cop error on one-liner class definition and nested enforced style. ([@viralpraxis][]) +* [#14083](https://github.com/rubocop/rubocop/pull/14083): Fix `Style/ConditionalAssignment` cop error on one-line if-then-else. ([@viralpraxis][]) +* [#14104](https://github.com/rubocop/rubocop/pull/14104): Fix `Style/ConditionalAssignment` cop error on indexed assignment without arguments. ([@viralpraxis][]) +* [#14084](https://github.com/rubocop/rubocop/pull/14084): Fix `Style/RedundantLineContinuation` cop error on multiline assignment with line continuation. ([@viralpraxis][]) +* [#14096](https://github.com/rubocop/rubocop/pull/14096): Fix error for `Style/SafeNavigation` with longer `&&` chain (e.g. `a && a.b && a.b.c`). ([@lovro-bikic][]) +* [#14068](https://github.com/rubocop/rubocop/pull/14068): Fix wrong autocorrection for `Style/MapIntoArray` when using `push` or `append` with hash argument without braces. ([@lovro-bikic][]) + +### Changes + +* [#14093](https://github.com/rubocop/rubocop/pull/14093): Register offenses for redundant parens around method arguments for `Style/RedundantParentheses`. ([@lovro-bikic][]) +* [#14064](https://github.com/rubocop/rubocop/pull/14064): Prefer `References` over `Reference` in cop configs. ([@sambostock][]) + +## 1.75.2 (2025-04-03) + +### Changes + +* [#14065](https://github.com/rubocop/rubocop/pull/14065): Update `Lint/RedundantTypeConversion` to register an offense for `to_json.to_s`. ([@lovro-bikic][]) + +### Bug fixes + +* [#14041](https://github.com/rubocop/rubocop/issues/14041): Fix an error when using ERB templated config YAML with server mode. ([@koic][]) +* [#14048](https://github.com/rubocop/rubocop/pull/14048): Do not emit a warning for a zero-sized file while checking if it is executable. ([@viralpraxis][]) +* [#14053](https://github.com/rubocop/rubocop/issues/14053): Fix incorrect autocorrect for `Lint/DeprecatedOpenSSLConstant` cipher constant argument is not `cbc`. ([@koic][]) +* [#14051](https://github.com/rubocop/rubocop/issues/14051): Fix incorrect autocorrect for `Style/RedundantCondition` when true is used as the true branch and the condition takes arguments. ([@koic][]) +* [#14062](https://github.com/rubocop/rubocop/issues/14062): Fix false positives for `Lint/ReturnInVoidContext` when returning inside `define_method` or a nested singleton method. ([@earlopain][]) +* [#14057](https://github.com/rubocop/rubocop/pull/14057): Fix `Style/ConditionalAssignment` cop error on dynamic string node in branch. ([@viralpraxis][]) +* [#14047](https://github.com/rubocop/rubocop/pull/14047): Fix `Style/FrozenStringLiteralComment` cop errors on emacs-styled magic comment. ([@viralpraxis][]) + +## 1.75.1 (2025-03-26) + +### Changes + +* [#14038](https://github.com/rubocop/rubocop/pull/14038): Rename `EnforcedStyle: allow_named_parameter` to `EnforcedStyle: only_numbered_parameters` in `Style/ItBlockParameter`. ([@koic][]) + +## 1.75.0 (2025-03-26) + +### New features + +* [#12049](https://github.com/rubocop/rubocop/issues/12049): Add new `Style/HashFetchChain` cop to detect chained `fetch` calls that can be replaced with a single call to `dig`. ([@dvandersluis][]) +* [#13597](https://github.com/rubocop/rubocop/issues/13597): Add new `Style/ItBlockParameter` cop. ([@koic][]) +* [#13899](https://github.com/rubocop/rubocop/pull/13899): Enable reusable Prism parse result for Ruby LSP add-on. ([@koic][]) +* [#14015](https://github.com/rubocop/rubocop/pull/14015): Support `it` block parameter in `Layout` cops. ([@koic][]) +* [#14017](https://github.com/rubocop/rubocop/pull/14017): Support `it` block parameter in `Lint` cops. ([@koic][]) +* [#14018](https://github.com/rubocop/rubocop/pull/14018): Support `it` block parameter in `Metrics` cops. ([@koic][]) +* [#14013](https://github.com/rubocop/rubocop/pull/14013): Support `it` block parameter in `Style` cops. ([@koic][]) +* [#14025](https://github.com/rubocop/rubocop/pull/14025): Support `TargetRubyVersion: 3.5` (experimental). ([@earlopain][]) + +### Bug fixes + +* [#14022](https://github.com/rubocop/rubocop/pull/14022): Fix an error for `Style/HashFetchChain` when no arguments are given to `fetch`. ([@koic][]) +* [#14028](https://github.com/rubocop/rubocop/pull/14028): Fix false negative for `Layout/MultilineMethodParameterLineBreaks` when class method definitions are used. ([@vlad-pisanov][]) +* [#14027](https://github.com/rubocop/rubocop/pull/14027): Fix false negative for `Layout/LineLength` when autocorrecting class method definitions. ([@vlad-pisanov][]) +* [#8099](https://github.com/rubocop/rubocop/issues/8099): Fix infinite loop between `Layout/SpaceAroundOperators` and `Layout/HashAlignment` with `EnforcedHashRocketStyle` being an array containing `table`. ([@dvandersluis][]) +* [#14021](https://github.com/rubocop/rubocop/pull/14021): Fix handling of long heredoc lines with SplitStrings enabled. ([@mauro-oto][]) +* [#13968](https://github.com/rubocop/rubocop/pull/13968): Fix `InternalAffairs/RedundantDescribedClassAsSubject` cop error on missing `describe`. ([@viralpraxis][]) +* [#14036](https://github.com/rubocop/rubocop/pull/14036): Fix false negative for `Lint/ShadowingOuterLocalVariable` when block local variable is used inside a condition. ([@lovro-bikic][]) +* [#13990](https://github.com/rubocop/rubocop/issues/13990): Fix a false positive for `Lint/UselessAssignment` when a variable is reassigned in a different branch. ([@eugeneius][]) +* [#14012](https://github.com/rubocop/rubocop/pull/14012): Fix incorrect autocorrections for `Style/SoleNestedConditional`. ([@lovro-bikic][]) +* [#14020](https://github.com/rubocop/rubocop/pull/14020): Fix comment autocorrection for `Style/IfInsideElse`. ([@lovro-bikic][]) + +### Changes + +* [#12358](https://github.com/rubocop/rubocop/issues/12358): Add `does` as a forbidden prefix to `Naming/PredicateName`. ([@dvandersluis][]) +* [#13621](https://github.com/rubocop/rubocop/issues/13621): Add `ForbiddenIdentifiers` and `ForbiddenPatterns` config options to `Naming/MethodName` cop. ([@tejasbubane][]) +* [#13986](https://github.com/rubocop/rubocop/issues/13986): Add support for `Array#intersection` to `Style/ArrayIntersect`. ([@dvandersluis][]) +* [#14006](https://github.com/rubocop/rubocop/pull/14006): Allow cop renames to trigger warnings instead of fatal errors. ([@dvandersluis][]) +* [#13617](https://github.com/rubocop/rubocop/issues/13617): Use the `prism` translation layer to analyze Ruby 3.4+ by default. ([@earlopain][]) +* [#14024](https://github.com/rubocop/rubocop/pull/14024): Change `Style/RedundantParentheses` to offend parentheses for chained `&&` expressions. ([@lovro-bikic][]) +* [#14029](https://github.com/rubocop/rubocop/pull/14029): Add `AllowConsecutiveConditionals` setting to `Style/Next` to allow consecutive conditional statements. ([@vlad-pisanov][]) +* [#14016](https://github.com/rubocop/rubocop/pull/14016): Update `Style/RedundantFormat` to register offenses when the only argument to `format` or `sprintf` is a constant. ([@dvandersluis][]) + +## 1.74.0 (2025-03-13) + +### New features + +* [#13936](https://github.com/rubocop/rubocop/pull/13936): Adds new cop `Style/ComparableBetween`. ([@lovro-bikic][]) +* [#13943](https://github.com/rubocop/rubocop/pull/13943): Allow writing steep annotation to method definition for `Style/CommentedKeyword`. ([@dak2][]) + +### Bug fixes + +* [#13969](https://github.com/rubocop/rubocop/issues/13969): Fix a false positive for `Lint/SharedMutableDefault` when `capacity` keyword argument is used. ([@koic][]) +* [#13945](https://github.com/rubocop/rubocop/pull/13945): Fix a false positive for `Style/DoubleNegation` when calling `define_method`/`define_singleton_method` with a numblock. ([@earlopain][]) +* [#13971](https://github.com/rubocop/rubocop/pull/13971): Fix false alarm for config obsoletion. ([@koic][]) +* [#13960](https://github.com/rubocop/rubocop/pull/13960): Fix a false negative for `Lint/ReturnInVoidContext` when returning out of a block. ([@earlopain][]) +* [#13947](https://github.com/rubocop/rubocop/pull/13947): Fix a false negative for `Lint/UselessConstantScoping` for constants defined in `class << self`. ([@earlopain][]) +* [#13949](https://github.com/rubocop/rubocop/pull/13949): Fix a false negative for `Lint/NonLocalExitFromIterator` with numblocks. ([@earlopain][]) +* [#13975](https://github.com/rubocop/rubocop/issues/13975): Fix false positives for `Style/RedundantCurrentDirectoryInPath` when using a complex current directory path in `require_relative`. ([@koic][]) +* [#13963](https://github.com/rubocop/rubocop/issues/13963): Fix wrong autocorrect for `Lint/LiteralAsCondition` when the literal is followed by `return`, `break`, or `next`. ([@earlopain][]) +* [#13946](https://github.com/rubocop/rubocop/pull/13946): Fix some false positives for `Style/MethodCallWithArgsParentheses` with `EnforcedStyle: omit_parentheses` style and numblocks. ([@earlopain][]) +* [#13950](https://github.com/rubocop/rubocop/pull/13950): Fix sporadic errors about `rubocop-rails` or `rubocop-performance` extraction, even if they are already part of the Gemfile. ([@earlopain][]) +* [#13981](https://github.com/rubocop/rubocop/pull/13981): Prevent redundant plugin loading when a duplicate plugin is specified in an inherited config. ([@koic][]) +* [#13965](https://github.com/rubocop/rubocop/issues/13965): Update `Lint/RedundantCopDisableDirective` to register an offense when cop names are given with improper casing. ([@dvandersluis][]) +* [#13948](https://github.com/rubocop/rubocop/pull/13948): Fix wrong autocorrect for `Style/RescueModifier` when using parallel assignment and the right-hand-side is not a bracketed array. ([@earlopain][]) + +### Changes + +* [#12851](https://github.com/rubocop/rubocop/issues/12851): Add `EnforcedStyleForClasses` and `EnforcedStyleForModules` configuration options to `Style/ClassAndModuleChildren`. ([@dvandersluis][]) +* [#13979](https://github.com/rubocop/rubocop/pull/13979): Add `Mode: conservative` configuration to `Style/FormatStringToken` to make the cop only register offenses for strings given to `printf`, `sprintf`, `format`, and `%`. ([@dvandersluis][]) +* [#13977](https://github.com/rubocop/rubocop/issues/13977): Allow `TLS1_1` and `TLS1_2` by default in `Naming/VariableNumber` to accommodate OpenSSL version parameter names. ([@koic][]) +* [#13967](https://github.com/rubocop/rubocop/pull/13967): Make `Lint/RedundantTypeConversion` aware of redundant `to_d`. ([@koic][]) + +## 1.73.2 (2025-03-04) + +### Bug fixes + +* [#13942](https://github.com/rubocop/rubocop/pull/13942): Fix incorrect disabling of departments when inheriting configuration. ([@koic][]) +* [#13766](https://github.com/rubocop/rubocop/issues/13766): Fix false positives for `Style/InverseMethods` when using `any?` or `none?` with safe navigation operator. ([@koic][]) +* [#13938](https://github.com/rubocop/rubocop/pull/13938): Fix false positives for `Style/RedundantCondition` when a variable or a constant is used. ([@koic][]) +* [#13935](https://github.com/rubocop/rubocop/pull/13935): Fix a false negative for `Style/RedundantFreeze` when calling methods that produce frozen objects with numblocks. ([@earlopain][]) +* [#13928](https://github.com/rubocop/rubocop/issues/13928): Fix `end pattern with unmatched parenthesis: / (RegexpError)` on Ruby 3.2.0. ([@dvandersluis][]) +* [#13933](https://github.com/rubocop/rubocop/issues/13933): Fix wrong autocorrect for `Style/KeywordParametersOrder` when the arguments are on multiple lines and contain comments. ([@earlopain][]) + +### Changes + +* [#12669](https://github.com/rubocop/rubocop/issues/12669): Update autocorrection for `Lint/EmptyConditionalBody` to be safe. ([@dvandersluis][]) + +## 1.73.1 (2025-02-27) + +### Bug fixes + +* [#13920](https://github.com/rubocop/rubocop/issues/13920): Fix an error for `Lint/MixedCaseRange` when `/[[ ]]/` is used. ([@koic][]) +* [#13912](https://github.com/rubocop/rubocop/pull/13912): Fix wrong autocorrect for `Lint/EmptyConditionalBody` when assigning to a variable with only a single branch. ([@earlopain][]) +* [#13913](https://github.com/rubocop/rubocop/issues/13913): Fix false positives for `Style/RedundantCondition` when using when true is used as the true branch and the condition is not a predicate method. ([@koic][]) +* [#13909](https://github.com/rubocop/rubocop/issues/13909): Fix false positive with `Layout/ClosingParenthesisIndentation` when first parameter is a hash. ([@tejasbubane][]) +* [#13915](https://github.com/rubocop/rubocop/pull/13915): Fix writing generics type of rbs-inline annotation for nested class in `Style/CommentedKeyword`. ([@dak2][]) +* [#13916](https://github.com/rubocop/rubocop/issues/13916): Fix `Lint/LiteralAsCondition` acting on the right hand side of && nodes. ([@zopolis4][]) + +## 1.73.0 (2025-02-26) + +### New features + +* [#11024](https://github.com/rubocop/rubocop/issues/11024): Add `require_always` option to `Style/EndlessMethod`. ([@koic][]) +* [#11024](https://github.com/rubocop/rubocop/issues/11024): Add `require_single_line` option to `Style/EndlessMethod`. ([@jtannas][]) +* [#9935](https://github.com/rubocop/rubocop/issues/9935): Introduce EnforcedStyleForMultiline "diff_comma". ([@flavorjones][]) + +### Bug fixes + +* [#13867](https://github.com/rubocop/rubocop/issues/13867): Fix an error for plugins when not running RuboCop through Bundler. ([@earlopain][]) +* [#13902](https://github.com/rubocop/rubocop/pull/13902): Fix false negative for `Style/RedundantSelfAssignment` when the method receives a block. ([@vlad-pisanov][]) +* [#13826](https://github.com/rubocop/rubocop/issues/13826): Fix false positives for regex cops when `Lint/MixedCaseRange` is enabled. ([@earlopain][]) +* [#13818](https://github.com/rubocop/rubocop/issues/13818): Fix false positives for `Lint/Void` when using operator method call without argument. ([@koic][]) +* [#13896](https://github.com/rubocop/rubocop/pull/13896): Fix a false positive for `Style/TrivialAccessors` with `instance_eval` and numblocks. ([@earlopain][]) +* [#13910](https://github.com/rubocop/rubocop/pull/13910): Fix false positives for `Style/EndlessMethod` when using setter method definitions. ([@koic][]) +* [#13889](https://github.com/rubocop/rubocop/pull/13889): Fix autocorrection for `Layout/LineLength` with interpolated strings when not on the first line. ([@dvandersluis][]) +* [#13900](https://github.com/rubocop/rubocop/issues/13900): Fix infinite loop between `Layout/EmptyLinesAroundAccessModifier` and `Layout/EmptyLinesAroundBlockBody` with `EnforcedStyle: no_empty_lines`. ([@dvandersluis][]) +* [#12692](https://github.com/rubocop/rubocop/issues/12692): Fix `Style/AccessorGrouping` with constants. ([@tejasbubane][]) +* [#13882](https://github.com/rubocop/rubocop/issues/13882): Fix `Style/RedundantFormat` for annotated template strings with missing hash keys. ([@dvandersluis][]) +* [#13880](https://github.com/rubocop/rubocop/issues/13880): Fix `Style/RedundantFormat` when given double-splatted arguments. ([@dvandersluis][]) +* [#13907](https://github.com/rubocop/rubocop/pull/13907): Don't offer autocorrect for `Style/StringConcatenation` when numblocks are used. ([@earlopain][]) +* [#13876](https://github.com/rubocop/rubocop/issues/13876): Don't consider `require 'pp'` to be redundant for `Lint/RedundantRequireStatement`. ([@earlopain][]) +* [#13885](https://github.com/rubocop/rubocop/issues/13885): Update `Style/HashExcept` and `Style/HashSlice` to not register an offense if selecting over the hash value. ([@dvandersluis][]) + +### Changes + +* [#12948](https://github.com/rubocop/rubocop/issues/12948): Add `ForbiddenNames` configuration to `Naming/VariableName` to specify names that are forbidden. ([@dvandersluis][]) +* [#13117](https://github.com/rubocop/rubocop/issues/13117): Add partial autocorrect support to `Lint/LiteralAsCondition` cop to check for redundant conditions. ([@zopolis4][]) +* [#13892](https://github.com/rubocop/rubocop/pull/13892): Allow merging of configured arrays and non-arrays. ([@sambostock][]) +* [#13833](https://github.com/rubocop/rubocop/pull/13833): Add `Reference` to common params. ([@sambostock][]) +* [#13890](https://github.com/rubocop/rubocop/pull/13890): Update `Lint/RedundantTypeConversion` to not register an offense when given a constructor with `exception: false`. ([@dvandersluis][]) +* [#13729](https://github.com/rubocop/rubocop/pull/13729): Update `Style/RedundantCondition` cop to detect conditional expressions where the true branch is `true` and suggest replacing them with a logical OR. ([@datpmt][]) + +## 1.72.2 (2025-02-17) + +### Bug fixes + +* [#13853](https://github.com/rubocop/rubocop/pull/13853): Fix exclusion of relative paths in plugin's `AllCops: Exclude` as expected. ([@koic][]) +* [#13844](https://github.com/rubocop/rubocop/issues/13844): Fix an error for `Style/RedundantFormat` when a template argument is used without keyword arguments. ([@koic][]) +* [#13857](https://github.com/rubocop/rubocop/pull/13857): Fix an error for `Style/RedundantFormat` when numeric placeholders is used in the template argument. ([@koic][]) +* [#13861](https://github.com/rubocop/rubocop/issues/13861): Fix `ArgumentError` related to two deprecated `AllowedPattern` APIs. ([@koic][]) +* [#13849](https://github.com/rubocop/rubocop/issues/13849): Fix an error for `Lint/UselessConstantScoping` when multiple assigning to constants after `private` access modifier. ([@koic][]) +* [#13856](https://github.com/rubocop/rubocop/issues/13856): Fix false positives for `Lint/UselessConstantScoping` when a constant is used after `private` access modifier with arguments. ([@koic][]) + +### Changes + +* [#13846](https://github.com/rubocop/rubocop/issues/13846): Mark `Style/RedundantFormat` as unsafe autocorrect. ([@koic][]) + +## 1.72.1 (2025-02-15) + +### Bug fixes + +* [#13836](https://github.com/rubocop/rubocop/issues/13836): Fix an error for `Style/RedundantParentheses` when a different expression appears before a range literal. ([@koic][]) +* [#13839](https://github.com/rubocop/rubocop/issues/13839): Fix false positives for `Lint/RedundantTypeConversion` when passing block arguments when generating a Hash or a Set. ([@koic][]) + +### Changes + +* [#13840](https://github.com/rubocop/rubocop/pull/13840): Extension plugin is loaded automatically with `require 'rubocop/rspec/support'. ([@koic][]) + +## 1.72.0 (2025-02-14) + +### New features + +* [#13740](https://github.com/rubocop/rubocop/pull/13740): Add new `Lint/CopDirectiveSyntax` cop. ([@kyanagi][]) +* [#13800](https://github.com/rubocop/rubocop/issues/13800): Add new `Lint/SuppressedExceptionInNumberConversion` cop. ([@koic][]) +* [#13702](https://github.com/rubocop/rubocop/pull/13702): Add new `Lint/RedundantTypeConversion` cop. ([@dvandersluis][]) +* [#13831](https://github.com/rubocop/rubocop/pull/13831): Add new `Lint/UselessConstantScoping` cop. ([@koic][]) +* [#13793](https://github.com/rubocop/rubocop/pull/13793): Add new `Style/RedundantFormat` cop to check for uses of `format` or `sprintf` with only a single string argument. ([@dvandersluis][]) +* [#13581](https://github.com/rubocop/rubocop/pull/13581): Add new `InternalAffairs/LocationExists` cop to check for code that can be replaced with `Node#loc?` or `Node#loc_is?`. ([@dvandersluis][]) +* [#13661](https://github.com/rubocop/rubocop/issues/13661): Make server mode detect local paths in .rubocop.yml under `inherit_from` and `require` for automatically restart. ([@koic][]) +* [#13721](https://github.com/rubocop/rubocop/pull/13721): `Naming/PredicateName`: Optionally use Sorbet to detect predicate methods. ([@issyl0][]) +* [#6012](https://github.com/rubocop/rubocop/issues/6012): Support RuboCop extension plugin. ([@koic][]) + +### Bug fixes + +* [#13807](https://github.com/rubocop/rubocop/issues/13807): Fix false negatives for `Style/RedundantParentheses` when chaining `[]` method calls. ([@koic][]) +* [#13788](https://github.com/rubocop/rubocop/issues/13788): Fix false negatives for `Style/RedundantParentheses` when `[]` method is called with variable or constant receivers. ([@koic][]) +* [#13811](https://github.com/rubocop/rubocop/issues/13811): Fix false negatives for `Style/RedundantParentheses` when handling range literals with redundant parentheses. ([@koic][]) +* [#13796](https://github.com/rubocop/rubocop/pull/13796): Fix crash in `Layout/EmptyLinesAroundMethodBody` for endless methods. ([@dvandersluis][]) +* [#13817](https://github.com/rubocop/rubocop/pull/13817): Fix false positive for format specifier with non-numeric precision. ([@dvandersluis][]) +* [#12672](https://github.com/rubocop/rubocop/issues/12672): Fix false positives for `Lint/FormatParameterMismatch` when the width value is interpolated. ([@dvandersluis][]) +* [#12795](https://github.com/rubocop/rubocop/issues/12795): Fix `Layout/BlockAlignment` for blocks that are the body of an endless method. ([@dvandersluis][]) +* [#13822](https://github.com/rubocop/rubocop/pull/13822): Fix undefined method Logger when processing watched file notifications. ([@vinistock][]) +* [#13805](https://github.com/rubocop/rubocop/pull/13805): Make the language_server-protocol dependency version stricter. ([@koic][]) + +## 1.71.2 (2025-02-04) + +### Bug fixes + +* [#13782](https://github.com/rubocop/rubocop/pull/13782): Fix an error `Layout/ElseAlignment` when `else` is part of a numblock. ([@earlopain][]) +* [#13395](https://github.com/rubocop/rubocop/issues/13395): Fix a false positive for `Lint/UselessAssignment` when assigning in branch and block. ([@pCosta99][]) +* [#13783](https://github.com/rubocop/rubocop/pull/13783): Fix a false positive for `Lint/Void` when `each` numblock with conditional expressions that has multiple statements. ([@earlopain][]) +* [#13787](https://github.com/rubocop/rubocop/issues/13787): Fix incorrect autocorrect for `Style/ExplicitBlockArgument` when using arguments of `zsuper` in method definition. ([@koic][]) +* [#13785](https://github.com/rubocop/rubocop/pull/13785): Fix `Style/EachWithObject` cop error in case of single block argument. ([@viralpraxis][]) +* [#13781](https://github.com/rubocop/rubocop/pull/13781): Fix a false positive for `Lint/UnmodifiedReduceAccumulator` when omitting the accumulator in a nested numblock. ([@earlopain][]) + +## 1.71.1 (2025-01-31) + +### Bug fixes + +* [#10081](https://github.com/rubocop/rubocop/issues/10081): Add the missing `include RuboCop::RSpec::ExpectOffense` in rubocop/rspec/support.rb. ([@d4rky-pl][]) +* [#13765](https://github.com/rubocop/rubocop/pull/13765): Fix a false negative for `Lint/AmbiguousBlockAssociation` with numblocks. ([@earlopain][]) +* [#13759](https://github.com/rubocop/rubocop/pull/13759): Fix a false negative for `Lint/ConstantDefinitionInBlock` with numblocks. ([@earlopain][]) +* [#13741](https://github.com/rubocop/rubocop/pull/13741): Register an offense for `Naming/BlockForwarding` and `Style/ArgumentsForwarding` with Ruby >= 3.4 when the block argument is referenced inside a block. This was previously disabled because of a bug in Ruby 3.3.0. ([@earlopain][]) +* [#13777](https://github.com/rubocop/rubocop/pull/13777): Fix a false negative for `Layout/EmptyLineBetweenDefs` with `DefLikeMacros` and numblocks. ([@earlopain][]) +* [#13769](https://github.com/rubocop/rubocop/pull/13769): Fix a false negative for `Style/RedundantParentheses` with numblocks. ([@earlopain][]) +* [#13780](https://github.com/rubocop/rubocop/pull/13780): Fix a false positive `Style/AccessModifierDeclarations` when using access modifier in a numblock. ([@earlopain][]) +* [#13775](https://github.com/rubocop/rubocop/pull/13775): Fix a false positive for `Lint/AssignmentInCondition` when assigning in numblocks. ([@earlopain][]) +* [#13773](https://github.com/rubocop/rubocop/pull/13773): Fix false positives for `Layout/RedundantLineBreak` when using numbered block parameter. ([@koic][]) +* [#13761](https://github.com/rubocop/rubocop/pull/13761): Fix a false positive for `Style/SuperArguments` when calling super in a numblock. ([@earlopain][]) +* [#13768](https://github.com/rubocop/rubocop/pull/13768): Fix a false positive for `Lint/UnreachableCode` with `instance_eval` numblock. ([@earlopain][]) +* [#13750](https://github.com/rubocop/rubocop/issues/13750): Fix false positives for `Style/RedundantSelfAssignment` when assigning to attribute of `self`. ([@koic][]) +* [#13739](https://github.com/rubocop/rubocop/issues/13739): Fix false positive for `Style/HashExcept` and `Style/HashSlice` when checking for inclusion with a range. ([@dvandersluis][]) +* [#13751](https://github.com/rubocop/rubocop/issues/13751): Fix false positive in `Layout/ExtraSpacing` with `ForceEqualSignAlignment: true` for endless methods. ([@dvandersluis][]) +* [#13767](https://github.com/rubocop/rubocop/pull/13767): Fix `Style/IdenticalConditionalBranches` autocorrect when condition is inside assignment. ([@dvandersluis][]) +* [#13764](https://github.com/rubocop/rubocop/pull/13764): Fix a false negative for `Layout/SingleLineBlockChain` with numblocks. ([@earlopain][]) +* [#13771](https://github.com/rubocop/rubocop/pull/13771): Fix wrong autocorrect for `Style/SoleNestedConditional` when using numblocks. ([@earlopain][]) + +## 1.71.0 (2025-01-22) + +### New features + +* [#13735](https://github.com/rubocop/rubocop/pull/13735): Add new `Lint/ArrayLiteralInRegexp` cop. ([@dvandersluis][]) +* [#13507](https://github.com/rubocop/rubocop/pull/13507): Add new `Style/HashSlice` cop. ([@lovro-bikic][]) + +### Bug fixes + +* [#13684](https://github.com/rubocop/rubocop/issues/13684): Fix a false positive for `Style/FrozenStringLiteralComment` when using the frozen string literal magic comment in Active Admin's arb files. ([@koic][]) +* [#13372](https://github.com/rubocop/rubocop/issues/13372): Add `rubocop_cache` to the path given by `--cache-root` when pruning cache. ([@capncavedan][]) +* [#13257](https://github.com/rubocop/rubocop/issues/13257): Fix department disable/enable comments enabling the cop for the whole file even if that file is excluded by the cop. ([@earlopain][]) +* [#13704](https://github.com/rubocop/rubocop/issues/13704): Fix false positives for `Lint/OutOfRangeRegexpRef` when matching with `match` using safe navigation. ([@koic][]) +* [#13720](https://github.com/rubocop/rubocop/issues/13720): Fix false positives for `Style/BlockDelimiters` when using brace blocks as conditions under `EnforcedStyle: semantic`. ([@koic][]) +* [#13688](https://github.com/rubocop/rubocop/issues/13688): Fix false negative on `Style/RedundantLineContinuation` when the continuation is preceded by an interpolated string. ([@dvandersluis][]) +* [#13677](https://github.com/rubocop/rubocop/issues/13677): Fix false negative on `Style/RedundantLineContinuation` when the continuation is followed by a percent array. ([@dvandersluis][]) +* [#13692](https://github.com/rubocop/rubocop/pull/13692): Fix false positive in `Style/RedundantLineContinuation` when the ruby code ends with a commented continuation. ([@dvandersluis][]) +* [#13675](https://github.com/rubocop/rubocop/pull/13675): Fix invalid autocorrect for `Style/ArrayFirstLast` when calling `.[]` or `&.[]` with 0 or -1. ([@dvandersluis][]) +* [#13685](https://github.com/rubocop/rubocop/issues/13685): Fix syntax error introduced by `Lint/SafeNavigationChain` when adding safe navigation to an operator call inside a hash. ([@dvandersluis][]) +* [#13725](https://github.com/rubocop/rubocop/issues/13725): Fix an incorrect autocorrect for `Style/IfUnlessModifier` when using omitted hash values in an assignment. ([@elliottt][]) +* [#13667](https://github.com/rubocop/rubocop/issues/13667): Maintain precedence in autocorrect for `Style/SoleNestedConditional`. ([@tejasbubane][]) +* [#13679](https://github.com/rubocop/rubocop/issues/13679): Fix false positive for `Style/RedundantLineContinuation` when calling methods with fully qualified constants. ([@earlopain][]) +* [#13728](https://github.com/rubocop/rubocop/pull/13728): Fix a RuboCop error on provided glob pattern which matches directory. ([@viralpraxis][]) +* [#13693](https://github.com/rubocop/rubocop/pull/13693): Fix `Style/ConditionalAssignment` cop error on `unless` without `else` and `assign_inside_condition` enforced style. ([@viralpraxis][]) +* [#13669](https://github.com/rubocop/rubocop/pull/13669): Fix `Style/FrozenStringLiteralComment` cop error on unnormalized magic comment and `never` enforced style. ([@viralpraxis][]) +* [#13696](https://github.com/rubocop/rubocop/pull/13696): Update `Metrics/CollectionLiteralLength` to only register for `[]` when called on `Set`. ([@dvandersluis][]) + +### Changes + +* [#13709](https://github.com/rubocop/rubocop/pull/13709): Add support for safe navigation to `Lint/FloatComparison`. ([@dvandersluis][]) +* [#13711](https://github.com/rubocop/rubocop/pull/13711): Add support for safe navigation to `Layout/MultilineMethodCallBraceLayout`. ([@dvandersluis][]) +* [#13712](https://github.com/rubocop/rubocop/pull/13712): Add support for safe navigation to `Layout/MultilineMethodArgumentLineBreaks`. ([@dvandersluis][]) +* [#13714](https://github.com/rubocop/rubocop/pull/13714): Add support for safe navigation to `Security/CompoundHash`. ([@dvandersluis][]) +* [#13674](https://github.com/rubocop/rubocop/pull/13674): Add support for safe navigation to `Style/BlockDelimiters`. ([@dvandersluis][]) +* [#13673](https://github.com/rubocop/rubocop/pull/13673): Add support for safe navigation to `Style/CollectionMethods`. ([@dvandersluis][]) +* [#13672](https://github.com/rubocop/rubocop/pull/13672): Add support for safe navigation to `Style/MapToSet`. ([@dvandersluis][]) +* [#13671](https://github.com/rubocop/rubocop/pull/13671): Add support for safe navigation to `Style/MethodCallWithoutArgsParentheses`. ([@dvandersluis][]) +* [#13701](https://github.com/rubocop/rubocop/pull/13701): Add support for safe navigation to `Lint/NumericOperationWithConstantResult`. ([@dvandersluis][]) +* [#13700](https://github.com/rubocop/rubocop/pull/13700): Add support for safe navigation to `Lint/RedundantStringCoercion`. ([@dvandersluis][]) +* [#13698](https://github.com/rubocop/rubocop/pull/13698): Add support for safe navigation to `Lint/UselessNumericOperation`. ([@dvandersluis][]) +* [#13686](https://github.com/rubocop/rubocop/pull/13686): Add wildcard support to `--show-cops`. ([@kyanagi][]) +* [#13724](https://github.com/rubocop/rubocop/pull/13724): Make `Style/RedundantParentheses` aware of parenthesized assignment. ([@koic][]) +* [#13732](https://github.com/rubocop/rubocop/pull/13732): Update `Style/RedundantLineContinuation` to handle required continuations following `super`. ([@dvandersluis][]) + +## 1.70.0 (2025-01-10) + +### New features + +* [#13474](https://github.com/rubocop/rubocop/pull/13474): Add new `Style/ItAssignment` cop to detect local assignments to `it` inside blocks. ([@dvandersluis][]) +* [#11013](https://github.com/rubocop/rubocop/issues/11013): Add new `Lint/SharedMutableDefault` cop to alert on mutable Hash defaults. ([@corsonknowles][]) +* [#13612](https://github.com/rubocop/rubocop/pull/13612): Create new cop `Lint/ConstantReassignment`. ([@lovro-bikic][]) +* [#13628](https://github.com/rubocop/rubocop/pull/13628): Make LSP server support quick fix code action. ([@koic][]) +* [#13607](https://github.com/rubocop/rubocop/pull/13607): Support passing the target ruby version through an environment variable. ([@elliottt][]) +* [#13628](https://github.com/rubocop/rubocop/pull/13628): Add support for Ruby LSP as a built-in add-on. ([@koic][]) +* [#13284](https://github.com/rubocop/rubocop/issues/13284): Add new `target_gem_version` API to change behavior of a cop at runtime depending on which gem version is present. ([@earlopain][]) + +### Bug fixes + +* [#13589](https://github.com/rubocop/rubocop/pull/13589): Fix `Lint/NonAtomicFileOperation` to detect offenses with fully qualified constants. ([@viralpraxis][]) +* [#13630](https://github.com/rubocop/rubocop/pull/13630): Fix CLI `--format` option to accept fully qualified formatter class names. ([@viralpraxis][]) +* [#13624](https://github.com/rubocop/rubocop/pull/13624): Don't show warnings from `Lint/Syntax` when a syntax error occurs. ([@earlopain][]) +* [#13605](https://github.com/rubocop/rubocop/pull/13605): Fix `RuboCop::Cop::Util.to_string_literal` to work correctly with frozen strings. ([@viralpraxis][]) +* [#12393](https://github.com/rubocop/rubocop/issues/12393): Fix false negatives for `Lint/Void` inside of non-modifier conditionals. ([@GabeIsman][]) +* [#13623](https://github.com/rubocop/rubocop/issues/13623): Fix false negatives for `Style/MultipleComparison` when setting `AllowMethodComparison: false` and comparing with simple method calls. ([@koic][]) +* [#13644](https://github.com/rubocop/rubocop/pull/13644): Fix a false positive for `Layout/EmptyLinesAroundAccessModifier` when an access modifier and an expression are on the same line. ([@koic][]) +* [#13645](https://github.com/rubocop/rubocop/issues/13645): Fix a false positive for `Style/MethodCallWithArgsParentheses` when setting `EnforcedStyle: omit_parentheses` and last argument is an endless range. ([@earlopain][]) +* [#13614](https://github.com/rubocop/rubocop/issues/13614): Fix false positives for `Style/RaiseArgs` with anonymous splat and triple dot forwarding. ([@earlopain][]) +* [#13591](https://github.com/rubocop/rubocop/pull/13591): Fix false positives for `Lint/NestedMethodDefinition` when defining a method on a constant or a method call. ([@koic][]) +* [#13594](https://github.com/rubocop/rubocop/pull/13594): Fix false positives for `Style/MultipleComparison` when using multiple safe navigation method calls. ([@koic][]) +* [#13654](https://github.com/rubocop/rubocop/pull/13654): Fix false positives for `Style/RedundantInitialize` when empty initialize method has arguments. ([@marocchino][]) +* [#13608](https://github.com/rubocop/rubocop/pull/13608): Fix crash when running `rubocop -d` on a config with a remote `inherit_from` that causes a duplicate setting warning. ([@dvandersluis][]) +* [#12430](https://github.com/rubocop/rubocop/issues/12430): Fix false negatives in `Style/RedundantLineContinuation` with multiple line continuations. ([@dvandersluis][]) +* [#13638](https://github.com/rubocop/rubocop/pull/13638): Fix false positive for `Naming/BlockForwarding` when method just returns the block argument. ([@mvz][]) +* [#13599](https://github.com/rubocop/rubocop/issues/13599): Fix incorrect autocorrect for `Layout/HashAlignment` when there is a multiline positional argument and `Layout/ArgumentAlignment` is configured with `EnforcedStyle: with_fixed_indentation`. ([@dvandersluis][]) +* [#13586](https://github.com/rubocop/rubocop/issues/13586): Fix regression in `Layout/SpaceAroundOperators` when different comparison operators were aligned with each other. ([@dvandersluis][]) +* [#13603](https://github.com/rubocop/rubocop/pull/13603): Fix `Lint/LiteralInInterpolation` cop error on invalid string literal. ([@viralpraxis][]) +* [#13582](https://github.com/rubocop/rubocop/pull/13582): Fix `Lint/NonAtomicFileOperation` cop error on non-constant receiver. ([@viralpraxis][]) +* [#13598](https://github.com/rubocop/rubocop/pull/13598): Fix `Lint/Void` cop error on `if` without body. ([@viralpraxis][]) +* [#13634](https://github.com/rubocop/rubocop/pull/13634): Fix `Style/ClassAndModuleChildren` cop error on `compact` enforced style and unindented body. ([@viralpraxis][]) +* [#13642](https://github.com/rubocop/rubocop/pull/13642): Fix `Style/FloatDivision` cop error if `#to_f` has implicit receiver. ([@viralpraxis][]) +* [#13517](https://github.com/rubocop/rubocop/pull/13517): Fixes `Style/HashExcept` to recognize safe navigation when `ActiveSupportExtensionsEnabled` config is enabled. ([@lovro-bikic][]) +* [#13585](https://github.com/rubocop/rubocop/pull/13585): Fix `Style/HashSyntax` cop error on implicit `call` method. ([@viralpraxis][]) +* [#13632](https://github.com/rubocop/rubocop/pull/13632): Fix `Style/MissingElse` cop error if `Style/EmptyElse`'s `EnforcedStyle` is not `both` and `if` expression contains `elsif`. ([@viralpraxis][]) +* [#13659](https://github.com/rubocop/rubocop/pull/13659): Fix `Style/MissingElse` cop error if `Style/EmptyElse`'s `EnforcedStyle` is not `both` and `if` expression contains multiple `elsif`. ([@viralpraxis][]) +* [#13596](https://github.com/rubocop/rubocop/pull/13596): Fix `Style/RedundantCondition` cop error on parentheses and modifier `if` in `else`. ([@viralpraxis][]) +* [#13616](https://github.com/rubocop/rubocop/pull/13616): Fix incorrect autocorrect for `Style/RedundantRegexpArgument` when the regex contains a single quote. ([@mrzasa][]) +* [#13619](https://github.com/rubocop/rubocop/pull/13619): Fix `Style/YodaExpression` cop error in case of suffix form of operator. ([@viralpraxis][]) +* [#13578](https://github.com/rubocop/rubocop/issues/13578): Update `Layout/LineContinuationSpacing` to ignore continuations inside a `regexp` or `xstr`. ([@dvandersluis][]) +* [#13601](https://github.com/rubocop/rubocop/issues/13601): Update `Style/SuperArguments` to handle `super` with a block or with a chained method with a block. ([@dvandersluis][]) +* [#13568](https://github.com/rubocop/rubocop/pull/13568): Fix `NoMethodError` in `ConfigValidator` when a Cop's config is not a `Hash` and raise `ValidationError` instead. ([@amomchilov][]) + +### Changes + +* [#13665](https://github.com/rubocop/rubocop/pull/13665): Add support for safe navigation to `Style/ObjectThen`. ([@dvandersluis][]) +* [#13657](https://github.com/rubocop/rubocop/pull/13657): Add support for safe navigation to `Layout/HashAlignment`. ([@dvandersluis][]) +* [#13656](https://github.com/rubocop/rubocop/pull/13656): Add support for safe navigation to `Layout/HeredocArgumentClosingParenthesis`. ([@dvandersluis][]) +* [#13655](https://github.com/rubocop/rubocop/pull/13655): Add support for safe navigation to `Layout/LineLength`. ([@dvandersluis][]) +* [#13662](https://github.com/rubocop/rubocop/pull/13662): Add support for safe navigation to `Style/SendWithLiteralMethodName`. ([@dvandersluis][]) +* [#13557](https://github.com/rubocop/rubocop/issues/13557): Fix false positives for `Lint/NumericOperationWithConstantResult`. ([@earlopain][]) +* [#13658](https://github.com/rubocop/rubocop/pull/13658): Fix invalid autocorrect for `Style/SlicingWithRange` when calling `.[]` or `&.[]` with a correctable range. ([@dvandersluis][]) +* [#13548](https://github.com/rubocop/rubocop/pull/13548): Enhance `Lint/DuplicateSetElement` to detect offences within `SortedSet`. ([@viralpraxis][]) +* [#13646](https://github.com/rubocop/rubocop/pull/13646): Update `Layout/TrailingWhitespace` to support blank characters other than space and tab. ([@krororo][]) +* [#13652](https://github.com/rubocop/rubocop/pull/13652): Update `Metrics/MethodLength` to make use of `AllowedMethods` and `AllowedPatterns` for methods defined dynamically with `define_method`. ([@dvandersluis][]) +* [#13606](https://github.com/rubocop/rubocop/issues/13606): Update `Style/AccessModifierDeclarations` to add `AllowModifiersOnAliasMethod` configuration (default `true`). ([@dvandersluis][]) +* [#13663](https://github.com/rubocop/rubocop/pull/13663): Update `Style/RedundantSelfAssignment` to handle safe navigation on the right-hand side of the assignment. ([@dvandersluis][]) + +## 1.69.2 (2024-12-12) + +### Bug fixes + +* [#13553](https://github.com/rubocop/rubocop/issues/13553): Fix an incorrect autocorrect for `Style/MultipleComparison` when a variable is compared multiple times after a method call. ([@koic][]) +* [#13562](https://github.com/rubocop/rubocop/pull/13562): Fix `Bundler/DuplicatedGem` cop error in case of empty branch. ([@viralpraxis][]) +* [#13573](https://github.com/rubocop/rubocop/pull/13573): Fix `Lint/UnescapedBracketInRegexp` cop failure with invalid multibyte escape. ([@earlopain][]) +* [#13556](https://github.com/rubocop/rubocop/issues/13556): Fix false positives for `Style/FileNull` when using `'nul'` string. ([@koic][]) +* [#12995](https://github.com/rubocop/rubocop/issues/12995): Fix `--disable-uncorrectable` to not insert directives inside a string. ([@dvandersluis][]) +* [#13320](https://github.com/rubocop/rubocop/issues/13320): Fix incorrect autocorrect when `Layout/LineContinuationLeadingSpace` and `Style/StringLiterals` autocorrects in the same pass. ([@dvandersluis][]) +* [#13299](https://github.com/rubocop/rubocop/issues/13299): Fix `Style/BlockDelimiters` to always accept braces when an operator method argument is chained. ([@dvandersluis][]) +* [#13565](https://github.com/rubocop/rubocop/pull/13565): Fix `Style/RedundantLineContinuation` false negatives when a redundant continuation follows a required continuation. ([@dvandersluis][]) +* [#13551](https://github.com/rubocop/rubocop/pull/13551): Fix an incorrect autocorrect for `Style/IfWithSemicolon` when using multi value assignment in `if` with a semicolon is used. ([@koic][]) +* [#13534](https://github.com/rubocop/rubocop/pull/13534): Fix `Layout/LineLength` cop failure in case of YARD-comment-like string. ([@viralpraxis][]) +* [#13558](https://github.com/rubocop/rubocop/pull/13558): Fix `Lint/NonAtomicFileOperation` cop error in case of implicit receiver. ([@viralpraxis][]) +* [#13564](https://github.com/rubocop/rubocop/pull/13564): Fix `Metrics/ClassLength` cop error in case of chained assignments. ([@viralpraxis][]) +* [#13570](https://github.com/rubocop/rubocop/pull/13570): Fix `Naming/RescuedExceptionsVariableName` cop error when exception is assigned with writer method. ([@viralpraxis][]) +* [#13559](https://github.com/rubocop/rubocop/pull/13559): Fix a false positive for `Style/RedundantLineContinuation` when a method definition is used as an argument for a method call. ([@davidrunger][]) +* [#13574](https://github.com/rubocop/rubocop/pull/13574): Fix `Style/ExactRegexpMatch` cop error on invalid regular expression literal. ([@viralpraxis][]) +* [#13554](https://github.com/rubocop/rubocop/pull/13554): Fix `Style/FrozenStringLiteralComment` false positive in case of non-downcased value literal. ([@viralpraxis][]) +* [#13569](https://github.com/rubocop/rubocop/pull/13569): Fix `Style/MethodCallWithoutArgsParentheses` cop error in case of mass hash assignment. ([@viralpraxis][]) +* [#13542](https://github.com/rubocop/rubocop/pull/13542): Fix `Style/RedundantCondition` cop failure in case of empty arguments. ([@viralpraxis][]) +* [#13509](https://github.com/rubocop/rubocop/issues/13509): Update `Layout/ExtraSpacing` and `Layout/SpaceAroundOperators` to handle preceding operators inside strings. ([@dvandersluis][]) + +## 1.69.1 (2024-12-03) + +### Bug fixes + +* [#13502](https://github.com/rubocop/rubocop/issues/13502): Fix an incorrect autocorrect for `Style/DigChain` when using safe navigation method chain with `dig` method. ([@koic][]) +* [#13505](https://github.com/rubocop/rubocop/issues/13505): Fix an error for `Style/ParallelAssignment` when using the anonymous splat operator. ([@earlopain][]) +* [#13184](https://github.com/rubocop/rubocop/pull/13184): Fix some false positives in `Lint/UnreachableCode`. ([@isuckatcs][]) +* [#13494](https://github.com/rubocop/rubocop/pull/13494): Fix false positives for `Style/HashExcept` cop when using `reject/!include?`, `reject/!in?` or `select/!exclude?` combinations. ([@lovro-bikic][]) +* [#13522](https://github.com/rubocop/rubocop/pull/13522): Fix `Lint/UnescapedBracketInRegexp` cop failure with invalid regular expression. ([@viralpraxis][]) +* [#13523](https://github.com/rubocop/rubocop/pull/13523): Fix `Style::AccessModifierDeclarations` cop failure in case of `if` node without `else`. ([@viralpraxis][]) +* [#13524](https://github.com/rubocop/rubocop/pull/13524): Fix `Style/RedundantArgument` cop failure while inspecting string literal with invalid encoding. ([@viralpraxis][]) +* [#13528](https://github.com/rubocop/rubocop/pull/13528): Fix `Style/RedundantParentheses` cop failure in case of splatted `case` node without condition. ([@viralpraxis][]) +* [#13521](https://github.com/rubocop/rubocop/pull/13521): Fix `Style/RedundantSelf` cop failure with `kwnilarg` argument node. ([@viralpraxis][]) +* [#13526](https://github.com/rubocop/rubocop/pull/13526): Fix `Style/StringConcatenation` cop failure when there are mixed implicit and explicit concatenations. ([@viralpraxis][]) +* [#13511](https://github.com/rubocop/rubocop/issues/13511): Fix false positive in `Lint/UnescapedBracketInRegexp` when using regexp_parser 2.9.2 and earlier. ([@dvandersluis][]) +* [#13096](https://github.com/rubocop/rubocop/issues/13096): Update `Style/BlockDelimiters` to not change braces when they are required for syntax. ([@dvandersluis][]) +* [#13512](https://github.com/rubocop/rubocop/pull/13512): Update `Style/LambdaCall` to be aware of safe navigation. ([@dvandersluis][]) + +## 1.69.0 (2024-11-26) + +### New features + +* [#13439](https://github.com/rubocop/rubocop/pull/13439): Add new `Lint/HashNewWithKeywordArgumentsAsDefault` cop. ([@koic][]) +* [#11191](https://github.com/rubocop/rubocop/issues/11191): Add new `Lint/NumericOperationWithConstantResult` cop. ([@zopolis4][]) +* [#13486](https://github.com/rubocop/rubocop/issues/13486): Add new `Style/DigChain` cop. ([@dvandersluis][]) +* [#13490](https://github.com/rubocop/rubocop/issues/13490): Add new `Style/FileNull` cop. ([@dvandersluis][]) +* [#13484](https://github.com/rubocop/rubocop/pull/13484): Add new `Style/FileTouch` cop. ([@lovro-bikic][]) +* [#13437](https://github.com/rubocop/rubocop/issues/13437): Add a new cop `Lint/UselessDefined` to detect cases such as `defined?('Foo')` when `defined?(Foo)` was intended. ([@earlopain][]) + +### Bug fixes + +* [#13455](https://github.com/rubocop/rubocop/pull/13455): Fix a false positive for `Layout/EmptyLineAfterGuardClause` when using a guard clause outside oneliner block. ([@koic][]) +* [#13412](https://github.com/rubocop/rubocop/issues/13412): Fix a false positive for `Style/RedundantLineContinuation` when there is a line continuation at the end of Ruby code followed by `__END__` data. ([@koic][]) +* [#13476](https://github.com/rubocop/rubocop/pull/13476): Allow to write generics type of RBS::Inline annotation after subclass definition in `Style/CommentedKeyword`. ([@dak2][]) +* [#13441](https://github.com/rubocop/rubocop/pull/13441): Fix an incorrect autocorrect for `Style/IfWithSemicolon` when using `return` with value in `if` with a semicolon is used. ([@koic][]) +* [#13448](https://github.com/rubocop/rubocop/pull/13448): Fix an incorrect autocorrect for `Style/IfWithSemicolon` when the then body contains an arithmetic operator method call with an argument. ([@koic][]) +* [#13199](https://github.com/rubocop/rubocop/issues/13199): Make `Style/RedundantCondition` skip autocorrection when a branch has a comment. ([@koic][]) +* [#13411](https://github.com/rubocop/rubocop/pull/13411): Fix `Style/BitwisePredicate` when having regular method. ([@d4be4st][]) +* [#13432](https://github.com/rubocop/rubocop/pull/13432): Fix false positive for `Lint/FloatComparison` against nil. ([@lovro-bikic][]) +* [#13461](https://github.com/rubocop/rubocop/pull/13461): Fix false positives for `Lint/InterpolationCheck` when using invalid syntax in interpolation. ([@koic][]) +* [#13402](https://github.com/rubocop/rubocop/issues/13402): Fix a false positive for `Lint/SafeNavigationConsistency` when using unsafe navigation with both `&&` and `||`. ([@koic][]) +* [#13434](https://github.com/rubocop/rubocop/issues/13434): Fix a false positive for `Naming/MemoizedInstanceVariableName` for assignment methods`. ([@earlopain][]) +* [#13415](https://github.com/rubocop/rubocop/issues/13415): Fix false positives for `Naming/MemoizedInstanceVariableName` when using `initialize_clone`, `initialize_copy`, or `initialize_dup`. ([@koic][]) +* [#13421](https://github.com/rubocop/rubocop/issues/13421): Fix false positives for `Style/SafeNavigation` when using a method chain that exceeds the `MaxChainLength` value and includes safe navigation operator. ([@koic][]) +* [#13433](https://github.com/rubocop/rubocop/issues/13433): Fix autocorrection for `Style/AccessModifierDeclarations` for multiple inline symbols. ([@dvandersluis][]) +* [#13430](https://github.com/rubocop/rubocop/issues/13430): Fix EmptyLinesAroundMethodBody for methods with arguments spanning multiple lines. ([@aduth][]) +* [#13438](https://github.com/rubocop/rubocop/pull/13438): Fix incorrect correction in `Lint/Void` if an operator is called in a void context using a dot. ([@dvandersluis][]) +* [#13419](https://github.com/rubocop/rubocop/pull/13419): Fix `Lint/DeprecatedOpenSSLConstant` false positive when the argument is a safe navigation method call. ([@dvandersluis][]) +* [#13404](https://github.com/rubocop/rubocop/pull/13404): Fix `Style/AccessModifierDeclarations` to register (as positive or negative, depending on `AllowModifiersOnSymbols` value) access modifiers with multiple symbols. ([@dvandersluis][]) +* [#13436](https://github.com/rubocop/rubocop/pull/13436): Fix incorrect offense and autocorrect for `Lint/RedundantSplatExpansion` when percent literal array is used in a safe navigation method call. ([@lovro-bikic][]) +* [#13442](https://github.com/rubocop/rubocop/pull/13442): Fix an incorrect autocorrect for `Style/NestedTernaryOperator` when ternary operators are nested and the inner condition is parenthesized. ([@koic][]) +* [#13444](https://github.com/rubocop/rubocop/pull/13444): Fix an incorrect autocorrect for `Style/OneLineConditional` when the else branch of a ternary operator has multiple expressions. ([@koic][]) +* [#13483](https://github.com/rubocop/rubocop/issues/13483): Fix an incorrect autocorrect for `Style/RedundantRegexpArgument` when using escaped double quote character. ([@koic][]) +* [#13497](https://github.com/rubocop/rubocop/pull/13497): Fix infinite loop error for `Style/IfWithSemicolon` when using nested if/;/end in if body. ([@koic][]) +* [#13477](https://github.com/rubocop/rubocop/issues/13477): Update `Layout/LeadingCommentSpace` to accept multiline shebangs at the top of the file. ([@dvandersluis][]) +* [#13453](https://github.com/rubocop/rubocop/issues/13453): Update `Style/AccessModifierDeclarations` to handle `attr_*` methods with multiple parameters. ([@dvandersluis][]) +* [#12597](https://github.com/rubocop/rubocop/issues/12597): Update `Style/SingleLineDoEndBlock` to not register an offense if it will introduce a conflicting `Layout/RedundantLineBreak` offense. ([@dvandersluis][]) + +### Changes + +* [#11680](https://github.com/rubocop/rubocop/issues/11680): Add autocorrection for strings to `Layout/LineLength` when `SplitStrings` is set to `true`. ([@dvandersluis][]) +* [#13470](https://github.com/rubocop/rubocop/pull/13470): Make `Style/ArrayIntersect` aware of `none?`. ([@earlopain][]) +* [#13481](https://github.com/rubocop/rubocop/pull/13481): Support unicode-display_width v3. ([@gemmaro][]) +* [#13473](https://github.com/rubocop/rubocop/pull/13473): Update `Lint/ItWithoutArgumentsInBlock` to not register offenses in Ruby 3.4. ([@dvandersluis][]) +* [#13420](https://github.com/rubocop/rubocop/pull/13420): Update `Lint/RedundantSafeNavigation` to register an offense when the receiver is `self`. ([@dvandersluis][]) +* [#11393](https://github.com/rubocop/rubocop/issues/11393): Update `Lint/UnusedMethodArgument` to allow the class names for `IgnoreNotImplementedMethods` to be configured. ([@dvandersluis][]) +* [#13058](https://github.com/rubocop/rubocop/issues/13058): Update `Style/AccessModifierDeclarations` to accept modifier with splatted method call. ([@dvandersluis][]) + +## 1.68.0 (2024-10-31) + +### New features + +* [#13050](https://github.com/rubocop/rubocop/issues/13050): Add new `Style/BitwisePredicate` cop. ([@koic][]) +* [#12140](https://github.com/rubocop/rubocop/issues/12140): Add new `Style/CombinableDefined` cop. ([@dvandersluis][]) +* [#12988](https://github.com/rubocop/rubocop/issues/12988): Add new `Style/AmbiguousEndlessMethodDefinition` cop. ([@dvandersluis][]) +* [#11514](https://github.com/rubocop/rubocop/issues/11514): Add new `Lint/UnescapedBracketInRegexp` cop. ([@dvandersluis][]) +* [#13360](https://github.com/rubocop/rubocop/pull/13360): Add `AllowSteepAnnotation` config option to `Layout/LeadingCommentSpace`. ([@tk0miya][]) +* [#13146](https://github.com/rubocop/rubocop/issues/13146): Add new `IgnoreDuplicateElseBranch` option to `Lint/DuplicateBranch`. ([@fatkodima][]) +* [#13171](https://github.com/rubocop/rubocop/issues/13171): Add new `Style/SafeNavigationChainLength` cop. ([@fatkodima][]) +* [#13252](https://github.com/rubocop/rubocop/pull/13252): Add new `Style/KeywordArgumentsMerging` cop. ([@fatkodima][]) + +### Bug fixes + +* [#13401](https://github.com/rubocop/rubocop/pull/13401): Fix a false negative for `Style/RedundantLineContinuation` when there is a line continuation at the EOF. ([@koic][]) +* [#13368](https://github.com/rubocop/rubocop/issues/13368): Fix an incorrect autocorrect for `Naming/BlockForwarding` with `Style/ExplicitBlockArgument`. ([@koic][]) +* [#13391](https://github.com/rubocop/rubocop/pull/13391): Fix deserialization of unknown encoding offenses. ([@earlopain][]) +* [#13348](https://github.com/rubocop/rubocop/issues/13348): Ensure `Style/BlockDelimiters` autocorrection does not move other code between the block and comment. ([@dvandersluis][]) +* [#13382](https://github.com/rubocop/rubocop/pull/13382): Fix an error during error handling for custom ruby extractors when the extractor is a class. ([@earlopain][]) +* [#13309](https://github.com/rubocop/rubocop/issues/13309): Fix a false negative for `Lint/UselessAssignment` cop when there is a useless assignment followed by a block. ([@pCosta99][]) +* [#13255](https://github.com/rubocop/rubocop/pull/13255): Fix false negatives for `Style/MapIntoArray` when using non-splatted arguments. ([@vlad-pisanov][]) +* [#13356](https://github.com/rubocop/rubocop/issues/13356): Fix a false positive for `Layout/SpaceBeforeBrackets` when there is a dot before `[]=`. ([@earlopain][]) +* [#13365](https://github.com/rubocop/rubocop/issues/13365): Fix false positives for `Lint/SafeNavigationConsistency` when using safe navigation on the LHS with operator method on the RHS of `&&`. ([@koic][]) +* [#13390](https://github.com/rubocop/rubocop/issues/13390): Fix false positives for `Style/GuardClause` when using a local variable assigned in a conditional expression in a branch. ([@koic][]) +* [#13337](https://github.com/rubocop/rubocop/issues/13337): Fix false positives for `Style/RedundantLineContinuation` when required line continuations for `&&` is used with an assignment after a line break. ([@koic][]) +* [#13387](https://github.com/rubocop/rubocop/issues/13387): Fix false positives in `Style/RedundantParentheses` when parentheses are used around method chain with `do`...`end` block in keyword argument. ([@koic][]) +* [#13341](https://github.com/rubocop/rubocop/issues/13341): Fix false positives for `Lint/SafeNavigationChain` when a safe navigation operator is used with a method call as the RHS operand of `&&` for the same receiver. ([@koic][]) +* [#13324](https://github.com/rubocop/rubocop/issues/13324): Fix `--disable-uncorrectable` to not insert a comment inside a string continuation. ([@dvandersluis][]) +* [#13364](https://github.com/rubocop/rubocop/issues/13364): Fix incorrect autocorrect with `Lint/UselessAssignment` a multiple assignment or `for` contains an inner assignment. ([@dvandersluis][]) +* [#13353](https://github.com/rubocop/rubocop/issues/13353): Fix an incorrect autocorrect for `Style/BlockDelimiters` when `EnforcedStyle: semantic` is set and used with `Layout/SpaceInsideBlockBraces`. ([@koic][]) +* [#13361](https://github.com/rubocop/rubocop/issues/13361): Fix false positives for `Style/RedundantInterpolationUnfreeze` and `Style/RedundantFreeze` when strings contain interpolated global, instance, and class variables. ([@vlad-pisanov][]) +* [#13343](https://github.com/rubocop/rubocop/issues/13343): Prevent `Layout/LineLength` from breaking up a method with arguments chained onto a heredoc delimiter. ([@dvandersluis][]) +* [#13374](https://github.com/rubocop/rubocop/issues/13374): Return exit code 0 with `--display-only-correctable` and `--display-only-safe-correctable` when no offenses are displayed. ([@dvandersluis][]) +* [#13193](https://github.com/rubocop/rubocop/issues/13193): Fix false positive in `Style/MultipleComparison` when `ComparisonsThreshold` exceeds 2. ([@fatkodima][], [@vlad-pisanov][]) +* [#13325](https://github.com/rubocop/rubocop/pull/13325): Fix an incorrect autocorrect for `Lint/NonAtomicFileOperation` when using a postfix `unless` for file existence checks before creating a file, in cases with `Dir.mkdir`. ([@kotaro0522][]) +* [#13397](https://github.com/rubocop/rubocop/pull/13397): Update `PercentLiteralCorrector` to be able to write pairs of delimiters without excessive escaping. ([@dvandersluis][]) +* [#13336](https://github.com/rubocop/rubocop/issues/13336): Update `Style/SafeNavigation` to not autocorrect if the RHS of an `and` node is an `or` node. ([@dvandersluis][]) +* [#13378](https://github.com/rubocop/rubocop/issues/13378): When removing parens in `Style/TernaryParentheses` with a `send` node condition, ensure its arguments are parenthesized. ([@dvandersluis][]) + +### Changes + +* [#13347](https://github.com/rubocop/rubocop/pull/13347): When running `rubocop -V`, show the analysis Ruby version of the current directory. ([@earlopain][]) + +## 1.67.0 (2024-10-15) + +### New features + +* [#13259](https://github.com/rubocop/rubocop/issues/13259): Add new `Lint/DuplicateSetElement` cop. ([@koic][]) +* [#13223](https://github.com/rubocop/rubocop/pull/13223): Add `AllowRBSInlineAnnotation` config option to `Layout/LeadingCommentSpace` to support RBS::Inline style annotation comments. ([@tk0miya][]) +* [#13310](https://github.com/rubocop/rubocop/issues/13310): Display analysis Ruby version in `rubocop -V`. ([@koic][]) + +### Bug fixes + +* [#13314](https://github.com/rubocop/rubocop/pull/13314): Fix a false negative for `Style/Semicolon` when using a semicolon between a closing parenthesis after a line break and a consequent expression. ([@koic][]) +* [#13217](https://github.com/rubocop/rubocop/pull/13217): Fix a false positive in `Lint/ParenthesesAsGroupedExpression` with compound ranges. ([@gsamokovarov][]) +* [#13268](https://github.com/rubocop/rubocop/pull/13268): Fix a false positive for `Style/BlockDelimiters` when a single line do-end block with an inline `rescue` with a semicolon before `rescue`. ([@koic][]) +* [#13298](https://github.com/rubocop/rubocop/pull/13298): Fix an error for `Layout/AccessModifierIndentation` when the access modifier is on the same line as the class definition. ([@koic][]) +* [#13198](https://github.com/rubocop/rubocop/pull/13198): Fix an error for `Style/OneLineConditional` when using nested if/then/else/end. ([@koic][]) +* [#13316](https://github.com/rubocop/rubocop/issues/13316): Fix an incorrect autocorrect for `Lint/ImplicitStringConcatenation` with `Lint/TripleQuotes` when string literals with triple quotes are used. ([@koic][]) +* [#13220](https://github.com/rubocop/rubocop/issues/13220): Fix an incorrect autocorrect for `Style/ArgumentsForwarding` when using only forwarded arguments in brackets. ([@koic][]) +* [#13202](https://github.com/rubocop/rubocop/issues/13202): Fix an incorrect autocorrect for `Style/CombinableLoops` when looping over the same data with different block variable names. ([@koic][]) +* [#13291](https://github.com/rubocop/rubocop/issues/13291): Fix an incorrect autocorrect for `Style/RescueModifier` when using modifier rescue for method call with heredoc argument. ([@koic][]) +* [#13226](https://github.com/rubocop/rubocop/pull/13226): Fix `--auto-gen-config` when passing an absolute config path. ([@earlopain][]) +* [#13225](https://github.com/rubocop/rubocop/issues/13225): Avoid syntax error when correcting `Style/OperatorMethodCall` with `/` operations followed by a parenthesized argument. ([@dvandersluis][]) +* [#13235](https://github.com/rubocop/rubocop/issues/13235): Fix an error for `Style/IfUnlessModifier` when multiline `if` that fits on one line and using implicit method call with hash value omission syntax. ([@koic][]) +* [#13219](https://github.com/rubocop/rubocop/pull/13219): Fix a false positive for `Style/ArgumentsForwarding` with Ruby 3.0 and optional position arguments. ([@earlopain][]) +* [#13271](https://github.com/rubocop/rubocop/issues/13271): Fix a false positive for `Lint/AmbiguousRange` when using rational literals. ([@koic][]) +* [#13260](https://github.com/rubocop/rubocop/issues/13260): Fix a false positive for `Lint/RedundantSafeNavigation` with namespaced constants. ([@earlopain][]) +* [#13224](https://github.com/rubocop/rubocop/pull/13224): Fix false positives for `Style/OperatorMethodCall` with named forwarding. ([@earlopain][]) +* [#13213](https://github.com/rubocop/rubocop/issues/13213): Fix false positives for `Style/AccessModifierDeclarations` when `AllowModifiersOnAttrs: true` and using splat with a percent symbol array, or with a constant. ([@koic][]) +* [#13145](https://github.com/rubocop/rubocop/issues/13145): Fix false positives for `Style/RedundantLineContinuation` when line continuations with comparison operator and the LHS is wrapped in parentheses. ([@koic][]) +* [#12875](https://github.com/rubocop/rubocop/issues/12875): Fix false positive for `Style/ArgumentsForwarding` when argument is used inside a block. ([@dvandersluis][]) +* [#13239](https://github.com/rubocop/rubocop/pull/13239): Fix false positive for `Style/CollectionCompact` when using `delete_if`. ([@masato-bkn][]) +* [#13210](https://github.com/rubocop/rubocop/pull/13210): Fix omit_parentheses style for pattern match with value omission in single-line branch. ([@gsamokovarov][]) +* [#13149](https://github.com/rubocop/rubocop/issues/13149): Handle crashes in custom Ruby extractors more gracefully. ([@earlopain][]) +* [#13319](https://github.com/rubocop/rubocop/issues/13319): Handle literal forward slashes inside a `regexp` in `Lint/LiteralInInterpolation`. ([@dvandersluis][]) +* [#13208](https://github.com/rubocop/rubocop/pull/13208): Fix an incorrect autocorrect for `Style/IfWithSemicolon` when single-line `if/;/end` when the then body contains a method call with `[]` or `[]=`. ([@koic][]) +* [#13318](https://github.com/rubocop/rubocop/issues/13318): Prevent modifying blocks with `Style/HashEachMethods` if the hash is modified within the block. ([@dvandersluis][]) +* [#13293](https://github.com/rubocop/rubocop/pull/13293): Fix `TargetRubyVersion` from a gemspec when the gemspec is not named like the folder it is located in. ([@earlopain][]) +* [#13211](https://github.com/rubocop/rubocop/pull/13211): Fix wrong autocorrect for `Style/GuardClause` when using heredoc without `else` branch. ([@earlopain][]) +* [#13215](https://github.com/rubocop/rubocop/pull/13215): Fix wrong autocorrect for `Lint/BigDecimalNew` when using `::BigDecimal.new`. ([@earlopain][]) +* [#13215](https://github.com/rubocop/rubocop/pull/13215): Fix wrong autocorrect for `Style/MethodCallWithArgsParentheses` with `EnforcedStyle: omit_parentheses` and whitespace. ([@earlopain][]) +* [#13302](https://github.com/rubocop/rubocop/issues/13302): Fix incompatible autocorrect between `Style/RedundantBegin` and `Style/BlockDelimiters` with `EnforcedStyle: braces_for_chaining`. ([@earlopain][]) + +### Changes + +* [#13221](https://github.com/rubocop/rubocop/pull/13221): Do not group accessors having RBS::Inline annotation comments in `Style/AccessorGrouping`. ([@tk0miya][]) +* [#13286](https://github.com/rubocop/rubocop/issues/13286): Add `AllowedMethods` configuration to `Layout/FirstMethodArgumentLineBreak`. ([@dvandersluis][]) +* [#13110](https://github.com/rubocop/rubocop/issues/13110): Add support in `Style/ArgumentsForwarding` for detecting forwarding of all anonymous arguments. ([@dvandersluis][]) +* [#13222](https://github.com/rubocop/rubocop/pull/13222): Allow to write RBS::Inline annotation comments after method definition in `Style/CommentedKeyword`. ([@tk0miya][]) +* [#13253](https://github.com/rubocop/rubocop/pull/13253): Emit a deprecation when custom cops inherit from `RuboCop::Cop::Cop`. ([@earlopain][]) +* [#13300](https://github.com/rubocop/rubocop/pull/13300): Set `EnforcedShorthandSyntax: either` by default for `Style/HashSyntax`. ([@koic][]) +* [#13254](https://github.com/rubocop/rubocop/pull/13254): Enhance the autocorrect for `Naming/InclusiveLanguage` when a sole suggestion is set. ([@koic][]) +* [#13232](https://github.com/rubocop/rubocop/issues/13232): Make server mode aware of auto-restart for local config update. ([@koic][]) +* [#13270](https://github.com/rubocop/rubocop/pull/13270): Make `Style/SelectByRegexp` aware of `filter` in Ruby version 2.6 or above. ([@masato-bkn][]) +* [#9816](https://github.com/rubocop/rubocop/issues/9816): Refine `Lint/SafeNavigationConsistency` cop to check that the safe navigation operator is applied consistently and without excess or deficiency. ([@koic][]) +* [#13256](https://github.com/rubocop/rubocop/issues/13256): Report and correct more `Style/SafeNavigation` offenses. ([@dvandersluis][]) +* [#13245](https://github.com/rubocop/rubocop/pull/13245): Support `filter/filter!` in `Style/CollectionCompact`. ([@masato-bkn][]) +* [#13281](https://github.com/rubocop/rubocop/pull/13281): Support Ruby 3.4 for `Lint/UriRegexp` to avoid obsolete API. ([@koic][]) +* [#13229](https://github.com/rubocop/rubocop/issues/13229): Update `Style/MapIntoArray` to be able to handle arrays created using `[].tap`. ([@dvandersluis][]) +* [#13305](https://github.com/rubocop/rubocop/pull/13305): Update `Style/ReturnNilInPredicateMethodDefinition` to detect implicit `nil` returns inside `if`. ([@dvandersluis][]) +* [#13327](https://github.com/rubocop/rubocop/pull/13327): Make server mode aware of auto-restart for .rubocop_todo.yml update. ([@koic][]) + +## 1.66.1 (2024-09-04) + +### Bug fixes + +* [#13191](https://github.com/rubocop/rubocop/pull/13191): Fix an error for `Style/IfWithSemicolon` when using nested single-line if/;/end in block of if/else branches. ([@koic][]) +* [#13178](https://github.com/rubocop/rubocop/pull/13178): Fix false positive for `Style/EmptyLiteral` with `Hash.new([])`. ([@earlopain][]) +* [#13176](https://github.com/rubocop/rubocop/issues/13176): Fix crash in `Style/EmptyElse` when `AllowComments: true` and the else clause is missing. ([@vlad-pisanov][]) +* [#13185](https://github.com/rubocop/rubocop/pull/13185): Fix false negatives in `Style/MapIntoArray` autocorrection when using `ensure`, `def`, `defs` and `for`. ([@vlad-pisanov][]) + +## 1.66.0 (2024-08-31) + +### New features + +* [#13077](https://github.com/rubocop/rubocop/pull/13077): Add new global `StringLiteralsFrozenByDefault` option for correct analysis with `RUBYOPT=--enable=frozen-string-literal`. ([@earlopain][]) +* [#13080](https://github.com/rubocop/rubocop/pull/13080): Add new `DocumentationExtension` global option to serve documentation with extensions different than `.html`. ([@earlopain][]) +* [#13074](https://github.com/rubocop/rubocop/issues/13074): Add new `Lint/UselessNumericOperation` cop to check for inconsequential numeric operations. ([@zopolis4][]) +* [#13061](https://github.com/rubocop/rubocop/issues/13061): Add new `Style/RedundantInterpolationUnfreeze` cop to check for `dup` and `@+` on interpolated strings in Ruby >= 3.0. ([@earlopain][]) + +### Bug fixes + +* [#13093](https://github.com/rubocop/rubocop/issues/13093): Fix an error for `Lint/ImplicitStringConcatenation` when implicitly concatenating a string literal with a line break and string interpolation. ([@koic][]) +* [#13098](https://github.com/rubocop/rubocop/issues/13098): Fix an error for `Style/IdenticalConditionalBranches` when handling empty case branches. ([@koic][]) +* [#13113](https://github.com/rubocop/rubocop/pull/13113): Fix an error for `Style/IfWithSemicolon` when a nested `if` with a semicolon is used. ([@koic][]) +* [#13097](https://github.com/rubocop/rubocop/issues/13097): Fix an error for `Style/InPatternThen` when using alternative pattern matching deeply. ([@koic][]) +* [#13159](https://github.com/rubocop/rubocop/pull/13159): Fix an error for `Style/OneLineConditional` when using if/then/else/end with multiple expressions in the `then` body. ([@koic][]) +* [#13092](https://github.com/rubocop/rubocop/pull/13092): Fix an incorrect autocorrect for `Layout/EmptyLineBetweenDefs` when two method definitions are on the same line separated by a semicolon. ([@koic][]) +* [#13116](https://github.com/rubocop/rubocop/pull/13116): Fix an incorrect autocorrect for `Style/IfWithSemicolon` when a single-line `if/;/end` has an argument in the then body expression. ([@koic][]) +* [#13161](https://github.com/rubocop/rubocop/pull/13161): Fix incorrect autocorrect for `Style/IfWithSemicolon` when using multiple expressions in the `else` body. ([@koic][]) +* [#13132](https://github.com/rubocop/rubocop/pull/13132): Fix incorrect autocorrect for `Style/TrailingBodyOnMethodDefinition` when an expression precedes a method definition on the same line with a semicolon. ([@koic][]) +* [#13164](https://github.com/rubocop/rubocop/pull/13164): Fix incorrect autocorrect behavior for `Layout/BlockAlignment` when `EnforcedStyleAlignWith: either (default)`. ([@koic][]) +* [#13087](https://github.com/rubocop/rubocop/pull/13087): Fix an incorrect autocorrect for `Style/MultipleComparison` when expression with more comparisons precedes an expression with less comparisons. ([@fatkodima][]) +* [#13172](https://github.com/rubocop/rubocop/pull/13172): Fix an error for `Layout/EmptyLinesAroundExceptionHandlingKeywords` when `ensure` or `else` and `end` are on the same line. ([@koic][]) +* [#13107](https://github.com/rubocop/rubocop/issues/13107): Fix an error for `Lint/ImplicitStringConcatenation` when there are multiple adjacent string interpolation literals on the same line. ([@koic][]) +* [#13111](https://github.com/rubocop/rubocop/pull/13111): Fix an error for `Style/GuardClause` when if clause is empty and correction would not fit on single line because of `Layout/LineLength`. ([@earlopain][]) +* [#13137](https://github.com/rubocop/rubocop/pull/13137): Fix an error for `Style/ParallelAssignment` when using `__FILE__`. ([@earlopain][]) +* [#13143](https://github.com/rubocop/rubocop/pull/13143): Fix an error during `TargetRubyVersion` detection if the gemspec is not valid syntax. ([@earlopain][]) +* [#13131](https://github.com/rubocop/rubocop/pull/13131): Fix false negatives for `Lint/Void` when using `ensure`, `defs` and `numblock`. ([@vlad-pisanov][]) +* [#13174](https://github.com/rubocop/rubocop/pull/13174): Fix false negatives for `Style/MapIntoArray` when initializing the destination using `Array[]`, `Array([])`, or `Array.new([])`. ([@vlad-pisanov][]) +* [#13173](https://github.com/rubocop/rubocop/pull/13173): Fix false negatives for `Style/EmptyLiteral` when using `Array[]`, `Hash[]`, `Array.new([])` and `Hash.new([])`. ([@vlad-pisanov][]) +* [#13126](https://github.com/rubocop/rubocop/issues/13126): Fix a false positive for `Style/Alias` when using multiple `alias` in `def`. ([@koic][]) +* [#13085](https://github.com/rubocop/rubocop/issues/13085): Fix a false positive for `Style/EmptyElse` when a comment-only `else` is used after `elsif` and `AllowComments: true` is set. ([@koic][]) +* [#13118](https://github.com/rubocop/rubocop/issues/13118): Fix a false positive for `Style/MapIntoArray` when splatting. ([@earlopain][]) +* [#13105](https://github.com/rubocop/rubocop/issues/13105): Fix false positives for `Style/ArgumentsForwarding` when forwarding kwargs/block arg with non-matching additional args. ([@koic][]) +* [#13139](https://github.com/rubocop/rubocop/issues/13139): Fix false positives for `Style/RedundantCondition` when using modifier `if` or `unless`. ([@koic][]) +* [#13134](https://github.com/rubocop/rubocop/pull/13134): Fix false negative for `Lint/Void` when using using frozen literals. ([@vlad-pisanov][]) +* [#13148](https://github.com/rubocop/rubocop/pull/13148): Fix incorrect autocorrect for `Lint/EmptyConditionalBody` when missing `elsif` body with `end` on the same line. ([@koic][]) +* [#13109](https://github.com/rubocop/rubocop/pull/13109): Fix an error for the `Lockfile` parser when it contains incompatible `BUNDLED WITH` versions. ([@earlopain][]) +* [#13112](https://github.com/rubocop/rubocop/pull/13112): Fix detection of `TargetRubyVersion` through the gemfile if the gemfile ruby version is below 2.7. ([@earlopain][]) +* [#13155](https://github.com/rubocop/rubocop/pull/13155): Fixes an error when the server cache directory has too long path, causing rubocop to fail even with caching disabled. ([@protocol7][]) + +### Changes + +* [#13150](https://github.com/rubocop/rubocop/issues/13150): Allow `get_!`, `set_!`, `get_?`, `set_?`, `get_=`, and `set_=` in `Naming/AccessorMethodName`. ([@koic][]) +* [#13103](https://github.com/rubocop/rubocop/issues/13103): Make `Lint/UselessAssignment` autocorrection safe. ([@koic][]) +* [#13099](https://github.com/rubocop/rubocop/issues/13099): Make `Style/RedundantRegexpArgument` respect the `EnforcedStyle` of `Style/StringLiterals`. ([@koic][]) +* [#13165](https://github.com/rubocop/rubocop/pull/13165): Remove dependency on the `rexml` gem. ([@bquorning][]) +* [#13090](https://github.com/rubocop/rubocop/pull/13090): Require RuboCop AST 1.32.0+ to use `RuboCop::AST::RationalNode`. ([@koic][]) + +## 1.65.1 (2024-08-01) + +### New features + +* [#13068](https://github.com/rubocop/rubocop/pull/13068): Add config validation to `Naming/PredicateName` to check that all `ForbiddenPrefixes` are being checked. ([@maxjacobson][]) + +### Bug fixes + +* [#13051](https://github.com/rubocop/rubocop/issues/13051): Fix an error for `Lint/FloatComparison` when comparing with rational literal. ([@koic][]) +* [#13065](https://github.com/rubocop/rubocop/issues/13065): Fix an error for `Lint/UselessAssignment` when same name variables are assigned using chained assignment. ([@koic][]) +* [#13062](https://github.com/rubocop/rubocop/pull/13062): Fix an error for `Style/InvertibleUnlessCondition` when using empty parenthesis as condition. ([@earlopain][]) +* [#11438](https://github.com/rubocop/rubocop/issues/11438): Explicitly load `fileutils` before calculating `before_us`. ([@r7kamura][]) +* [#13044](https://github.com/rubocop/rubocop/issues/13044): Fix false negatives for `Lint/ImplicitStringConcatenation` when using adjacent string interpolation literals on the same line. ([@koic][]) +* [#13083](https://github.com/rubocop/rubocop/pull/13083): Fix a false positive for `Style/GlobalStdStream` when using namespaced constants like `Foo::STDOUT`. ([@earlopain][]) +* [#13081](https://github.com/rubocop/rubocop/pull/13081): Fix a false positive for `Style/ZeroLengthPredicate` when using safe navigation and non-zero comparison. ([@fatkodima][]) +* [#13041](https://github.com/rubocop/rubocop/issues/13041): Fix false positives for `Lint/UselessAssignment` when pattern match variable is assigned and used in a block. ([@koic][]) +* [#13076](https://github.com/rubocop/rubocop/issues/13076): Fix an incorrect autocorrect for `Naming/RescuedExceptionsVariableName` when using hash value omission. ([@koic][]) + +## 1.65.0 (2024-07-10) + +### New features + +* [#13030](https://github.com/rubocop/rubocop/pull/13030): Add new `Gemspec/AddRuntimeDependency` cop. ([@koic][]) + +### Bug fixes + +* [#12954](https://github.com/rubocop/rubocop/issues/12954): Fix a false negative for `Style/ArgumentsForwarding` when arguments forwarding in `yield`. ([@koic][]) +* [#13033](https://github.com/rubocop/rubocop/issues/13033): Fix a false positive for `Layout/SpaceAroundOperators` when using multiple spaces between an operator and a tailing comment. ([@koic][]) +* [#12885](https://github.com/rubocop/rubocop/issues/12885): Fix a false positive for `Lint/ToEnumArguments` when enumerator is created for another method. ([@koic][]) +* [#13018](https://github.com/rubocop/rubocop/issues/13018): Fix a false positive for `Style/MethodCallWithArgsParentheses` when `EnforcedStyle: omit_parentheses` is set and parenthesized method call is used before constant resolution. ([@koic][]) +* [#12986](https://github.com/rubocop/rubocop/issues/12986): Fix a false positive for `Style/RedundantBegin` when endless method definition with `rescue`. ([@koic][]) +* [#12985](https://github.com/rubocop/rubocop/issues/12985): Fix an error for `Style/RedundantRegexpCharacterClass` when using regexp_parser gem 2.3.1 or older. ([@koic][]) +* [#13010](https://github.com/rubocop/rubocop/issues/13010): Fix an error for `Style/SuperArguments` when the hash argument is or-assigned. ([@koic][]) +* [#13023](https://github.com/rubocop/rubocop/issues/13023): Fix an error for `Style/SymbolProc` when using lambda `->` with one argument and multiline `do`...`end` block. ([@koic][]) +* [#12989](https://github.com/rubocop/rubocop/issues/12989): Fix an error for the `inherit_gem` config when the Gemfile contains an uninstalled git gem. ([@earlopain][]) +* [#12975](https://github.com/rubocop/rubocop/issues/12975): Fix an error for the `inherit_gem` config when running RuboCop without bundler and no Gemfile exists. ([@earlopain][]) +* [#12997](https://github.com/rubocop/rubocop/pull/12997): Fix an error for `Lint/UnmodifiedReduceAccumulator` when the block is empty. ([@earlopain][]) +* [#12979](https://github.com/rubocop/rubocop/issues/12979): Fix false negatives for `Lint/Void` when void expression with guard clause is not on last line. ([@koic][]) +* [#12716](https://github.com/rubocop/rubocop/issues/12716): Fix false negatives for `Lint/Void` when using parenthesized void operators. ([@koic][]) +* [#12471](https://github.com/rubocop/rubocop/issues/12471): Fix false negatives for `Style/ZeroLengthPredicate` when using safe navigation operator. ([@koic][]) +* [#12960](https://github.com/rubocop/rubocop/issues/12960): Fix false positives for `Lint/NestedMethodDefinition` when definition of method on variable. ([@koic][]) +* [#13012](https://github.com/rubocop/rubocop/issues/13012): Fix false positives for `Style/HashExcept` when using `reject` and calling `include?` method with bang. ([@koic][]) +* [#12983](https://github.com/rubocop/rubocop/issues/12983): Fix false positives for `Style/SendWithLiteralMethodName` using `send` with writer method name. ([@koic][]) +* [#12957](https://github.com/rubocop/rubocop/issues/12957): Fix false positives for `Style/SuperArguments` when calling super in a block. ([@koic][]) + +### Changes + +* [#12970](https://github.com/rubocop/rubocop/issues/12970): Add `CountModifierForms` option to `Metrics/BlockNesting` and set it to `false` by default. ([@koic][]) +* [#13032](https://github.com/rubocop/rubocop/pull/13032): Display warning messages for deprecated APIs. ([@koic][]) +* [#13031](https://github.com/rubocop/rubocop/pull/13031): Enable YJIT by default in server mode. ([@koic][]) +* [#12557](https://github.com/rubocop/rubocop/issues/12557): Make server mode aware of auto-restart for `bundle update`. ([@koic][]) +* [#12616](https://github.com/rubocop/rubocop/issues/12616): Make `Style/MapCompactWithConditionalBlock` aware of `filter_map`. ([@koic][]) +* [#13035](https://github.com/rubocop/rubocop/issues/13035): Support autocorrect for `Lint/ImplicitStringConcatenation`. ([@koic][]) + +## 1.64.1 (2024-05-31) + +### Bug fixes + +* [#12951](https://github.com/rubocop/rubocop/pull/12951): Fix an error for `Style/Copyright` when `AutocorrectNotice` is missing. ([@koic][]) +* [#12932](https://github.com/rubocop/rubocop/pull/12932): Fix end position of diagnostic for LSP. ([@ksss][]) +* [#12926](https://github.com/rubocop/rubocop/issues/12926): Fix a false positive for `Style/SuperArguments` when the methods block argument is reassigned before `super`. ([@earlopain][]) +* [#12931](https://github.com/rubocop/rubocop/issues/12931): Fix false positives for `Style/RedundantLineContinuation` when line continuations involve `break`, `next`, or `yield` with a return value. ([@koic][]) +* [#12924](https://github.com/rubocop/rubocop/issues/12924): Fix false positives for `Style/SendWithLiteralMethodName` when `public_send` argument is a method name that cannot be autocorrected. ([@koic][]) + +## 1.64.0 (2024-05-23) + +### New features + +* [#12904](https://github.com/rubocop/rubocop/pull/12904): Add new `either_consistent` `SupportedShorthandSyntax` to `Style/HashSyntax`. ([@pawelma][]) +* [#12842](https://github.com/rubocop/rubocop/issues/12842): Add new `Style/SendWithLiteralMethodName` cop. ([@koic][]) +* [#12309](https://github.com/rubocop/rubocop/issues/12309): Add new `Style/SuperArguments` cop. ([@earlopain][]) +* [#12917](https://github.com/rubocop/rubocop/pull/12917): Suggest correct formatter name for `--format` command line option. ([@koic][]) +* [#12242](https://github.com/rubocop/rubocop/issues/12242): Support `AllowModifiersOnAttrs` option for `Style/AccessModifierDeclarations`. ([@krororo][]) +* [#11585](https://github.com/rubocop/rubocop/issues/11585): Support `AllowedMethods` for `Style/DocumentationMethod`. ([@koic][]) + +### Bug fixes + +* [#7189](https://github.com/rubocop/rubocop/issues/7189): Fix a false positive for `Style/Copyright` when using multiline copyright notice. ([@koic][]) +* [#12914](https://github.com/rubocop/rubocop/pull/12914): Fix a false negative for `Layout/EmptyComment` when using an empty comment next to code after comment line. ([@koic][]) +* [#12919](https://github.com/rubocop/rubocop/issues/12919): Fix false negatives for `Style/ArgumentsForwarding` when forward target is `super`. ([@koic][]) +* [#12923](https://github.com/rubocop/rubocop/pull/12923): Fix false negatives for `Style/ArgumentsForwarding` when forward target is safe navigation method. ([@koic][]) +* [#12894](https://github.com/rubocop/rubocop/issues/12894): Fix false positives for `Style/MapIntoArray` when using `each` without receiver with `<<` to build an array. ([@koic][]) +* [#12876](https://github.com/rubocop/rubocop/issues/12876): Fix an error for the lockfile parser if a gemfile exists but a lockfile doesn't. ([@earlopain][]) +* [#12888](https://github.com/rubocop/rubocop/issues/12888): Fix `--no-exclude-limit` generating a todo with `Max` config instead of listing everything out with `Exclude`. ([@earlopain][]) +* [#12898](https://github.com/rubocop/rubocop/issues/12898): Fix an error for `TargetRailsVersion` when parsing from the lockfile with prerelease rails. ([@earlopain][]) + +### Changes + +* [#12908](https://github.com/rubocop/rubocop/pull/12908): Add rubocop-rspec back to suggested extensions when rspec-rails is in use. ([@pirj][]) +* [#12884](https://github.com/rubocop/rubocop/issues/12884): Align output from `cop.documentation_url` with `--show-docs-url` when passing a config as argument. ([@earlopain][]) +* [#12905](https://github.com/rubocop/rubocop/pull/12905): Support `ActiveSupportExtensionsEnabled` for `Style/SymbolProc`. ([@koic][]) +* [#12897](https://github.com/rubocop/rubocop/pull/12897): Respect user's intentions with `workspace/executeCommand` LSP method. ([@koic][]) + +## 1.63.5 (2024-05-09) + +### Bug fixes + +* [#12877](https://github.com/rubocop/rubocop/pull/12877): Fix an infinite loop error for `Layout/FirstArgumentIndentation` when specifying `EnforcedStyle: with_fixed_indentation` of `Layout/ArrayAlignment`. ([@koic][]) +* [#12873](https://github.com/rubocop/rubocop/issues/12873): Fix an error for `Metrics/BlockLength` when the `CountAsOne` config is invalid. ([@koic][]) +* [#12881](https://github.com/rubocop/rubocop/pull/12881): Fix incorrect autocorrect when `Style/NumericPredicate` is used with negations. ([@fatkodima][]) +* [#12882](https://github.com/rubocop/rubocop/pull/12882): Fix `Layout/CommentIndentation` for comment-only pattern matching. ([@nekketsuuu][]) + +## 1.63.4 (2024-04-28) + +### Bug fixes + +* [#12871](https://github.com/rubocop/rubocop/pull/12871): Fix an error for `rubocop -V` when `.rubocop.yml` contains ERB. ([@earlopain][]) +* [#12862](https://github.com/rubocop/rubocop/issues/12862): Fix a false positive for `Style/RedundantLineContinuation` when line continuations involve `return` with a return value. ([@koic][]) +* [#12664](https://github.com/rubocop/rubocop/pull/12664): Fix handling of `textDocument/diagnostic`. ([@muxcmux][]) +* [#12865](https://github.com/rubocop/rubocop/issues/12865): Fix Rails Cops, which weren't reporting any violations unless running with `bundle exec`. ([@amomchilov][]) + +## 1.63.3 (2024-04-22) + +### Bug fixes + +* [#12857](https://github.com/rubocop/rubocop/pull/12857): Fix false negatives for `Lint/UnreachableCode` when using pattern matching. ([@koic][]) +* [#12852](https://github.com/rubocop/rubocop/issues/12852): Fix an error for `Lint/EmptyFile` in formatters when using cache. ([@earlopain][]) +* [#12848](https://github.com/rubocop/rubocop/issues/12848): Fix an error that occurs in `RuboCop::Lockfile` when the constant Bundler is uninitialized. ([@koic][]) + +### Changes + +* [#12855](https://github.com/rubocop/rubocop/pull/12855): Set custom program name for the built-in LSP server. ([@koic][]) + +## 1.63.2 (2024-04-16) + +### Bug fixes + +* [#12843](https://github.com/rubocop/rubocop/issues/12843): Fix an error for `Lint/MixedCaseRange` when a character between `Z` and `a` is used in the regexp range. ([@koic][]) +* [#12846](https://github.com/rubocop/rubocop/issues/12846): Fix an error for `RuboCop::Lockfile` when there is no Bundler environment. ([@koic][]) +* [#12832](https://github.com/rubocop/rubocop/issues/12832): Fix an error for `Style/ArgumentsForwarding` when using block arg in nested method definitions. ([@koic][]) +* [#12841](https://github.com/rubocop/rubocop/pull/12841): Fix false negatives for `Lint/UnreachableLoop` when using pattern matching. ([@koic][]) +* [#12835](https://github.com/rubocop/rubocop/issues/12835): Allow global offenses to be disabled by directive comments. ([@earlopain][]) + +### Changes + +* [#12845](https://github.com/rubocop/rubocop/pull/12845): Exclude `debug/open_nonstop` from `Lint/Debugger` by default. ([@koic][]) + +## 1.63.1 (2024-04-10) + +### Bug fixes + +* [#12828](https://github.com/rubocop/rubocop/pull/12828): Fix a false positive for `Lint/AssignmentInCondition` if assigning inside a method call. ([@earlopain][]) +* [#12823](https://github.com/rubocop/rubocop/issues/12823): Fixed "uninitialized constant `RuboCop::Lockfile::Bundler`", caused when running RuboCop without `bundler exec` on codebases that use `rubocop-rails`. ([@amomchilov][]) + +## 1.63.0 (2024-04-08) + +### New features + +* [#11878](https://github.com/rubocop/rubocop/issues/11878): Add new `Style/MapIntoArray` cop. ([@ymap][]) +* [#12186](https://github.com/rubocop/rubocop/pull/12186): Add new `requires_gem` API for declaring which gems a Cop needs. ([@amomchilov][]) + +### Bug fixes + +* [#12769](https://github.com/rubocop/rubocop/issues/12769): Fix a false positive for `Lint/RedundantWithIndex` when calling `with_index` with receiver and a block. ([@koic][]) +* [#12547](https://github.com/rubocop/rubocop/issues/12547): Added a comment recommending upgrading to the latest version of Rubocop in the error text when an Infinite loop detected error occurs. ([@Hiroto-Iizuka][]) +* [#12782](https://github.com/rubocop/rubocop/pull/12782): Fix an error for `Style/Alias` with `EnforcedStyle: prefer_alias` when calling `alias_method` with fewer than 2 arguments. ([@earlopain][]) +* [#12781](https://github.com/rubocop/rubocop/pull/12781): Fix an error for `Style/ExactRegexpMatch` when calling `match` without a receiver. ([@earlopain][]) +* [#12780](https://github.com/rubocop/rubocop/issues/12780): Fix an error for `Style/RedundantEach` when using `reverse_each.each` without a block. ([@earlopain][]) +* [#12731](https://github.com/rubocop/rubocop/pull/12731): Treat `&.` the same way as `.` for setter methods in `Lint/AssignmentInCondition`. ([@jonas054][]) +* [#12793](https://github.com/rubocop/rubocop/issues/12793): Fix false positives for `Style/RedundantLineContinuation` when using line continuation with modifier. ([@koic][]) +* [#12807](https://github.com/rubocop/rubocop/issues/12807): Fix false positives for `Naming/BlockForwarding` when using explicit block forwarding in block method and others. ([@koic][]) +* [#12796](https://github.com/rubocop/rubocop/pull/12796): Fix false positives for `Style/EvalWithLocation` when using `eval` with a line number from a method call or a variable. ([@koic][]) +* [#12794](https://github.com/rubocop/rubocop/issues/12794): Fix false positives for `Style/RedundantArgument` when when single-quoted strings for cntrl character. ([@koic][]) +* [#12797](https://github.com/rubocop/rubocop/issues/12797): Fix false positives for `Style/RedundantLineContinuation` when using line continuations with `&&` or `||` operator in assignment. ([@koic][]) +* [#12793](https://github.com/rubocop/rubocop/issues/12793): Fix false positives for `Style/RedundantLineContinuation` when multi-line continuations with operators. ([@koic][]) +* [#12801](https://github.com/rubocop/rubocop/issues/12801): Fix incorrect autocorrect for `Style/CollectionCompact` when using `delete_if`. ([@koic][]) +* [#12789](https://github.com/rubocop/rubocop/pull/12789): Make `Style/RedundantPercentQ` safe on multiline strings. ([@boardfish][]) +* [#12802](https://github.com/rubocop/rubocop/pull/12802): Return global offenses for `Naming/FileName` and `Naming/InclusiveLanguage` for empty files. ([@earlopain][]) +* [#12804](https://github.com/rubocop/rubocop/pull/12804): Return global offenses for `Style/Copyright` when the file is empty. ([@earlopain][]) + +### Changes + +* [#12813](https://github.com/rubocop/rubocop/pull/12813): Add rubocop-rspec_rails to suggested extensions and extension doc. ([@ydah][]) +* [#12820](https://github.com/rubocop/rubocop/pull/12820): Add support more Capybara debugger entry points for `Lint/Debugger`. ([@ydah][]) +* [#12676](https://github.com/rubocop/rubocop/issues/12676): Adjust offending range in LSP. ([@koic][]) +* [#12815](https://github.com/rubocop/rubocop/issues/12815): Ignore `Rakefile.rb` in `Naming/FileName` in the default config. ([@artur-intech][]) +* [#12800](https://github.com/rubocop/rubocop/pull/12800): Handle empty obsoletion config. ([@sambostock][]) +* [#12721](https://github.com/rubocop/rubocop/issues/12721): Make `Lint/Debugger` aware of `ruby/debug` requires. ([@earlopain][]) +* [#12817](https://github.com/rubocop/rubocop/pull/12817): Make `rubocop -V` display rubocop-rspec_rails version when using it. ([@ydah][]) +* [#12180](https://github.com/rubocop/rubocop/pull/12180): Replace regex with `Bundler::LockfileParser`. ([@amomchilov][]) + +## 1.62.1 (2024-03-11) + +### Bug fixes + +* [#12761](https://github.com/rubocop/rubocop/issues/12761): Fix a false positive for `Style/HashEachMethods` when the key block argument of `Enumerable#each` method is unused after `chunk`. ([@koic][]) +* [#12768](https://github.com/rubocop/rubocop/pull/12768): Fix a false positive for `Style/NilComparison` without receiver and `EnforcedStyle: comparison`. ([@earlopain][]) +* [#12752](https://github.com/rubocop/rubocop/pull/12752): Fix an error for `Gemspec/RequiredRubyVersion` when the file is empty. ([@earlopain][]) +* [#12770](https://github.com/rubocop/rubocop/pull/12770): Fix an error for `Lint/RedundantWithIndex` when the method has no receiver. ([@earlopain][]) +* [#12775](https://github.com/rubocop/rubocop/pull/12775): Fix an error for `Lint/UselessTimes` when no block is present. ([@earlopain][]) +* [#12772](https://github.com/rubocop/rubocop/pull/12772): Fix an error for `Style/ClassVars` when calling `class_variable_set` without arguments. ([@earlopain][]) +* [#12773](https://github.com/rubocop/rubocop/pull/12773): Fix an error for `Style/For` with `EnforcedStyle: for` when no receiver. ([@earlopain][]) +* [#12765](https://github.com/rubocop/rubocop/pull/12765): Fix an error for `Layout/MultilineMethodCallIndentation` with safe navigation and assignment method. ([@earlopain][]) +* [#12703](https://github.com/rubocop/rubocop/issues/12703): Fix an error for `Lint/MixedCaseRange` with invalid byte sequence in UTF-8. ([@earlopain][]) +* [#12755](https://github.com/rubocop/rubocop/pull/12755): Fix an exception for `RedundantCurrentDirectoryInPath` in case of `require_relative` without arguments. ([@viralpraxis][]) +* [#12710](https://github.com/rubocop/rubocop/issues/12710): Fix a false negative for `Layout/EmptyLineAfterMagicComment` when the file is comments only. ([@earlopain][]) +* [#12758](https://github.com/rubocop/rubocop/issues/12758): Fix false positives for `Layout/RedundantLineBreak` when using `&&` or `||` after a backslash newline. ([@koic][]) +* [#12763](https://github.com/rubocop/rubocop/pull/12763): Fix an infinite loop for `Style/MultilineMethodSignature` when there is a newline directly after the def keyword. ([@earlopain][]) +* [#12774](https://github.com/rubocop/rubocop/pull/12774): Fix an infinite loop for `Style/RaiseArgs` with `EnforcedStyle: compact` when passing more than 2 arguments to `raise`. ([@earlopain][]) +* [#12663](https://github.com/rubocop/rubocop/issues/12663): Fix `Lint/Syntax` getting disabled by `rubocop:disable Lint/Syntax`. ([@earlopain][]) +* [#12756](https://github.com/rubocop/rubocop/pull/12756): Only parse target Ruby from gemspec if array elements are strings. ([@davidrunger][]) + +### Changes + +* [#12730](https://github.com/rubocop/rubocop/pull/12730): Skip `LineLength` phase on `--auto-gen-only-exclude`. ([@sambostock][]) + +## 1.62.0 (2024-03-06) + +### New features + +* [#12600](https://github.com/rubocop/rubocop/issues/12600): Support Prism as a Ruby parser (experimental). ([@koic][]) +* [#12725](https://github.com/rubocop/rubocop/pull/12725): Support `TargetRubyVersion 3.4` (experimental). ([@koic][]) + +### Bug fixes + +* [#12746](https://github.com/rubocop/rubocop/pull/12746): Fix a false positive for `Lint/ToEnumArguments` when enumerator is created for another method in no arguments method definition. ([@koic][]) +* [#12726](https://github.com/rubocop/rubocop/issues/12726): Fix a false positive for `Style/RedundantLineContinuation` when using line concatenation and calling a method with keyword arguments without parentheses. ([@koic][]) +* [#12738](https://github.com/rubocop/rubocop/issues/12738): Fix an error for `Style/Encoding` when magic encoding with mixed case present. ([@koic][]) +* [#12732](https://github.com/rubocop/rubocop/pull/12732): Fix error determining target Ruby when gemspec `required_ruby_version` is read from another file. ([@davidrunger][]) +* [#12736](https://github.com/rubocop/rubocop/issues/12736): Fix invalid autocorrect in `Layout/SpaceInsideHashLiteralBraces`. ([@bquorning][]) +* [#12667](https://github.com/rubocop/rubocop/issues/12667): Don't load excluded configuration. ([@jonas054][]) + +## 1.61.0 (2024-02-29) + +### New features + +* [#12682](https://github.com/rubocop/rubocop/issues/12682): Add `--editor-mode` CLI option. ([@koic][]) +* [#12657](https://github.com/rubocop/rubocop/pull/12657): Support `AutoCorrect: contextual` option for LSP. ([@koic][]) +* [#12273](https://github.com/rubocop/rubocop/issues/12273): Make `OffenseCountFormatter` display autocorrection information. ([@koic][]) +* [#12679](https://github.com/rubocop/rubocop/pull/12679): Publish `RuboCop::LSP.enable` API to enable LSP mode. ([@koic][]) +* [#12699](https://github.com/rubocop/rubocop/issues/12699): Support searching for `.rubocop.yml` and `rubocop/config.yml` in compliance with dot-config. ([@koic][]) + +### Bug fixes + +* [#12720](https://github.com/rubocop/rubocop/issues/12720): Fix a false positive for `Style/ArgumentsForwarding` when using block arg forwarding to within block with Ruby 3.3.0. ([@koic][]) +* [#12714](https://github.com/rubocop/rubocop/issues/12714): Fix an error for `Gemspec/RequiredRubyVersion` when `required_ruby_version` is specified with `Gem::Requirement.new` and is higher than `TargetRubyVersion`. ([@koic][]) +* [#12690](https://github.com/rubocop/rubocop/issues/12690): Fix an error for `Style/CaseLikeIf` when using `==` with literal and using ternary operator. ([@koic][]) +* [#12668](https://github.com/rubocop/rubocop/issues/12668): Fix an incorrect autocorrect for `Lint/EmptyConditionalBody` when missing `if` body with conditional `else` body. ([@koic][]) +* [#12683](https://github.com/rubocop/rubocop/issues/12683): Fix an incorrect autocorrect for `Style/MapCompactWithConditionalBlock` when using guard clause with `next` implicitly nil. ([@koic][]) +* [#12693](https://github.com/rubocop/rubocop/issues/12693): Fix an incorrect autocorrect for `Style/ObjectThen` when using `yield_self` without receiver. ([@koic][]) +* [#12646](https://github.com/rubocop/rubocop/issues/12646): Fix `--auto-gen-config` bug for `Layout/SpaceBeforeBlockBraces`. ([@jonas054][]) +* [#12717](https://github.com/rubocop/rubocop/issues/12717): Fix regexp for inline disable comments in `Style/CommentedKeyword`. ([@jonas054][]) +* [#12695](https://github.com/rubocop/rubocop/issues/12695): Fix bug in `Include` from inherited file in a parent directory. ([@jonas054][]) +* [#12656](https://github.com/rubocop/rubocop/pull/12656): Fix an error for `Layout/RedundantLineBreak` when using index access call chained on multiline hash literal. ([@koic][]) +* [#12691](https://github.com/rubocop/rubocop/issues/12691): Fix an error for `Style/MultilineTernaryOperator` when nesting multiline ternary operators. ([@koic][]) +* [#12707](https://github.com/rubocop/rubocop/pull/12707): Fix false negative for `Style/RedundantAssignment` when using pattern matching. ([@koic][]) +* [#12674](https://github.com/rubocop/rubocop/pull/12674): Fix false negatives for `Style/RedundantReturn` when using pattern matching. ([@koic][]) +* [#12673](https://github.com/rubocop/rubocop/pull/12673): Fix false negatives for `Lint/RedundantSafeNavigation` when using safe navigation operator for literal receiver. ([@koic][]) +* [#12719](https://github.com/rubocop/rubocop/pull/12719): Fix false negatives for `Style/ArgumentsForwarding` when using forwardable block arguments with Ruby 3.2+. ([@koic][]) +* [#12687](https://github.com/rubocop/rubocop/issues/12687): Fix a false positive for `Lint/Void` when `each` block with conditional expressions that has multiple statements. ([@koic][]) +* [#12649](https://github.com/rubocop/rubocop/issues/12649): Fix false positives for `Style/InverseMethods` when using relational comparison operator with safe navigation. ([@koic][]) +* [#12711](https://github.com/rubocop/rubocop/pull/12711): Handle implicit receivers in `Style/InvertibleUnlessCondition`. ([@sambostock][]) +* [#12648](https://github.com/rubocop/rubocop/pull/12648): Fix numblock regressions in `omit_parentheses` `Style/MethodCallWithArgsParentheses`. ([@gsamokovarov][]) + +### Changes + +* [#12641](https://github.com/rubocop/rubocop/pull/12641): Make error message clearer when the namespace is incorrect. ([@maruth-stripe][]) +* [#12637](https://github.com/rubocop/rubocop/pull/12637): Mark `Style/RaiseArgs` as unsafe. ([@r7kamura][]) +* [#12645](https://github.com/rubocop/rubocop/pull/12645): Change source order for target ruby to check gemspec after RuboCop configuration. ([@jenshenny][]) + +## 1.60.2 (2024-01-24) + +### Bug fixes + +* [#12627](https://github.com/rubocop/rubocop/issues/12627): Fix a false positive for `Layout/RedundantLineBreak` when using index access call chained on multiple lines with backslash. ([@koic][]) +* [#12626](https://github.com/rubocop/rubocop/pull/12626): Fix a false positive for `Style/ArgumentsForwarding` when naming a block argument `&`. ([@koic][]) +* [#12635](https://github.com/rubocop/rubocop/pull/12635): Fix a false positive for `Style/HashEachMethods` when both arguments are unused. ([@earlopain][]) +* [#12636](https://github.com/rubocop/rubocop/pull/12636): Fix an error for `Style/HashEachMethods` when a block with both parameters has no body. ([@earlopain][]) +* [#12638](https://github.com/rubocop/rubocop/issues/12638): Fix an `Errno::ENOENT` error when using server mode. ([@koic][]) +* [#12628](https://github.com/rubocop/rubocop/pull/12628): Fix a false positive for `Style/ArgumentsForwarding` when using block arg forwarding with positional arguments forwarding to within block. ([@koic][]) +* [#12642](https://github.com/rubocop/rubocop/pull/12642): Fix false positives for `Style/HashEachMethods` when using array converter method. ([@koic][]) +* [#12632](https://github.com/rubocop/rubocop/issues/12632): Fix an infinite loop error when `EnforcedStyle: explicit` of `Naming/BlockForwarding` with `Style/ArgumentsForwarding`. ([@koic][]) + +## 1.60.1 (2024-01-17) + +### Bug fixes + +* [#12625](https://github.com/rubocop/rubocop/pull/12625): Fix an error when server cache dir has read-only file system. ([@Strzesia][]) +* [#12618](https://github.com/rubocop/rubocop/issues/12618): Fix false positives for `Style/ArgumentsForwarding` when using block argument forwarding with other arguments. ([@koic][]) +* [#12614](https://github.com/rubocop/rubocop/issues/12614): Fix false positiveis for `Style/RedundantParentheses` when parentheses in control flow keyword with multiline style argument. ([@koic][]) + +### Changes + +* [#12617](https://github.com/rubocop/rubocop/issues/12617): Make `Style/CollectionCompact` aware of `grep_v` with nil. ([@koic][]) + +## 1.60.0 (2024-01-15) + +### Bug fixes + +* [#12603](https://github.com/rubocop/rubocop/issues/12603): Fix an infinite loop error for `Style/MultilineTernaryOperator` when using a method call as a ternary operator condition with a line break between receiver and method. ([@koic][]) +* [#12549](https://github.com/rubocop/rubocop/issues/12549): Fix a false positive for `Style/RedundantLineContinuation` when line continuations for multiline leading dot method chain with a blank line. ([@koic][]) +* [#12610](https://github.com/rubocop/rubocop/pull/12610): Accept parentheses in argument calls with blocks for `Style/MethodCallWithArgsParentheses` `omit_parentheses` style. ([@gsamokovarov][]) +* [#12580](https://github.com/rubocop/rubocop/pull/12580): Fix an infinite loop error for `Layout/EndAlignment` when misaligned in singleton class assignments with `EnforcedStyleAlignWith: variable`. ([@koic][]) +* [#12548](https://github.com/rubocop/rubocop/issues/12548): Fix an infinite loop error for `Layout/FirstArgumentIndentation` when specifying `EnforcedStyle: with_fixed_indentation` of `Layout/ArrayAlignment`. ([@koic][]) +* [#12236](https://github.com/rubocop/rubocop/issues/12236): Fix an error for `Lint/ShadowedArgument` when self assigning to a block argument in `for`. ([@koic][]) +* [#12569](https://github.com/rubocop/rubocop/issues/12569): Fix an error for `Style/IdenticalConditionalBranches` when using `if`...`else` with identical leading lines that assign to `self.foo`. ([@koic][]) +* [#12437](https://github.com/rubocop/rubocop/issues/12437): Fix an infinite loop error for `EnforcedStyle: omit_parentheses` of `Style/MethodCallWithArgsParentheses` with `Style/SuperWithArgsParentheses`. ([@koic][]) +* [#12558](https://github.com/rubocop/rubocop/issues/12558): Fix an incorrect autocorrect for `Style/MapToHash` when using `map.to_h` without receiver. ([@koic][]) +* [#12179](https://github.com/rubocop/rubocop/issues/12179): Let `--auto-gen-config` generate `Exclude` when `Max` is overridden. ([@jonas054][]) +* [#12574](https://github.com/rubocop/rubocop/issues/12574): Fix bug for unrecognized style in --auto-gen-config. ([@jonas054][]) +* [#12542](https://github.com/rubocop/rubocop/issues/12542): Fix false positive for `Lint/MixedRegexpCaptureTypes` when using look-ahead matcher. ([@marocchino][]) +* [#12607](https://github.com/rubocop/rubocop/pull/12607): Fix a false positive for `Style/RedundantParentheses` when regexp literal attempts to match against a parenthesized condition. ([@koic][]) +* [#12539](https://github.com/rubocop/rubocop/pull/12539): Fix false positives for `Lint/LiteralAssignmentInCondition` when a collection literal contains non-literal elements. ([@koic][]) +* [#12571](https://github.com/rubocop/rubocop/issues/12571): Fix false positives for `Naming/BlockForwarding` when using explicit block forwarding in block method. ([@koic][]) +* [#12537](https://github.com/rubocop/rubocop/issues/12537): Fix false positives for `Style/RedundantParentheses` when `AllowInMultilineConditions: true` of `Style/ParenthesesAroundCondition`. ([@koic][]) +* [#12578](https://github.com/rubocop/rubocop/pull/12578): Fix false positives for `Style/ArgumentsForwarding` when rest arguments forwarding to a method in block. ([@koic][]) +* [#12540](https://github.com/rubocop/rubocop/issues/12540): Fix false positives for `Style/HashEachMethods` when rest block argument of `Enumerable#each` method is used. ([@koic][]) +* [#12529](https://github.com/rubocop/rubocop/issues/12529): Fix false positives for `Style/ParenthesesAroundCondition`. ([@koic][]) +* [#12556](https://github.com/rubocop/rubocop/issues/12556): Fix false positives for `Style/RedundantParentheses` when parentheses are used around a semantic operator in expressions within assignments. ([@koic][]) +* [#12541](https://github.com/rubocop/rubocop/pull/12541): Fix false negative in `Style/ArgumentsForwarding` when a block is forwarded but other args aren't. ([@dvandersluis][]) +* [#12581](https://github.com/rubocop/rubocop/pull/12581): Handle trailing line continuation in `Layout/LineContinuationLeadingSpace`. ([@eugeneius][]) +* [#12601](https://github.com/rubocop/rubocop/issues/12601): Make `Style/EachForSimpleLoop` accept block with no parameters. ([@koic][]) + +### Changes + +* [#12535](https://github.com/rubocop/rubocop/pull/12535): Allow --autocorrect with --display-only-fail-level-offenses. ([@naveg][]) +* [#12572](https://github.com/rubocop/rubocop/pull/12572): Follow a Ruby 3.3 warning for `Security/Open` when `open` with a literal string starting with a pipe. ([@koic][]) +* [#12453](https://github.com/rubocop/rubocop/issues/12453): Make `Style/RedundantEach` aware of safe navigation operator. ([@koic][]) +* [#12233](https://github.com/rubocop/rubocop/issues/12233): Make `Style/SlicingWithRange` aware of redundant and beginless range. ([@koic][]) +* [#12388](https://github.com/rubocop/rubocop/pull/12388): Reject additional 'expanded' `EnforcedStyle` options when `--no-auto-gen-enforced-style` is given. ([@kpost][]) +* [#12593](https://github.com/rubocop/rubocop/pull/12593): Require Parser 3.3.0.2 or higher. ([@koic][]) + +## 1.59.0 (2023-12-11) + +### New features + +* [#12518](https://github.com/rubocop/rubocop/pull/12518): Add new `Lint/ItWithoutArgumentsInBlock` cop. ([@koic][]) + +### Bug fixes + +* [#12434](https://github.com/rubocop/rubocop/issues/12434): Fix a false positive for `Lint/LiteralAssignmentInCondition` when using interpolated string or xstring literals. ([@koic][]) +* [#12435](https://github.com/rubocop/rubocop/issues/12435): Fix a false positive for `Lint/SelfAssignment` when using attribute assignment with method call with arguments. ([@koic][]) +* [#12444](https://github.com/rubocop/rubocop/issues/12444): Fix false positive for `Style/HashEachMethods` when receiver literal is not a hash literal. ([@koic][]) +* [#12524](https://github.com/rubocop/rubocop/issues/12524): Fix a false positive for `Style/MethodCallWithArgsParentheses` when `EnforcedStyle: omit_parentheses` and parens in `when` clause is used to pass an argument. ([@koic][]) +* [#12505](https://github.com/rubocop/rubocop/pull/12505): Fix a false positive for `Style/RedundantParentheses` when using parenthesized `lambda` or `proc` with `do`...`end` block. ([@koic][]) +* [#12442](https://github.com/rubocop/rubocop/issues/12442): Fix an incorrect autocorrect for `Style/CombinableLoops` when looping over the same data as previous loop in `do`...`end` and `{`...`}` blocks. ([@koic][]) +* [#12432](https://github.com/rubocop/rubocop/pull/12432): Fix a false positive for `Lint/LiteralAssignmentInCondition` when using parallel assignment with splat operator in block of guard condition. ([@koic][]) +* [#12441](https://github.com/rubocop/rubocop/issues/12441): Fix false positives for `Style/HashEachMethods` when using destructed block arguments. ([@koic][]) +* [#12436](https://github.com/rubocop/rubocop/issues/12436): Fix false positives for `Style/RedundantParentheses` when a part of range is a parenthesized condition. ([@koic][]) +* [#12429](https://github.com/rubocop/rubocop/issues/12429): Fix incorrect autocorrect for `Style/MapToHash` when using dot method calls for `to_h`. ([@koic][]) +* [#12488](https://github.com/rubocop/rubocop/issues/12488): Make `Lint/HashCompareByIdentity` aware of safe navigation operator. ([@koic][]) +* [#12489](https://github.com/rubocop/rubocop/issues/12489): Make `Lint/NextWithoutAccumulator` aware of safe navigation operator. ([@koic][]) +* [#12490](https://github.com/rubocop/rubocop/issues/12490): Make `Lint/NumberConversion` aware of safe navigation operator. ([@koic][]) +* [#12491](https://github.com/rubocop/rubocop/issues/12491): Make `Lint/RedundantWithIndex` aware of safe navigation operator. ([@koic][]) +* [#12492](https://github.com/rubocop/rubocop/issues/12492): Make `Lint/RedundantWithObject` aware of safe navigation operator. ([@koic][]) +* [#12493](https://github.com/rubocop/rubocop/issues/12493): Make `Lint/UnmodifiedReduceAccumulator` aware of safe navigation operator. ([@koic][]) +* [#12473](https://github.com/rubocop/rubocop/issues/12473): Make `Style/ClassCheck` aware of safe navigation operator. ([@koic][]) +* [#12445](https://github.com/rubocop/rubocop/issues/12445): Make `Style/CollectionCompact` aware of safe navigation operator. ([@koic][]) +* [#12474](https://github.com/rubocop/rubocop/issues/12474): Make `Style/ConcatArrayLiterals` aware of safe navigation operator. ([@koic][]) +* [#12476](https://github.com/rubocop/rubocop/issues/12476): Make `Style/DateTime` aware of safe navigation operator. ([@koic][]) +* [#12479](https://github.com/rubocop/rubocop/issues/12479): Make `Style/EachWithObject` aware of safe navigation operator. ([@koic][]) +* [#12446](https://github.com/rubocop/rubocop/issues/12446): Make `Style/HashExcept` aware of safe navigation operator. ([@koic][]) +* [#12447](https://github.com/rubocop/rubocop/issues/12447): Make `Style/MapCompactWithConditionalBlock` aware of safe navigation operator. ([@koic][]) +* [#12484](https://github.com/rubocop/rubocop/issues/12484): Make `Style/Next` aware of safe navigation operator. ([@koic][]) +* [#12486](https://github.com/rubocop/rubocop/issues/12486): Make `Style/RedundantArgument` aware of safe navigation operator. ([@koic][]) +* [#12454](https://github.com/rubocop/rubocop/issues/12454): Make `Style/RedundantFetchBlock` aware of safe navigation operator. ([@koic][]) +* [#12495](https://github.com/rubocop/rubocop/issues/12495): Make `Layout/RedundantLineBreak` aware of safe navigation operator. ([@koic][]) +* [#12455](https://github.com/rubocop/rubocop/issues/12455): Make `Style/RedundantSortBy` aware of safe navigation operator. ([@koic][]) +* [#12456](https://github.com/rubocop/rubocop/issues/12456): Make `Style/RedundantSortBy` aware of safe navigation operator. ([@koic][]) +* [#12480](https://github.com/rubocop/rubocop/issues/12480): Make `Style/ExactRegexpMatch` aware of safe navigation operator. ([@koic][]) +* [#12457](https://github.com/rubocop/rubocop/issues/12457): Make `Style/Sample` aware of safe navigation operator. ([@koic][]) +* [#12458](https://github.com/rubocop/rubocop/issues/12458): Make `Style/SelectByRegexp` cops aware of safe navigation operator. ([@koic][]) +* [#12494](https://github.com/rubocop/rubocop/issues/12494): Make `Layout/SingleLineBlockChain` aware of safe navigation operator. ([@koic][]) +* [#12461](https://github.com/rubocop/rubocop/issues/12461): Make `Style/StringChars` aware of safe navigation operator. ([@koic][]) +* [#12468](https://github.com/rubocop/rubocop/issues/12468): Make `Style/Strip` aware of safe navigation operator. ([@koic][]) +* [#12469](https://github.com/rubocop/rubocop/issues/12469): Make `Style/UnpackFirst` aware of safe navigation operator. ([@koic][]) + +### Changes + +* [#12522](https://github.com/rubocop/rubocop/pull/12522): Make `Style/MethodCallWithoutArgsParentheses` allow the parenthesized `it` method in a block. ([@koic][]) +* [#12523](https://github.com/rubocop/rubocop/pull/12523): Make `Style/RedundantSelf` allow the `self.it` method in a block. ([@koic][]) + +## 1.58.0 (2023-12-01) + +### New features + +* [#12420](https://github.com/rubocop/rubocop/pull/12420): Add new `Lint/LiteralAssignmentInCondition` cop. ([@koic][]) +* [#12353](https://github.com/rubocop/rubocop/issues/12353): Add new `Style/SuperWithArgsParentheses` cop. ([@koic][]) +* [#12406](https://github.com/rubocop/rubocop/issues/12406): Add new `Style/ArrayFirstLast` cop. ([@fatkodima][]) + +### Bug fixes + +* [#12372](https://github.com/rubocop/rubocop/issues/12372): Fix a false negative for `Lint/Debugger` when used within method arguments a `begin`...`end` block. ([@koic][]) +* [#12378](https://github.com/rubocop/rubocop/pull/12378): Fix a false negative for `Style/Semicolon` when a semicolon at the beginning of a lambda block. ([@koic][]) +* [#12146](https://github.com/rubocop/rubocop/issues/12146): Fix a false positive for `Lint/FloatComparison` when comparing against zero. ([@earlopain][]) +* [#12404](https://github.com/rubocop/rubocop/issues/12404): Fix a false positive for `Layout/RescueEnsureAlignment` when aligned `rescue` in `do`-`end` numbered block in a method. ([@koic][]) +* [#12374](https://github.com/rubocop/rubocop/issues/12374): Fix a false positive for `Layout/SpaceBeforeSemicolon` when a space between an opening lambda brace and a semicolon. ([@koic][]) +* [#12326](https://github.com/rubocop/rubocop/pull/12326): Fix an error for `Style/RedundantDoubleSplatHashBraces` when method call for parenthesized no hash double double splat. ([@koic][]) +* [#12361](https://github.com/rubocop/rubocop/issues/12361): Fix an incorrect autocorrect for `Naming/BlockForwarding` and `Style/ArgumentsForwarding` when autocorrection conflicts for anonymous arguments. ([@koic][]) +* [#12324](https://github.com/rubocop/rubocop/issues/12324): Fix an error for `Layout/RescueEnsureAlignment` when using `rescue` in `do`...`end` block assigned to object attribute. ([@koic][]) +* [#12322](https://github.com/rubocop/rubocop/issues/12322): Fix an error for `Style/CombinableLoops` when looping over the same data for the third consecutive time or more. ([@koic][]) +* [#12366](https://github.com/rubocop/rubocop/pull/12366): Fix a false negative for `Layout/ExtraSpacing` when a file has exactly two comments. ([@eugeneius][]) +* [#12373](https://github.com/rubocop/rubocop/issues/12373): Fix a false negative for `Lint/SymbolConversion` when using string interpolation. ([@earlopain][]) +* [#12402](https://github.com/rubocop/rubocop/issues/12402): Fix false negatives for `Style/RedundantLineContinuation` when redundant line continuations for a block are used, especially without parentheses around first argument. ([@koic][]) +* [#12311](https://github.com/rubocop/rubocop/issues/12311): Fix false negatives for `Style/RedundantParentheses` when parentheses around logical operator keywords in method definition. ([@koic][]) +* [#12394](https://github.com/rubocop/rubocop/issues/12394): Fix false negatives for `Style/RedundantReturn` when `lambda` (`->`) ending with `return`. ([@koic][]) +* [#12377](https://github.com/rubocop/rubocop/issues/12377): Fix false positives for `Lint/Void` when a collection literal that includes non-literal elements in a method definition. ([@koic][]) +* [#12407](https://github.com/rubocop/rubocop/pull/12407): Fix an incorrect autocorrect for `Style/MapToHash` with `Layout/SingleLineBlockChain`. ([@koic][]) +* [#12409](https://github.com/rubocop/rubocop/issues/12409): Fix an incorrect autocorrect for `Lint/SafeNavigationChain` when ordinary method chain exists after safe navigation leading dot method call. ([@koic][]) +* [#12363](https://github.com/rubocop/rubocop/issues/12363): Fix incorrect rendering of HTML character entities in `HTMLFormatter` formatter. ([@koic][]) +* [#12424](https://github.com/rubocop/rubocop/issues/12424): Make `Style/HashEachMethods` aware of safe navigation operator. ([@koic][]) +* [#12413](https://github.com/rubocop/rubocop/issues/12413): Make `Style/InverseMethods` aware of safe navigation operator. ([@koic][]) +* [#12408](https://github.com/rubocop/rubocop/pull/12408): Make `Style/MapToHash` aware of safe navigation operator. ([@koic][]) + +### Changes + +* [#12328](https://github.com/rubocop/rubocop/issues/12328): Make `Style/AutoResourceCleanup` aware of `Tempfile.open`. ([@koic][]) +* [#12412](https://github.com/rubocop/rubocop/issues/12412): Enhance `Lint/RedundantSafeNavigation` to handle conversion methods with defaults. ([@fatkodima][]) +* [#12410](https://github.com/rubocop/rubocop/issues/12410): Enhance `Lint/SelfAssignment` to check attribute assignment and key assignment. ([@fatkodima][]) +* [#12370](https://github.com/rubocop/rubocop/issues/12370): Make `Style/HashEachMethods` aware of unused block value. ([@koic][]) +* [#12380](https://github.com/rubocop/rubocop/issues/12380): Make `Style/RedundantParentheses` aware of lambda or proc. ([@koic][]) +* [#12421](https://github.com/rubocop/rubocop/pull/12421): Make `Style/SelfAssignment` aware of `%`, `^`, `<<`, and `>>` operators. ([@koic][]) +* [#12305](https://github.com/rubocop/rubocop/pull/12305): Require `rubocop-ast` version 1.30 or greater. ([@sambostock][]) +* [#12337](https://github.com/rubocop/rubocop/issues/12337): Supports `EnforcedStyleForRationalLiterals` option for `Layout/SpaceAroundOperators`. ([@koic][]) +* [#12296](https://github.com/rubocop/rubocop/issues/12296): Support `RedundantRestArgumentNames`, `RedundantKeywordRestArgumentNames`, and `RedundantBlockArgumentNames` options for `Style/ArgumentsForwarding`. ([@koic][]) + +## 1.57.2 (2023-10-26) + +### Bug fixes + +* [#12274](https://github.com/rubocop/rubocop/issues/12274): Fix a false positive for `Lint/Void` when `each`'s receiver is an object of `Enumerator` to which `filter` has been applied. ([@koic][]) +* [#12291](https://github.com/rubocop/rubocop/issues/12291): Fix a false positive for `Metrics/ClassLength` when a class with a singleton class definition. ([@koic][]) +* [#12293](https://github.com/rubocop/rubocop/issues/12293): Fix a false positive for `Style/RedundantDoubleSplatHashBraces` when using double splat hash braces with `merge` and method chain. ([@koic][]) +* [#12298](https://github.com/rubocop/rubocop/issues/12298): Fix a false positive for `Style/RedundantParentheses` when using a parenthesized hash literal as the first argument in a method call without parentheses. ([@koic][]) +* [#12283](https://github.com/rubocop/rubocop/pull/12283): Fix an error for `Style/SingleLineDoEndBlock` when using single line `do`...`end` with no body. ([@koic][]) +* [#12312](https://github.com/rubocop/rubocop/issues/12312): Fix an incorrect autocorrect for `Style/HashSyntax` when braced hash key and value are the same and it is used in `if`...`else`. ([@koic][]) +* [#12307](https://github.com/rubocop/rubocop/issues/12307): Fix an infinite loop error for `Layout/EndAlignment` when `EnforcedStyleAlignWith: variable` and using a conditional statement in a method argument on the same line and `end` with method call is not aligned. ([@koic][]) +* [#11652](https://github.com/rubocop/rubocop/issues/11652): Make `--auto-gen-config` generate `inherit_from` correctly inside ERB `if`. ([@jonas054][]) +* [#12310](https://github.com/rubocop/rubocop/issues/12310): Drop `base64` gem from runtime dependency. ([@koic][]) +* [#12300](https://github.com/rubocop/rubocop/issues/12300): Fix an error for `Style/IdenticalConditionalBranches` when `if`...`else` with identical leading lines and using index assign. ([@koic][]) +* [#12286](https://github.com/rubocop/rubocop/issues/12286): Fix false positives for `Style/RedundantDoubleSplatHashBraces` when using double splat with a hash literal enclosed in parenthesized ternary operator. ([@koic][]) +* [#12279](https://github.com/rubocop/rubocop/issues/12279): Fix false positives for `Lint/EmptyConditionalBody` when missing 2nd `if` body with a comment. ([@koic][]) +* [#12275](https://github.com/rubocop/rubocop/issues/12275): Fix a false positive for `Style/RedundantDoubleSplatHashBraces` when using double splat within block argument containing a hash literal in an array literal. ([@koic][]) +* [#12284](https://github.com/rubocop/rubocop/issues/12284): Fix false positives for `Style/SingleArgumentDig` when using some anonymous argument syntax. ([@koic][]) +* [#12301](https://github.com/rubocop/rubocop/issues/12301): Make `Style/RedundantFilterChain` aware of safe navigation operator. ([@koic][]) + +## 1.57.1 (2023-10-13) + +### Bug fixes + +* [#12271](https://github.com/rubocop/rubocop/issues/12271): Fix a false positive for `Lint/RedundantSafeNavigation` when using snake case constant receiver. ([@koic][]) +* [#12265](https://github.com/rubocop/rubocop/issues/12265): Fix an error for `Layout/MultilineMethodCallIndentation` when usingarithmetic operation with block inside a grouped expression. ([@koic][]) +* [#12177](https://github.com/rubocop/rubocop/pull/12177): Fix an incorrect autocorrect for `Style/RedundantException`. ([@ydah][]) +* [#12261](https://github.com/rubocop/rubocop/issues/12261): Fix an infinite loop for `Layout/MultilineMethodCallIndentation` when multiline method chain with a block argument and method chain. ([@ydah][]) +* [#12263](https://github.com/rubocop/rubocop/issues/12263): Fix false positives for `Style/RedundantDoubleSplatHashBraces` when method call for no hash braced double splat receiver. ([@koic][]) +* [#12262](https://github.com/rubocop/rubocop/pull/12262): Fix an incorrect autocorrect for `Style/RedundantDoubleSplatHashBraces` when using double splat hash braces with `merge` method call twice. ([@koic][]) + +## 1.57.0 (2023-10-11) + +### New features + +* [#12227](https://github.com/rubocop/rubocop/pull/12227): Add new `Style/SingleLineDoEndBlock` cop. ([@koic][]) +* [#12246](https://github.com/rubocop/rubocop/pull/12246): Make `Lint/RedundantSafeNavigation` aware of constant receiver. ([@koic][]) +* [#12257](https://github.com/rubocop/rubocop/issues/12257): Make `Style/RedundantDoubleSplatHashBraces` aware of `merge` methods. ([@koic][]) + +### Bug fixes + +* [#12244](https://github.com/rubocop/rubocop/issues/12244): Fix a false negative for `Lint/Debugger` when using debugger method inside block. ([@koic][]) +* [#12231](https://github.com/rubocop/rubocop/issues/12231): Fix a false negative for `Metrics/ModuleLength` when defining a singleton class in a module. ([@koic][]) +* [#12249](https://github.com/rubocop/rubocop/issues/12249): Fix a false positive `Style/IdenticalConditionalBranches` when `if`..`else` with identical leading lines and assign to condition value. ([@koic][]) +* [#12253](https://github.com/rubocop/rubocop/pull/12253): Fix `Lint/LiteralInInterpolation` to accept an empty string literal interpolated in words literal. ([@knu][]) +* [#12198](https://github.com/rubocop/rubocop/issues/12198): Fix an error for flip-flop with beginless or endless ranges. ([@koic][]) +* [#12259](https://github.com/rubocop/rubocop/issues/12259): Fix an error for `Lint/MixedCaseRange` when using nested character class in regexp. ([@koic][]) +* [#12237](https://github.com/rubocop/rubocop/issues/12237): Fix an error for `Style/NestedTernaryOperator` when a ternary operator has a nested ternary operator within an `if`. ([@koic][]) +* [#12228](https://github.com/rubocop/rubocop/pull/12228): Fix false negatives for `Style/MultilineBlockChain` when using multiline block chain with safe navigation operator. ([@koic][]) +* [#12247](https://github.com/rubocop/rubocop/pull/12247): Fix false negatives for `Style/RedundantParentheses` when using logical or comparison expressions with redundant parentheses. ([@koic][]) +* [#12226](https://github.com/rubocop/rubocop/issues/12226): Fix false positives for `Layout/MultilineMethodCallIndentation` when aligning methods in multiline block chain. ([@koic][]) +* [#12076](https://github.com/rubocop/rubocop/issues/12076): Fixed an issue where the top-level cache folder was named differently during two consecutive rubocop runs. ([@K-S-A][]) + +### Changes + +* [#12235](https://github.com/rubocop/rubocop/pull/12235): Enable auto parallel inspection when config file is specified. ([@aboutNisblee][]) +* [#12234](https://github.com/rubocop/rubocop/pull/12234): Enhance `Style/FormatString`'s autocorrection when using known conversion methods whose return value is not an array. ([@koic][]) +* [#12128](https://github.com/rubocop/rubocop/issues/12128): Make `Style/GuardClause` aware of `define_method`. ([@koic][]) +* [#12126](https://github.com/rubocop/rubocop/pull/12126): Make `Style/RedundantFilterChain` aware of `select.present?` when `ActiveSupportExtensionsEnabled` config is `true`. ([@koic][]) +* [#12250](https://github.com/rubocop/rubocop/pull/12250): Mark `Lint/RedundantRequireStatement` as unsafe autocorrect. ([@koic][]) +* [#12097](https://github.com/rubocop/rubocop/issues/12097): Mark unsafe autocorrect for `Style/ClassEqualityComparison`. ([@koic][]) +* [#12210](https://github.com/rubocop/rubocop/issues/12210): Mark `Style/RedundantFilterChain` as unsafe autocorrect. ([@koic][]) + +## 1.56.4 (2023-09-28) + +### Bug fixes + +* [#12221](https://github.com/rubocop/rubocop/issues/12221): Fix a false positive for `Layout/EmptyLineAfterGuardClause` when using `return` before guard condition with heredoc. ([@koic][]) +* [#12213](https://github.com/rubocop/rubocop/issues/12213): Fix a false positive for `Lint/OrderedMagicComments` when comment text `# encoding: ISO-8859-1` is embedded within example code as source code comment. ([@koic][]) +* [#12205](https://github.com/rubocop/rubocop/issues/12205): Fix an error for `Style/OperatorMethodCall` when using `foo bar./ baz`. ([@koic][]) +* [#12208](https://github.com/rubocop/rubocop/issues/12208): Fix an incorrect autocorrect for the `--disable-uncorrectable` command line option when registering an offense is outside a percent array. ([@koic][]) +* [#12203](https://github.com/rubocop/rubocop/pull/12203): Fix an incorrect autocorrect for `Lint/SafeNavigationChain` when using safe navigation with comparison operator as an expression of logical operator or comparison operator's operand. ([@koic][]) +* [#12206](https://github.com/rubocop/rubocop/pull/12206): Fix an incorrect autocorrect for `Style/OperatorMethodCall` when using `foo./bar`. ([@koic][]) +* [#12202](https://github.com/rubocop/rubocop/pull/12202): Fix an incorrect autocorrect for `Style/RedundantConditional` when unless/else with boolean results. ([@ydah][]) +* [#12199](https://github.com/rubocop/rubocop/issues/12199): Fix false negatives for `Layout/MultilineMethodCallIndentation` when using safe navigation operator. ([@koic][]) + +### Changes + +* [#12197](https://github.com/rubocop/rubocop/pull/12197): Make `Style/CollectionMethods` aware of `collect_concat`. ([@koic][]) + +## 1.56.3 (2023-09-11) + +### Bug fixes + +* [#12151](https://github.com/rubocop/rubocop/issues/12151): Make `Layout/EmptyLineAfterGuardClause` allow `:nocov:` directive after guard clause. ([@koic][]) +* [#12195](https://github.com/rubocop/rubocop/issues/12195): Fix a false negative for `Layout/SpaceAfterNot` when a newline is present after `!`. ([@ymap][]) +* [#12192](https://github.com/rubocop/rubocop/issues/12192): Fix a false positive for `Layout/RedundantLineBreak` when using quoted symbols with a single newline. ([@ymap][]) +* [#12190](https://github.com/rubocop/rubocop/issues/12190): Fix a false positive for `Layout/SpaceAroundOperators` when aligning operators vertically. ([@koic][]) +* [#12171](https://github.com/rubocop/rubocop/issues/12171): Fix a false positive for `Style/ArrayIntersect` when using block argument for `Enumerable#any?`. ([@koic][]) +* [#12172](https://github.com/rubocop/rubocop/issues/12172): Fix a false positive for `Style/EmptyCaseCondition` when using `return`, `break`, `next` or method call before empty case condition. ([@koic][]) +* [#12162](https://github.com/rubocop/rubocop/issues/12162): Fix an error for `Bundler/DuplicatedGroup` when there's a duplicate set of groups and the `group` value contains a splat. ([@koic][]) +* [#12182](https://github.com/rubocop/rubocop/issues/12182): Fix an error for `Lint/UselessAssignment` when variables are assigned using chained assignment and remain unreferenced. ([@koic][]) +* [#12181](https://github.com/rubocop/rubocop/issues/12181): Fix an incorrect autocorrect for `Lint/UselessAssignment` when variables are assigned with sequential assignment using the comma operator and unreferenced. ([@koic][]) +* [#12187](https://github.com/rubocop/rubocop/issues/12187): Fix an incorrect autocorrect for `Style/SoleNestedConditional` when comment is in an empty nested `if` body. ([@ymap][]) +* [#12183](https://github.com/rubocop/rubocop/pull/12183): Fix an incorrect autocorrect for `Style/MultilineTernaryOperator` when returning a multiline ternary operator expression with safe navigation method call. ([@koic][]) +* [#12168](https://github.com/rubocop/rubocop/issues/12168): Fix bug in `Style/ArgumentsForwarding` when there are repeated send nodes. ([@owst][]) +* [#12185](https://github.com/rubocop/rubocop/pull/12185): Set target version for `Layout/HeredocIndentation`. ([@tagliala][]) + +## 1.56.2 (2023-08-29) + +### Bug fixes + +* [#12138](https://github.com/rubocop/rubocop/issues/12138): Fix a false positive for `Layout/LineContinuationLeadingSpace` when a backslash is part of a multiline string literal. ([@ymap][]) +* [#12155](https://github.com/rubocop/rubocop/pull/12155): Fix false positive for `Layout/RedundantLineBreak` when using a modified singleton method definition. ([@koic][]) +* [#12143](https://github.com/rubocop/rubocop/issues/12143): Fix a false positive for `Lint/ToEnumArguments` when using anonymous keyword arguments forwarding. ([@koic][]) +* [#12148](https://github.com/rubocop/rubocop/pull/12148): Fix an incorrect autocorrect for `Lint/NonAtomicFileOperation` when using `FileUtils.remove_dir`, `FileUtils.remove_entry`, or `FileUtils.remove_entry_secure`. ([@koic][]) +* [#12141](https://github.com/rubocop/rubocop/issues/12141): Fix false positive for `Style/ArgumentsForwarding` when method def includes additional kwargs. ([@owst][]) +* [#12154](https://github.com/rubocop/rubocop/issues/12154): Fix incorrect `diagnosticProvider` value of LSP. ([@koic][]) + +## 1.56.1 (2023-08-21) + +### Bug fixes + +* [#12136](https://github.com/rubocop/rubocop/pull/12136): Fix a false negative for `Layout/LeadingCommentSpace` when using `#+` or `#-` as they are not RDoc comments. ([@koic][]) +* [#12113](https://github.com/rubocop/rubocop/issues/12113): Fix a false positive for `Bundler/DuplicatedGroup` when groups are duplicated but `source`, `git`, `platforms`, or `path` values are different. ([@koic][]) +* [#12134](https://github.com/rubocop/rubocop/issues/12134): Fix a false positive for `Style/MethodCallWithArgsParentheses` when parentheses are used in one-line `in` pattern matching. ([@koic][]) +* [#12111](https://github.com/rubocop/rubocop/issues/12111): Fix an error for `Bundler/DuplicatedGroup` group declaration has keyword option. ([@koic][]) +* [#12109](https://github.com/rubocop/rubocop/issues/12109): Fix an error for `Style/ArgumentsForwarding` cop when forwarding kwargs/block arg and an additional arg. ([@ydah][]) +* [#12117](https://github.com/rubocop/rubocop/issues/12117): Fix a false positive for `Style/ArgumentsForwarding` cop when not always forwarding block. ([@owst][]) +* [#12115](https://github.com/rubocop/rubocop/pull/12115): Fix an error for `Style/Lambda` when using numbered parameter with a multiline `->` call. ([@koic][]) +* [#12124](https://github.com/rubocop/rubocop/issues/12124): Fix false positives for `Style/RedundantParentheses` when parentheses in `super` or `yield` call with multiline style argument. ([@koic][]) +* [#12120](https://github.com/rubocop/rubocop/pull/12120): Fix false positives for `Style/SymbolArray` when `%i` array containing unescaped `[`, `]`, `(`, or `)`. ([@koic][]) +* [#12133](https://github.com/rubocop/rubocop/pull/12133): Fix `Style/RedundantSelfAssignmentBranch` to handle heredocs. ([@r7kamura][]) +* [#12105](https://github.com/rubocop/rubocop/issues/12105): Fix target ruby `Gem::Requirement` matcher and version parsing to support multiple version constraints. ([@ItsEcholot][]) + +## 1.56.0 (2023-08-09) + +### New features + +* [#12074](https://github.com/rubocop/rubocop/pull/12074): Add new `Bundler/DuplicatedGroup` cop. ([@OwlKing][]) +* [#12078](https://github.com/rubocop/rubocop/pull/12078): Make LSP server support `rubocop.formatAutocorrectsAll` execute command. ([@koic][]) + +### Bug fixes + +* [#12106](https://github.com/rubocop/rubocop/issues/12106): Fix a false negative for `Style/RedundantReturn` when returning value with guard clause and `return` is used. ([@koic][]) +* [#12095](https://github.com/rubocop/rubocop/pull/12095): Fix a false positive for `Style/Alias` when `EncforcedStyle: prefer_alias` and using `alias` with interpolated symbol argument. ([@koic][]) +* [#12098](https://github.com/rubocop/rubocop/pull/12098): Fix a false positive for `Style/ClassEqualityComparison` when comparing interpolated string class name for equality. ([@koic][]) +* [#12102](https://github.com/rubocop/rubocop/pull/12102): Fix an error for `Style/LambdaCall` when using nested lambda call `x.().()`. ([@koic][]) +* [#12099](https://github.com/rubocop/rubocop/pull/12099): Fix an incorrect autocorrect for `Style/Alias` when `EncforcedStyle: prefer_alias_method` and using `alias` with interpolated symbol argument. ([@koic][]) +* [#12085](https://github.com/rubocop/rubocop/issues/12085): Fix an error for `Lint/SuppressedException` when `AllowNil: true` is set and endless method definition is used. ([@koic][]) +* [#12087](https://github.com/rubocop/rubocop/issues/12087): Fix false positives for `Style/ArgumentsForwarding` with additional args/kwargs in def/send nodes. ([@owst][]) +* [#12071](https://github.com/rubocop/rubocop/issues/12071): Fix `Style/SymbolArray` false positives when using square brackets or interpolation in a symbol literal in a percent style array. ([@jasondoc3][]) +* [#12061](https://github.com/rubocop/rubocop/issues/12061): Support regex in StringLiteralsInInterpolation. ([@jonas054][]) +* [#12091](https://github.com/rubocop/rubocop/pull/12091): With `--fail-level A` ignore non-correctable offenses at :info severity. ([@naveg][]) + +### Changes + +* [#12094](https://github.com/rubocop/rubocop/pull/12094): Add `base64` gem to runtime dependency to suppress Ruby 3.3's warning. ([@koic][]) + +## 1.55.1 (2023-07-31) + +### Bug fixes + +* [#12068](https://github.com/rubocop/rubocop/pull/12068): Fix a false positive for `Style/ReturnNilInPredicateMethodDefinition` when the last method argument in method definition is `nil`. ([@koic][]) +* [#12082](https://github.com/rubocop/rubocop/issues/12082): Fix an error for `Lint/UselessAssignment` when a variable is assigned and unreferenced in `for` with multiple variables. ([@koic][]) +* [#12079](https://github.com/rubocop/rubocop/issues/12079): Fix an error for `Style/MixinGrouping` when mixin method has no arguments. ([@koic][]) +* [#11637](https://github.com/rubocop/rubocop/pull/11637): Correct Rubocop for `private_class_method` method documentation. ([@bigzed][]) +* [#12070](https://github.com/rubocop/rubocop/pull/12070): Fix false positive in `Style/ArgumentsForwarding` when receiver forwards args/kwargs. ([@owst][]) + +## 1.55.0 (2023-07-25) + +### New features + +* [#11794](https://github.com/rubocop/rubocop/pull/11794): Add support to `Style/ArgumentsForwarding` for anonymous arg/kwarg forwarding in Ruby 3.2. ([@owst][]) +* [#12044](https://github.com/rubocop/rubocop/issues/12044): Make LSP server support `layoutMode` option to run layout cops. ([@koic][]) +* [#12056](https://github.com/rubocop/rubocop/pull/12056): Make LSP server support `lintMode` option to run lint cops. ([@koic][]) +* [#12046](https://github.com/rubocop/rubocop/issues/12046): Make `ReturnNilInPredicateMethodDefinition` aware of `nil` at the end of predicate method definition. ([@koic][]) + +### Bug fixes + +* [#12055](https://github.com/rubocop/rubocop/pull/12055): Allow parentheses in single-line match patterns when using the `omit_parentheses` style of `Style/MethodCallWithArgsParentheses`. ([@gsamokovarov][]) +* [#12050](https://github.com/rubocop/rubocop/pull/12050): Fix a false positive for `Layout/RedundantLineBreak` when inspecting the `%` form string `%\n\n`. ([@koic][]) +* [#12063](https://github.com/rubocop/rubocop/pull/12063): Fix `Style/CombinableLoops` when one of the loops is empty. ([@fatkodima][]) +* [#12059](https://github.com/rubocop/rubocop/issues/12059): Fix a false negative for `Style/StringLiteralsInInterpolation` for symbols with interpolation. ([@fatkodima][]) +* [#11834](https://github.com/rubocop/rubocop/issues/11834): Fix false positive for when variable in inside conditional branch in nested node. ([@alexeyschepin][]) +* [#11802](https://github.com/rubocop/rubocop/issues/11802): Improve handling of `[]` and `()` with percent symbol arrays. ([@jasondoc3][]) +* [#12052](https://github.com/rubocop/rubocop/issues/12052): Fix "Subfolders can't include glob special characters". ([@meric426][], [@loveo][]) +* [#12062](https://github.com/rubocop/rubocop/pull/12062): Fix `LoadError` when loading RuboCop from a symlinked location on Windows. ([@p0deje][]) + +### Changes + +* [#12064](https://github.com/rubocop/rubocop/pull/12064): Make `Style/RedundantArgument` aware of `exit` and `exit!`. ([@koic][]) +* [#12015](https://github.com/rubocop/rubocop/issues/12015): Mark `Style/HashConversion` as unsafe autocorrection. ([@koic][]) + +## 1.54.2 (2023-07-13) + +### Bug fixes + +* [#12043](https://github.com/rubocop/rubocop/pull/12043): Fix a false negative for `Layout/ExtraSpacing` when some characters are vertically aligned. ([@koic][]) +* [#12040](https://github.com/rubocop/rubocop/pull/12040): Fix a false positive for `Layout/TrailingEmptyLines` to prevent the following incorrect autocorrection when inspecting the `%` form string `%\n\n`. ([@koic][]) +* [#1867](https://github.com/rubocop/rubocop/issues/1867): Fix an error when `AllCops:Exclude` is empty in .rubocop.yml. ([@koic][]) +* [#12034](https://github.com/rubocop/rubocop/issues/12034): Fix invalid byte sequence in UTF-8 error when using an invalid encoding string. ([@koic][]) +* [#12038](https://github.com/rubocop/rubocop/pull/12038): Output the "server restarting" message to stderr. ([@knu][]) + +## 1.54.1 (2023-07-04) + +### Bug fixes + +* [#12024](https://github.com/rubocop/rubocop/issues/12024): Fix a false positive for `Lint/RedundantRegexpQuantifiers` when interpolation is used in a regexp literal. ([@koic][]) +* [#12020](https://github.com/rubocop/rubocop/issues/12020): This PR fixes an infinite loop error for `Layout/SpaceAfterComma` with `Layout/SpaceBeforeSemicolon` when autocorrection conflicts. ([@koic][]) +* [#12014](https://github.com/rubocop/rubocop/pull/12014): Fix an error for `Lint/UselessAssignment` when part of a multiple assignment is enclosed in parentheses. ([@koic][]) +* [#12011](https://github.com/rubocop/rubocop/pull/12011): Fix an error for `Metrics/MethodLength` when using a heredoc in a block without block arguments. ([@koic][]) +* [#12010](https://github.com/rubocop/rubocop/pull/12010): Fix false negatives for `Style/RedundantRegexpArgument` when using safe navigation operator. ([@koic][]) + +## 1.54.0 (2023-07-01) + +### New features + +* [#12000](https://github.com/rubocop/rubocop/pull/12000): Support safe or unsafe autocorrect config for LSP. ([@koic][]) + +### Bug fixes + +* [#12005](https://github.com/rubocop/rubocop/issues/12005): Fix a false negative for `Lint/Debugger` when using debugger method inside lambda. ([@koic][]) +* [#11986](https://github.com/rubocop/rubocop/issues/11986): Fix a false positive for `Lint/MixedCaseRange` when the number of characters at the start or end of range is other than 1. ([@koic][]) +* [#11992](https://github.com/rubocop/rubocop/issues/11992): Fix an unexpected `NoMethodError` for built-in language server when an internal error occurs. ([@koic][]) +* [#11994](https://github.com/rubocop/rubocop/issues/11994): Fix an error for `Layout/LineEndStringConcatenationIndentation` when inspecting the `%` from string `%\n\n`. ([@koic][]) +* [#12007](https://github.com/rubocop/rubocop/issues/12007): Fix an error for `Layout/SpaceAroundOperators` when using unary operator with double colon. ([@koic][]) +* [#11996](https://github.com/rubocop/rubocop/issues/11996): Fix an error for `Style/IfWithSemicolon` when without branch bodies. ([@koic][]) +* [#12009](https://github.com/rubocop/rubocop/pull/12009): Fix an error for `Style/YodaCondition` when equality check method is used without the first argument. ([@koic][]) +* [#11998](https://github.com/rubocop/rubocop/issues/11998): Fix an error when inspecting blank heredoc delimiter. ([@koic][]) +* [#11989](https://github.com/rubocop/rubocop/issues/11989): Fix an incorrect autocorrect for `Style/RedundantRegexpArgument` when using unicode chars. ([@koic][]) +* [#12001](https://github.com/rubocop/rubocop/issues/12001): Fix code length calculator for method calls with heredoc. ([@fatkodima][]) +* [#12002](https://github.com/rubocop/rubocop/pull/12002): Fix `Lint/Void` cop for `__ENCODING__` constant. ([@fatkodima][]) + +### Changes + +* [#11983](https://github.com/rubocop/rubocop/pull/11983): Add Ridgepole files to default `Include` list. ([@ydah][]) +* [#11738](https://github.com/rubocop/rubocop/issues/11738): Enhances empty_line_between_defs to treat configured macros like defs. ([@catwomey][]) + +## 1.53.1 (2023-06-26) + +### Bug fixes + +* [#11974](https://github.com/rubocop/rubocop/issues/11974): Fix an error for `Style/RedundantCurrentDirectoryInPath` when using string interpolation in `require_relative`. ([@koic][]) +* [#11981](https://github.com/rubocop/rubocop/issues/11981): Fix an incorrect autocorrect for `Style/RedundantRegexpArgument` when using double quote and single quote characters. ([@koic][]) +* [#11836](https://github.com/rubocop/rubocop/issues/11836): Should not offense single-quoted symbol containing double quotes in `Lint/SymbolConversion` . ([@KessaPassa][]) + +## 1.53.0 (2023-06-23) + +### New features + +* [#11561](https://github.com/rubocop/rubocop/pull/11561): Add new `Lint/MixedCaseRange` cop. ([@rwstauner][]) +* [#11565](https://github.com/rubocop/rubocop/pull/11565): Add new `Lint/RedundantRegexpQuantifiers` cop. ([@jaynetics][]) +* [#11925](https://github.com/rubocop/rubocop/issues/11925): Add new `Style/RedundantCurrentDirectoryInPath` cop. ([@koic][]) +* [#11595](https://github.com/rubocop/rubocop/pull/11595): Add new `Style/RedundantRegexpArgument` cop. ([@koic][]) +* [#11967](https://github.com/rubocop/rubocop/pull/11967): Add new `Style/ReturnNilInPredicateMethodDefinition` cop. ([@koic][]) +* [#11745](https://github.com/rubocop/rubocop/pull/11745): Add new `Style/YAMLFileRead` cop. ([@koic][]) +* [#11926](https://github.com/rubocop/rubocop/pull/11926): Support built-in LSP server. ([@koic][]) + +### Bug fixes + +* [#11953](https://github.com/rubocop/rubocop/issues/11953): Fix a false negative for `Lint/DuplicateHashKey` when there is a duplicated constant key in the hash literal. ([@koic][]) +* [#11945](https://github.com/rubocop/rubocop/issues/11945): Fix a false negative for `Style/RedundantSelfAssignmentBranch` when using method chaining or arguments in ternary branch. ([@koic][]) +* [#11949](https://github.com/rubocop/rubocop/issues/11949): Fix a false positive for `Layout/RedundantLineBreak` when using a line broken string. ([@koic][]) +* [#11931](https://github.com/rubocop/rubocop/pull/11931): Fix a false positive for `Lint/RedundantRequireStatement` when using `PP.pp`. ([@koic][]) +* [#11946](https://github.com/rubocop/rubocop/pull/11946): Fix an error for `Lint/NumberConversion` when using multiple number conversion methods. ([@koic][]) +* [#11972](https://github.com/rubocop/rubocop/issues/11972): Fix an error for `Lint/Void` when `CheckForMethodsWithNoSideEffects: true` and using a method definition. ([@koic][]) +* [#11958](https://github.com/rubocop/rubocop/pull/11958): Fix error for `Style/IdenticalConditionalBranches` when using empty parentheses in the `if` branch. ([@koic][]) +* [#11962](https://github.com/rubocop/rubocop/issues/11962): Fix an error for `Style/RedundantStringEscape` when an escaped double quote precedes interpolation in a symbol literal. ([@koic][]) +* [#11947](https://github.com/rubocop/rubocop/issues/11947): Fix an error for `Style/ConditionalAssignment` with an assignment that uses `if` branch bodies, which include a block. ([@koic][]) +* [#11959](https://github.com/rubocop/rubocop/pull/11959): Fix false negatives for `Layout/EmptyLinesAroundExceptionHandlingKeywords` when using Ruby 2.5's `rescue` inside block and Ruby 2.7's numbered block. ([@koic][]) +* [#10902](https://github.com/rubocop/rubocop/issues/10902): Fix an error for `Style/RedundantRegexpEscape` string with invalid byte sequence in UTF-8. ([@ydah][]) +* [#11562](https://github.com/rubocop/rubocop/pull/11562): Fixed escaped octal handling and detection in `Lint/DuplicateRegexpCharacterClassElement`. ([@rwstauner][]) + +### Changes + +* [#11904](https://github.com/rubocop/rubocop/pull/11904): Mark `Layout/ClassStructure` as unsafe to autocorrect. ([@nevans][]) +* [#8506](https://github.com/rubocop/rubocop/issues/8506): Add `AllowedParentClasses` config to `Lint/MissingSuper`. ([@iMacTia][]) + +## 1.52.1 (2023-06-12) + +### Bug fixes + +* [#11944](https://github.com/rubocop/rubocop/pull/11944): Fix an incorrect autocorrect for `Style/SoleNestedConditional` with `Style/MethodCallWithArgsParentheses`. ([@koic][]) +* [#11930](https://github.com/rubocop/rubocop/pull/11930): Fix exception on `Lint/InheritException` when class definition has non-constant siblings. ([@rafaelfranca][]) +* [#11919](https://github.com/rubocop/rubocop/issues/11919): Fix an error for `Lint/UselessAssignment` when a variable is assigned and unreferenced in `for`. ([@koic][]) +* [#11928](https://github.com/rubocop/rubocop/pull/11928): Fix an incorrect autocorrect for `Lint/AmbiguousBlockAssociation`. ([@koic][]) +* [#11915](https://github.com/rubocop/rubocop/pull/11915): Fix a false positive for `Lint/RedundantSafeNavigation` when `&.` is used for `to_s`, `to_i`, `to_d`, and other coercion methods. ([@lucthev][]) + +### Changes + +* [#11942](https://github.com/rubocop/rubocop/pull/11942): Require Parser 3.2.2.3 or higher. ([@koic][]) + +## 1.52.0 (2023-06-02) + +### New features + +* [#11873](https://github.com/rubocop/rubocop/pull/11873): Add `ComparisonsThreshold` config option to `Style/MultipleComparison`. ([@fatkodima][]) +* [#11886](https://github.com/rubocop/rubocop/pull/11886): Add new `Style/RedundantArrayConstructor` cop. ([@koic][]) +* [#11873](https://github.com/rubocop/rubocop/pull/11873): Add new `Style/RedundantRegexpConstructor` cop. ([@koic][]) +* [#11841](https://github.com/rubocop/rubocop/pull/11841): Add new `Style/RedundantFilterChain` cop. ([@fatkodima][]) +* [#11908](https://github.com/rubocop/rubocop/issues/11908): Support `AllowedReceivers` for `Style/CollectionMethods`. ([@koic][]) + +### Bug fixes + +* [#11890](https://github.com/rubocop/rubocop/pull/11890): Fix a false negative for `Lint/RedundantSafeNavigation` when `&.` is used for `to_d`. ([@koic][]) +* [#11880](https://github.com/rubocop/rubocop/issues/11880): Fix a false positive for `Style/ExactRegexpMatch` when using literal with quantifier in regexp. ([@koic][]) +* [#11902](https://github.com/rubocop/rubocop/pull/11902): Fix a false positive for `Style/RequireOrder` when single-quoted string and double-quoted string are mixed. ([@koic][]) +* [#11879](https://github.com/rubocop/rubocop/pull/11879): Fix a false positive for `Style/SelectByRegexp` when Ruby 2.2 or lower analysis. ([@koic][]) +* [#11891](https://github.com/rubocop/rubocop/issues/11891): Fix `Style/AccessorGrouping` to accept macros separated from accessors by space. ([@fatkodima][]) +* [#11905](https://github.com/rubocop/rubocop/issues/11905): Fix an error for `Lint/UselessAssignment` when a variable is assigned with rest assignment and unreferenced. ([@koic][]) +* [#11899](https://github.com/rubocop/rubocop/issues/11899): Fix an incorrect autocorrect for `Style/SingleLineMethods` when using Ruby 3.0 and `Style/EndlessMethod` is disabled. ([@koic][]) +* [#11884](https://github.com/rubocop/rubocop/issues/11884): Make `rubocop -V` display rubocop-factory_bot version when using it. ([@koic][]) +* [#11893](https://github.com/rubocop/rubocop/issues/11893): Fix a false positive for `Lint/InheritException` when inheriting `Exception` with omitted namespace. ([@koic][]) +* [#11898](https://github.com/rubocop/rubocop/pull/11898): Fix offences in calls inside blocks with braces for `Style/MethodCallWithArgsParentheses` with `omit_parentheses` enforced style. ([@gsamokovarov][]) +* [#11857](https://github.com/rubocop/rubocop/pull/11857): Server mode: only read $stdin when -s or --stdin argument provided. ([@naveg][]) + +## 1.51.0 (2023-05-13) + +### New features + +* [#11819](https://github.com/rubocop/rubocop/pull/11819): Add autocorrection for `Lint/AmbiguousBlockAssociation`. ([@r7kamura][]) +* [#11597](https://github.com/rubocop/rubocop/issues/11597): Add autocorrection for `Lint/UselessAssignment`. ([@r7kamura][]) +* [#11848](https://github.com/rubocop/rubocop/pull/11848): Add autocorrection for `Lint/Void`. ([@r7kamura][]) +* [#11851](https://github.com/rubocop/rubocop/pull/11851): Add autocorrection for `Naming/MemoizedInstanceVariableName`. ([@r7kamura][]) +* [#11856](https://github.com/rubocop/rubocop/pull/11856): Add autocorrection for `Style/CombinableLoops`. ([@r7kamura][]) +* [#11824](https://github.com/rubocop/rubocop/pull/11824): Add autocorrection for `Lint/TopLevelReturnWithArgument`. ([@r7kamura][]) +* [#11869](https://github.com/rubocop/rubocop/pull/11869): Add new `Style/ExactRegexpMatch` cop. ([@koic][]) +* [#11814](https://github.com/rubocop/rubocop/pull/11814): Make `Style/CollectionCompact` aware of `delete_if`. ([@koic][]) +* [#11866](https://github.com/rubocop/rubocop/pull/11866): Make `Style/Semicolon` aware of redundant semicolons in string interpolation braces. ([@koic][]) + +### Bug fixes + +* [#11812](https://github.com/rubocop/rubocop/issues/11812): Fix a false negative for `Style/Attr` when using `attr` and method definitions. ([@koic][]) +* [#11861](https://github.com/rubocop/rubocop/issues/11861): Fix a false positive for `Layout/SpaceAfterSemicolon` when no space between a semicolon and a closing brace of string interpolation. ([@koic][]) +* [#11830](https://github.com/rubocop/rubocop/pull/11830): Fix a false positive for `Lint/IncompatibleIoSelectWithFiberScheduler`. ([@koic][]) +* [#11846](https://github.com/rubocop/rubocop/issues/11846): Fix a false positive for `Lint/RedundantStringCoercion` when using `to_s(argument)` in `puts` argument. ([@koic][]) +* [#11865](https://github.com/rubocop/rubocop/pull/11865): Fix an error for `Naming/ConstantName` when assigning a constant from an empty branch of `else`. ([@koic][]) +* [#11844](https://github.com/rubocop/rubocop/issues/11844): Fix a false positive for `Style/RedundantLineContinuation` when using line concatenation for assigning a return value and without argument parentheses. ([@koic][]) +* [#11808](https://github.com/rubocop/rubocop/pull/11808): Fix a false positive for `Style/RegexpLiteral` when using a regexp starts with equal as a method argument. ([@koic][]) +* [#11822](https://github.com/rubocop/rubocop/issues/11822): Fix an error for `Layout/SpaceInsideBlockBraces` when a method call with a multiline block is used as an argument. ([@koic][]) +* [#11849](https://github.com/rubocop/rubocop/issues/11849): Fix an error for `Style/ConditionalAssignment` when `EnforcedStyle: assign_inside_condition` and using empty `case` condition. ([@koic][]) +* [#11967](https://github.com/rubocop/rubocop/pull/11967): Fix error for `Style/IfInsideElse` when a deep nested multiline `if...then...elsif...else...end`. ([@koic][]) +* [#11842](https://github.com/rubocop/rubocop/pull/11842): Fix an error for `Style/IfUnlessModifier` when using multiple `if` modifier in the long one line. ([@koic][]) +* [#11835](https://github.com/rubocop/rubocop/pull/11835): Fix an error for `Style/RequireOrder` when multiple `require` are not sorted. ([@koic][]) +* [#11809](https://github.com/rubocop/rubocop/issues/11809): Fix an incorrect autocorrect for `Naming/RescuedExceptionsVariableName` when exception variable is referenced after `rescue` statement. ([@koic][]) +* [#11852](https://github.com/rubocop/rubocop/issues/11852): Fix an incorrect autocorrect for `Style/EvalWithLocation` when using `eval` without line number and with parenthesized method call. ([@koic][]) +* [#11862](https://github.com/rubocop/rubocop/issues/11862): Fix an incorrect autocorrect for `Style/GuardClause` when using `raise` in `else` branch in a one-liner with `then`. ([@koic][]) +* [#11868](https://github.com/rubocop/rubocop/issues/11868): Fix a false positive for `Style/HashExcept` when method's receiver/argument is not the same as block key argument. ([@fatkodima][]) +* [#11858](https://github.com/rubocop/rubocop/pull/11858): Fix false positives when using source comments in blocks. ([@reitermarkus][]) +* [#11510](https://github.com/rubocop/rubocop/pull/11510): Fix `Lint/UselessAssignment` false positive when using numbered block parameters. ([@sambostock][]) +* [#11872](https://github.com/rubocop/rubocop/pull/11872): Fix `Gemspec/DevelopmentDependencies` not trigger when add_development_dependency has more then one arguments. ([@Bhacaz][]) +* [#11820](https://github.com/rubocop/rubocop/issues/11820): Fix `Lint/EmptyConditionalBody` false-positives for commented empty `elsif` body. ([@r7kamura][]) + +### Changes + +* [#11859](https://github.com/rubocop/rubocop/pull/11859): Add rubocop-factory_bot to suggested extensions. ([@ydah][]) +* [#11791](https://github.com/rubocop/rubocop/pull/11791): **(Breaking)** Drop runtime support for Ruby 2.6 and JRuby 9.3 (CRuby 2.6 compatible). ([@koic][]) +* [#11826](https://github.com/rubocop/rubocop/pull/11826): Exclude `**/*.jb` from `Lint/TopLevelReturnWithArgument`. ([@r7kamura][]) +* [#11871](https://github.com/rubocop/rubocop/pull/11871): Mark `Style/DataInheritance` as unsafe autocorrect, `Style/OpenStructUse` as unsafe, and `Security/CompoundHash` as unsafe. ([@koic][]) + +## 1.50.2 (2023-04-17) + +### Bug fixes + +* [#11799](https://github.com/rubocop/rubocop/pull/11799): Fix a false positive for `Style/CollectionCompact` when using `reject` on hash to reject nils in Ruby 2.3 analysis. ([@koic][]) +* [#11792](https://github.com/rubocop/rubocop/issues/11792): Fix an error for `Lint/DuplicateMatchPattern` when using hash pattern with `if` guard. ([@koic][]) +* [#11800](https://github.com/rubocop/rubocop/issues/11800): Mark `Style/InvertibleUnlessCondition` as unsafe. ([@koic][]) + +## 1.50.1 (2023-04-12) + +### Bug fixes + +* [#11787](https://github.com/rubocop/rubocop/issues/11787): Fix a false positive for `Lint/DuplicateMatchPattern` when repeated `in` patterns but different `if` guard is used. ([@koic][]) +* [#11789](https://github.com/rubocop/rubocop/pull/11789): Fix false negatives for `Style/ParallelAssignment` when Ruby 2.7+. ([@koic][]) +* [#11783](https://github.com/rubocop/rubocop/issues/11783): Fix a false positive for `Style/RedundantLineContinuation` using line concatenation for assigning a return value and without argument parentheses. ([@koic][]) + +## 1.50.0 (2023-04-11) + +### New features + +* [#11749](https://github.com/rubocop/rubocop/pull/11749): Add new `Lint/DuplicateMatchPattern` cop. ([@koic][]) +* [#11773](https://github.com/rubocop/rubocop/pull/11773): Make `Layout/ClassStructure` aware of singleton class. ([@koic][]) +* [#11779](https://github.com/rubocop/rubocop/pull/11779): Make `Lint/RedundantStringCoercion` aware of print method arguments. ([@koic][]) +* [#11776](https://github.com/rubocop/rubocop/pull/11776): Make `Metrics/ClassLength` aware of singleton class. ([@koic][]) +* [#11775](https://github.com/rubocop/rubocop/pull/11775): Make `Style/TrailingBodyOnClass` aware of singleton class. ([@koic][]) + +### Bug fixes + +* [#11758](https://github.com/rubocop/rubocop/issues/11758): Fix a false positive for `Style/RedundantLineContinuation` when line continuations for string. ([@koic][]) +* [#11754](https://github.com/rubocop/rubocop/pull/11754): Fix a false positive for `Style/RedundantLineContinuation` when using `&&` and `||` with a multiline condition. ([@ydah][]) +* [#11765](https://github.com/rubocop/rubocop/issues/11765): Fix an error for `Style/MultilineMethodSignature` when line break after `def` keyword. ([@koic][]) +* [#11762](https://github.com/rubocop/rubocop/issues/11762): Fix an incorrect autocorrect for `Style/ClassEqualityComparison` when comparing a variable or return value for equality. ([@koic][]) +* [#11752](https://github.com/rubocop/rubocop/pull/11752): Fix a false positive for `Style/RedundantLineContinuation` when using line concatenation and calling a method without parentheses. ([@koic][]) + +## 1.49.0 (2023-04-03) + +### New features + +* [#11122](https://github.com/rubocop/rubocop/issues/11122): Add new `Style/RedundantLineContinuation` cop. ([@ydah][]) +* [#11696](https://github.com/rubocop/rubocop/issues/11696): Add new `Style/DataInheritance` cop. ([@ktopolski][]) +* [#11746](https://github.com/rubocop/rubocop/pull/11746): Make `Layout/EndAlignment` aware of pattern matching. ([@koic][]) +* [#11750](https://github.com/rubocop/rubocop/pull/11750): Make `Metrics/BlockNesting` aware of numbered parameter. ([@koic][]) +* [#11699](https://github.com/rubocop/rubocop/issues/11699): Make `Style/ClassEqualityComparison` aware of `Class#to_s` and `Class#inspect` for class equality comparison. ([@koic][]) +* [#11737](https://github.com/rubocop/rubocop/pull/11737): Make `Style/MapToHash` and `Style/MapToSet` aware of numbered parameters. ([@koic][]) +* [#11732](https://github.com/rubocop/rubocop/issues/11732): Make `Style/MapToHash` and `Style/MapToSet` aware of symbol proc. ([@koic][]) +* [#11703](https://github.com/rubocop/rubocop/pull/11703): Make `Naming/InclusiveLanguage` support autocorrection when there is only one suggestion. ([@koic][]) + +### Bug fixes + +* [#11730](https://github.com/rubocop/rubocop/issues/11730): Fix an error for `Layout/HashAlignment` when using anonymous keyword rest arguments. ([@koic][]) +* [#11704](https://github.com/rubocop/rubocop/issues/11704): Fix a false positive for `Lint/UselessMethodDefinition` when method definition with non access modifier containing only `super` call. ([@koic][]) +* [#11723](https://github.com/rubocop/rubocop/issues/11723): Fix a false positive for `Style/IfUnlessModifier` when using one-line pattern matching as a `if` condition. ([@koic][]) +* [#11725](https://github.com/rubocop/rubocop/issues/11725): Fix an error when insufficient permissions to server cache dir are granted. ([@koic][]) +* [#11715](https://github.com/rubocop/rubocop/issues/11715): Ensure default configuration loads. ([@koic][]) +* [#11742](https://github.com/rubocop/rubocop/pull/11742): Fix error handling in bundler standalone mode. ([@composerinteralia][]) +* [#11712](https://github.com/rubocop/rubocop/pull/11712): Fix a crash in `Lint/EmptyConditionalBody`. ([@gsamokovarov][]) +* [#11641](https://github.com/rubocop/rubocop/issues/11641): Fix a false negative for `Layout/ExtraSpacing` when there are many comments with extra spaces. ([@nobuyo][]) +* [#11740](https://github.com/rubocop/rubocop/pull/11740): Fix a false positive for `Lint/NestedMethodDefinition` when nested definition inside `*_eval` and `*_exec` method call with a numblock. ([@ydah][]) +* [#11685](https://github.com/rubocop/rubocop/issues/11685): Fix incorrect directive comment insertion when percent array violates `Layout/LineLength` cop. ([@nobuyo][]) +* [#11706](https://github.com/rubocop/rubocop/issues/11706): Fix infinite loop when `--disable-uncorrectable` option and there is a multi-line percent array violates `Layout/LineLength`. ([@nobuyo][]) +* [#11697](https://github.com/rubocop/rubocop/issues/11697): Fix `Lint/Syntax` behavior when `--only` is not given the cop name. ([@koic][]) +* [#11709](https://github.com/rubocop/rubocop/pull/11709): Fix value omission false positive in `Style/MethodCallWithArgsParentheses`. ([@gsamokovarov][]) + +### Changes + +* [#11739](https://github.com/rubocop/rubocop/pull/11739): Make `Style/RedundantParentheses` aware of redundant method argument parentheses. ([@koic][]) +* [#10766](https://github.com/rubocop/rubocop/issues/10766): Use the path given by `--cache-root` to be the parent for `rubocop_cache` dir like other ways to specify it. ([@nobuyo][]) + +## 1.48.1 (2023-03-13) + +### Bug fixes + +* [#11673](https://github.com/rubocop/rubocop/pull/11673): Fix incorrect `Style/HashSyntax` autocorrection for assignment methods. ([@gsamokovarov][]) +* [#11682](https://github.com/rubocop/rubocop/issues/11682): Fix a false positive for `Lint/UselessRescue` when using `Thread#raise` in `rescue` clause. ([@koic][]) +* [#11672](https://github.com/rubocop/rubocop/issues/11672): Fix an error for `Layout/BlockEndNewline` when multiline block `}` is not on its own line and it is used as multiple arguments. ([@koic][]) +* [#11675](https://github.com/rubocop/rubocop/pull/11675): `Style/AccessorGrouping`: Fix sibling detection for methods with type sigs. ([@issyl0][]) +* [#11658](https://github.com/rubocop/rubocop/issues/11658): Fix `Lint/Debugger` should not allow pry. ([@ThHareau][]) +* [#11689](https://github.com/rubocop/rubocop/pull/11689): Fix `Lint/Syntax` behavior when `Enabled: false` of `Lint` department. ([@koic][]) +* [#11677](https://github.com/rubocop/rubocop/issues/11677): Fix the severity for `Lint/Syntax`. ([@koic][]) +* [#11691](https://github.com/rubocop/rubocop/pull/11691): Fix an error for `Gemspec/DependencyVersion` when method called on gem name argument for `add_dependency`. ([@koic][]) + +## 1.48.0 (2023-03-06) + +### New features + +* [#11628](https://github.com/rubocop/rubocop/issues/11628): Add new `Style/DirEmpty` cop. ([@ydah][]) +* [#11629](https://github.com/rubocop/rubocop/issues/11629): Add new `Style/FileEmpty` cop. ([@ydah][]) + +### Bug fixes + +* [#11654](https://github.com/rubocop/rubocop/pull/11654): Fix a false positive for `Lint/MissingSuper` when no `super` call and when defining some method. ([@koic][]) +* [#11661](https://github.com/rubocop/rubocop/pull/11661): Fix an error for `Style/Documentation` when namespace is a variable. ([@koic][]) +* [#11647](https://github.com/rubocop/rubocop/pull/11647): Fix an error for `Style/IfWithBooleanLiteralBranches` when using `()` as a condition. ([@koic][]) +* [#11646](https://github.com/rubocop/rubocop/pull/11646): Fix an error for `Style/NegatedIfElseCondition` when using `()` as a condition. ([@koic][]) +* [#11659](https://github.com/rubocop/rubocop/pull/11659): Fix an incorrect autocorrect for `Lint/OrAssignmentToConstant` when using or-assignment to a constant in method definition. ([@koic][]) +* [#11663](https://github.com/rubocop/rubocop/issues/11663): Fix an incorrect autocorrect for `Style/BlockDelimiters` when multi-line blocks to `{` and `}` with arithmetic operation method chain. ([@koic][]) +* [#11638](https://github.com/rubocop/rubocop/pull/11638): Fix a false positive for `Lint/UselessAccessModifier` when using same access modifier inside and outside the `included` block. ([@ydah][]) +* [#11164](https://github.com/rubocop/rubocop/issues/11164): Suppress server mode message with `-f json`. ([@jasondoc3][]) +* [#11643](https://github.com/rubocop/rubocop/pull/11643): Fix incorrect shorthand autocorrections in calls inside parentheses. ([@gsamokovarov][]) +* [#11650](https://github.com/rubocop/rubocop/pull/11650): `Style/AccessorGrouping`: Fix detection of Sorbet `sig {}` blocks. ([@issyl0][]) +* [#11657](https://github.com/rubocop/rubocop/issues/11657): Use cop name to check if cop inside registry is enabled. Previously, it was able to cause large memory usage during linting. ([@fatkodima][]) + +### Changes + +* [#11482](https://github.com/rubocop/rubocop/issues/11482): Avoid comment deletion by `Style/IfUnlessModifier` when the modifier form expression has long comment. ([@nobuyo][]) +* [#11649](https://github.com/rubocop/rubocop/issues/11649): Support `MinBranchesCount` config for `Style/CaseLikeIf` cop. ([@fatkodima][]) + +## 1.47.0 (2023-03-01) + +### New features + +* [#11475](https://github.com/rubocop/rubocop/pull/11475): Add autocorrect for hash in `Lint/LiteralInInterpolation`. ([@KessaPassa][]) +* [#11584](https://github.com/rubocop/rubocop/pull/11584): Add `Metrics/CollectionLiteralLength` cop. ([@sambostock][]) + +### Bug fixes + +* [#11615](https://github.com/rubocop/rubocop/issues/11615): Fix a false negative for `Lint/MissingSuper` when no `super` call with `Class.new` block. ([@koic][]) +* [#11615](https://github.com/rubocop/rubocop/issues/11615): Fix a false negative for `Lint/MissingSuper` when using `Class.new` without parent class argument. ([@koic][]) +* [#11040](https://github.com/rubocop/rubocop/issues/11040): Fix a false positive for `Style/IfUnlessModifier` when `defined?`'s argument value is undefined. ([@koic][]) +* [#11607](https://github.com/rubocop/rubocop/issues/11607): Fix a false positive for `Style/RedundantRegexpEscape` when an escaped hyphen follows after an escaped opening square bracket within a character class. ([@SparLaimor][]) +* [#11626](https://github.com/rubocop/rubocop/issues/11626): Fix a false positive for `Style/ZeroLengthPredicate` when using `File.new(path).size.zero?`. ([@koic][]) +* [#11620](https://github.com/rubocop/rubocop/pull/11620): Fix an error for `Lint/ConstantResolution` when using `__ENCODING__`. ([@koic][]) +* [#11625](https://github.com/rubocop/rubocop/pull/11625): Fix an error for `Lint/EmptyConditionalBody` when missing `if` body and using method call for return value. ([@koic][]) +* [#11631](https://github.com/rubocop/rubocop/issues/11631): Fix an incorrect autocorrect for `Style/ArgumentsForwarding` when using arguments forwarding for `.()` call. ([@koic][]) +* [#11621](https://github.com/rubocop/rubocop/issues/11621): Fix an incorrect autocorrect for `Layout/ClassStructure` using heredoc inside method. ([@fatkodima][]) +* [#3591](https://github.com/rubocop/rubocop/issues/3591): Handle modifier `while` and `until` expressions in `Lint/UselessAssignment`. ([@bfad][]) +* [#11202](https://github.com/rubocop/rubocop/issues/11202): Fixed usage of `--only` flag with `--auto-gen-config`. ([@istvanfazakas][]) + +### Changes + +* [#11623](https://github.com/rubocop/rubocop/pull/11623): Add rubocop-capybara to suggested extensions and extension doc. ([@ydah][]) + +## 1.46.0 (2023-02-22) + +### New features + +* [#11569](https://github.com/rubocop/rubocop/pull/11569): Support `TargetRubyVersion 3.3` (experimental). ([@koic][]) + +### Bug fixes + +* [#11574](https://github.com/rubocop/rubocop/pull/11574): Fix a broken shorthand syntax autocorrection. ([@gsamokovarov][]) +* [#11599](https://github.com/rubocop/rubocop/pull/11599): Fix a false positive for `Layout/LineContinuationSpacing` when using percent literals. ([@koic][]) +* [#11556](https://github.com/rubocop/rubocop/issues/11556): Fix a false positive for `Lint/Debugger` when `p` is an argument of method call. ([@koic][]) +* [#11591](https://github.com/rubocop/rubocop/issues/11591): Fix a false positive for `Lint/ToEnumArguments` when enumerator is not created for `__callee__` and `__callee__` methods. ([@koic][]) +* [#11603](https://github.com/rubocop/rubocop/pull/11603): Actually run temporarily enabled cops. ([@tdeo][]) +* [#11579](https://github.com/rubocop/rubocop/pull/11579): Fix an error for `Layout/HeredocArgumentClosingParenthesis` when heredoc is a method argument in a parenthesized block argument. ([@koic][]) +* [#11576](https://github.com/rubocop/rubocop/pull/11576): Fix an error for `Lint/UselessRescue` when `rescue` does not exception variable and `ensure` has empty body. ([@koic][]) +* [#11608](https://github.com/rubocop/rubocop/pull/11608): Fix an error for `Lint/RefinementImportMethods` when using `include` on the top level. ([@koic][]) +* [#11589](https://github.com/rubocop/rubocop/pull/11589): Fix an error for `Layout/HeredocArgumentClosingParenthesis` when heredoc is a branch body in a method argument of a parenthesized argument. ([@koic][]) +* [#11567](https://github.com/rubocop/rubocop/issues/11567): Fix `Layout/EndAlignment` false negative. ([@j-miyake][]) +* [#11582](https://github.com/rubocop/rubocop/issues/11582): Fix checking if token with large offset begins its line. ([@fatkodima][]) +* [#11412](https://github.com/rubocop/rubocop/issues/11412): Mark `Style/ArrayIntersect` as unsafe. ([@koic][]) +* [#11559](https://github.com/rubocop/rubocop/pull/11559): Fixed false positives and negatives in `Style/RedundantRegexpCharacterClass` when using octal escapes (e.g. "\0"). ([@jaynetics][]) +* [#11575](https://github.com/rubocop/rubocop/pull/11575): Fix parentheses in value omissions for multiple assignments. ([@gsamokovarov][]) + +### Changes + +* [#11586](https://github.com/rubocop/rubocop/issues/11586): Handle `ruby2_keywords` in `Style/DocumentationMethod` cop. ([@fatkodima][]) +* [#11604](https://github.com/rubocop/rubocop/issues/11604): Make `Naming/VariableNumber` to allow `x86_64` CPU architecture name by default. ([@koic][]) +* [#11596](https://github.com/rubocop/rubocop/issues/11596): Make `Style/AccessorGrouping` aware of method call before accessor. ([@koic][]) +* [#11588](https://github.com/rubocop/rubocop/pull/11588): Optimize `Style/WordArray` complex matrix check. ([@sambostock][]) +* [#11573](https://github.com/rubocop/rubocop/pull/11573): Handle hash patterns and pins in `Lint/OutOfRangeRegexpRef` cop. ([@fatkodima][]) +* [#11564](https://github.com/rubocop/rubocop/pull/11564): Remove print debug methods from default for `Lint/Debugger`. ([@koic][]) + +## 1.45.1 (2023-02-08) + +### Bug fixes + +* [#11552](https://github.com/rubocop/rubocop/pull/11552): Fix a false positive for `Lint/Debugger` when methods containing different method chains. ([@ydah][]) +* [#11548](https://github.com/rubocop/rubocop/pull/11548): Fix an error for `Style/AccessModifierDeclarations` when if a non method definition was included. ([@ydah][]) +* [#11554](https://github.com/rubocop/rubocop/issues/11554): Fix an error for `Style/RedundantCondition` when the branches contains empty hash literal argument. ([@koic][]) +* [#11549](https://github.com/rubocop/rubocop/issues/11549): Fix an error for third party cops when inheriting `RuboCop::Cop::Cop`. ([@koic][]) + +## 1.45.0 (2023-02-08) + +### New features + +* [#10839](https://github.com/rubocop/rubocop/pull/10839): Add API for 3rd party template support. ([@r7kamura][]) +* [#11528](https://github.com/rubocop/rubocop/pull/11528): Add new `Style/RedundantHeredocDelimiterQuotes` cop. ([@koic][]) +* [#11188](https://github.com/rubocop/rubocop/issues/11188): Add a `--no-detach` option for `--start-server`. This will start the server process in the foreground, which can be helpful when running within Docker where detaching the process terminates the container. ([@f1sherman][]) +* [#11546](https://github.com/rubocop/rubocop/pull/11546): Make `Lint/UselessAccessModifier` aware of Ruby 3.2's `Data.define`. ([@koic][]) +* [#11396](https://github.com/rubocop/rubocop/pull/11396): Add ability to profile rubocop execution via `--profile` and `--memory` options. ([@fatkodima][]) + +### Bug fixes + +* [#11491](https://github.com/rubocop/rubocop/pull/11491): Fix a crash on `Lint/UselessAssignment`. ([@gsamokovarov][]) +* [#11515](https://github.com/rubocop/rubocop/pull/11515): Fix a false negative for `Naming/HeredocDelimiterNaming` when using lowercase. ([@koic][]) +* [#11511](https://github.com/rubocop/rubocop/issues/11511): Fix a false negative for `Style/YodaCondition` when using constant. ([@koic][]) +* [#11520](https://github.com/rubocop/rubocop/pull/11520): Fix a false negative for `Style/YodaExpression` when using constant. ([@koic][]) +* [#11521](https://github.com/rubocop/rubocop/issues/11521): Fix a false positive for `Lint/FormatParameterMismatch` when using `Kernel.format` with the interpolated number of decimal places fields match. ([@koic][]) +* [#11545](https://github.com/rubocop/rubocop/pull/11545): Fix the following false positive for `Lint/NestedMethodDefinition` when using numbered parameter. ([@koic][]) +* [#11535](https://github.com/rubocop/rubocop/issues/11535): Fix a false positive for `Style/NumberedParametersLimit` when only `_2` or higher numbered parameter is used. ([@koic][]) +* [#11508](https://github.com/rubocop/rubocop/issues/11508): Fix a false positive for `Style/OperatorMethodCall` when using multiple arguments for operator method. ([@koic][]) +* [#11503](https://github.com/rubocop/rubocop/issues/11503): Fix a false positive for `Style/RedundantCondition` when using method argument with operator. ([@koic][]) +* [#11529](https://github.com/rubocop/rubocop/pull/11529): Fix an incorrect autocorrect for `Layout/ClassStructure` when definitions that need to be sorted are defined alternately. ([@ydah][]) +* [#11530](https://github.com/rubocop/rubocop/pull/11530): Fix an incorrect autocorrect for `Style/AccessModifierDeclarations` when multiple groupable access modifiers are defined. ([@ydah][]) +* [#10910](https://github.com/rubocop/rubocop/pull/10910): Fix an incorrect autocorrect for `Style/MultilineTernaryOperator` when contains a comment. ([@ydah][]) +* [#11522](https://github.com/rubocop/rubocop/pull/11522): Don't flag default keyword arguments in `Style/ArgumentsForwarding`. ([@splattael][]) +* [#11547](https://github.com/rubocop/rubocop/pull/11547): Fix a false positive for `Lint/NestedMethodDefinition` when using Ruby 3.2's `Data.define`. ([@koic][]) +* [#11537](https://github.com/rubocop/rubocop/pull/11537): Fix an infinite loop error for `Layout/ArrayAlignment` when using assigning unbracketed array elements. ([@koic][]) +* [#11516](https://github.com/rubocop/rubocop/pull/11516): Fix missing parentheses in shorthand hash syntax as argument calls. ([@gsamokovarov][]) + +### Changes + +* [#11504](https://github.com/rubocop/rubocop/issues/11504): Allow `initialize` method in `Style/DocumentationMethod`. ([@koic][]) +* [#11541](https://github.com/rubocop/rubocop/pull/11541): Enable autocorrection for `Layout/LineContinuationLeadingSpace`. ([@eugeneius][]) +* [#11542](https://github.com/rubocop/rubocop/pull/11542): Mark `Layout/AssignmentIndentation` as safe and `Lint/AssignmentInCondition` as unsafe for autocorrection. ([@eugeneius][]) +* [#11517](https://github.com/rubocop/rubocop/issues/11517): Make `Lint/Debugger` aware of `p`, `PP.pp`, and `pp` methods. ([@koic][]) +* [#11539](https://github.com/rubocop/rubocop/pull/11539): Remove `bundler` from default `AllowedGems` of `Gemspec/DevelopmentDependencies`. ([@koic][]) + +## 1.44.1 (2023-01-25) + +### Bug fixes + +* [#11492](https://github.com/rubocop/rubocop/issues/11492): Fix an error for `Lint/Void` when configuring `CheckForMethodsWithNoSideEffects: true`. ([@koic][]) +* [#11400](https://github.com/rubocop/rubocop/issues/11400): Fix an incorrect autocorrect for `Naming/BlockForwarding` and `Lint/AmbiguousOperator` when autocorrection conflicts for ambiguous splat argument. ([@fatkodima][]) +* [#11483](https://github.com/rubocop/rubocop/issues/11483): Fix `Layout/ClosingParenthesisIndentation` for keyword splat arguments. ([@fatkodima][]) +* [#11487](https://github.com/rubocop/rubocop/pull/11487): Fix a false positive for `Lint/FormatParameterMismatch` when format string is only interpolated string. ([@ydah][]) +* [#11485](https://github.com/rubocop/rubocop/issues/11485): Fix a false positive for `Lint/UselessAssignment` when using numbered block parameter. ([@koic][]) + +## 1.44.0 (2023-01-23) + +### New features + +* [#11410](https://github.com/rubocop/rubocop/issues/11410): Add new `Style/InvertibleUnlessCondition` cop. ([@fatkodima][]) +* [#11338](https://github.com/rubocop/rubocop/issues/11338): Add new `Style/ComparableClamp` cop. ([@koic][]) +* [#11350](https://github.com/rubocop/rubocop/issues/11350): Make `Lint/DeprecatedClassMethods` aware of deprecated `attr` with boolean 2nd argument. ([@koic][]) +* [#11457](https://github.com/rubocop/rubocop/pull/11457): Make `Metrics/BlockNesting` aware of pattern matching. ([@koic][]) +* [#11458](https://github.com/rubocop/rubocop/pull/11458): Make `Metrics/CyclomaticComplexity` aware of pattern matching. ([@koic][]) +* [#11469](https://github.com/rubocop/rubocop/pull/11469): Add `Gemspec/DevelopmentDependencies` cop. ([@sambostock][]) + +### Bug fixes + +* [#11445](https://github.com/rubocop/rubocop/issues/11445): Fix an incorrect autocorrect for `Style/BlockDelimiters` when there is a comment after the closing brace and bracket. ([@koic][]) +* [#11428](https://github.com/rubocop/rubocop/pull/11428): Apply value omission exceptions in super invocations. ([@gsamokovarov][]) +* [#11420](https://github.com/rubocop/rubocop/issues/11420): Fix a false positive for `Lint/UselessRescue` when using exception variable in `ensure` clause. ([@koic][]) +* [#11460](https://github.com/rubocop/rubocop/issues/11460): Fix an error for `Style/OperatorMethodCall` when using `foo.> 42`. ([@koic][]) +* [#11456](https://github.com/rubocop/rubocop/pull/11456): Fix value omissions in `yield` invocations. ([@gsamokovarov][]) +* [#11467](https://github.com/rubocop/rubocop/issues/11467): Fix a false negative for `Style/MethodCallWithoutArgsParentheses` when calling method on a receiver and assigning to a variable with the same name. ([@koic][]) +* [#11430](https://github.com/rubocop/rubocop/issues/11430): Fix an infinite loop error for `Layout/BlockEndNewline` when multiline blocks with newlines before the `; end`. ([@koic][]) +* [#11442](https://github.com/rubocop/rubocop/pull/11442): Fix a crash during anonymous rest argument forwarding. ([@gsamokovarov][]) +* [#11447](https://github.com/rubocop/rubocop/pull/11447): Fix an incorrect autocorrect for `Style/RedundantDoubleSplatHashBraces` when using nested double splat hash braces. ([@koic][]) +* [#11459](https://github.com/rubocop/rubocop/pull/11459): Make `Lint/UselessRuby2Keywords` aware of conditions. ([@splattael][]) +* [#11415](https://github.com/rubocop/rubocop/issues/11415): Fix a false positive for `Lint/UselessMethodDefinition` when method definition contains rest arguments. ([@koic][]) +* [#11418](https://github.com/rubocop/rubocop/issues/11418): Fix a false positive for `Style/MethodCallWithArgsParentheses` when using anonymous rest arguments or anonymous keyword rest arguments. ([@koic][]) +* [#11431](https://github.com/rubocop/rubocop/pull/11431): Fix a crash in `Style/HashSyntax`. ([@gsamokovarov][]) +* [#11444](https://github.com/rubocop/rubocop/issues/11444): Fix a false positive for `Lint/ShadowingOuterLocalVariable` when using numbered block parameter. ([@koic][]) +* [#11477](https://github.com/rubocop/rubocop/issues/11477): Fix an error when using YAML alias with server mode. ([@koic][]) +* [#11419](https://github.com/rubocop/rubocop/issues/11419): Fix a false positive for `Lint/RedundantRequireStatement` when using `pretty_inspect`. ([@koic][]) +* [#11439](https://github.com/rubocop/rubocop/issues/11439): Fix an incorrect autocorrect for `Style/MinMaxComparison` when using `a < b a : b` with `elsif/else`. ([@ydah][]) +* [#11464](https://github.com/rubocop/rubocop/pull/11464): Fix a false negative for `Lint/FormatParameterMismatch` when include interpolated string. ([@ydah][]) +* [#11425](https://github.com/rubocop/rubocop/pull/11425): Fix a false negative for `Lint/Void` when using methods that takes blocks. ([@krishanbhasin-shopify][]) +* [#11437](https://github.com/rubocop/rubocop/pull/11437): Fix an error for `Style/AccessModifierDeclarations` when access modifier is inlined with a method on the top level. ([@koic][]) +* [#11455](https://github.com/rubocop/rubocop/pull/11455): Fix crash with `super value_omission:` followed by a method call. ([@gsamokovarov][]) + +### Changes + +* [#11465](https://github.com/rubocop/rubocop/pull/11465): Make `Style/Semicolon` aware of redundant semicolon in block. ([@koic][]) +* [#11471](https://github.com/rubocop/rubocop/pull/11471): Change to not output not configured warning when renamed and pending cop. ([@ydah][]) + +## 1.43.0 (2023-01-10) + +### New features + +* [#11359](https://github.com/rubocop/rubocop/issues/11359): Add new `Lint/UselessRescue` cop. ([@fatkodima][]) +* [#11389](https://github.com/rubocop/rubocop/pull/11389): Add autocorrect for `Style/MissingElse`. ([@FnControlOption][]) + +### Bug fixes + +* [#11386](https://github.com/rubocop/rubocop/pull/11386): Fix a false positive for `Style/OperatorMethodCall` when using anonymous forwarding. ([@koic][]) +* [#11409](https://github.com/rubocop/rubocop/issues/11409): Fix an incorrect autocorrect for `Style/HashSyntax` when using hash value omission and `EnforcedStyle: no_mixed_keys`. ([@koic][]) +* [#11405](https://github.com/rubocop/rubocop/issues/11405): Fix undefined method `range_between' for `Style/WhileUntilModifier`. ([@such][]) +* [#11374](https://github.com/rubocop/rubocop/pull/11374): Fix an error for `Style/StringHashKeys` when using invalid symbol in encoding UTF-8 as keys. ([@koic][]) +* [#11392](https://github.com/rubocop/rubocop/pull/11392): Fix an incorrect autocorrect for `Style/RedundantDoubleSplatHashBraces` using double splat in double splat hash braces. ([@koic][]) +* [#8990](https://github.com/rubocop/rubocop/issues/8990): Make `Style/HashEachMethods` aware of built-in `Thread.current`. ([@koic][]) +* [#11390](https://github.com/rubocop/rubocop/issues/11390): Fix an incorrect autocorrect for `Style/HashSyntax` when hash first argument key and hash value only are the same which has a method call on the next line. ([@koic][]) +* [#11379](https://github.com/rubocop/rubocop/pull/11379): Fix a false negative for `Style/OperatorMethodCall` when using `a.+ b.something`. ([@koic][]) +* [#11180](https://github.com/rubocop/rubocop/issues/11180): Fix an error for `Style/RedundantRegexpEscape` when using `%r` to provide regexp expressions. ([@si-lens][]) +* [#11403](https://github.com/rubocop/rubocop/pull/11403): Fix bad offense for parenthesised calls in literals for `omit_parentheses` style in `Style/MethodCallWithArgsParentheses`. ([@gsamokovarov][]) +* [#11407](https://github.com/rubocop/rubocop/pull/11407): Fix an error for `Style/HashSyntax` when expression follows hash key assignment. ([@fatkodima][]) +* [#11377](https://github.com/rubocop/rubocop/issues/11377): Fix `Style/OperatorMethodCall` when forwarding arguments. ([@sambostock][]) + +### Changes + +* [#11382](https://github.com/rubocop/rubocop/pull/11382): Require `unicode-display_width` 2.4.0 or higher. ([@fatkodima][]) +* [#11381](https://github.com/rubocop/rubocop/pull/11381): Require Parser 3.2.0.0 or higher. ([@koic][]) +* [#11380](https://github.com/rubocop/rubocop/pull/11380): Disable `Style/YodaExpression` by default. ([@koic][]) +* [#11303](https://github.com/rubocop/rubocop/issues/11303): Make `Metrics/ParameterLists` aware of `Struct.new` and `Data.define` blocks. ([@koic][]) + +## 1.42.0 (2023-01-01) + +### New features + +* [#11339](https://github.com/rubocop/rubocop/issues/11339): Add new `Style/MapToSet` cop. ([@koic][]) +* [#11341](https://github.com/rubocop/rubocop/pull/11341): Add new `Style/MinMaxComparison` cop. ([@koic][]) +* [#9222](https://github.com/rubocop/rubocop/issues/9222): Add new `Style/YodaExpression` cop. ([@fatkodima][]) +* [#11261](https://github.com/rubocop/rubocop/pull/11261): Allow inherit_from to accept a glob. ([@alexevanczuk][]) + +### Bug fixes + +* [#11204](https://github.com/rubocop/rubocop/issues/11204): Fix a false negative for `Lint/RedundantCopDisableDirective` when using `--except` command line option. ([@koic][]) +* [#11369](https://github.com/rubocop/rubocop/pull/11369): Fix an error for `Lint/UselessRuby2Keywords` when using `Proc#ruby2_keywords`. ([@koic][]) +* [#11351](https://github.com/rubocop/rubocop/pull/11351): Fix an incorrect autocorrect for `Lint/RegexpAsCondition` when using regexp literal with bang. ([@koic][]) +* [#11329](https://github.com/rubocop/rubocop/pull/11329): Accept simple freezed constants in `Layout/ClassStructure` and correctly handle class methods. ([@fatkodima][]) +* [#11344](https://github.com/rubocop/rubocop/pull/11344): Fix an error for `Style/GuardClause` when using heredoc as an argument of raise in `then` branch and it does not have `else` branch. ([@koic][]) +* [#11335](https://github.com/rubocop/rubocop/pull/11335): Fix an error for `Style/RequireOrder` when only one `require`. ([@koic][]) +* [#11348](https://github.com/rubocop/rubocop/pull/11348): Fix an error for `Style/SelectByRegexp` when block body is empty. ([@koic][]) +* [#11320](https://github.com/rubocop/rubocop/issues/11320): Fix a false positive for `Lint/RequireParentheses` when assigning ternary operator. ([@koic][]) +* [#11361](https://github.com/rubocop/rubocop/issues/11361): Make `Style/MethodDefParentheses` aware of Ruby 3.2's anonymous rest and keyword rest arguments. ([@koic][]) +* [#11346](https://github.com/rubocop/rubocop/issues/11346): Fix a false positive for `Style/RedundantStringEscape` when using escaped space in heredoc. ([@koic][]) +* [#10858](https://github.com/rubocop/rubocop/issues/10858): Fix `Style/IdenticalConditionalBranches` to ignore identical leading lines when branch has single child and is used in return context. ([@fatkodima][]) +* [#11237](https://github.com/rubocop/rubocop/issues/11237): Fix `Layout/CommentIndentation` comment aligned with access modifier indentation when EnforcedStyle is outdent. ([@soroktree][]) +* [#11330](https://github.com/rubocop/rubocop/pull/11330): Fix an error for `Style/RequireOrder` when using `require` inside `rescue` body. ([@fatkodima][]) +* [#8751](https://github.com/rubocop/rubocop/issues/8751): Accept `super` within ranges for `Layout/SpaceAroundKeyword` cop. ([@fatkodima][]) +* [#10194](https://github.com/rubocop/rubocop/issues/10194): Accept bracketed arrays within 2d arrays containing subarrays with complex content for `Style/WordArray` cop. ([@fatkodima][]) + +### Changes + +* [#8366](https://github.com/rubocop/rubocop/issues/8366): Ignore private constants in `Layout/ClassStructure` cop. ([@fatkodima][]) +* [#11325](https://github.com/rubocop/rubocop/issues/11325): Support autocorrection for percent literals in `Style/ConcatArrayLiterals`. ([@fatkodima][]) +* [#11327](https://github.com/rubocop/rubocop/pull/11327): Make `Style/ZeroLengthPredicate` aware of `array.length.zero?`. ([@koic][]) +* [#10976](https://github.com/rubocop/rubocop/issues/10976): Support pattern matching for `Lint/OutOfRangeRegexpRef` cop. ([@fatkodima][]) + +## 1.41.1 (2022-12-22) + +### Bug fixes + +* [#11293](https://github.com/rubocop/rubocop/issues/11293): Fix a false negative for `Style/Documentation` when using macro. ([@koic][]) +* [#11313](https://github.com/rubocop/rubocop/issues/11313): Fix a false positive for `Naming/BlockForwarding` when the block argument is reassigned. ([@fatkodima][]) +* [#11014](https://github.com/rubocop/rubocop/pull/11014): Fix a false positive for `Style/Alias`cop when alias in a method def. ([@ydah][]) +* [#11309](https://github.com/rubocop/rubocop/issues/11309): Fix a false positive for `Style/RedundantStringEscape` when using a redundant escaped string interpolation `\#\{foo}`. ([@koic][]) +* [#11307](https://github.com/rubocop/rubocop/pull/11307): Fix an error for `Style/GuardClause` when using lvar as an argument of raise in `else` branch. ([@ydah][]) +* [#11308](https://github.com/rubocop/rubocop/issues/11308): Fix disabling departments via comment. ([@fatkodima][]) + +### Changes + +* [#11312](https://github.com/rubocop/rubocop/issues/11312): Mark `Style/ConcatArrayLiterals` as unsafe. ([@koic][]) + +## 1.41.0 (2022-12-20) + +### New features + +* [#11305](https://github.com/rubocop/rubocop/pull/11305): Add new `Style/RedundantDoubleSplatHashBraces` cop. ([@koic][]) +* [#10812](https://github.com/rubocop/rubocop/pull/10812): New AllowMultilineFinalElement option for all LineBreaks cops. ([@Korri][]) +* [#11277](https://github.com/rubocop/rubocop/issues/11277): Add new `Style/ConcatArrayLiterals` cop. ([@koic][]) + +### Bug fixes + +* [#11255](https://github.com/rubocop/rubocop/pull/11255): Fix an error for `Style/RequireOrder` when `require` with no arguments is put between `require`. ([@ydah][]) +* [#11273](https://github.com/rubocop/rubocop/issues/11273): Fix a false positive for `Lint/DuplicateMethods` when there are same `alias_method` name outside `rescue` or `ensure` scopes. ([@koic][]) +* [#11267](https://github.com/rubocop/rubocop/issues/11267): Fix an error for `Style/RequireOrder` when modifier conditional is used between `require`. ([@ydah][]) +* [#11254](https://github.com/rubocop/rubocop/pull/11254): Fix an error for `Style/RequireOrder` when `require` is a method argument. ([@koic][]) +* [#11266](https://github.com/rubocop/rubocop/issues/11266): Fix a false positive for `Style/RedundantConstantBase` when enabling `Lint/ConstantResolution`. ([@koic][]) +* [#11296](https://github.com/rubocop/rubocop/pull/11296): Fix an error for `Lint/NonAtomicFileOperation` when use file existence checks line break `unless` by postfix before creating file. ([@koic][]) +* [#11284](https://github.com/rubocop/rubocop/issues/11284): Fix an incorrect autocorrect for `Style/WordArray` when assigning `%w()` array. ([@koic][]) +* [#11299](https://github.com/rubocop/rubocop/pull/11299): Fix `base_dir` in `TargetFinder#find_files()`. ([@dukaev][]) +* [#11250](https://github.com/rubocop/rubocop/pull/11250): Fix an error for `Style/GuardClause` when a method call whose last argument is not a string is in the condition body. ([@ydah][]) +* [#11298](https://github.com/rubocop/rubocop/issues/11298): Fix `Lint/SafeNavigationChain` to correctly handle `[]` operator followed by save navigation and method chain. ([@fatkodima][]) +* [#11256](https://github.com/rubocop/rubocop/issues/11256): Fix an incorrect autocorrect for `Style/HashSyntax` when without parentheses call expr follows after multiple keyword arguments method call. ([@koic][]) +* [#11289](https://github.com/rubocop/rubocop/pull/11289): Correctly detect Rails version when using only parts of the framework, instead of the "rails" gem. ([@bdewater][]) +* [#11262](https://github.com/rubocop/rubocop/pull/11262): Fix an error for `Style/IfUnlessModifier` when the body is a method call with hash splat. ([@fatkodima][]) +* [#11281](https://github.com/rubocop/rubocop/pull/11281): Fix `NoMethodError` for `Style/Documentation` when a class nested under non-constant values. ([@arika][]) + +### Changes + +* [#11306](https://github.com/rubocop/rubocop/pull/11306): Make `Style/IfWithSemicolon` aware of one line without `else` body. ([@koic][]) + +## 1.40.0 (2022-12-08) + +### New features + +* [#11179](https://github.com/rubocop/rubocop/pull/11179): Add `Style/RedundantConstantBase` cop. ([@r7kamura][]) +* [#11205](https://github.com/rubocop/rubocop/pull/11205): Add `--[no-]auto-gen-enforced-style` CLI option. ([@ydah][]) +* [#11235](https://github.com/rubocop/rubocop/pull/11235): Add `Style/RequireOrder` cop. ([@r7kamura][]) +* [#11219](https://github.com/rubocop/rubocop/issues/11219): Make `Style/SelectByRegexp` aware of `!~` method. ([@koic][]) +* [#11224](https://github.com/rubocop/rubocop/pull/11224): Add new cop `Style/ArrayIntersect` which replaces `(array1 & array2).any?` with `array1.intersect?(array2)`, method `Array#intersect?` was added in ruby 3.1. ([@KirIgor][]) +* [#11211](https://github.com/rubocop/rubocop/pull/11211): Add autocorrect for `Lint/AssignmentInCondition`. ([@r7kamura][]) + +### Bug fixes + +* [#5251](https://github.com/rubocop/rubocop/issues/5251): Fix loading of configuration in multi-file edge case. ([@NobodysNightmare][]) +* [#11192](https://github.com/rubocop/rubocop/issues/11192): Fix a false positive for `Lint/ParenthesesAsGroupedExpression` when using a block argument. ([@ydah][]) +* [#11143](https://github.com/rubocop/rubocop/issues/11143): Fix RedundantCopDisableDirective errors when encountering several department comments. ([@isarcasm][]) +* [#11230](https://github.com/rubocop/rubocop/issues/11230): Fix an incorrect autocorrect for `Lint/SafeNavigationChain` when using safe navigation with `[]` operator followed by method chain. ([@koic][]) +* [#11181](https://github.com/rubocop/rubocop/pull/11181): Fix pattern to match .tool-versions files that specify multiple runtimes. ([@noelblaschke][]) +* [#11239](https://github.com/rubocop/rubocop/issues/11239): Fix an incorrect autocorrect for `Style/GuardClause` when using heredoc as an argument of raise in branch body. ([@koic][]) +* [#11182](https://github.com/rubocop/rubocop/issues/11182): Fix an incorrect autocorrect for `EnforcedShorthandSyntax: always` of `Style/HashSyntax` with `Style/IfUnlessModifier` when using Ruby 3.1. ([@koic][]) +* [#11184](https://github.com/rubocop/rubocop/issues/11184): Fix an error for `Lint/ShadowingOuterLocalVariable` when a block local variable has same name as an outer `until` scope variable. ([@koic][]) +* [#11198](https://github.com/rubocop/rubocop/pull/11198): Fix an error for `Lint/EmptyConditionalBody` when one using line if/;/end without then body. ([@koic][]) +* [#11196](https://github.com/rubocop/rubocop/issues/11196): Fix a false positive for `Style/GuardClause` when using `raise` in `then` body of `if..elsif..end` form. ([@koic][]) +* [#11213](https://github.com/rubocop/rubocop/pull/11213): Support redundant department disable in scope of `Lint/RedundantCopDisableDirective` cop. ([@isarcasm][]) +* [#11200](https://github.com/rubocop/rubocop/issues/11200): Fix an incorrect autocorrect for `Layout/MultilineMethodCallBraceLayout` when using method chain for heredoc argument in multiline literal brace layout. ([@koic][]) +* [#11190](https://github.com/rubocop/rubocop/pull/11190): Fix an error for `Style/IfWithSemicolon` when using one line if/;/end without then body. ([@koic][]) +* [#11244](https://github.com/rubocop/rubocop/pull/11244): Fix a false negative for `Style/RedundantReturn` when dynamic define methods. ([@ydah][]) + +### Changes + +* [#11218](https://github.com/rubocop/rubocop/pull/11218): Update severity of `Bundler/DuplicatedGem`, `Bundler/InsecureProtocolSource`, `Gemspec/DeprecatedAttributeAssignment`, `Gemspec/DuplicatedAssignment`, `Gemspec/RequireMFA`, `Gemspec/RequiredRubyVersion`, and `Gemspec/RubyVersionGlobalsUsage` cops to warning. ([@koic][]) +* [#11222](https://github.com/rubocop/rubocop/pull/11222): Make `Style/RedundantArgument` aware of `Array#sum`. ([@koic][]) +* [#11070](https://github.com/rubocop/rubocop/issues/11070): Add ability to count method calls as one line to code length related `Metric` cops. ([@fatkodima][]) +* [#11226](https://github.com/rubocop/rubocop/pull/11226): Make `Lint/Void` aware of used lambda and proc in void context. ([@koic][]) +* [#11206](https://github.com/rubocop/rubocop/pull/11206): Change `Lint/InterpolationCheck` from `Safe: false` to `SafeAutoCorrect: false`. ([@r7kamura][]) +* [#11212](https://github.com/rubocop/rubocop/issues/11212): Make `Lint/DeprecatedConstants` aware of deprecated `Struct::Group` and `Struct::Passwd` classes. ([@koic][]) +* [#11236](https://github.com/rubocop/rubocop/pull/11236): Remove `respond_to` from default value of `AllowedMethods` for `Style/SymbolProc`. ([@koic][]) +* [#11185](https://github.com/rubocop/rubocop/pull/11185): Make `Style/HashSyntax` aware of without parentheses call expr follows. ([@koic][]) +* [#11203](https://github.com/rubocop/rubocop/pull/11203): Support multiple arguments on `Lint/SendWithMixinArgument`. ([@r7kamura][]) +* [#11229](https://github.com/rubocop/rubocop/pull/11229): Add `cc` to `AllowedNames` of `MethodParameterName` cop. ([@tjschuck][]) +* [#11116](https://github.com/rubocop/rubocop/issues/11116): Handle ternaries in `Style/SafeNavigation`. ([@fatkodima][]) + +## 1.39.0 (2022-11-14) + +### New features + +* [#11091](https://github.com/rubocop/rubocop/pull/11091): Add autocorrect for `Layout/LineContinuationLeadingSpace`. ([@FnControlOption][]) + +### Bug fixes + +* [#11150](https://github.com/rubocop/rubocop/issues/11150): Improve `Style/RedundantRegexpEscape` to catch unnecessarily escaped hyphens within a character class. ([@si-lens][]) +* [#11168](https://github.com/rubocop/rubocop/issues/11168): Fix an incorrect autocorrect for `Style/ClassEqualityComparison` when using instance variable comparison in module. ([@koic][]) +* [#11176](https://github.com/rubocop/rubocop/pull/11176): Fix a false positive cases for `Lint/DuplicateMethods` when using duplicate nested method. ([@koic][]) +* [#11164](https://github.com/rubocop/rubocop/issues/11164): Suppress "RuboCop server starting..." message with `--server --format json`. ([@koic][]) +* [#11156](https://github.com/rubocop/rubocop/pull/11156): Fix `Style/OperatorMethodCall` autocorrection when operators are chained. ([@gsamokovarov][]) +* [#11139](https://github.com/rubocop/rubocop/issues/11139): Fix a false negative for `Style/HashEachMethods` when using each with a symbol proc argument. ([@ydah][]) +* [#11161](https://github.com/rubocop/rubocop/issues/11161): Fix a false positive for `Style/HashAsLastArrayItem` when using double splat operator. ([@koic][]) +* [#11151](https://github.com/rubocop/rubocop/pull/11151): Fix a false positive for `Lint/SuppressedException`. ([@akihikodaki][]) +* [#11123](https://github.com/rubocop/rubocop/issues/11123): Fix autocorrection bug for `Style/StringLiterals` when using multiple escape characters. ([@si-lens][]) +* [#11165](https://github.com/rubocop/rubocop/issues/11165): Fix a false positive for `Style/RedundantEach` when any method is used between methods containing `each` in the method name. ([@koic][]) +* [#11177](https://github.com/rubocop/rubocop/pull/11177): Fix a false positive for `Style/ObjectThen` cop with TargetRubyVersion < 2.6. ([@epaew][]) +* [#11173](https://github.com/rubocop/rubocop/issues/11173): Fix an incorrect autocorrect for `Style/CollectionCompact` when using `reject` with block pass arg and no parentheses. ([@koic][]) +* [#11137](https://github.com/rubocop/rubocop/issues/11137): Fix a false positive for `Style/RedundantEach` when using a symbol proc argument. ([@ydah][]) +* [#11142](https://github.com/rubocop/rubocop/pull/11142): Fix `Style/RedundantEach` for non-chained `each_` calls. ([@fatkodima][]) + +### Changes + +* [#11130](https://github.com/rubocop/rubocop/pull/11130): Check blank percent literal by `Layout/SpaceInsidePercentLiteralDelimiters`. ([@r7kamura][]) +* [#11163](https://github.com/rubocop/rubocop/pull/11163): Mark `Style/HashExcept` as unsafe. ([@r7kamura][]) +* [#11171](https://github.com/rubocop/rubocop/pull/11171): Support inline visibility definition on checking visibility. ([@r7kamura][]) +* [#11158](https://github.com/rubocop/rubocop/pull/11158): Add `if` to allowed names list for MethodParameterName. ([@okuramasafumi][]) + +## 1.38.0 (2022-11-01) + +### New features + +* [#11110](https://github.com/rubocop/rubocop/pull/11110): Add new `Style/RedundantEach` cop. ([@koic][]) +* [#10255](https://github.com/rubocop/rubocop/pull/10255): Add simple autocorrect for `Style/GuardClause`. ([@FnControlOption][]) +* [#11126](https://github.com/rubocop/rubocop/pull/11126): Have `Lint/RedundantRequireStatement` mark `set` as a redundant require in Ruby 3.2+. ([@drenmi][]) +* [#11001](https://github.com/rubocop/rubocop/pull/11001): Add option to raise cop errors `--raise-cop-error`. ([@wildmaples][]) +* [#10987](https://github.com/rubocop/rubocop/pull/10987): Opt-in cop compatibility in redundant directives. ([@tdeo][]) + +### Bug fixes + +* [#11125](https://github.com/rubocop/rubocop/pull/11125): Fix an error for `Layout/SpaceInsideHashLiteralBraces` when using method argument that both key and value are hash literals. ([@koic][]) +* [#11132](https://github.com/rubocop/rubocop/issues/11132): Fix clobbering error on `Lint/EmptyConditionalBody`. ([@r7kamura][]) +* [#11117](https://github.com/rubocop/rubocop/issues/11117): Fix a false positive for `Style/BlockDelimiters` when specifying `EnforcedStyle: semantic` and using a single line block with {} followed by a safe navigation method call. ([@koic][]) +* [#11120](https://github.com/rubocop/rubocop/issues/11120): Fix an incorrect autocorrect for `Lint/RedundantRequireStatement` when using redundant `require` with modifier form. ([@koic][]) + +### Changes + +* [#11131](https://github.com/rubocop/rubocop/pull/11131): Check newline in empty reference bracket on `Layout/SpaceInsideReferenceBrackets`. ([@r7kamura][]) +* [#11045](https://github.com/rubocop/rubocop/pull/11045): Update the `Style/ModuleFunction` documentation to suggest `class << self` as an alternative. ([@rdeckard][]) +* [#11006](https://github.com/rubocop/rubocop/issues/11006): Allow multiple `elsif` for `Style/IfWithBooleanLiteralBranches`. ([@koic][]) +* [#11113](https://github.com/rubocop/rubocop/pull/11113): Report the count of files in the Worst and the Offense Count formatters. ([@hosamaly][]) + +## 1.37.1 (2022-10-24) + +### Bug fixes + +* [#11102](https://github.com/rubocop/rubocop/issues/11102): Fix an error for `Style/AccessModifierDeclarations` when using access modifier in a block. ([@koic][]) +* [#11107](https://github.com/rubocop/rubocop/issues/11107): Fix a false positive for `Style/OperatorMethodCall` when a constant receiver uses an operator method. ([@koic][]) +* [#11104](https://github.com/rubocop/rubocop/issues/11104): Fix an error for `Style/CollectionCompact` when using `reject` method and receiver is a variable. ([@koic][]) +* [#11114](https://github.com/rubocop/rubocop/issues/11114): Fix an error for `Style/OperatorMethodCall` when using `obj.!`. ([@koic][]) +* [#11088](https://github.com/rubocop/rubocop/issues/11088): Fix an error when specifying `SuggestExtensions: true`. ([@koic][]) +* [#11089](https://github.com/rubocop/rubocop/issues/11089): Fix an error for `Style/RedundantStringEscape` when using character literals (e.g. `?a`). ([@ydah][]) +* [#11098](https://github.com/rubocop/rubocop/issues/11098): Fix false positive for `Style/RedundantStringEscape`. ([@tdeo][]) +* [#11095](https://github.com/rubocop/rubocop/pull/11095): Fix an error for `Style/RedundantStringEscape` cop when using `?\n` string character literal. ([@koic][]) + +## 1.37.0 (2022-10-20) + +### New features + +* [#11043](https://github.com/rubocop/rubocop/issues/11043): Add new `Lint/DuplicateMagicComment` cop. ([@koic][]) +* [#10409](https://github.com/rubocop/rubocop/issues/10409): Add `--no-exclude-limit` CLI option. ([@r7kamura][]) +* [#10986](https://github.com/rubocop/rubocop/pull/10986): Add autocorrect for `Style/StaticClass`. ([@FnControlOption][]) +* [#11018](https://github.com/rubocop/rubocop/issues/11018): Add `AllowedMethods` and `AllowedPatterns` for `Lint/NestedMethodDefinition`. ([@koic][]) +* [#11055](https://github.com/rubocop/rubocop/pull/11055): Implement `Lint/DuplicateMethods` for object singleton class. ([@tdeo][]) +* [#10997](https://github.com/rubocop/rubocop/pull/10997): Make `rubocop` command aware of `--server` option from .rubocop and RUBOCOP_OPTS. ([@koic][]) +* [#11079](https://github.com/rubocop/rubocop/issues/11079): Add new `Style/OperatorMethodCall` cop. ([@koic][]) +* [#10439](https://github.com/rubocop/rubocop/issues/10439): Add new `Style/RedundantStringEscape` cop. ([@owst][]) + +### Bug fixes + +* [#11034](https://github.com/rubocop/rubocop/issues/11034): Fix server mode behavior when using `--stderr`. ([@tdeo][]) +* [#11028](https://github.com/rubocop/rubocop/issues/11028): Fix a false positive for `Lint/RequireParentheses` when using ternary operator in square brackets. ([@koic][]) +* [#11051](https://github.com/rubocop/rubocop/issues/11051): Preserve comments on `Style/AccessModifierDeclarations` autocorrection. ([@r7kamura][]) +* [#9116](https://github.com/rubocop/rubocop/issues/9116): Support `super` method in `Layout/FirstArgumentIndentation`. ([@tdeo][]) +* [#11068](https://github.com/rubocop/rubocop/pull/11068): Fix a false positive for `Style/RedundantRegexpCharacterClass` when using starting with "\0" number. ([@koic][]) +* [#11082](https://github.com/rubocop/rubocop/pull/11082): Fix an incorrect autocorrect for `Lint/SafeNavigationChain` when safe navigation on the right-hand side of the arithmetic operator. ([@ydah][]) +* [#10982](https://github.com/rubocop/rubocop/pull/10982): Do not autocorrect parentheses for calls in assignments in conditional branches for `Style/MethodCallWithArgsParentheses` with `omit_parentheses`. ([@gsamokovarov][]) +* [#11084](https://github.com/rubocop/rubocop/issues/11084): Fix an error for `Style/ParallelAssignment` when using parallel assignment in singleton method. ([@koic][]) +* [#11078](https://github.com/rubocop/rubocop/pull/11078): Fix a false positive for `Style/RedundantBegin` when using endless method definition for `begin` with multiple statements. ([@koic][]) +* [#11074](https://github.com/rubocop/rubocop/issues/11074): Fix a false positive for `Lint/RedundantDirGlobSort` when using `Dir.glob` with multiple arguments. ([@koic][]) +* [#11025](https://github.com/rubocop/rubocop/issues/11025): Check comments for disables in `RedundantInitialize` cop. ([@HeroProtagonist][]) +* [#11003](https://github.com/rubocop/rubocop/issues/11003): Fix clobbering exception in EmptyConditionalBody cop when if branch is empty but else is not. ([@srcoley][]) +* [#11026](https://github.com/rubocop/rubocop/issues/11026): Fix an error occurred for `Style/SymbolArray` and `Style/WordArray` when empty percent array. ([@ydah][]) +* [#11022](https://github.com/rubocop/rubocop/issues/11022): Fix an incorrect autocorrect for `Style/RedundantCondition` when using redundant brackets access condition. ([@koic][]) +* [#11037](https://github.com/rubocop/rubocop/issues/11037): Fix a false positive for `Style/CollectionCompact` when using `to_enum.reject` or `lazy.reject` methods with Ruby 3.0 or lower. ([@koic][]) +* [#11017](https://github.com/rubocop/rubocop/pull/11017): Fix an autocorrect for `Lint/EmptyConditionalBody` that causes a SyntaxError when missing `if` and `else` body. ([@ydah][]) +* [#11047](https://github.com/rubocop/rubocop/issues/11047): Fix an incorrect autocorrect for `Lint/SafeNavigationChain` when using `+@` and `-@` methods. ([@koic][]) +* [#11015](https://github.com/rubocop/rubocop/pull/11015): Fix a false positive for `Style/HashSyntax` when without parentheses call expr follows after nested method call. ([@koic][]) +* [#11067](https://github.com/rubocop/rubocop/issues/11067): Fix a false positive for `Lint/DuplicateRegexpCharacterClassElement` when using regexp character starts with escaped zero number. ([@koic][]) +* [#11030](https://github.com/rubocop/rubocop/issues/11030): Fix an incorrect autocorrect for `Lint/UnusedMethodArgument` and `Style::ExplicitBlockArgument` when autocorrection conflicts for `&block` argument. ([@koic][]) +* [#11069](https://github.com/rubocop/rubocop/issues/11069): Fix an incorrect autocorrect for `Lint/RedundantCopDisableDirective` when disable directive contains free comment. ([@koic][]) +* [#11063](https://github.com/rubocop/rubocop/pull/11063): Preserve comments on `Style/AccessorGrouping` autocorrection. ([@r7kamura][]) +* [#10994](https://github.com/rubocop/rubocop/issues/10994): Fix an error when running 3rd party gem that does not require server. ([@koic][]) + +### Changes + +* [#11054](https://github.com/rubocop/rubocop/pull/11054): Implement correct behavior for compact mode for `Layout/SpaceInsideArrayLiteralBrackets`. ([@tdeo][]) +* [#10924](https://github.com/rubocop/rubocop/issues/10924): `Style/NegatedIfElseCondition` also checks negative conditions inside parentheses. ([@tsugimoto][]) +* [#11042](https://github.com/rubocop/rubocop/pull/11042): Mark `Lint/OrderedMagicComments` as unsafe autocorrection. ([@koic][]) +* [#11057](https://github.com/rubocop/rubocop/pull/11057): Make `Lint/RedundantRequireStatement` aware of `pp`, `ruby2_keywords`, and `fiber`. ([@koic][]) +* [#10988](https://github.com/rubocop/rubocop/pull/10988): Raise error when both safe and unsafe autocorrect options are specified. ([@koic][]) +* [#11032](https://github.com/rubocop/rubocop/pull/11032): Detect empty Hash literal braces containing only newlines and spaces on `Layout/SpaceInsideHashLiteralBraces`. ([@r7kamura][]) + +## 1.36.0 (2022-09-01) + +### New features + +* [#10931](https://github.com/rubocop/rubocop/pull/10931): Add `AllowOnSelfClass` option to `Style/CaseEquality`. ([@sambostock][]) + +### Bug fixes + +* [#10958](https://github.com/rubocop/rubocop/issues/10958): Fix an infinite loop for `Layout/SpaceInsideBlockBraces` when `EnforcedStyle` is `no_space` and using multiline block. ([@ydah][]) +* [#10903](https://github.com/rubocop/rubocop/pull/10903): Skip forking off extra processes for parallel inspection when only a single file needs to be inspected. ([@wjwh][]) +* [#10919](https://github.com/rubocop/rubocop/issues/10919): Fix a huge performance regression between 1.32.0 and 1.33.0. ([@ydah][]) +* [#10951](https://github.com/rubocop/rubocop/issues/10951): Fix an autocorrection error for `Lint/EmptyConditionalBody` when some conditional branch is empty. ([@ydah][]) +* [#10927](https://github.com/rubocop/rubocop/issues/10927): Fix a false positive for `Style/HashTransformKeys` and `Style/HashTransformValues` when not using transformed block argument. ([@koic][]) +* [#10979](https://github.com/rubocop/rubocop/issues/10979): Fix a false positive for `Style/RedundantParentheses` when using parentheses with pin operator except for variables. ([@Tietew][]) +* [#10962](https://github.com/rubocop/rubocop/pull/10962): Fix a false positive for `Lint/ShadowingOuterLocalVariable` when conditional with if/elsif/else branches. ([@ydah][]) +* [#10969](https://github.com/rubocop/rubocop/issues/10969): Fix a false negative for `AllowedPatterns` of `Lint/AmbiguousBlockAssociation` when using a method chain. ([@jcalvert][]) +* [#10963](https://github.com/rubocop/rubocop/issues/10963): Fix a false positive for `Layout/IndentationWidth` when using aligned empty `else` in pattern matching. ([@koic][]) +* [#10975](https://github.com/rubocop/rubocop/pull/10975): Fix possible wrong autocorrection in namespace on `Style/PerlBackrefs`. ([@r7kamura][]) + +### Changes + +* [#10928](https://github.com/rubocop/rubocop/pull/10928): Add more autocorrect support on `Style/EachForSimpleLoop`. ([@r7kamura][]) +* [#10960](https://github.com/rubocop/rubocop/issues/10960): Add `as` to `AllowedNames` in default configuration for `Naming/MethodParameterName` cop. ([@koic][]) +* [#10966](https://github.com/rubocop/rubocop/pull/10966): Add autocorrect support to `Style/AccessModifierDeclarations`. ([@r7kamura][]) +* [#10940](https://github.com/rubocop/rubocop/pull/10940): Add server mode status to `-V` option. ([@koic][]) + +## 1.35.1 (2022-08-22) + +### Bug fixes + +* [#10926](https://github.com/rubocop/rubocop/issues/10926): Make `Style/SafeNavigation` aware of a redundant nil check. ([@koic][]) +* [#10944](https://github.com/rubocop/rubocop/issues/10944): Fix an incorrect autocorrect for `Lint/LiteralInInterpolation` when using `"#{nil}"`. ([@koic][]) +* [#10921](https://github.com/rubocop/rubocop/issues/10921): Fix an error when ERB pre-processing of the configuration file. ([@koic][]) +* [#10936](https://github.com/rubocop/rubocop/issues/10936): Fix an error for `Lint/NonAtomicFileOperation` when using `FileTest.exist?` as a condition for `elsif`. ([@koic][]) +* [#10920](https://github.com/rubocop/rubocop/issues/10920): Fix an incorrect autocorrect for `Style/SoleNestedConditional` when using nested conditional and branch contains a comment. ([@koic][]) +* [#10939](https://github.com/rubocop/rubocop/issues/10939): Fix an error for `Style/Next` when line break before condition. ([@koic][]) + +## 1.35.0 (2022-08-12) + +### New features + +* [#9364](https://github.com/rubocop/rubocop/pull/9364): Add `Style/MagicCommentFormat` cop. ([@dvandersluis][], [@mattbearman][]) +* [#10776](https://github.com/rubocop/rubocop/pull/10776): New option (`consistent`) for `EnforcedShorthandSyntax` in `Style/HashSyntax` to avoid mixing shorthand and non-shorthand hash keys in ruby 3.1. ([@h-lame][]) + +### Bug fixes + +* [#10899](https://github.com/rubocop/rubocop/issues/10899): Fix an error for `Lint/ShadowingOuterLocalVariable` when the same variable name as a block variable is used in return value assignment of `if`. ([@koic][]) +* [#10916](https://github.com/rubocop/rubocop/pull/10916): Fix an error when .rubocop.yml is empty. ([@koic][]) +* [#10915](https://github.com/rubocop/rubocop/pull/10915): Fix numblock support to `Layout/BlockAlignment`, `Layout/BlockEndNewline`, `Layout/EmptyLinesAroundAccessModifier`, `Layout/EmptyLinesAroundBlockBody`, `Layout/IndentationWidth`, `Layout/LineLength`, `Layout/MultilineBlockLayout`, `Layout/SpaceBeforeBlockBraces`, `Lint/NextWithoutAccumulator`, `Lint/NonDeterministicRequireOrder`, `Lint/RedundantWithIndex`, `Lint/RedundantWithObject`, `Lint/UnreachableLoop`, `Lint/UselessAccessModifier`, `Lint/Void`, `Metrics/AbcSize`, `Metrics/CyclomaticComplexity`, `Style/CollectionMethods`, `Style/CombinableLoops`, `Style/EachWithObject`, `Style/For`, `Style/HashEachMethods`, `Style/InverseMethods`, `Style/MethodCalledOnDoEndBlock`, `Style/MultilineBlockChain`, `Style/Next`, `Style/ObjectThen`, `Style/Proc`, `Style/RedundantBegin`, `Style/RedundantSelf`, `Style/RedundantSortBy` and `Style/TopLevelMethodDefinition`. ([@gsamokovarov][]) +* [#10895](https://github.com/rubocop/rubocop/issues/10895): Fix incorrect autocomplete in `Style/RedundantParentheses` when a heredoc is used in an array. ([@dvandersluis][]) +* [#10909](https://github.com/rubocop/rubocop/pull/10909): Fix loading behavior on running without `bundle exec`. ([@r7kamura][]) +* [#10913](https://github.com/rubocop/rubocop/issues/10913): Make `Style/ArgumentsForwarding` aware of anonymous block argument. ([@koic][]) +* [#10911](https://github.com/rubocop/rubocop/pull/10911): Fix `Style/ClassMethodsDefinitions` for non-self receivers. ([@sambostock][]) + +### Changes + +* [#10915](https://github.com/rubocop/rubocop/pull/10915): Depend on rubocop-ast 1.20.1 for numblocks support in #macro?. ([@gsamokovarov][]) + +## 1.34.1 (2022-08-09) + +### Bug fixes + +* [#10893](https://github.com/rubocop/rubocop/issues/10893): Fix an error when running `rubocop` without `bundle exec`. ([@koic][]) + +## 1.34.0 (2022-08-09) + +### New features + +* [#10170](https://github.com/rubocop/rubocop/pull/10170): Add new `InternalAffairs/SingleLineComparison` cop. ([@dvandersluis][]) + +### Bug fixes + +* [#10552](https://github.com/rubocop/rubocop/issues/10552): Require RuboCop AST 1.20.0+ to fix a false positive for `Lint/OutOfRangeRegexpRef` when using fixed-encoding regopt. ([@koic][]) +* [#10512](https://github.com/rubocop/rubocop/issues/10512): Fix a false positive for `Lint/ShadowingOuterLocalVariable` conditional statement and block variable. ([@ydah][]) +* [#10864](https://github.com/rubocop/rubocop/pull/10864): `min` and `max` results in false positives for `Style/SymbolProc` similarly to `select` and `reject`. ([@mollerhoj][]) +* [#10846](https://github.com/rubocop/rubocop/issues/10846): Fix a false negative for `Style/DoubleNegation` when there is a hash or an array at return location of method. ([@nobuyo][]) +* [#10875](https://github.com/rubocop/rubocop/pull/10875): Fix an obsolete option configuration values are duplicated when generating `.rubocop_todo.yml`. ([@ydah][]) +* [#10877](https://github.com/rubocop/rubocop/issues/10877): Fix crash with `Layout/BlockEndNewline` heredoc detection. ([@dvandersluis][]) +* [#10859](https://github.com/rubocop/rubocop/issues/10859): Fix `Lint/Debugger` to be able to handle method chains correctly. ([@dvandersluis][]) +* [#10883](https://github.com/rubocop/rubocop/issues/10883): Fix `Style/RedundantParentheses` to be able to detect offenses and properly correct when the end parentheses and comma are on their own line. ([@dvandersluis][]) +* [#10881](https://github.com/rubocop/rubocop/issues/10881): Fix `Style/SoleNestedConditional` to properly wrap `block` and `csend` nodes when necessary. ([@dvandersluis][]) +* [#10867](https://github.com/rubocop/rubocop/pull/10867): Mark autocorrection for `Lint/EmptyConditionalBody` as unsafe. ([@dvandersluis][]) +* [#10871](https://github.com/rubocop/rubocop/issues/10871): Restore `RuboCop::ConfigLoader.project_root` as deprecated. ([@koic][]) + +### Changes + +* [#10857](https://github.com/rubocop/rubocop/issues/10857): Add `AllowedPatterns` to `Style/NumericLiterals`. ([@dvandersluis][]) +* [#10648](https://github.com/rubocop/rubocop/issues/10648): Allow `Style/TernaryParentheses` to take priority over `Style/RedundantParentheses` when parentheses are enforced. ([@dvandersluis][]) +* [#10731](https://github.com/rubocop/rubocop/issues/10731): Show tip for suggested extensions that are installed but not loaded in .rubocop.yml. ([@nobuyo][]) +* [#10845](https://github.com/rubocop/rubocop/pull/10845): Support Bundler-like namespaced feature on require config. ([@r7kamura][]) +* [#10773](https://github.com/rubocop/rubocop/issues/10773): Require Parser 3.1.2.1 or higher. ([@dvandersluis][]) + +## 1.33.0 (2022-08-04) + +### Bug fixes + +* [#10830](https://github.com/rubocop/rubocop/issues/10830): Fix an incorrect autocorrect for `Layout/FirstArgumentIndentation` when specifying `EnforcedStyle: with_fixed_indentation` of `Layout/ArgumentAlignment` and `EnforcedStyle: consistent` of `Layout/FirstArgumentIndentation` and enabling `Layout/FirstMethodArgumentLineBreak`. ([@koic][]) +* [#10825](https://github.com/rubocop/rubocop/issues/10825): Fix an incorrect autocorrect for `Style/ClassAndModuleChildren` when using nested one-liner class. ([@koic][]) +* [#10843](https://github.com/rubocop/rubocop/issues/10843): Fix a false positive for `Style/HashExcept` when using `reject` and calling `include?` method with symbol array and second block value. ([@koic][]) +* [#10853](https://github.com/rubocop/rubocop/pull/10853): Fix an autocorrect for `Style/RedundantSort` with logical operator. ([@ydah][]) +* [#10842](https://github.com/rubocop/rubocop/issues/10842): Make server mode aware of `CacheRootDirectory` config option value, `RUBOCOP_CACHE_ROOT`, and `XDG_CACHE_HOME` environment variables. ([@koic][]) +* [#10833](https://github.com/rubocop/rubocop/issues/10833): Fix an incorrect autocorrect for `Style/RedundantCondition` when branches contains arithmetic operation. ([@koic][]) +* [#10864](https://github.com/rubocop/rubocop/issues/10864): Fix a false positive for `Style/SymbolProc` when using `Hash#reject`. ([@koic][]) +* [#10771](https://github.com/rubocop/rubocop/issues/10771): Make server mode aware of `--cache-root` command line option. ([@koic][]) +* [#10831](https://github.com/rubocop/rubocop/pull/10831): Fix an error when using `changed_parameters` in obsoletion.yml by external library. ([@koic][]) +* [#10850](https://github.com/rubocop/rubocop/pull/10850): Fix `Style/ClassEqualityComparison` autocorrection within module. ([@r7kamura][]) +* [#10832](https://github.com/rubocop/rubocop/issues/10832): Fix an incorrect autocorrect for `Layout/BlockEndNewline` when multiline block `}` is not on its own line and using heredoc argument. ([@koic][]) + +### Changes + +* [#10841](https://github.com/rubocop/rubocop/pull/10841): Don't hash shared libraries for cache key. ([@ChrisBr][]) +* [#10862](https://github.com/rubocop/rubocop/pull/10862): Add autocorrection to `Lint/EmptyConditionalBody`. ([@dvandersluis][]) +* [#10829](https://github.com/rubocop/rubocop/pull/10829): Deprecate `IgnoredMethods` option in favor of the `AllowedMethods` and `AllowedPatterns` options. ([@ydah][]) + +## 1.32.0 (2022-07-21) + +### New features + +* [#10820](https://github.com/rubocop/rubocop/pull/10820): Add new `Style/EmptyHeredoc` cop. ([@koic][]) +* [#10691](https://github.com/rubocop/rubocop/pull/10691): Add new `Layout/MultilineMethodParameterLineBreaks` cop. ([@Korri][]) +* [#10790](https://github.com/rubocop/rubocop/pull/10790): Support `AllowComments` option for `Style/EmptyElse`. ([@ydah][]) +* [#10792](https://github.com/rubocop/rubocop/pull/10792): Add new `Lint/RequireRangeParentheses` cop. ([@koic][]) +* [#10692](https://github.com/rubocop/rubocop/pull/10692): Break long method definitions when auto-correcting. ([@Korri][]) + +### Bug fixes + +* [#10824](https://github.com/rubocop/rubocop/pull/10824): Make `Lint/DeprecatedClassMethods` aware of `ENV.clone` and `ENV.dup`. ([@koic][]) +* [#10788](https://github.com/rubocop/rubocop/issues/10788): Relax `Style/FetchEnvVar` to allow `ENV[]` in LHS of `||`. ([@j-miyake][]) +* [#10813](https://github.com/rubocop/rubocop/issues/10813): Fix recursive deletion to suppression in `Lint/NonAtomicFileOperation`. ([@ydah][]) +* [#10791](https://github.com/rubocop/rubocop/issues/10791): Fix an incorrect autocorrect for `Style/Semicolon` when using endless range before semicolon. ([@koic][]) +* [#10781](https://github.com/rubocop/rubocop/pull/10781): Fix a suggestions for safer conversions for `Lint/NonAtomicFileOperation`. ([@ydah][]) +* [#10263](https://github.com/rubocop/rubocop/pull/10263): Fix the value of `Enabled` leaking between configurations. ([@jonas054][]) + +### Changes + +* [#10613](https://github.com/rubocop/rubocop/issues/10613): Allow autocorrecting with -P/--parallel and make it the default. ([@jonas054][]) +* Add EnforcedStyle (leading/trailing) configuration to `Layout::LineContinuationLeadingSpace`. ([@bquorning][]) +* [#10784](https://github.com/rubocop/rubocop/pull/10784): Preserve multiline semantics on `Style/SymbolArray` and `Style/WordArray`. ([@r7kamura][]) +* [#10814](https://github.com/rubocop/rubocop/pull/10814): Avoid buffering stdout when running in server mode. ([@ccutrer][]) +* [#10817](https://github.com/rubocop/rubocop/pull/10817): Add autocorrect support for `Lint/SafeNavigationChain`. ([@r7kamura][]) +* [#10810](https://github.com/rubocop/rubocop/pull/10810): Support safe navigation operator on `Style/SymbolProc`. ([@r7kamura][]) +* [#10803](https://github.com/rubocop/rubocop/pull/10803): Require RuboCop AST 1.9.1 or higher. ([@koic][]) -### Bug Fixes - -* [#2123](https://github.com/bbatsov/rubocop/pull/2123): Fix handing of dynamic widths `Lint/FormatParameterMismatch`. ([@edmz][]) -* [#2116](https://github.com/bbatsov/rubocop/pull/2116): Fix named params (using hash) `Lint/FormatParameterMismatch`. ([@edmz][]) -* [#2135](https://github.com/bbatsov/rubocop/issues/2135): Ignore `super` and `zsuper` nodes in `Style/SymbolProc`. ([@bbatsov][]) -* [#2165](https://github.com/bbatsov/rubocop/issues/2165): Fix a NPE in `Style/Alias`. ([@bbatsov][]) -* [#2168](https://github.com/bbatsov/rubocop/issues/2168): Fix a NPE in `Rails/TimeZone`. ([@bbatsov][]) -* [#2169](https://github.com/bbatsov/rubocop/issues/2169): Fix a NPE in `Rails/Date`. ([@bbatsov][]) -* [#2105](https://github.com/bbatsov/rubocop/pull/2105): Fix a warning that was thrown when enabling `Style/OptionHash`. ([@wli][]) -* [#2107](https://github.com/bbatsov/rubocop/pull/2107): Fix auto-correct of `Style/ParallelAssignment` for nested expressions. ([@rrosenblum][]) -* [#2111](https://github.com/bbatsov/rubocop/issues/2111): Deal with byte order mark in `Style/InitialIndentation`. ([@jonas054][]) -* [#2113](https://github.com/bbatsov/rubocop/issues/2113): Handle non-string tokens in `Style/ExtraSpacing`. ([@jonas054][]) -* [#2129](https://github.com/bbatsov/rubocop/issues/2129): Handle empty interpolations in `Style/SpaceInsideStringInterpolation`. ([@lumeet][]) -* [#2119](https://github.com/bbatsov/rubocop/issues/2119): Do not raise an error in `Style/RescueEnsureAlignment` and `Style/RescueModifier` when processing an excluded file. ([@rrosenblum][]) -* [#2149](https://github.com/bbatsov/rubocop/issues/2149): Do not register an offense in `Rails/Date` when `Date#to_time` is called with a time zone argument. ([@maxjacobson][]) -* Do not register a `Rails/TimeZone` offense when using Time.new safely. ([@maxjacobson][]) -* [#2124](https://github.com/bbatsov/rubocop/issues/2124): Fix bug in `Style/EmptyLineBetweenDefs` when there are only comments between method definitions. ([@lumeet][]) -* [#2154](https://github.com/bbatsov/rubocop/issues/2154): `Performance/StringReplacement` can auto-correct replacements with backslash in them. ([@rrosenblum][]) -* [#2009](https://github.com/bbatsov/rubocop/issues/2009): Fix bug in `RuboCop::ConfigLoader.load_file` when `safe_yaml` is required. ([@eitoball][]) -* [#2155](https://github.com/bbatsov/rubocop/issues/2155): Configuration `EndAlignment: AlignWith: variable` only applies when the operands of `=` are on the same line. ([@jonas054][]) -* Fix bug in `Style/IndentationWidth` when `rescue` or `ensure` is preceded by an empty body. ([@lumeet][]) -* [#2183](https://github.com/bbatsov/rubocop/issues/2183): Fix bug in `Style/BlockDelimiters` when auto-correcting adjacent braces. ([@lumeet][]) -* [#2199](https://github.com/bbatsov/rubocop/issues/2199): Make `rubocop` exit with error when there are only `Lint/UnneededDisable` offenses. ([@jonas054][]) -* Fix handling of empty parentheses when auto-correcting in `Style/SymbolProc`. ([@lumeet][]) - -## 0.33.0 (05/08/2015) - -### New features - -* [#2081](https://github.com/bbatsov/rubocop/pull/2081): New cop `Style/Send` checks for the use of `send` and instead encourages changing it to `BasicObject#__send__` or `Object#public_send` (disabled by default). ([@syndbg][]) -* [#2057](https://github.com/bbatsov/rubocop/pull/2057): New cop `Lint/FormatParameterMismatch` checks for a mismatch between the number of fields expected in format/sprintf/% and what was pased to it. ([@edmz][]) -* [#2010](https://github.com/bbatsov/rubocop/pull/2010): Add `space` style for SpaceInsideStringInterpolation. ([@gotrevor][]) -* [#2007](https://github.com/bbatsov/rubocop/pull/2007): Allow any modifier before `def`, not only visibility modifiers. ([@fphilipe][]) -* [#1980](https://github.com/bbatsov/rubocop/pull/1980): `--auto-gen-config` now outputs an excluded files list for failed cops (up to a maxiumum of 15 files). ([@bmorrall][]) -* [#2004](https://github.com/bbatsov/rubocop/pull/2004): Introduced `--exclude-limit COUNT` to configure how many files `--auto-gen-config` will exclude. ([@awwaiid][], [@jonas054][]) -* [#1918](https://github.com/bbatsov/rubocop/issues/1918): New configuration parameter `AllCops:DisabledByDefault` when set to `true` makes only cops found in user configuration enabled, which makes cop selection *opt-in*. ([@jonas054][]) -* New cop `Performance/StringReplacement` checks for usages of `gsub` that can be replaced with `tr` or `delete`. ([@rrosenblum][]) -* [#2001](https://github.com/bbatsov/rubocop/issues/2001): New cop `Style/InitialIndentation` checks for indentation of the first non-blank non-comment line in a file. ([@jonas054][]) -* [#2060](https://github.com/bbatsov/rubocop/issues/2060): New cop `Style/RescueEnsureAlignment` checks for bad alignment of `rescue` and `ensure` keywords. ([@lumeet][]) -* New cop `Style/OptionalArguments` checks for optional arguments that do not appear at the end of an argument list. ([@rrosenblum][]) -* New cop `Lint/CircularArgumentReference` checks for "circular argument references" in keyword arguments, which Ruby 2.2 warns against. ([@maxjacobson][], [@sliuu][]) -* [#2030](https://github.com/bbatsov/rubocop/issues/2030): New cop `Style/OptionHash` checks for option hashes and encourages changing them to keyword arguments (disabled by default). ([@maxjacobson][]) - -### Changes - -* [#2052](https://github.com/bbatsov/rubocop/pull/2052): `Style/RescueModifier` uses token stream to identify offenses. ([@urbanautomaton][]) -* Rename `Rails/Date` and `Rails/TimeZone` style names to "strict" and "flexible" and make "flexible" to be default. ([@palkan][]) -* [#2035](https://github.com/bbatsov/rubocop/issues/2035): `Style/ExtraSpacing` is now enabled by default and has a configuration parameter `AllowForAlignment` that is `true` by default, making it allow extra spacing if it's used for alignment purposes. ([@jonas054][]) - -### Bugs fixed - -* [#2014](https://github.com/bbatsov/rubocop/pull/2014): Fix `Style/TrivialAccessors` to support AllowPredicates: false. ([@gotrevor][]) -* [#1988](https://github.com/bbatsov/rubocop/issues/1988): Fix bug in `Style/ParallelAssignment` when assigning from `Module::CONSTANT`. ([@rrosenblum][]) -* [#1995](https://github.com/bbatsov/rubocop/pull/1995): Improve message for `Rails/TimeZone`. ([@palkan][]) -* [#1977](https://github.com/bbatsov/rubocop/issues/1977): Fix bugs in `Rails/Date` and `Rails/TimeZone` when using namespaced Time/Date. ([@palkan][]) -* [#1973](https://github.com/bbatsov/rubocop/issues/1973): Do not register an offense in `Performance/Detect` when `select` is called on `Enumerable::Lazy`. ([@palkan][]) -* [#2015](https://github.com/bbatsov/rubocop/issues/2015): Fix bug occurring for auto-correction of a misaligned `end` in a file with only one method. ([@jonas054][]) -* Allow string interpolation segments inside single quoted string literals when double quotes are preferred. ([@segiddins][]) -* [#2026](https://github.com/bbatsov/rubocop/issues/2026): Allow `Time.current` when style is "acceptable".([@palkan][]) -* [#2029](https://github.com/bbatsov/rubocop/issues/2029): Fix bug where `Style/RedundantReturn` auto-corrects returning implicit hashes to invalid syntax. ([@rrosenblum][]) -* [#2021](https://github.com/bbatsov/rubocop/issues/2021): Fix bug in `Style/BlockDelimiters` when a `semantic` expression is used in an array or a range. ([@lumeet][]) -* [#1992](https://github.com/bbatsov/rubocop/issues/1992): Allow parentheses in assignment to a variable with the same name as the method's in `Style/MethodCallParentheses`. ([@lumeet][]) -* [#2045](https://github.com/bbatsov/rubocop/issues/2045): Fix crash in `Style/IndentationWidth` when using `private_class_method def self.foo` syntax. ([@unmanbearpig][]) -* [#2006](https://github.com/bbatsov/rubocop/issues/2006): Fix crash in `Style/FirstParameterIndentation` in case of nested offenses. ([@unmanbearpig][]) -* [#2059](https://github.com/bbatsov/rubocop/issues/2059): Don't check for trivial accessors in modules. ([@bbatsov][]) -* Add proper punctuation to the end of offense messages, where it is missing. ([@lumeet][]) -* [#2071](https://github.com/bbatsov/rubocop/pull/2071): Keep line breaks in place on WordArray autocorrect.([@unmanbearpig][]) -* [#2075](https://github.com/bbatsov/rubocop/pull/2075): Properly correct `Style/PercentLiteralDelimiters` with escape characters in them. ([@rrosenblum][]) -* [#2023](https://github.com/bbatsov/rubocop/issues/2023): Avoid auto-correction corruption in `IndentationWidth`. ([@jonas054][]) -* [#2080](https://github.com/bbatsov/rubocop/issues/2080): Properly parse code in `Performance/Count` when calling `select..count` in a class that extends an enumerable. ([@rrosenblum][]) -* [#2093](https://github.com/bbatsov/rubocop/issues/2093): Fix bug in `Style/OneLineConditional` which should not raise an offense with an 'if/then/end' statement. ([@sliuu][]) - -## 0.32.1 (24/06/2015) - -### New features - -* `Debugger` cop now checks catches methods called with arguments. ([@crazydog115][]) - -### Bugs fixed - -* Make it possible to disable `Lint/UnneededDisable`. ([@jonas054][]) -* [#1958](https://github.com/bbatsov/rubocop/issues/1958): Show name of `Lint/UnneededDisable` when `-D/--display-cop-names` is given. ([@jonas054][]) -* Do not show `Style/NonNilCheck` offenses as corrected when the source code is not modified. ([@rrosenblum][]) -* Fix auto-correct in `Style/RedundantReturn` when `return` has no arguments. ([@lumeet][]) -* [#1955](https://github.com/bbatsov/rubocop/issues/1955): Fix false positive for `Style/TrailingComma` cop. ([@mattjmcnaughton][]) -* [#1928](https://github.com/bbatsov/rubocop/issues/1928): Avoid auto-correcting two alignment offenses in the same area at the same time. ([@jonas054][]) -* [#1964](https://github.com/bbatsov/rubocop/issues/1964): Fix `RedundantBegin` auto-correct issue with comments by doing a smaller correction. ([@jonas054][]) -* [#1978](https://github.com/bbatsov/rubocop/pull/1978): Don't count disabled offences if fail-level is autocorrect. ([@sch1zo][]) -* [#1986](https://github.com/bbatsov/rubocop/pull/1986): Fix Date false positives on variables. ([@palkan][]) - -### Changes - -* [#1708](https://github.com/bbatsov/rubocop/issues/1708): Improve message for `FirstParameterIndentation`. ([@tejasbubane][]) -* [#1959](https://github.com/bbatsov/rubocop/issues/1959): Allow `Lint/UnneededDisable` to be inline disabled. ([@rrosenblum][]) - -## 0.32.0 (06/06/2015) - -### New features - -* Adjust behavior of `TrailingComma` cop to account for multi-line hashes nested within method calls. ([@panthomakos][]) -* [#1719](https://github.com/bbatsov/rubocop/pull/1719): Display an error and abort the program if input file can't be found. ([@matugm][]) -* New cop `SpaceInsideStringInterpolation` checks for spaces within string interpolations. ([@glasnt][]) -* New cop `NestedMethodDefinition` checks for method definitions inside other methods. ([@ojab][]) -* `LiteralInInterpolation` cop does auto-correction. ([@tmr08c][]) -* [#1865](https://github.com/bbatsov/rubocop/issues/1865): New cop `Lint/UnneededDisable` checks for `rubocop:disable` comments that can be removed. ([@jonas054][]) -* `EmptyElse` cop does auto-correction. ([@lumeet][]) -* Show reference links when displaying style guide links. ([@rrosenblum][]) -* `Debugger` cop now checks for the Capybara debug method `save_screenshot`. ([@crazydog115][]) -* [#1282](https://github.com/bbatsov/rubocop/issues/1282): `CaseIndentation` cop does auto-correction. ([@lumeet][]) -* [#1928](https://github.com/bbatsov/rubocop/issues/1928): Do auto-correction one offense at a time (rather than one cop at a time) if there are tabs in the code. ([@jonas054][]) - -### Changes - -* Prefer `SpaceInsideBlockBraces` to `SpaceBeforeSemicolon` and `SpaceAfterSemicolon` to avoid an infinite loop when auto-correcting. ([@lumeet][]) -* [#1873](https://github.com/bbatsov/rubocop/issues/1873): Move `ParallelAssignment` cop from Performance to Style. ([@rrosenblum][]) -* Add `getlocal` to acceptable methods of `Rails/TimeZone`. ([@ojab][]) -* [#1851](https://github.com/bbatsov/rubocop/issues/1851), [#1948](https://github.com/bbatsov/rubocop/issues/1948): Change offense message for `ClassLength` and `ModuleLength` to match that of `MethodLength`. ([@bquorning][]) - -### Bugs fixed - -* Don't count required keyword args when specifying `CountKeywordArgs: false` for `ParameterLists`. ([@sumeet][]) -* [#1879](https://github.com/bbatsov/rubocop/issues/1879): Avoid auto-correcting hash with trailing comma into invalid code in `BracesAroundHashParameters`. ([@jonas054][]) -* [#1868](https://github.com/bbatsov/rubocop/issues/1868): Do not register an offense in `Performance/Count` when `select` is called with symbols or strings as the parameters. ([@rrosenblum][]) -* `Sample` rewritten to properly handle shuffle randomness source, first/last params and non-literal ranges. ([@chastell][]) -* [#1873](https://github.com/bbatsov/rubocop/issues/1873): Modify `ParallelAssignment` to properly autocorrect when the assignment is protected by a modifier statement. ([@rrosenblum][]) -* Configure `ParallelAssignment` to work with non-standard `IndentationWidths`. ([@rrosenblum][]) -* [#1899](https://github.com/bbatsov/rubocop/issues/1899): Be careful about comments when auto-correcting in `BracesAroundHashParameters`. ([@jonas054][]) -* [#1897](https://github.com/bbatsov/rubocop/issues/1897): Don't report that semicolon separated statements can be converted to modifier form in `IfUnlessModifier` (and don't auto-correct them). ([@jonas054][]) -* [#1644](https://github.com/bbatsov/rubocop/issues/1644): Don't search the entire file system when a folder is named `,` (fix for jruby and rbx). ([@rrosenblum][]) -* [#1803](https://github.com/bbatsov/rubocop/issues/1803): Don't warn for `return` from `lambda` block in `NonLocalExitFromIterator`. ([@ypresto][]) -* [#1905](https://github.com/bbatsov/rubocop/issues/1905): Ignore sparse and trailing comments in `Style/Documentation`. ([@RGBD][]) -* [#1923](https://github.com/bbatsov/rubocop/issues/1923): Handle properly `for` without body in `Style/Next`. ([@bbatsov][]) -* [#1901](https://github.com/bbatsov/rubocop/issues/1901): Do not auto correct comments that are missing a note. ([@rrosenblum][]) -* [#1926](https://github.com/bbatsov/rubocop/issues/1926): Fix crash in `Style/AlignHash` when correcting a hash with a splat in it. ([@rrosenblum][]) -* [#1935](https://github.com/bbatsov/rubocop/issues/1935): Allow `Symbol#to_proc` blocks in Performance/Size. ([@m1foley][]) - -## 0.31.0 (05/05/2015) - -### New features - -* `Rails/TimeZone` emits acceptable methods on a violation when `EnforcedStyle` is `:acceptable`. ([@l8nite][]) -* Recognize rackup file (config.ru) out of the box. ([@carhartl][]) -* [#1788](https://github.com/bbatsov/rubocop/pull/1788): New cop `ModuleLength` checks for overly long module definitions. ([@sdeframond][]) -* New cop `Performance/Count` to convert `Enumerable#select...size`, `Enumerable#reject...size`, `Enumerable#select...count`, `Enumerable#reject...count` `Enumerable#select...length`, and `Enumerable#reject...length` to `Enumerable#count`. ([@rrosenblum][]) -* `CommentAnnotation` cop does auto-correction. ([@dylandavidson][]) -* New cop `Style/TrailingUnderscoreVariable` to remove trailing underscore variables from mass assignment. ([@rrosenblum][]) -* [#1136](https://github.com/bbatsov/rubocop/issues/1136): New cop `Performance/ParallelAssignment` to avoid usages of unnessary parallel assignment. ([@rrosenblum][]) -* [#1278](https://github.com/bbatsov/rubocop/issues/1278): `DefEndAlignment` and `EndAlignment` cops do auto-correction. ([@lumeet][]) -* `IndentationWidth` cop follows the `AlignWith` option of the `DefEndAlignment` cop. ([@lumeet][]) -* [#1837](https://github.com/bbatsov/rubocop/issues/1837): New cop `EachWithObjectArgument` checks that `each_with_object` isn't called with an immutable object as argument. ([@jonas054][]) -* `ArrayJoin` cop does auto-correction. ([@tmr08c][]) - -### Bugs fixed - -* [#1816](https://github.com/bbatsov/rubocop/issues/1816): Fix bug in `Sample` when calling `#shuffle` with something other than an element selector. ([@rrosenblum][]) -* [#1768](https://github.com/bbatsov/rubocop/pull/1768): `DefEndAlignment` recognizes preceding `private_class_method` or `public_class_method` before `def`. ([@til][]) -* [#1820](https://github.com/bbatsov/rubocop/issues/1820): Correct the logic in `AlignHash` for when to ignore a key because it's not on its own line. ([@jonas054][]) -* [#1829](https://github.com/bbatsov/rubocop/pull/1829): Fix bug in `Sample` and `FlatMap` that would cause them to report having been auto-corrected when they were not. ([@rrosenblum][]) -* [#1832](https://github.com/bbatsov/rubocop/pull/1832): Fix bug in `UnusedMethodArgument` that would cause them to report having been auto-corrected when they were not. ([@jonas054][]) -* [#1834](https://github.com/bbatsov/rubocop/issues/1834): Support only boolean values for `AutoCorrect` configuration parameter, and remove warning for unknown parameter. ([@jonas054][]) -* [#1843](https://github.com/bbatsov/rubocop/issues/1843): Fix crash in `TrailingBlankLines` when a file ends with a block comment without final newline. ([@jonas054][]) -* [#1849](https://github.com/bbatsov/rubocop/issues/1849): Fix bug where you can not have nested arrays in the Rake task configuration. ([@rrosenblum][]) -* Fix bug in `MultilineTernaryOperator` where it will not register an offense when only the false branch is on a separate line. ([@rrosenblum][]) -* Fix crash in `MultilineBlockLayout` when using new lambda literal syntax without parentheses. ([@hbd225][]) -* [#1859](https://github.com/bbatsov/rubocop/pull/1859): Fix bugs in `IfUnlessModifier` concerning comments and empty lines. ([@jonas054][]) -* Fix handling of trailing comma in `SpaceAroundBlockParameters` and `SpaceAfterComma`. ([@lumeet][]) - -## 0.30.1 (21/04/2015) - -### Bugs fixed - -* [#1691](https://github.com/bbatsov/rubocop/issues/1691): For assignments with line break after `=`, use `keyword` alignment in `EndAlignment` regardless of configured style. ([@jonas054][]) -* [#1769](https://github.com/bbatsov/rubocop/issues/1769): Fix bug where `LiteralInInterpolation` registers an offense for interpolation of `__LINE__`. ([@rrosenblum][]) -* [#1773](https://github.com/bbatsov/rubocop/pull/1773): Fix typo ('strptime' -> 'strftime') in `Rails/TimeZone`. ([@palkan][]) -* [#1777](https://github.com/bbatsov/rubocop/pull/1777): Fix offense message from Rails/TimeZone. ([@mzp][]) -* [#1784](https://github.com/bbatsov/rubocop/pull/1784): Add an explicit error message when config contains an empty section. ([@bankair][]) -* [#1791](https://github.com/bbatsov/rubocop/pull/1791): Fix autocorrection of `PercentLiteralDelimiters` with no content. ([@cshaffer][]) -* Fix handling of `while` and `until` with assignment in `IndentationWidth`. ([@lumeet][]) -* [#1793](https://github.com/bbatsov/rubocop/pull/1793): Fix bug in `TrailingComma` that caused `,` in comment to count as a trailing comma. ([@jonas054][]) -* [#1765](https://github.com/bbatsov/rubocop/pull/1765): Update 1.9 hash to stop triggering when the symbol is not valid in the 1.9 hash syntax. ([@crimsonknave][]) -* [#1806](https://github.com/bbatsov/rubocop/issues/1806): Require a newer version of `parser` and use its corrected solution for comment association in `Style/Documentation`. ([@jonas054][]) -* [#1792](https://github.com/bbatsov/rubocop/issues/1792): Fix bugs in `Sample` that did not account for array selectors with a range and passing random to shuffle. ([@rrosenblum][]) -* [#1770](https://github.com/bbatsov/rubocop/pull/1770): Add more acceptable methods to `Rails/TimeZone` (`utc`, `localtime`, `to_i`, `iso8601` etc). ([@palkan][]) -* [#1795](https://github.com/bbatsov/rubocop/pull/1795): Fix bug in `TrailingBlankLines` that caused a crash for files containing only newlines. ([@renuo][]) - -## 0.30.0 (06/04/2015) - -### New features - -* [#1767](https://github.com/bbatsov/rubocop/pull/1767): Do not register offenses on non-enumerable select/find_all by `Performance/Detect`. ([@palkan][]) -* [#1600](https://github.com/bbatsov/rubocop/issues/1600): Add `line_count_based` and `semantic` styles to the `BlockDelimiters` (formerly `Blocks`) cop. ([@clowder][], [@mudge][]) -* [#1712](https://github.com/bbatsov/rubocop/pull/1712): Set `Offense#corrected?` to `true`, `false`, or `nil` when it was, wasn't, or can't be auto-corrected, respectively. ([@vassilevsky][]) -* [#1669](https://github.com/bbatsov/rubocop/pull/1669): Add command-line switch `--display-style-guide`. ([@marxarelli][]) -* [#1405](https://github.com/bbatsov/rubocop/issues/1405): Add Rails TimeZone and Date cops. ([@palkan][]) -* [#1641](https://github.com/bbatsov/rubocop/pull/1641): Add ruby19_no_mixed_keys style to `HashStyle` cop. ([@iainbeeston][]) -* [#1604](https://github.com/bbatsov/rubocop/issues/1604): Add `IgnoreClassMethods` option to `TrivialAccessors` cop. ([@bbatsov][]) -* [#1651](https://github.com/bbatsov/rubocop/issues/1651): The `Style/SpaceAroundOperators` cop now also detects extra spaces around operators. A list of operators that *may* be surrounded by multiple spaces is configurable. ([@bquorning][]) -* Add auto-correct to `Encoding` cop. ([@rrosenblum][]) -* [#1621](https://github.com/bbatsov/rubocop/issues/1621): `TrailingComma` has a new style `consistent_comma`. ([@tamird][]) -* [#1611](https://github.com/bbatsov/rubocop/issues/1611): Add `empty`, `nil`, and `both` `SupportedStyles` to `EmptyElse` cop. Default is `both`. ([@rrosenblum][]) -* [#1611](https://github.com/bbatsov/rubocop/issues/1611): Add new `MissingElse` cop. Default is to have this cop be disabled. ([@rrosenblum][]) -* [#1602](https://github.com/bbatsov/rubocop/issues/1602): Add support for `# :nodoc` in `Documentation`. ([@lumeet][]) -* [#1437](https://github.com/bbatsov/rubocop/issues/1437): Modify `HashSyntax` cop to allow the use of hash rockets for hashes that have symbol values when using ruby19 syntax. ([@rrosenblum][]) -* New cop `Style/SymbolLiteral` makes sure you're not using the string within symbol syntax unless it's needed. ([@bbatsov][]) -* [#1657](https://github.com/bbatsov/rubocop/issues/1657): Autocorrect can be turned off on a specific cop via the configuration. ([@jdoconnor][]) -* New cop `Style/AutoResourceCleanup` suggests the use of block taking versions of methods that do resource cleanup. ([@bbatsov][]) -* [#1275](https://github.com/bbatsov/rubocop/issues/1275): `WhileUntilModifier` cop does auto-correction. ([@lumeet][]) -* New cop `Performance/ReverseEach` to convert `reverse.each` to `reverse_each`. ([@rrosenblum][]) -* [#1281](https://github.com/bbatsov/rubocop/issues/1281): `IfUnlessModifier` cop does auto-correction. ([@lumeet][]) -* New cop `Performance/Detect` to detect usage of `select.first`, `select.last`, `find_all.first`, and `find_all.last` and convert them to use `detect` instead. ([@palkan][], [@rrosenblum][]) -* [#1728](https://github.com/bbatsov/rubocop/pull/1728): New cop `NonLocalExitFromIterator` checks for misused `return` in block. ([@ypresto][]) -* New cop `Performance/Size` to convert calls to `count` on `Array` and `Hash` to `size`. ([@rrosenblum][]) -* New cop `Performance/Sample` to convert usages of `shuffle.first`, `shuffle.last`, and `shuffle[Fixnum]` to `sample`. ([@rrosenblum][]) -* New cop `Performance/FlatMap` to convert `Enumerable#map...Array#flatten` and `Enumerable#collect...Array#flatten` to `Enumerable#flat_map`. ([@rrosenblum][]) -* [#1144](https://github.com/bbatsov/rubocop/issues/1144): New cop `ClosingParenthesisIndentation` checks the indentation of hanging closing parentheses. ([@jonas054][]) -* New Rails cop `FindBy` identifies usages of `where.first` and `where.take`. ([@bbatsov][]) -* New Rails cop `FindEach` identifies usages of `all.each`. ([@bbatsov][]) -* [#1342](https://github.com/bbatsov/rubocop/issues/1342): `IndentationConsistency` is now configurable with the styles `normal` and `rails`. ([@jonas054][]) - -### Bugs fixed - -* [#1705](https://github.com/bbatsov/rubocop/issues/1705): Fix crash when reporting offenses of `MissingElse` cop. ([@gerry3][]) -* [#1659](https://github.com/bbatsov/rubocop/pull/1659): Fix stack overflow with JRuby and Windows 8, during initial config validation. ([@pimterry][]) -* [#1694](https://github.com/bbatsov/rubocop/issues/1694): Ignore methods with a `blockarg` in `TrivialAccessors`. ([@bbatsov][]) -* [#1617](https://github.com/bbatsov/rubocop/issues/1617): Always read the html output template using utf-8. ([@bbatsov][]) -* [#1684](https://github.com/bbatsov/rubocop/issues/1684): Ignore symbol keys like `:"string"` in `HashSyntax`. ([@bbatsov][]) -* Handle explicit `begin` blocks in `Lint/Void`. ([@bbatsov][]) -* Handle symbols in `Lint/Void`. ([@bbatsov][]) -* [#1695](https://github.com/bbatsov/rubocop/pull/1695): Fix bug with `--auto-gen-config` and `SpaceInsideBlockBraces`. ([@meganemura][]) -* Correct issues with whitespace around multi-line lambda arguments. ([@zvkemp][]) -* [#1579](https://github.com/bbatsov/rubocop/issues/1579): Fix handling of similar-looking blocks in `BlockAlignment`. ([@lumeet][]) -* [#1676](https://github.com/bbatsov/rubocop/pull/1676): Fix auto-correct in `Lambda` when a new multi-line lambda is used as an argument. ([@lumeet][]) -* [#1656](https://github.com/bbatsov/rubocop/issues/1656): Fix bug that would include hidden directories implicitly. ([@jonas054][]) -* [#1728](https://github.com/bbatsov/rubocop/pull/1728): Fix bug in `LiteralInInterpolation` and `AssignmentInCondition`. ([@ypresto][]) -* [#1735](https://github.com/bbatsov/rubocop/issues/1735): Handle trailing space in `LineEndConcatenation` autocorrect. ([@jonas054][]) -* [#1750](https://github.com/bbatsov/rubocop/issues/1750): Escape offending code lines output by the HTML formatter in case they contain markup. ([@jonas054][]) -* [#1541](https://github.com/bbatsov/rubocop/issues/1541): No inspection of text that follows `__END__`. ([@jonas054][]) -* Fix comment detection in `Style/Documentation`. ([@lumeet][]) -* [#1637](https://github.com/bbatsov/rubocop/issues/1637): Fix handling of `binding` calls in `UnusedBlockArgument` and `UnusedMethodArgument`. ([@lumeet][]) - -### Changes - -* [#1397](https://github.com/bbatsov/rubocop/issues/1397): `UnneededPercentX` renamed to `CommandLiteral`. The cop can be configured to enforce using either `%x` or backticks around command literals, or using `%x` around multi-line commands and backticks around single-line commands. The cop ignores heredoc commands. ([@bquorning][]) -* [#1020](https://github.com/bbatsov/rubocop/issues/1020): Removed the `MaxSlashes` configuration option for `RegexpLiteral`. Instead, the cop can be configured to enforce using either `%r` or slashes around regular expressions, or using `%r` around multi-line regexes and slashes around single-line regexes. ([@bquorning][]) -* [#1734](https://github.com/bbatsov/rubocop/issues/1734): The default exclusion of hidden directories has been optimized for speed. ([@jonas054][]) -* [#1673](https://github.com/bbatsov/rubocop/issues/1673): `Style/TrivialAccessors` now requires matching names by default. ([@bbatsov][]) - -## 0.29.1 (13/02/2015) - -### Bugs fixed - -* [#1638](https://github.com/bbatsov/rubocop/issues/1638): Use Parser functionality rather than regular expressions for matching comments in `FirstParameterIndentation`. ([@jonas054][]) -* [#1642](https://github.com/bbatsov/rubocop/issues/1642): Raise the correct exception if the configuration file is malformed. ([@bquorning][]) -* [#1647](https://github.com/bbatsov/rubocop/issues/1647): Skip `SpaceAroundBlockParameters` when lambda has no argument. ([@eitoball][]) -* [#1649](https://github.com/bbatsov/rubocop/issues/1649): Handle exception assignments in `UselessSetterCall`. ([@bbatsov][]) -* [#1644](https://github.com/bbatsov/rubocop/issues/1644): Don't search the entire file system when a folder is named `,`. ([@bquorning][]) - -## 0.29.0 (05/02/2015) - -### New features - -* [#1430](https://github.com/bbatsov/rubocop/issues/1430): Add `--except` option for disabling cops on the command line. ([@jonas054][]) -* [#1506](https://github.com/bbatsov/rubocop/pull/1506): Add auto-correct from `EvenOdd` cop. ([@blainesch][]) -* [#1507](https://github.com/bbatsov/rubocop/issues/1507): `Debugger` cop now checks for the Capybara debug methods `save_and_open_page` and `save_and_open_screenshot`. ([@rrosenblum][]) -* [#1539](https://github.com/bbatsov/rubocop/pull/1539): Implement autocorrection for Rails/ReadWriteAttribute cop. ([@huerlisi][]) -* [#1324](https://github.com/bbatsov/rubocop/issues/1324): Add `AllCops/DisplayCopNames` configuration option for showing cop names in reports, like `--display-cop-names`. ([@jonas054][]) -* [#1271](https://github.com/bbatsov/rubocop/issues/1271): `Lambda` cop does auto-correction. ([@lumeet][]) -* [#1284](https://github.com/bbatsov/rubocop/issues/1284): Support namespaces, e.g. `Lint`, in the arguments to `--only` and `--except`. ([@jonas054][]) -* [#1276](https://github.com/bbatsov/rubocop/issues/1276): `SelfAssignment` cop does auto-correction. ([@lumeet][]) -* Add autocorrect to `RedundantException`. ([@mattjmcnaughton][]) -* [#1571](https://github.com/bbatsov/rubocop/pull/1571): New cop `StructInheritance` checks for inheritance from Struct.new. ([@mmozuras][]) -* [#1575](https://github.com/bbatsov/rubocop/issues/1575): New cop `DuplicateMethods` points out duplicate method name in class and module. ([@d4rk5eed][]) -* [#1144](https://github.com/bbatsov/rubocop/issues/1144): New cop `FirstParameterIndentation` checks the indentation of the first parameter in a method call. ([@jonas054][]) -* [#1627](https://github.com/bbatsov/rubocop/issues/1627): New cop `SpaceAroundBlockParameters` checks the spacing inside and after block parameters pipes. ([@jonas054][]) - -### Changes - -* [#1492](https://github.com/bbatsov/rubocop/pull/1492): Abort when auto-correct causes an infinite loop. ([@dblock][]) -* Options `-e`/`--emacs` and `-s`/`--silent` are no longer recognized. Using them will now raise an error. ([@bquorning][]) -* [#1565](https://github.com/bbatsov/rubocop/issues/1565): Let `--fail-level A` cause exit with error if all offenses are auto-corrected. ([@jonas054][]) -* [#1309](https://github.com/bbatsov/rubocop/issues/1309): Add argument handling to `MultilineBlockLayout`. ([@lumeet][]) - -### Bugs fixed - -* [#1634](https://github.com/bbatsov/rubocop/pull/1634): Fix `PerlBackrefs` Cop Autocorrections to Not Raise. ([@cshaffer][]) -* [#1553](https://github.com/bbatsov/rubocop/pull/1553): Fix bug where `Style/EmptyLinesAroundAccessModifier` interfered with `Style/EmptyLinesAroundBlockBody` when there is and access modifier at the beginning of a block. ([@volkert][]) -* Handle element assignment in `Lint/AssignmentInCondition`. ([@jonas054][]) -* [#1484](https://github.com/bbatsov/rubocop/issues/1484): Fix `EmptyLinesAroundAccessModifier` incorrectly finding a violation inside method calls with names identical to an access modifier. ([@dblock][]) -* Fix bug concerning `Exclude` properties inherited from a higher directory level. ([@jonas054][]) -* [#1500](https://github.com/bbatsov/rubocop/issues/1500): Fix crashing `--auto-correct --only IndentationWidth`. ([@jonas054][]) -* [#1512](https://github.com/bbatsov/rubocop/issues/1512): Fix false negative for typical string formatting examples. ([@kakutani][], [@jonas054][]) -* [#1504](https://github.com/bbatsov/rubocop/issues/1504): Fail with a meaningful error if the configuration file is malformed. ([@bquorning][]) -* Fix bug where `auto_correct` Rake tasks does not take in the options specified in its parent task. ([@rrosenblum][]) -* [#1054](https://github.com/bbatsov/rubocop/issues/1054): Handle comments within concatenated strings in `LineEndConcatenation`. ([@yujinakayama][], [@jonas054][]) -* [#1527](https://github.com/bbatsov/rubocop/issues/1527): Make autocorrect `BracesAroundHashParameter` leave the correct number of spaces. ([@mattjmcnaughton][]) -* [#1547](https://github.com/bbatsov/rubocop/issues/1547): Don't print `[Corrected]` when auto-correction was avoided in `Style/Semicolon`. ([@jonas054][]) -* [#1573](https://github.com/bbatsov/rubocop/issues/1573): Fix assignment-related auto-correction for `BlockAlignment`. ([@lumeet][]) -* [#1587](https://github.com/bbatsov/rubocop/pull/1587): Exit with exit code 1 if there were errors ("crashing" cops). ([@jonas054][]) -* [#1574](https://github.com/bbatsov/rubocop/issues/1574): Avoid auto-correcting `Hash.new` to `{}` when braces would be interpreted as a block. ([@jonas054][]) -* [#1591](https://github.com/bbatsov/rubocop/issues/1591): Don't check parameters inside `[]` in `MultilineOperationIndentation`. ([@jonas054][]) -* [#1509](https://github.com/bbatsov/rubocop/issues/1509): Ignore class methods in `Rails/Delegate`. ([@bbatsov][]) -* [#1594](https://github.com/bbatsov/rubocop/issues/1594): Fix `@example` warnings in Yard Doc documentation generation. ([@mattjmcnaughton][]) -* [#1598](https://github.com/bbatsov/rubocop/issues/1598): Fix bug in file inclusion when running from another directory. ([@jonas054][]) -* [#1580](https://github.com/bbatsov/rubocop/issues/1580): Don't print `[Corrected]` when auto-correction was avoided in `TrivialAccessors`. ([@lumeet][]) -* [#1612](https://github.com/bbatsov/rubocop/issues/1612): Allow `expand_path` on `inherit_from` in `.rubocop.yml`. ([@mattjmcnaughton][]) -* [#1610](https://github.com/bbatsov/rubocop/issues/1610): Check that class method names actually match the name of the containing class/module in `Style/ClassMethods`. ([@bbatsov][]) - -## 0.28.0 (10/12/2014) +## 1.31.2 (2022-07-07) + +### Bug fixes + +* [#10774](https://github.com/rubocop/rubocop/pull/10774): Fix false negatives in `Style/DocumentationMethod` when a public method is defined after a private one. ([@Darhazer][]) +* [#10764](https://github.com/rubocop/rubocop/issues/10764): Fix performance issue for `Layout/FirstHashElementIndentation` and `Layout/FirstArrayElementIndentation`. ([@j-miyake][]) +* [#10780](https://github.com/rubocop/rubocop/issues/10780): Fix an error when using `rubocop:auto_correct` deprecated custom rake task. ([@koic][]) +* [#10786](https://github.com/rubocop/rubocop/issues/10786): Fix a false positive for `Lint/NonAtomicFileOperation` when using complex conditional. ([@koic][]) +* [#10785](https://github.com/rubocop/rubocop/pull/10785): Fix a false negative for `Style/RedundantParentheses` when parens around a receiver of a method call with an argument. ([@koic][]) +* [#10026](https://github.com/rubocop/rubocop/issues/10026): Fix merging of array parameters in either parent of default config. ([@jonas054][]) + +## 1.31.1 (2022-06-29) + +### Bug fixes + +* [#10763](https://github.com/rubocop/rubocop/issues/10763): Fix a false positive for `Layout/LineContinuationSpacing` when using continuation keyword `\` after `__END__`. ([@koic][]) +* [#10755](https://github.com/rubocop/rubocop/issues/10755): Fix a false positive for `Lint/LiteralAsCondition` when using a literal in `case-in` condition where the match variable is used in `in` are accepted as a pattern matching. ([@koic][]) +* [#10760](https://github.com/rubocop/rubocop/issues/10760): Fix a false positive for `Lint/NonAtomicFileOperation` when using `FileTest.exist?` with `if` condition that has `else` branch. ([@koic][]) +* [#10745](https://github.com/rubocop/rubocop/issues/10745): Require JSON 2.3 or higher to fix an incompatible JSON API error. ([@koic][]) +* [#10754](https://github.com/rubocop/rubocop/issues/10754): Fix an incorrect autocorrect for `Style/HashExcept` when using a non-literal collection receiver for `include?`. ([@koic][]) +* [#10751](https://github.com/rubocop/rubocop/issues/10751): Fix autocorrect for `Layout/FirstHashElementIndentation`. ([@j-miyake][]) +* [#10750](https://github.com/rubocop/rubocop/pull/10750): Recover 7x slow running `rubocop`. ([@koic][]) + +## 1.31.0 (2022-06-27) + +### New features + +* [#10699](https://github.com/rubocop/rubocop/pull/10699): Add new global `ActiveSupportExtensionsEnabled` option. ([@nobuyo][]) +* [#10245](https://github.com/rubocop/rubocop/pull/10245): Add specification_version and rubygems_version to `Gemspec/DeprecatedAttributeAssignment`. ([@kaitielth][]) +* [#10696](https://github.com/rubocop/rubocop/pull/10696): Add new `Lint/NonAtomicFileOperation` cop. ([@ydah][]) +* [#6420](https://github.com/rubocop/rubocop/issues/6420): Add new `Layout/LineContinuationLeadingSpace` cop. ([@bquorning][]) +* [#6420](https://github.com/rubocop/rubocop/issues/6420): Add new `Layout/LineContinuationSpacing` cop. ([@bquorning][]) +* [#10706](https://github.com/rubocop/rubocop/pull/10706): Integrate rubocop-daemon to add server options. ([@koic][]) +* [#10722](https://github.com/rubocop/rubocop/pull/10722): Add new `Lint/ConstantOverwrittenInRescue` cop. ([@ydah][]) + +### Bug fixes + +* [#10700](https://github.com/rubocop/rubocop/issues/10700): Update `Style/EmptyMethod` to not correct if the correction would exceed the configuration for `Layout/LineLength`. ([@dvandersluis][]) +* [#10698](https://github.com/rubocop/rubocop/issues/10698): Enhance `Style/HashExcept` to support array inclusion checks. ([@nobuyo][]) +* [#10734](https://github.com/rubocop/rubocop/issues/10734): Handle `ClobberingError` in `Style/NestedTernaryOperator` when there are multiple nested ternaries. ([@dvandersluis][]) +* [#10689](https://github.com/rubocop/rubocop/issues/10689): Fix autocorrect for `Layout/FirstHashElementIndentation` and `Layout/FirstArrayElementIndentation`. ([@j-miyake][]) +* Fix `rubocop -V` not displaying the version information for rubocop-graphql, rubocop-md and rubocop-thread_safety. ([@Darhazer][]) +* [#10711](https://github.com/rubocop/rubocop/issues/10711): Fix an error for `Style/MultilineTernaryOperator` when the false branch is on a separate line. ([@koic][]) +* [#10719](https://github.com/rubocop/rubocop/issues/10719): Fix a false positive for `Lint/ParenthesesAsGroupedExpression` when using safe navigation operator. ([@koic][]) +* [#10736](https://github.com/rubocop/rubocop/pull/10736): Fix `Layout/SpaceInsideBlockBraces` for blocks with numbered arguments. ([@gsamokovarov][]) +* [#10749](https://github.com/rubocop/rubocop/pull/10749): Fix `Style/BlockDelimiters` for blocks with numbered arguments. ([@gsamokovarov][]) +* [#10737](https://github.com/rubocop/rubocop/issues/10737): Fix crash in `Style/ConditionalAssignment` with `EnforcedStyle: assign_inside_condition` when op-assigning a variable inside a `resbody`. ([@dvandersluis][]) +* [#7900](https://github.com/rubocop/rubocop/issues/7900): Fix `Style/FormatStringToken` false positive with formatted input and `template` style enforced, and add autocorrection. ([@FnControlOption][]) + +### Changes + +* [#10730](https://github.com/rubocop/rubocop/pull/10730): Change output timing of GitHubActionsFormatter. ([@r7kamura][]) +* [#10709](https://github.com/rubocop/rubocop/pull/10709): Deprecate `rubocop:auto_correct` custom rake task and newly split `rubocop:autocorrect` and `rubocop:autocorrect-all` custom rake tasks. ([@koic][]) +* [#9760](https://github.com/rubocop/rubocop/issues/9760): Change RangeHelp#range_with_surrounding_space to allow passing the range as a positional argument. ([@pirj][]) +* [#10693](https://github.com/rubocop/rubocop/issues/10693): Add ignore case for `Layout/EmptyLinesAroundAttributeAccessor` when there is a comment line on the next line. ([@ydah][]) +* [#10245](https://github.com/rubocop/rubocop/pull/10245): **(Breaking)** integrate `Gemspec/DateAssignment` into `Gemspec/DeprecatedAttributeAssignment`. ([@kaitielth][]) +* [#10697](https://github.com/rubocop/rubocop/pull/10697): Restore `Lint/UselessElseWithoutRescue` cop. ([@koic][]) +* [#10740](https://github.com/rubocop/rubocop/pull/10740): Make `Style/GuardClause` a bit more lenient when the replacement would make the code more verbose. ([@dvandersluis][]) + +## 1.30.1 (2022-06-06) + +### Bug fixes + +* [#10685](https://github.com/rubocop/rubocop/issues/10685): Fix a false positive for `Style/StringConcatenation` when `Mode: conservative` and first operand is not string literal. ([@koic][]) +* [#10670](https://github.com/rubocop/rubocop/pull/10670): Fix a false positive for `Style/FetchEnvVar` in the body with assignment method. ([@ydah][]) +* [#10671](https://github.com/rubocop/rubocop/issues/10671): Fix an incorrect autocorrect for `EnforcedStyle: with_first_argument` of `Layout/ArgumentAlignment` and `EnforcedColonStyle: separator` of `Layout/HashAlignment`. ([@koic][]) +* [#10676](https://github.com/rubocop/rubocop/pull/10676): Fix `--ignore-unrecognized-cops` option always showing empty warning even if there was no problem. ([@nobuyo][]) +* [#10674](https://github.com/rubocop/rubocop/issues/10674): Fix a false positive for `Naming/AccessorMethodName` with type of the first argument is other than `arg`. ([@ydah][]) +* [#10679](https://github.com/rubocop/rubocop/issues/10679): Fix a false positive for `Style/SafeNavigation` when `TargetRubyVersion: 2.2` or lower. ([@koic][]) + +### Changes + +* [#10673](https://github.com/rubocop/rubocop/pull/10673): Update auto-gen-config's comment re auto-correct for `SafeAutoCorrect: false`. ([@ydah][]) + +## 1.30.0 (2022-05-26) ### New features -* [#1450](https://github.com/bbatsov/rubocop/issues/1450): New cop `ExtraSpacing` points out unnecessary spacing in files. ([@blainesch][]) -* New cop `EmptyLinesAroundBlockBody` provides same functionality as the EmptyLinesAround(Class|Method|Module)Body but for blocks. ([@jcarbo][]) -* New cop `Style/EmptyElse` checks for empty `else`-clauses. ([@Koronen][]) -* [#1454](https://github.com/bbatsov/rubocop/issues/1454): New `--only-guide-cops` and `AllCops/StyleGuideCopsOnly` options that will only enforce cops that link to a style guide. ([@marxarelli][]) +* [#10065](https://github.com/rubocop/rubocop/issues/10065): Add new `Gemspec/DeprecatedAttributeAssignment` cop. ([@koic][]) +* [#10608](https://github.com/rubocop/rubocop/pull/10608): Add new `Style/MapCompactWithConditionalBlock` cop. ([@nobuyo][]) +* [#10627](https://github.com/rubocop/rubocop/issues/10627): Add command-line option `--ignore-unrecognized-cops` to ignore any unknown cops or departments in .rubocop.yml. ([@nobuyo][]) +* [#10620](https://github.com/rubocop/rubocop/pull/10620): Add Sorbet's `typed` sigil as a magic comment. ([@zachahn][]) + +### Bug fixes + +* [#10662](https://github.com/rubocop/rubocop/pull/10662): Recover Ruby 2.1 code analysis using `TargetRubyVersion: 2.1`. ([@koic][]) +* [#10396](https://github.com/rubocop/rubocop/issues/10396): Fix autocorrect for `Layout/IndentationWidth` to leave module/class body unchanged to avoid infinite autocorrect loop with `Layout/IndentationConsistency` when body trails after class/module definition. ([@johnny-miyake][]) +* [#10636](https://github.com/rubocop/rubocop/issues/10636): Fix false positive in `Style/RedundantCondition` when the branches call the same method on different receivers. ([@dvandersluis][]) +* [#10651](https://github.com/rubocop/rubocop/issues/10651): Fix autocorrect for `Style/For` when using array with operator methods as collection. ([@nobuyo][]) +* [#10629](https://github.com/rubocop/rubocop/pull/10629): Fix default Ruby version from 2.5 to 2.6. ([@koic][]) +* [#10661](https://github.com/rubocop/rubocop/pull/10661): Fix a false negative for `Style/SymbolProc` when method has no arguments and `AllowMethodsWithArguments: true`. ([@koic][]) +* [#10631](https://github.com/rubocop/rubocop/issues/10631): Fix autocorrect for `Style/RedundantBegin`. ([@johnny-miyake][]) +* [#10652](https://github.com/rubocop/rubocop/issues/10652): Fix a false positive for `Style/FetchEnvVar` in conditions. ([@ydah][]) +* [#10665](https://github.com/rubocop/rubocop/issues/10665): Fix an incorrect autocorrect for `EnforcedStyle: with_first_argument` of `Layout/ArgumentAlignment` and `EnforcedColonStyle: separator` of `Layout/HashAlignment`. ([@koic][]) +* [#10258](https://github.com/rubocop/rubocop/issues/10258): Recover Ruby 2.4 code analysis using `TargetRubyVersion: 2.4`. ([@koic][]) +* [#10668](https://github.com/rubocop/rubocop/pull/10668): Recover Ruby 2.0 code analysis using `TargetRubyVersion: 2.0`. ([@koic][]) +* [#10644](https://github.com/rubocop/rubocop/pull/10644): Recover Ruby 2.2 code analysis using `TargetRubyVersion: 2.2`. ([@koic][]) +* [#10639](https://github.com/rubocop/rubocop/issues/10639): Fix `Style/HashSyntax` to exclude files that violate it with `EnforceHashShorthandSyntax` when running `auto-gen-config`. ([@nobuyo][]) +* [#10633](https://github.com/rubocop/rubocop/issues/10633): Fix infinite autocorrection loop in `Style/AccessorGrouping` when combining multiple of the same accessor. ([@dvandersluis][]) +* [#10618](https://github.com/rubocop/rubocop/issues/10618): Fix `LineBreakCorrector` so that it won't remove a semicolon in the class/module body. ([@johnny-miyake][]) +* [#10646](https://github.com/rubocop/rubocop/issues/10646): Fix an incorrect autocorrect for `Style/SoleNestedConditional` when using `unless` and `&&` without parens in the outer condition and nested modifier condition. ([@koic][]) +* [#10659](https://github.com/rubocop/rubocop/issues/10659): Fix automatically appended path for `inherit_from` by `auto-gen-config` is incorrect if specified config file in a subdirectory as an option. ([@nobuyo][]) +* [#10640](https://github.com/rubocop/rubocop/pull/10640): Recover Ruby 2.3 code analysis using `TargetRubyVersion: 2.3`. ([@koic][]) +* [#10657](https://github.com/rubocop/rubocop/issues/10657): Fix `--auto-gen-config` command option ignores specified config file by option. ([@nobuyo][]) ### Changes -* [#801](https://github.com/bbatsov/rubocop/issues/801): New style `context_dependent` for `Style/BracesAroundHashParameters` looks at preceding parameter to determine if braces should be used for final parameter. ([@jonas054][]) -* [#1427](https://github.com/bbatsov/rubocop/issues/1427): Excluding directories on the top level is now done earlier, so that these file trees are not searched, thus saving time when inspecting projects with many excluded files. ([@jonas054][]) -* [#1325](https://github.com/bbatsov/rubocop/issues/1325): When running with `--auto-correct`, only offenses *that can not be corrected* will result in a non-zero exit code. ([@jonas054][]) -* [#1445](https://github.com/bbatsov/rubocop/issues/1445): Allow sprockets directive comments (starting with `#=`) in `Style/LeadingCommentSpace`. ([@bbatsov][]) +* [#10095](https://github.com/rubocop/rubocop/issues/10095): Change "auto-correct" to "autocorrect" in arguments, documentation, messages, comments, and specs. ([@chris-hewitt][]) +* [#10656](https://github.com/rubocop/rubocop/issues/10656): Mark `Style/RedundantInterpolation` as unsafe autocorrection. ([@koic][]) +* [#10616](https://github.com/rubocop/rubocop/pull/10616): Markdown formatter: skip files with no offenses. ([@rickselby][]) + +## 1.29.1 (2022-05-12) + +### Bug fixes + +* [#10625](https://github.com/rubocop/rubocop/issues/10625): Restore the specification to `TargetRubyVersion: 2.5`. ([@koic][]) +* [#10569](https://github.com/rubocop/rubocop/issues/10569): Fix a false positive for `Style/FetchEnvVar` when using the same `ENV` var as `if` condition in the body. ([@koic][]) +* [#10614](https://github.com/rubocop/rubocop/issues/10614): Make `Lint/NonDeterministicRequireOrder` aware of `require_relative`. ([@koic][]) +* [#10607](https://github.com/rubocop/rubocop/issues/10607): Fix autocorrect for `Style/RedundantCondition` when there are parenthesized method calls in each branch. ([@nobuyo][]) +* [#10622](https://github.com/rubocop/rubocop/issues/10622): Fix a false positive for `Style/RaiseArgs` when error type class constructor with keyword arguments and message argument. ([@koic][]) +* [#10610](https://github.com/rubocop/rubocop/pull/10610): Fix an error for `Naming/InclusiveLanguage` string with invalid byte sequence in UTF-8. ([@ydah][]) +* [#10605](https://github.com/rubocop/rubocop/issues/10605): Fix autocorrect for `Style/RedundantCondition` if argument for method in else branch is hash without braces. ([@nobuyo][]) -### Bugs fixed +## 1.29.0 (2022-05-06) -* Fix `%W[]` auto corrected to `%w(]`. ([@toy][]) -* Fix Style/ElseAlignment Cop to find the right parent on def/rescue/else/ensure/end. ([@oneamtu][]) -* [#1181](https://github.com/bbatsov/rubocop/issues/1181): *(fix again)* `Style/StringLiterals` cop stays away from strings inside interpolated expressions. ([@jonas054][]) -* [#1441](https://github.com/bbatsov/rubocop/issues/1441): Correct the logic used by `Style/Blocks` and other cops to determine if an auto-correction would alter the meaning of the code. ([@jonas054][]) -* [#1449](https://github.com/bbatsov/rubocop/issues/1449): Handle the case in `MultilineOperationIndentation` where instances of both correct style and unrecognized (plain wrong) style are detected during an `--auto-gen-config` run. ([@jonas054][]) -* [#1456](https://github.com/bbatsov/rubocop/pull/1456): Fix autocorrect in `SymbolProc` when there are multiple offenses on the same line. ([@jcarbo][]) -* [#1459](https://github.com/bbatsov/rubocop/issues/1459): Handle parenthesis around the condition in `--auto-correct` for `NegatedWhile`. ([@jonas054][]) -* [#1465](https://github.com/bbatsov/rubocop/issues/1465): Fix autocorrect of code like `#$1` in `PerlBackrefs`. ([@bbatsov][]) -* Fix autocorrect of code like `#$:` in `SpecialGlobalVars`. ([@bbatsov][]) -* [#1466](https://github.com/bbatsov/rubocop/issues/1466): Allow leading underscore for unused parameters in `SingleLineBlockParams`. ([@jonas054][]) -* [#1470](https://github.com/bbatsov/rubocop/issues/1470): Handle `elsif` + `else` in `ElseAlignment`. ([@jonas054][]) -* [#1474](https://github.com/bbatsov/rubocop/issues/1474): Multiline string with both `<<` and `\` caught by `Style/LineEndConcatenation` cop. ([@katieschilling][]) -* [#1485](https://github.com/bbatsov/rubocop/issues/1485): Ignore procs in `SymbolProc`. ([@bbatsov][]) -* [#1473](https://github.com/bbatsov/rubocop/issues/1473): `Style/MultilineOperationIndentation` doesn't recognize assignment to array/hash element. ([@jonas054][]) +### New features + +* [#10570](https://github.com/rubocop/rubocop/issues/10570): Add new `Gemspec/DependencyVersion` cop. ([@nobuyo][]) +* [#10542](https://github.com/rubocop/rubocop/pull/10542): Add markdown formatter. ([@joe-sharp][]) +* [#10539](https://github.com/rubocop/rubocop/issues/10539): Add `AllowedPatterns` configuration option to `Naming/VariableNumber` and `Naming/VariableName`. ([@henrahmagix][]) +* [#10568](https://github.com/rubocop/rubocop/issues/10568): Add new `Style/EnvHome` cop. ([@koic][]) + +### Bug fixes -## 0.27.1 (08/11/2014) +* [#10586](https://github.com/rubocop/rubocop/issues/10586): Fix a false positive for `Style/DoubleNegation` when using `define_method` or `define_singleton_method`. ([@ydah][]) +* [#10579](https://github.com/rubocop/rubocop/issues/10579): Fix a false positive for `Style/FetchEnvVar` when calling a method with safe navigation. ([@koic][]) +* [#10581](https://github.com/rubocop/rubocop/issues/10581): Fix a false positive for `Style/FetchEnvVar` when comparing with `ENV['TERM']`. ([@koic][]) +* [#10589](https://github.com/rubocop/rubocop/issues/10589): Fix autocorrect for `Style/RaiseArgs` with `EnforcedStyle: compact` and exception object is assigned to a local variable. ([@nobuyo][]) +* [#10325](https://github.com/rubocop/rubocop/issues/10325): Enhance `Style/RedundantCondition` by considering the case that variable assignments in each branch. ([@nobuyo][]) +* [#10592](https://github.com/rubocop/rubocop/issues/10592): Fix infinite loop on `Style/MultilineTernaryOperator` if using assignment method and condition/branch is multiline. ([@nobuyo][]) +* [#10536](https://github.com/rubocop/rubocop/issues/10536): Fix validation for command-line options combination of `--display-only-fail-level-offenses` and `--auto-correct`. ([@nobuyo][]) ### Changes -* [#1343](https://github.com/bbatsov/rubocop/issues/1343): Remove auto-correct from `RescueException` cop. ([@bbatsov][]) -* [#1425](https://github.com/bbatsov/rubocop/issues/1425): `AllCops/Include` configuration parameters are only taken from the project `.rubocop.yml` and files it inherits from, not from `.rubocop.yml` files in subdirectories. ([@jonas054][]) +* [#10577](https://github.com/rubocop/rubocop/pull/10577): **(Compatibility)** Drop support for Ruby 2.5 and JRuby 9.2 (CRuby 2.5 compatible). ([@koic][]) +* [#10585](https://github.com/rubocop/rubocop/pull/10585): Enhance the autocorrect for `Style/FetchEnvVar`. ([@johnny-miyake][]) +* [#10577](https://github.com/rubocop/rubocop/pull/10577): **(Breaking)** Retire `Lint/UselessElseWithoutRescue` cop. ([@koic][]) + +## 1.28.2 (2022-04-25) + +### Bug fixes + +* [#10566](https://github.com/rubocop/rubocop/issues/10566): Fix a false positive for `Lint/AmbiguousBlockAssociation` when using proc is used as a last argument. ([@koic][]) +* [#10573](https://github.com/rubocop/rubocop/issues/10573): Fix a false positive for `Layout/SpaceBeforeBrackets` when there is a dot before brackets. ([@nobuyo][]) +* [#10563](https://github.com/rubocop/rubocop/issues/10563): Fix `Style/BlockDelimiters` unexpectedly deletes block on moving comment if methods with block are chained. ([@nobuyo][]) +* [#10574](https://github.com/rubocop/rubocop/issues/10574): Fix a false positive for `Style/SingleArgumentDig` when using dig with arguments forwarding. ([@ydah][]) +* [#10565](https://github.com/rubocop/rubocop/pull/10565): Fix a false positive and a true negative for `Style/FetchEnvVar`. ([@koic][]) + +## 1.28.1 (2022-04-21) + +### Bug fixes + +* [#10559](https://github.com/rubocop/rubocop/issues/10559): Fix crash on CodeLengthCalculator if method call is not parenthesized. ([@nobuyo][]) +* [#10557](https://github.com/rubocop/rubocop/issues/10557): Fix a false positive for `Style/FetchEnvVar` when `ENV['key']` is a receiver of `||=`. ([@koic][]) + +## 1.28.0 (2022-04-21) + +### New features + +* [#10551](https://github.com/rubocop/rubocop/pull/10551): Add `AllowComments` option to `Style/RedundantInitialize` is true by default. ([@koic][]) +* [#10552](https://github.com/rubocop/rubocop/pull/10552): Support autocorrection for `Style/RedundantInitialize`. ([@koic][]) +* [#10441](https://github.com/rubocop/rubocop/pull/10441): Add `Security/CompoundHash` cop. ([@sambostock][], [@chrisseaton][]) +* [#10521](https://github.com/rubocop/rubocop/pull/10521): Add `use_builtin_english_names` style to `Style/SpecialGlobalVars`. ([@splattael][]) +* [#10522](https://github.com/rubocop/rubocop/issues/10522): Add new `Style/ObjectThen` cop. ([@ydah][]) +* [#10502](https://github.com/rubocop/rubocop/pull/10502): Add new `Style/FetchEnvVar` cop. ([@johnny-miyake][]) +* [#10544](https://github.com/rubocop/rubocop/pull/10544): Support auto-correction for `Lint/DuplicateRequire`. ([@koic][]) +* [#10481](https://github.com/rubocop/rubocop/issues/10481): Add command line options `--display-only-correctable` and `--display-only-safe-correctable`. ([@nobuyo][]) -### Bugs fixed +### Bug fixes + +* [#10528](https://github.com/rubocop/rubocop/issues/10528): Fix an infinite loop at autocorrect for `Layout/CaseIndentation`. ([@ydah][]) +* [#10537](https://github.com/rubocop/rubocop/pull/10537): Fix an incorrect auto-correct for `Style/MultilineTernaryOperator` when returning a multiline ternary operator expression with `break`, `next`, or method call. ([@koic][]) +* [#10529](https://github.com/rubocop/rubocop/issues/10529): Fix autocorrect for `Style/SoleNestedConditional` causes logical error when using a outer condition of method call by omitting parentheses for method arguments. ([@nobuyo][]) +* [#10530](https://github.com/rubocop/rubocop/issues/10530): Fix a false positive for `Style/RedundantRegexpCharacterClass` when using regexp character class with a character class containing multiple unicode code-points. ([@koic][]) +* [#10518](https://github.com/rubocop/rubocop/pull/10518): Fix a false positive for `Style/DoubleNegation` when inside returned conditional clauses with Ruby 2.7's pattern matching. ([@koic][]) +* [#10510](https://github.com/rubocop/rubocop/issues/10510): Fix an error for `Style/SingleArgumentDig` when using multiple `dig` in a method chain. ([@koic][]) +* [#10553](https://github.com/rubocop/rubocop/issues/10553): Fix crash with trailing tabs in heredocs for `Layout/TrailingWhitespace`. ([@dvandersluis][]) +* [#10488](https://github.com/rubocop/rubocop/issues/10488): Fix autocorrection for `Layout/MultilineMethodCallIndentation` breaks indentation for nesting of method calls. ([@nobuyo][]) +* [#10543](https://github.com/rubocop/rubocop/pull/10543): Fix incorrect code length calculation for few more patterns of hash folding asked. ([@nobuyo][]) +* [#10541](https://github.com/rubocop/rubocop/pull/10541): Fix an incorrect autocorrect for `Style/SpecialGlobalVars` when global variable as Perl name is used multiple times. ([@koic][]) +* [#10514](https://github.com/rubocop/rubocop/issues/10514): Fix an error for `Lint/EmptyConditionalBody` when missing second `elsif` body. ([@koic][]) +* [#10469](https://github.com/rubocop/rubocop/issues/10469): Fix code length calculation when kwargs written in single line. ([@nobuyo][]) + +### Changes -* [#1411](https://github.com/bbatsov/rubocop/issues/1411): Handle lambda calls without a selector in `MultilineOperationIndentation`. ([@bbatsov][]) -* [#1401](https://github.com/bbatsov/rubocop/issues/1401): Files in hidden directories, i.e. ones beginning with dot, can now be selected through configuration, but are still not included by default. ([@jonas054][]) -* [#1415](https://github.com/bbatsov/rubocop/issues/1415): String literals concatenated with backslashes are now handled correctly by `StringLiteralsInInterpolation`. ([@jonas054][]) -* [#1416](https://github.com/bbatsov/rubocop/issues/1416): Fix handling of `begin/rescue/else/end` in `ElseAlignment`. ([@jonas054][]) -* [#1413](https://github.com/bbatsov/rubocop/issues/1413): Support empty elsif branches in `MultilineIfThen`. ([@janraasch][], [@jonas054][]) -* [#1406](https://github.com/bbatsov/rubocop/issues/1406): Allow a newline in `SpaceInsideRangeLiteral`. ([@bbatsov][]) +* [#10555](https://github.com/rubocop/rubocop/pull/10555): Deprecate `IgnoredPatterns` in favour of `AllowedPatterns`. ([@dvandersluis][]) +* [#10356](https://github.com/rubocop/rubocop/issues/10356): Add `AllowConsecutiveConditionals` option to `Style/GuardClause` and the option is false by default. ([@ydah][]) +* [#10524](https://github.com/rubocop/rubocop/issues/10524): Mark `Style/RedundantInitialize` as unsafe. ([@koic][]) +* [#10280](https://github.com/rubocop/rubocop/issues/10280): Add `AllowComments` option to `Style/SymbolProc` and the option is false by default. ([@ydah][]) -## 0.27.0 (30/10/2014) +## 1.27.0 (2022-04-08) ### New features -* [#1348](https://github.com/bbatsov/rubocop/issues/1348): New cop `ElseAlignment` checks alignment of `else` and `elsif` keywords. ([@jonas054][]) -* [#1321](https://github.com/bbatsov/rubocop/issues/1321): New cop `MultilineOperationIndentation` checks indentation/alignment of binary operations if they span more than one line. ([@jonas054][]) -* [#1077](https://github.com/bbatsov/rubocop/issues/1077): New cop `Metrics/AbcSize` checks the ABC metric, based on assignments, branches, and conditions. ([@jonas054][], [@jfelchner][]) -* [#1352](https://github.com/bbatsov/rubocop/issues/1352): `WordArray` is now configurable with the `WordRegex` option. ([@bquorning][]) -* [#1181](https://github.com/bbatsov/rubocop/issues/1181): New cop `Style/StringLiteralsInInterpolation` checks quotes inside interpolated expressions in strings. ([@jonas054][]) -* [#872](https://github.com/bbatsov/rubocop/issues/872): `Style/IndentationWidth` is now configurable with the `Width` option. ([@jonas054][]) -* [#1396](https://github.com/bbatsov/rubocop/issues/1396): Include `.opal` files by default. ([@bbatsov][]) -* [#771](https://github.com/bbatsov/rubocop/issues/771): Three new `Style` cops, `EmptyLinesAroundMethodBody` , `EmptyLinesAroundClassBody` , and `EmptyLinesAroundModuleBody` replace the `EmptyLinesAroundBody` cop. ([@jonas054][]) +* [#10500](https://github.com/rubocop/rubocop/pull/10500): Add new `Lint/RefinementImportMethods` cop. ([@koic][]) +* [#10438](https://github.com/rubocop/rubocop/issues/10438): Add new `Style/RedundantInitialize` cop to check for unnecessary `initialize` methods. ([@dvandersluis][]) + +### Bug fixes + +* [#10464](https://github.com/rubocop/rubocop/issues/10464): Fix an incorrect autocorrect for `Lint/IncompatibleIoSelectWithFiberScheduler` when using `IO.select` with read (or write) argument and using return value. ([@koic][]) +* [#10506](https://github.com/rubocop/rubocop/issues/10506): Fix an error for `Style/RaiseArgs` when `raise` with `new` method without receiver. ([@koic][]) +* [#10479](https://github.com/rubocop/rubocop/issues/10479): Fix a false positive for `Lint/ShadowingOuterLocalVariable` conditional statement and block variable. ([@ydah][]) +* [#10189](https://github.com/rubocop/rubocop/issues/10189): Fix `--display-style-guide` so it works together with `--format offenses`. ([@jonas054][]) +* [#10465](https://github.com/rubocop/rubocop/issues/10465): Fix false positive for `Naming/BlockForwarding` when the block argument is assigned. ([@dvandersluis][]) +* [#10491](https://github.com/rubocop/rubocop/pull/10491): Improve the handling of comments in `Lint/EmptyConditionalBody`, `Lint/EmptyInPattern` and `Lint/EmptyWhen` when `AllowComments` is set to `true`. ([@Darhazer][]) +* [#10504](https://github.com/rubocop/rubocop/issues/10504): Fix a false positive for `Lint/UnusedMethodArgument` when using `raise NotImplementedError` with optional arguments. ([@koic][]) +* [#10494](https://github.com/rubocop/rubocop/issues/10494): Fix a false positive for `Style/HashSyntax` when `return` with one line `if` condition follows (without parentheses). ([@koic][]) +* [#10311](https://github.com/rubocop/rubocop/issues/10311): Fix false negative inside `do`..`end` for `Layout/RedundantLineBreak`. ([@jonas054][]) +* [#10468](https://github.com/rubocop/rubocop/issues/10468): Fix a false positive for `Style/FileWrite` when a splat argument is passed to `f.write`. ([@koic][]) +* [#10474](https://github.com/rubocop/rubocop/issues/10474): Fix a false positive for `Style/DoubleNegation` with `EnforcedStyle: allowed_in_returns` when inside returned conditional clauses. ([@ydah][]) +* [#10388](https://github.com/rubocop/rubocop/issues/10388): Fix an incorrectly adds a disable statement for `Layout/SpaceInsideArrayLiteralBrackets` with `--disable-uncorrectable`. ([@ydah][]) +* [#10489](https://github.com/rubocop/rubocop/issues/10489): Fix a false positive for `Lint/LambdaWithoutLiteralBlock` when using lambda with a symbol proc. ([@koic][]) ### Changes -* [#1084](https://github.com/bbatsov/rubocop/issues/1084): Disabled `Style/CollectionMethods` by default. ([@bbatsov][]) +* [#10191](https://github.com/rubocop/rubocop/issues/10191): Add `MaxChainLength` option to `Style/SafeNavigation` and the option is 2 by default. ([@ydah][]) + +## 1.26.1 (2022-03-22) + +### Bug fixes + +* [#10375](https://github.com/rubocop/rubocop/pull/10375): Fix error for auto-correction of `unless`/`else` nested inside each other. ([@jonas054][]) +* [#10457](https://github.com/rubocop/rubocop/pull/10457): Make `Style/SelectByRegexp` aware of `ENV` const. ([@koic][]) +* [#10462](https://github.com/rubocop/rubocop/issues/10462): Fix an incorrect autocorrect for `Lint/SymbolConversion` when using a quoted symbol key with hash rocket. ([@koic][]) +* [#10456](https://github.com/rubocop/rubocop/issues/10456): Fix a false positive for `Layout/MultilineMethodCallIndentation` when using `EnforcedStyle: indented` with indented assignment method. ([@koic][]) +* [#10459](https://github.com/rubocop/rubocop/pull/10459): Fix a false positive for `Layout/LineLength` when long URIs in yardoc comments to have titles. ([@ydah][]) +* [#10447](https://github.com/rubocop/rubocop/pull/10447): Fix an error for `Style/SoleNestedConditional` raises exception when inspecting `if ... end if ...`. ([@ydah][]) + +## 1.26.0 (2022-03-09) + +### New features + +* [#10419](https://github.com/rubocop/rubocop/pull/10419): Add new `Style/NestedFileDirname` cop. ([@koic][]) +* [#10433](https://github.com/rubocop/rubocop/pull/10433): Support `TargetRubyVersion 3.2` (experimental). ([@koic][]) + +### Bug fixes + +* [#10406](https://github.com/rubocop/rubocop/pull/10406): Fix a false positive for `Lint/InheritException` when inheriting a standard lib exception class that is not a subclass of `StandardError`. ([@koic][]) +* [#10421](https://github.com/rubocop/rubocop/issues/10421): Make `Style/DefWithParentheses` aware of endless method definition. ([@koic][]) +* [#10401](https://github.com/rubocop/rubocop/issues/10401): Fix a false positive for `Style/HashSyntax` when local variable hash key and hash value are the same. ([@koic][]) +* [#10424](https://github.com/rubocop/rubocop/pull/10424): Fix a false positive for `Security/YAMLLoad` when using Ruby 3.1+ (Psych 4). ([@koic][]) +* [#10446](https://github.com/rubocop/rubocop/pull/10446): `Lint/RedundantDirGlobSort` unset SafeAutoCorrect. ([@friendlyantz][]) +* [#10403](https://github.com/rubocop/rubocop/issues/10403): Fix an error for `Style/StringConcatenation` when string concatenation with multiline heredoc text. ([@koic][]) +* [#10432](https://github.com/rubocop/rubocop/pull/10432): Fix an error when using regexp with non-encoding option. ([@koic][]) +* [#10415](https://github.com/rubocop/rubocop/issues/10415): Fix an error for `Lint/UselessTimes` when using `1.times` with method chain. ([@koic][]) -### Bugs fixed +### Changes -* `AlignHash` no longer skips multiline hashes that contain some elements on the same line. ([@mvz][]) -* [#1349](https://github.com/bbatsov/rubocop/issues/1349): `BracesAroundHashParameters` no longer cleans up whitespace in autocorrect, as these extra corrections are likely to interfere with other cops' corrections. ([@jonas054][]) -* [#1350](https://github.com/bbatsov/rubocop/issues/1350): Guard against `Blocks` cop introducing syntax errors in auto-correct. ([@jonas054][]) -* [#1374](https://github.com/bbatsov/rubocop/issues/1374): To eliminate interference, auto-correction is now done by one cop at a time, with saving and re-parsing inbetween. ([@jonas054][]) -* [#1388](https://github.com/bbatsov/rubocop/issues/1388): Fix a false positive in `FormatString`. ([@bbatsov][]) -* [#1389](https://github.com/bbatsov/rubocop/issues/1389): Make `--out` to create parent directories. ([@yous][]) -* Refine HTML formatter. ([@yujinakayama][]) -* [#1410](https://github.com/bbatsov/rubocop/issues/1410): Handle specially Java primitive type references in `ColonMethodCall`. ([@bbatsov][]) +* [#10408](https://github.com/rubocop/rubocop/pull/10408): Mark `Lint/InheritException` as unsafe auto-correction. ([@koic][]) +* [#10407](https://github.com/rubocop/rubocop/pull/10407): Change `EnforcedStyle` from `runtime_error` to `standard_error` for `Lint/InheritException`. ([@koic][]) +* [#10414](https://github.com/rubocop/rubocop/pull/10414): Update auto-gen-config's auto-correction comments to be more clear. ([@maxjacobson][]) +* [#10427](https://github.com/rubocop/rubocop/issues/10427): Mark `Style/For` as unsafe auto-correction. ([@issyl0][]) +* [#10410](https://github.com/rubocop/rubocop/issues/10410): Improve help string for `--fail-level` CLI option. ([@tejasbubane][]) -## 0.26.1 (18/09/2014) +## 1.25.1 (2022-02-03) -### Bugs fixed +### Bug fixes -* [#1326](https://github.com/bbatsov/rubocop/issues/1326): Fix problem in `SpaceInsideParens` with detecting space inside parentheses used for grouping expressions. ([@jonas054][]) -* [#1335](https://github.com/bbatsov/rubocop/issues/1335): Restrict URI schemes permitted by `LineLength` when `AllowURI` is enabled. ([@smangelsdorf][]) -* [#1339](https://github.com/bbatsov/rubocop/issues/1339): Handle `eql?` and `equal?` in `OpMethod`. ([@bbatsov][]) -* [#1340](https://github.com/bbatsov/rubocop/issues/1340): Fix crash in `Style/SymbolProc` cop when the block calls a method with no explicit receiver. ([@smangelsdorf][]) +* [#10359](https://github.com/rubocop/rubocop/issues/10359): Fix a false positive and negative for `Style/HashSyntax` when using hash value omission. ([@koic][]) +* [#10387](https://github.com/rubocop/rubocop/issues/10387): Fix an error for `Style/RedundantBegin` when assigning nested `begin` blocks. ([@koic][]) +* [#10366](https://github.com/rubocop/rubocop/issues/10366): Fix a false positive for `Style/MethodCallWithArgsParentheses` when setting `EnforcedStyle: omit_parentheses` and using hash value omission with modifier from. ([@koic][]) +* [#10376](https://github.com/rubocop/rubocop/issues/10376): Fix an error for `Layout/RescueEnsureAlignment` when using `.()` call with block. ([@koic][]) +* [#10364](https://github.com/rubocop/rubocop/issues/10364): Fix an infinite loop error for `Layout/HashAlignment` when `EnforcedStyle: with_fixed_indentation` is specified for `Layout/ArgumentAlignment`. ([@koic][]) +* [#10371](https://github.com/rubocop/rubocop/pull/10371): Fix a false negative for `Style/HashSyntax` when `Hash[foo: foo]` or `{foo: foo}` is followed by a next expression. ([@koic][]) +* [#10394](https://github.com/rubocop/rubocop/issues/10394): Fix an error for `Style/SwapValues` when assigning receiver object at `def`. ([@koic][]) +* [#10379](https://github.com/rubocop/rubocop/issues/10379): Fix an error for `Layout/EmptyLinesAroundExceptionHandlingKeywords` when `rescue` and `end` are on the same line. ([@koic][]) -## 0.26.0 (03/09/2014) +## 1.25.0 (2022-01-18) ### New features -* New formatter `HTMLFormatter` generates a html file with a list of files with offences in them. ([@SkuliOskarsson][]) -* New cop `SpaceInsideRangeLiteral` checks for spaces around `..` and `...` in range literals. ([@bbatsov][]) -* New cop `InfiniteLoop` checks for places where `Kernel#loop` should have been used. ([@bbatsov][]) -* New cop `SymbolProc` checks for places where a symbol can be used as proc instead of a block. ([@bbatsov][]) -* `UselessAssignment` cop now suggests a variable name for possible typos if there's a variable-ish identifier similar to the unused variable name in the same scope. ([@yujinakayama][]) -* `PredicateName` cop now has separate configurations for prefices that denote predicate method names and predicate prefices that should be removed. ([@bbatsov][]) -* [#1272](https://github.com/bbatsov/rubocop/issues/1272): `Tab` cop does auto-correction. ([@yous][]) -* [#1274](https://github.com/bbatsov/rubocop/issues/1274): `MultilineIfThen` cop does auto-correction. ([@bbatsov][]) -* [#1279](https://github.com/bbatsov/rubocop/issues/1279): `DotPosition` cop does auto-correction. ([@yous][]) -* [#1277](https://github.com/bbatsov/rubocop/issues/1277): `SpaceBeforeFirstArg` cop does auto-correction. ([@yous][]) -* [#1310](https://github.com/bbatsov/rubocop/issues/1310): Handle `module_function` in `Style/AccessModifierIndentation` and `Style/EmptyLinesAroundAccessModifier`. ([@bbatsov][]) +* [#10351](https://github.com/rubocop/rubocop/pull/10351): Support `EnforcedShorthandSyntax: either` option for `Style/HashSyntax`. ([@koic][]) +* [#10339](https://github.com/rubocop/rubocop/issues/10339): Support auto-correction for `EnforcedStyle: explicit` of `Naming/BlockForwarding`. ([@koic][]) + +### Bug fixes + +* [#10344](https://github.com/rubocop/rubocop/pull/10344): Fix a false positive for `Style/CollectionCompact` when without receiver for bad methods. ([@koic][]) +* [#10353](https://github.com/rubocop/rubocop/pull/10353): Use `:ambiguous_regexp` to detect ambiguous Regexp in Ruby 3. ([@danieldiekmeier][], [@joergschiller][]) +* [#10336](https://github.com/rubocop/rubocop/issues/10336): Fix a false positive for `Style/TernaryParentheses` when using `in` keyword pattern matching as a ternary condition. ([@koic][]) +* [#10317](https://github.com/rubocop/rubocop/issues/10317): Fix a false positive for `Style/MethodCallWithArgsParentheses` when using hash value omission. ([@koic][]) +* [#8032](https://github.com/rubocop/rubocop/issues/8032): Improve ArgumentAlignment detection and correction for keyword arguments. ([@mvz][]) +* [#10331](https://github.com/rubocop/rubocop/pull/10331): Fix cop generator for nested departments. ([@fatkodima][]) +* [#10357](https://github.com/rubocop/rubocop/pull/10357): Fix a false positive for `Style/HashSyntax` when omitting the value. ([@berkos][]) +* [#10335](https://github.com/rubocop/rubocop/issues/10335): Fix a false positive for `Naming/BlockForwarding` when using multiple proc arguments. ([@koic][]) +* [#10350](https://github.com/rubocop/rubocop/pull/10350): Fix a false negative for `Lint/IncompatibleIoSelectWithFiberScheduler` when using `IO.select` with the first argument only. ([@koic][]) +* [#10358](https://github.com/rubocop/rubocop/pull/10358): Fix `Style/Sample` crash on beginless and endless range shuffle indexes. ([@gsamokovarov][]) +* [#10354](https://github.com/rubocop/rubocop/pull/10354): Fix `Gemspec/RequiredRubyVersion` version matcher when Gem::Requirement.new is used and initialised with multiple requirements. ([@nickpellant][]) ### Changes -* [#1289](https://github.com/bbatsov/rubocop/issues/1289): Use utf-8 as default encoding for inspected files. ([@jonas054][]) -* [#1304](https://github.com/bbatsov/rubocop/issues/1304): `Style/Encoding` is no longer a no-op on Ruby 2.x. It's also disabled by default, as projects not supporting 1.9 don't need to run it. ([@bbatsov][]) +* [#10343](https://github.com/rubocop/rubocop/pull/10343): Require Parser 3.1.0.0 or higher. ([@koic][]) + +## 1.24.1 (2021-12-31) + +### Bug fixes + +* [#10313](https://github.com/rubocop/rubocop/issues/10313): Fix autocorrect `Style/MapToHash` with multiline code. ([@tejasbubane][]) +* [#10251](https://github.com/rubocop/rubocop/issues/10251): Fix an incorrect autocorrect for `Gemspec/RequireMFA` when .gemspec file contains `metadata` keys assignments. ([@fatkodima][]) +* [#10329](https://github.com/rubocop/rubocop/issues/10329): Fix a false positive for `Lint/ParenthesesAsGroupedExpression` and an incorrect autocorrect for the cop with `Style/TernaryParentheses` when using ternary expression as a first argument. ([@koic][]) +* [#10317](https://github.com/rubocop/rubocop/issues/10317): Fix a false positive for `Style/MethodCallWithArgsParentheses` when using hash value omission. ([@koic][]) +* [#10333](https://github.com/rubocop/rubocop/pull/10333): Fix an incorrect autocorrect for `Naming/BlockForwarding` using explicit block forwarding without method definition parentheses. ([@koic][]) +* [#10321](https://github.com/rubocop/rubocop/issues/10321): Make `Style/MethodDefParentheses` aware of Ruby 3.1's anonymous block forwarding. ([@koic][]) +* [#10320](https://github.com/rubocop/rubocop/issues/10320): Fix an incorrect autocorrect for `Style/FileWrite` when using heredoc argument. ([@koic][]) +* [#10319](https://github.com/rubocop/rubocop/issues/10319): Require rubocop-ast 1.15.1 to fix a false positive for `Style/CombinableLoops` when the same method with different arguments and safe navigation. ([@koic][]) + +## 1.24.0 (2021-12-23) + +### New features + +* [#10279](https://github.com/rubocop/rubocop/pull/10279): Support Ruby 3.1's anonymous block forwarding syntax. ([@koic][]) +* [#10295](https://github.com/rubocop/rubocop/pull/10295): Support Ruby 3.1's hash value omission syntax for `Layout/HashAlignment`. ([@koic][]) +* [#10303](https://github.com/rubocop/rubocop/issues/10303): Add `AllowedNumbers` option to `Style/NumericLiterals`. ([@koic][]) +* [#10290](https://github.com/rubocop/rubocop/pull/10290): Add new `Naming/BlockForwarding` cop. ([@koic][]) +* [#10289](https://github.com/rubocop/rubocop/pull/10289): Add `EnforcedShorthandSyntax` option to `Style/HashSyntax` cop to support Ruby 3.1's hash value omission syntax by default. ([@koic][]) +* [#10257](https://github.com/rubocop/rubocop/pull/10257): Add new `Style/MapToHash` cop. ([@dvandersluis][]) +* [#10261](https://github.com/rubocop/rubocop/pull/10261): Add new `Style/FileRead` cop. ([@leoarnold][]) +* [#10291](https://github.com/rubocop/rubocop/pull/10291): Support Ruby 3.1's hash value omission syntax for `Layout/SpaceAfterColon`. ([@koic][]) +* [#10260](https://github.com/rubocop/rubocop/pull/10260): Add new `Style/FileWrite` cop. ([@leoarnold][]) +* [#10307](https://github.com/rubocop/rubocop/pull/10307): Support Ruby 2.7's numbered parameter for `Metrics/BlockLength`, `Metrics/ClassLength`, `Metrics/MethodLength`, and `Metrics/ModuleLength` cops. ([@koic][]) +* [#7671](https://github.com/rubocop/rubocop/issues/7671): Add cli option `--show-docs-url` to print out documentation url for given cops. ([@HeroProtagonist][]) +* [#10308](https://github.com/rubocop/rubocop/pull/10308): Make `Style/CollectionCompact` aware of block pass argument. ([@koic][]) + +### Bug fixes + +* [#10285](https://github.com/rubocop/rubocop/issues/10285): Fix an incorrect autocorrect for `Style/SoleNestedConditional` when using nested `if` within `if foo = bar`. ([@koic][]) +* [#10309](https://github.com/rubocop/rubocop/pull/10309): Fix a false positive for `Bundler/DuplicatedGem` when a gem conditionally duplicated within multi-statement bodies. ([@fatkodima][]) +* [#10300](https://github.com/rubocop/rubocop/issues/10300): Fix an incorrect autocorrect for `Layout/DotPosition` and `Style/RedundantSelf` when auto-correction conflicts. ([@koic][]) +* [#10284](https://github.com/rubocop/rubocop/issues/10284): Fix an incorrect autocorrect for `Style/RedundantRegexpCharacterClass` when regexp containing an unescaped `#`. ([@koic][]) +* [#10265](https://github.com/rubocop/rubocop/issues/10265): Fix `Style/IfInsideElse` to be able to handle `if-then` nested inside an `else` without clobbering. ([@dvandersluis][]) +* [#10297](https://github.com/rubocop/rubocop/issues/10297): Fix a false positive for `Lint/DeprecatedOpenSSLConstant` when building digest using an algorithm string and nested digest constants. ([@koic][]) +* [#10282](https://github.com/rubocop/rubocop/issues/10282): Fix an incorrect autocorrect for `Style/EmptyCaseCondition` when using `when ... then` in `case` in a method call. ([@koic][]) +* [#10273](https://github.com/rubocop/rubocop/issues/10273): Fix a false positive for `InternalAffairs/UndefinedConfig` to suppress a false wrong namespace warning. ([@koic][]) +* [#10305](https://github.com/rubocop/rubocop/issues/10305): Fix an incorrect autocorrect for `Style/HashConversion` when using `Hash[a || b]`. ([@koic][]) +* [#10264](https://github.com/rubocop/rubocop/pull/10264): Fix the following incorrect auto-correct for `Style/MethodCallWithArgsParentheses` with `Layout/SpaceBeforeFirstArg`. ([@koic][]) +* [#10276](https://github.com/rubocop/rubocop/issues/10276): Fix an incorrect autocorrect for `Style/RedundantInterpolation` when using a method call without parentheses in string interpolation. ([@koic][]) -### Bugs fixed +### Changes -* [#1263](https://github.com/bbatsov/rubocop/issues/1263): Do not report `%W` literals with special escaped characters in `UnneededCapitalW`. ([@jonas054][]) -* [#1286](https://github.com/bbatsov/rubocop/issues/1286): Fix a false positive in `VariableName`. ([@bbatsov][]) -* [#1211](https://github.com/bbatsov/rubocop/issues/1211): Fix false negative in `UselessAssignment` when there's a reference for the variable in an exclusive branch. ([@yujinakayama][]) -* [#1307](https://github.com/bbatsov/rubocop/issues/1307): Fix auto-correction of `RedundantBegin` cop deletes new line. ([@yous][]) -* [#1283](https://github.com/bbatsov/rubocop/issues/1283): Fix auto-correction of indented expressions in `PercentLiteralDelimiters`. ([@jonas054][]) -* [#1315](https://github.com/bbatsov/rubocop/pull/1315): `BracesAroundHashParameters` auto-correction removes whitespace around content inside braces. ([@jspanjers][]) -* [#1313](https://github.com/bbatsov/rubocop/issues/1313): Fix a false positive in `AndOr` when enforced style is `conditionals`. ([@bbatsov][]) -* Handle post-conditional `while` and `until` in `AndOr` when enforced style is `conditionals`. ([@yujinakayama][]) -* [#1319](https://github.com/bbatsov/rubocop/issues/1319): Fix a false positive in `FormatString`. ([@bbatsov][]) -* [#1287](https://github.com/bbatsov/rubocop/issues/1287): Allow missing blank line for EmptyLinesAroundAccessModifier if next line closes a block. ([@sch1zo][]) +* [#10253](https://github.com/rubocop/rubocop/pull/10253): Deprecate `RuboCop::Cop::EnforceSuperclass` module. ([@koic][]) +* [#10248](https://github.com/rubocop/rubocop/pull/10248): Make `Lint/DeprecatedClassMethods` aware of `ENV.freeze`. ([@koic][]) +* [#10269](https://github.com/rubocop/rubocop/issues/10269): Mark `Lint/IncompatibleIoSelectWithFiberScheduler` as unsafe auto-correction. ([@koic][]) +* [#8586](https://github.com/rubocop/rubocop/issues/8586): Add configuration parameter `AllowForAlignment` in `Layout/CommentIndentation`. ([@jonas054][]) -## 0.25.0 (15/08/2014) +## 1.23.0 (2021-11-15) ### New features -* [#1259](https://github.com/bbatsov/rubocop/issues/1259): Allow AndOr cop to autocorrect by adding method call parenthesis. ([@vrthra][]) -* [#1232](https://github.com/bbatsov/rubocop/issues/1232): Add EnforcedStyle option to cop `AndOr` to restrict it to conditionals. ([@vrthra][]) -* [#835](https://github.com/bbatsov/rubocop/issues/835): New cop `PercentQLiterals` checks if use of `%Q` and `%q` matches configuration. ([@jonas054][]) -* [#835](https://github.com/bbatsov/rubocop/issues/835): New cop `BarePercentLiterals` checks if usage of `%()` or `%Q()` matches configuration. ([@jonas054][]) -* [#1079](https://github.com/bbatsov/rubocop/pull/1079): New cop `MultilineBlockLayout` checks if a multiline block has an expression on the same line as the start of the block. ([@barunio][]) -* [#1217](https://github.com/bbatsov/rubocop/pull/1217): `Style::EmptyLinesAroundAccessModifier` cop does auto-correction. ([@tamird][]) -* [#1220](https://github.com/bbatsov/rubocop/issues/1220): New cop `PerceivedComplexity` is similar to `CyclomaticComplexity`, but reports when methods have a high complexity for a human reader. ([@jonas054][]) -* `Debugger` cop now checks for `binding.pry_remote`. ([@yous][]) -* [#1238](https://github.com/bbatsov/rubocop/issues/1238): Add `MinBodyLength` option to `Next` cop. ([@bbatsov][]) -* [#1241](https://github.com/bbatsov/rubocop/issues/1241): `TrailingComma` cop does auto-correction. ([@yous][]) -* [#1078](https://github.com/bbatsov/rubocop/pull/1078): New cop `BlockEndNewline` checks if the end statement of a multiline block is on its own line. ([@barunio][]) -* [#1078](https://github.com/bbatsov/rubocop/pull/1078): `BlockAlignment` cop does auto-correction. ([@barunio][]) +* [#10202](https://github.com/rubocop/rubocop/issues/10202): Add new `Lint/UselessRuby2Keywords` cop. ([@dvandersluis][]) +* [#10217](https://github.com/rubocop/rubocop/pull/10217): Add new `Style/OpenStructUse` cop. ([@mttkay][]) +* [#10243](https://github.com/rubocop/rubocop/pull/10243): Add new `Gemspec/RequireMFA` cop. ([@dvandersluis][]) + +### Bug fixes + +* [#10203](https://github.com/rubocop/rubocop/issues/10203): Fix `Style/FormatStringToken` to respect `IgnoredMethods` with nested structures. ([@tejasbubane][]) +* [#10242](https://github.com/rubocop/rubocop/pull/10242): Fix `last_column` value for `JSONFormatter`. ([@koic][]) +* [#10229](https://github.com/rubocop/rubocop/pull/10229): Fix a false positive for `Style/StringLiterals` when `EnforcedStyle: double_quotes` and using single quoted string with backslash. ([@koic][]) +* [#10174](https://github.com/rubocop/rubocop/issues/10174): Fix inherit_from_remote should follow remote includes path starting with `./`. ([@hirasawayuki][]) +* [#10234](https://github.com/rubocop/rubocop/pull/10234): Fix an error for `Style/Documentation` when using a cbase class. ([@koic][]) +* [#10227](https://github.com/rubocop/rubocop/issues/10227): Fix a false positive for `Style/ParenthesesAroundCondition` when parentheses in multiple expressions separated by semicolon. ([@koic][]) +* [#10230](https://github.com/rubocop/rubocop/issues/10230): Fix a false positive for `Lint/AmbiguousRange` when a range is composed of all literals except basic literals. ([@koic][]) + +### Changes + +* [#10221](https://github.com/rubocop/rubocop/issues/10221): Update `Naming::FileName` to recognize `Struct`s as classes that satisfy the `ExpectMatchingDefinition` requirement. ([@dvandersluis][]) +* [#10220](https://github.com/rubocop/rubocop/issues/10220): Update `Naming/FileName` to make `CheckDefinitionPathHierarchy` roots configurable. ([@grosser][]) +* [#10199](https://github.com/rubocop/rubocop/pull/10199): Change `AllowAdjacentOneLineDefs` config parameter of `Layout/EmptyLineBetweenDefs` to `true` by default . ([@koic][]) +* [#10236](https://github.com/rubocop/rubocop/pull/10236): Make `Lint/NumberConversion` aware of `to_r`. ([@koic][]) + +## 1.22.3 (2021-10-27) + +### Bug fixes + +* [#10166](https://github.com/rubocop/rubocop/pull/10166): Fix a false positive for `Style/StringLiterals` when using some meta characters (e.g. `'\s'`, `'\z'`) with `EnforcedStyle: double_quotes`. ([@koic][]) +* [#10216](https://github.com/rubocop/rubocop/issues/10216): Fix an incorrect autocorrect for `Style/SelectByRegexp` when using `lvar =~ blockvar` in a block. ([@koic][]) +* [#10207](https://github.com/rubocop/rubocop/pull/10207): Fix false positive in `Layout/DotPosition` when the selector is on the same line as the closing bracket of the receiver. ([@mvz][]) ### Changes -* [#1220](https://github.com/bbatsov/rubocop/issues/1220): New namespace `Metrics` created and some `Style` cops moved there. ([@jonas054][]) -* Drop support for Ruby 1.9.2 in accordance with [the end of the security maintenance extension](https://www.ruby-lang.org/en/news/2014/07/01/eol-for-1-8-7-and-1-9-2/). ([@yujinakayama][]) +* [#10209](https://github.com/rubocop/rubocop/pull/10209): Make `Lint/DeprecatedConstants` aware of `Net::HTTPServerException`. ([@koic][]) + +## 1.22.2 (2021-10-22) + +### Bug fixes + +* [#10165](https://github.com/rubocop/rubocop/issues/10165): Fix `Layout/DotPosition` false positives when the selector and receiver are on the same line. ([@dvandersluis][]) +* [#10171](https://github.com/rubocop/rubocop/pull/10171): Fix `Style/HashTransformKeys` and `Style/HashTransformValues` incorrect auto-correction when inside block body. ([@franzliedke][]) +* [#10180](https://github.com/rubocop/rubocop/issues/10180): Fix an error for `Style/SelectByRegexp` when using `match?` without a receiver. ([@koic][]) +* [#10193](https://github.com/rubocop/rubocop/pull/10193): Fix an error for `Layout/EmptyLinesAroundExceptionHandlingKeywords` when `begin` and `rescue` are on the same line. ([@koic][]) +* [#10185](https://github.com/rubocop/rubocop/issues/10185): Fix a false positive for `Lint/AmbiguousRange` when using `self` in a range literal. ([@koic][]) +* [#10200](https://github.com/rubocop/rubocop/issues/10200): Fix an error when inspecting a directory named `*`. ([@koic][]) +* [#10149](https://github.com/rubocop/rubocop/pull/10149): Fix `Bundler/GemComment` where it would not detect an offense in some cases when `OnlyFor` is set to `restrictive_version_specifiers`. ([@Drowze][]) -### Bugs fixed +### Changes -* [#1251](https://github.com/bbatsov/rubocop/issues/1251): Fix `PercentLiteralDelimiters` auto-correct indentation error. ([@hannestyden][]) -* [#1197](https://github.com/bbatsov/rubocop/issues/1197): Fix false positive for new lambda syntax in `SpaceInsideBlockBraces`. ([@jonas054][]) -* [#1201](https://github.com/bbatsov/rubocop/issues/1201): Fix error at anonymous keyword splat arguments in some variable cops. ([@yujinakayama][]) -* Fix false positive in `UnneededPercentQ` for `/%Q(something)/`. ([@jonas054][]) -* Fix `SpacesInsideBrackets` for `Hash#[]` calls with spaces after left bracket. ([@mcls][]) -* [#1210](https://github.com/bbatsov/rubocop/issues/1210): Fix false positive in `UnneededPercentQ` for `%Q(\t")`. ([@jonas054][]) -* Fix false positive in `UnneededPercentQ` for heredoc strings with `%q`/`%Q`. ([@jonas054][]) -* [#1214](https://github.com/bbatsov/rubocop/issues/1214): Don't destroy code in `AlignHash` autocorrect. ([@jonas054][]) -* [#1219](https://github.com/bbatsov/rubocop/issues/1219): Don't report bad alignment for `end` or `}` in `BlockAlignment` if it doesn't begin its line. ([@jonas054][]) -* [#1227](https://github.com/bbatsov/rubocop/issues/1227): Don't permanently change yamler as it can affect other apps. ([@jonas054][]) -* [#1184](https://github.com/bbatsov/rubocop/issues/1184): Fix a false positive in `Output` cop. ([@bbatsov][]) -* [#1256](https://github.com/bbatsov/rubocop/issues/1256): Ignore block-pass in `TrailingComma`. ([@tamird][]) -* [#1255](https://github.com/bbatsov/rubocop/issues/1255): Compare without context in `AutocorrectUnlessChangingAST`. ([@jonas054][]) -* [#1262](https://github.com/bbatsov/rubocop/issues/1262): Handle regexp and backtick literals in `VariableInterpolation`. ([@bbatsov][]) +* [#10157](https://github.com/rubocop/rubocop/pull/10157): Updated `Gemspec/RequiredRubyVersion` handle being set to blank values. ([@dvandersluis][]) +* [#10176](https://github.com/rubocop/rubocop/pull/10176): Unmark `AutoCorrect: false` from `Security/JSONLoad`. ([@koic][]) +* [#10186](https://github.com/rubocop/rubocop/issues/10186): Explicit block arg is not counted for `Metrics/ParameterLists`. ([@koic][]) -## 0.24.1 (03/07/2014) +## 1.22.1 (2021-10-04) -### Bugs fixed +### Bug fixes -* [#1174](https://github.com/bbatsov/rubocop/issues/1174): Fix `--auto-correct` crash in `AlignParameters`. ([@jonas054][]) -* [#1176](https://github.com/bbatsov/rubocop/issues/1176): Fix `--auto-correct` crash in `IndentationWidth`. ([@jonas054][]) -* [#1177](https://github.com/bbatsov/rubocop/issues/1177): Avoid suggesting underscore-prefixed name for unused keyword arguments and auto-correcting in that way. ([@yujinakayama][]) -* [#1157](https://github.com/bbatsov/rubocop/issues/1157): Validate `--only` arguments later when all cop names are known. ([@jonas054][]) -* [#1188](https://github.com/bbatsov/rubocop/issues/1188), [#1190](https://github.com/bbatsov/rubocop/issues/1190): Fix crash in `LineLength` cop when `AllowURI` option is enabled. ([@yujinakayama][]) -* [#1191](https://github.com/bbatsov/rubocop/issues/1191): Fix crash on empty body branches in a loop in `Next` cop. ([@yujinakayama][]) +* [#10143](https://github.com/rubocop/rubocop/issues/10143): Fix an error for `Lint/RequireRelativeSelfPath` when using a variable as an argument of `require_relative`. ([@koic][]) +* [#10140](https://github.com/rubocop/rubocop/issues/10140): Fix false positive for `Layout/DotPosition` when a heredoc receives a method on the same line as the start sigil in `trailing` style. ([@dvandersluis][]) +* [#10148](https://github.com/rubocop/rubocop/issues/10148): Fix `Style/QuotedSymbols` handling escaped characters incorrectly. ([@dvandersluis][]) +* [#10145](https://github.com/rubocop/rubocop/issues/10145): Update `Style/SelectByRegexp` to ignore cases where the receiver appears to be a hash. ([@dvandersluis][]) -## 0.24.0 (25/06/2014) +## 1.22.0 (2021-09-29) ### New features -* [#639](https://github.com/bbatsov/rubocop/issues/639): Support square bracket setters in `UselessSetterCall`. ([@yujinakayama][]) -* [#835](https://github.com/bbatsov/rubocop/issues/835): `UnneededCapitalW` cop does auto-correction. ([@sfeldon][]) -* [#1092](https://github.com/bbatsov/rubocop/issues/1092): New cop `DefEndAlignment` takes over responsibility for checking alignment of method definition `end`s from `EndAlignment`, and is configurable. ([@jonas054][]) -* [#1145](https://github.com/bbatsov/rubocop/issues/1145): New cop `ClassCheck` enforces consistent use of `is_a?` or `kind_of?`. ([@bbatsov][]) -* [#1161](https://github.com/bbatsov/rubocop/pull/1161): New cop `SpaceBeforeComma` detects spaces before a comma. ([@agrimm][]) -* [#1161](https://github.com/bbatsov/rubocop/pull/1161): New cop `SpaceBeforeSemicolon` detects spaces before a semicolon. ([@agrimm][]) -* [#835](https://github.com/bbatsov/rubocop/issues/835): New cop `UnneededPercentQ` checks for usage of the `%q`/`%Q` syntax when `''` or `""` would do. ([@jonas054][]) -* [#977](https://github.com/bbatsov/rubocop/issues/977): Add `AllowURI` option (enabled by default) to `LineLength` cop. ([@yujinakayama][]) +* [#8431](https://github.com/rubocop/rubocop/issues/8431): Add `Safety` section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`. ([@dvandersluis][]) +* [#10132](https://github.com/rubocop/rubocop/issues/10132): Reorganize output of `rubocop --help` for better clarity. ([@dvandersluis][]) +* [#10111](https://github.com/rubocop/rubocop/pull/10111): Add new `Style/NumberedParametersLimit` cop. ([@dvandersluis][]) +* [#10025](https://github.com/rubocop/rubocop/pull/10025): Changed cop `SpaceInsideParens` to include a `compact` style. ([@itay-grudev][]) +* [#10084](https://github.com/rubocop/rubocop/issues/10084): Add new `Lint/RequireRelativeSelfPath` cop. ([@koic][]) +* [#8327](https://github.com/rubocop/rubocop/issues/8327): Add new cop `Style/SelectByRegexp`. ([@dvandersluis][]) +* [#10100](https://github.com/rubocop/rubocop/pull/10100): Add new `Style/NumberedParameters` cop. ([@Hugo-Hache][]) +* [#10103](https://github.com/rubocop/rubocop/issues/10103): Add `AllowHttpProtocol` option to `Bundler/InsecureProtocolSource`. ([@koic][]) +* [#10102](https://github.com/rubocop/rubocop/pull/10102): Add new `Security/IoMethods` cop. ([@koic][]) + +### Bug fixes + +* [#10110](https://github.com/rubocop/rubocop/issues/10110): Update `Layout/DotPosition` to be able to handle heredocs. ([@dvandersluis][]) +* [#10134](https://github.com/rubocop/rubocop/issues/10134): Update `Style/MutableConstant` to not consider multiline uninterpolated strings as unfrozen in ruby 3.0. ([@dvandersluis][]) +* [#10124](https://github.com/rubocop/rubocop/pull/10124): Fix `Layout/RedundantLineBreak` adding extra space within method chains. ([@dvandersluis][]) +* [#10118](https://github.com/rubocop/rubocop/issues/10118): Fix crash with `Style/RedundantSort` when the block doesn't only contain a single `send` node. ([@dvandersluis][]) +* [#10135](https://github.com/rubocop/rubocop/issues/10135): Fix `Style/WordArray` to exclude files in `--auto-gen-config` when `percent` style is given but brackets are required. ([@dvandersluis][]) +* [#10090](https://github.com/rubocop/rubocop/issues/10090): Fix a false negative for `Style/ArgumentsForwarding` when using only kwrest arg. ([@koic][]) +* [#10099](https://github.com/rubocop/rubocop/pull/10099): Update`Style/RedundantFreeze` to stop considering `ENV` values as immutable. ([@byroot][]) +* [#10078](https://github.com/rubocop/rubocop/pull/10078): Fix `Layout/LineLength` reported length when ignoring directive comments. ([@dvandersluis][]) +* [#9934](https://github.com/rubocop/rubocop/issues/9934): Fix configuration loading to not raise an error for an obsolete ruby version that is subsequently overridden. ([@dvandersluis][]) +* [#10136](https://github.com/rubocop/rubocop/issues/10136): Update `Lint/AssignmentInCondition` to not consider assignments within blocks in conditions. ([@dvandersluis][]) +* [#9588](https://github.com/rubocop/rubocop/issues/9588): Fix causing a variable to be shadowed from outside the rescue block in the logic of `Naming/RescuedExceptionsVariableName`. ([@lilisako][]) +* [#10096](https://github.com/rubocop/rubocop/issues/10096): Fix `Lint/AmbiguousOperatorPrecedence` with `and`/`or` operators. ([@dvandersluis][]) +* [#10106](https://github.com/rubocop/rubocop/issues/10106): Fix `Style/RedundantSelf` for pattern matching. ([@dvandersluis][]) +* [#10066](https://github.com/rubocop/rubocop/issues/10066): Fix how `MinDigits` is calculated for `Style/NumericLiterals` when generating a configuration file. ([@dvandersluis][]) ### Changes -* Unused block local variables (`obj.each { |arg; this| }`) are now handled by `UnusedBlockArgument` cop instead of `UselessAssignment` cop. ([@yujinakayama][]) -* [#1141](https://github.com/bbatsov/rubocop/issues/1141): Clarify in the message from `TrailingComma` that a trailing comma is never allowed for lists where some items share a line. ([@jonas054][]) +* [#10088](https://github.com/rubocop/rubocop/pull/10088): Update `Lint/BooleanSymbol` to be `SafeAutoCorrect: false` rather than `Safe: false`. ([@dvandersluis][]) +* [#10122](https://github.com/rubocop/rubocop/pull/10122): Update `Style/RedundantSort` to be unsafe, and revert the special case for `size` from [#10061](https://github.com/rubocop/rubocop/pull/10061). ([@dvandersluis][]) +* [#10130](https://github.com/rubocop/rubocop/issues/10130): Update `Lint/ElseLayout` to be able to handle an `else` with only a single line. ([@dvandersluis][]) + +## 1.21.0 (2021-09-13) + +### New features + +* [#7849](https://github.com/rubocop/rubocop/issues/7849): Add new `Lint/AmbiguousOperatorPrecedence` cop. ([@dvandersluis][]) +* [#9061](https://github.com/rubocop/rubocop/issues/9061): Add new `Lint/IncompatibleIoSelectWithFiberScheduler` cop. ([@koic][]) + +### Bug fixes -### Bugs fixed +* [#10067](https://github.com/rubocop/rubocop/pull/10067): Fix an error for `Lint/NumberConversion` when using nested number conversion methods. ([@koic][]) +* [#10054](https://github.com/rubocop/rubocop/pull/10054): Fix a false positive for `Layout/SpaceAroundOperators` when match operators between `<<` and `+=`. ([@koic][]) +* [#10061](https://github.com/rubocop/rubocop/issues/10061): Fix a false positive for `Style/RedundantSort` when using `size` method in the block. ([@koic][]) +* [#10063](https://github.com/rubocop/rubocop/pull/10063): Fix a false positive for `Layout/SingleLineBlockChain` when method call chained on a new line after a single line block with trailing dot. ([@koic][]) +* [#10064](https://github.com/rubocop/rubocop/pull/10064): Fix `Style/ExplicitBlockArgument` corrector assuming any existing block argument was named `block`. ([@byroot][]) +* [#10070](https://github.com/rubocop/rubocop/issues/10070): Fix a false positive for `Style/MutableConstant` when using non-interpolated heredoc in Ruby 3.0. ([@koic][]) -* [#1133](https://github.com/bbatsov/rubocop/issues/1133): Handle `reduce/inject` with no arguments in `EachWithObject`. ([@bbatsov][]) -* [#1152](https://github.com/bbatsov/rubocop/issues/1152): Handle `while/until` with no body in `Next`. ([@tamird][]) -* Fix a false positive in `UselessSetterCall` for setter call on a local variable that contains a non-local object. ([@yujinakayama][]) -* [#1158](https://github.com/bbatsov/rubocop/issues/1158): Fix auto-correction of floating-point numbers. ([@bbatsov][]) -* [#1159](https://github.com/bbatsov/rubocop/issues/1159): Fix checking of `begin`..`end` structures, blocks, and parenthesized expressions in `IndentationWidth`. ([@jonas054][]) -* [#1159](https://github.com/bbatsov/rubocop/issues/1159): More rigid conditions for when `attr` is considered an offense. ([@jonas054][]) -* [#1167](https://github.com/bbatsov/rubocop/issues/1167): Fix handling of parameters spanning multiple lines in `TrailingComma`. ([@jonas054][]) -* [#1169](https://github.com/bbatsov/rubocop/issues/1169): Fix handling of ternary op conditions in `ParenthesesAroundCondition`. ([@bbatsov][]) -* [#1147](https://github.com/bbatsov/rubocop/issues/1147): WordArray checks arrays with special characters. ([@camilleldn][]) -* Fix a false positive against `return` in a loop in `Next` cop. ([@yujinakayama][]) -* [#1165](https://github.com/bbatsov/rubocop/issues/1165): Support `rescue`/`else`/`ensure` bodies in `IndentationWidth`. ([@jonas054][]) -* Fix false positive for aligned list of values after `when` in `IndentationWidth`. ([@jonas054][]) +### Changes + +* [#9674](https://github.com/rubocop/rubocop/issues/9674): Disable `Style/AsciiComments` by default. ([@dvandersluis][]) +* [#10051](https://github.com/rubocop/rubocop/pull/10051): Improve the messaging for `Style/Documentation` to be more clear about what class/module needs documentation. ([@dvandersluis][]) +* [#10074](https://github.com/rubocop/rubocop/pull/10074): Update `Naming/InclusiveLanguage` to be disabled by default. ([@dvandersluis][]) +* [#10068](https://github.com/rubocop/rubocop/pull/10068): Mark `Style/AndOr` as unsafe auto-correction. ([@koic][]) -## 0.23.0 (02/06/2014) +## 1.20.0 (2021-08-26) ### New features -* [#1117](https://github.com/bbatsov/rubocop/issues/1117): `BlockComments` cop does auto-correction. ([@jonas054][]) -* [#1124](https://github.com/bbatsov/rubocop/pull/1124): `TrivialAccessors` cop auto-corrects class-level accessors. ([@ggilder][]) -* [#1062](https://github.com/bbatsov/rubocop/pull/1062): New cop `InlineComment` checks for inline comments. ([@salbertson][]) -* [#1118](https://github.com/bbatsov/rubocop/issues/1118): Add checking and auto-correction of right brackets in `IndentArray` and `IndentHash`. ([@jonas054][]) - -### Changes +* [#10040](https://github.com/rubocop/rubocop/pull/10040): Make `Lint/Debugger` aware of debug.rb. ([@koic][]) +* [#9580](https://github.com/rubocop/rubocop/issues/9580): Add a new cop that enforces which bundler gem file to use. ([@gregfletch][]) + +### Bug fixes + +* [#10033](https://github.com/rubocop/rubocop/issues/10033): Fix an incorrect auto-correct for `Style/BlockDelimiters` when there is a comment after the closing brace and using method chaining. ([@koic][]) +* [#6630](https://github.com/rubocop/rubocop/issues/6630): Updated `Style/CommentAnnotation` to be able to handle multiword keyword phrases. ([@dvandersluis][]) +* [#7836](https://github.com/rubocop/rubocop/issues/7836): Update `Style/BlockDelimiters` to add `begin`...`end` when converting a block containing `rescue` or `ensure` to braces. ([@dvandersluis][]) +* [#10031](https://github.com/rubocop/rubocop/issues/10031): Fix a false positive for `Style/HashExcept` when comparing with hash value. ([@koic][]) + +### Changes + +* [#10034](https://github.com/rubocop/rubocop/pull/10034): Add `RubyJard` debugger calls to `DebuggerMethods` of `Lint/Debugger`. ([@DanielVartanov][]) +* [#10006](https://github.com/rubocop/rubocop/pull/10006): Interpolated string literals are no longer frozen since Ruby 3.0. ([@splattael][]) +* [#9328](https://github.com/rubocop/rubocop/issues/9328): Recognize shareable_constant_value magic comment. ([@thearjunmdas][], [@caalberts][]) +* [#10036](https://github.com/rubocop/rubocop/issues/10036): Mark `Style/StructInheritance` as unsafe auto-correction. ([@koic][]) -* [#1097](https://github.com/bbatsov/rubocop/issues/1097): Add optional namespace prefix to cop names: `Style/LineLength` instead of `LineLength` in config files, `--only` argument, `--show-cops` output, and `# rubocop:disable`. ([@jonas054][]) -* [#1075](https://github.com/bbatsov/rubocop/issues/1075): More strict limits on when to require trailing comma. ([@jonas054][]) -* Renamed `Rubocop` module to `RuboCop`. ([@bbatsov][]) +## 1.19.1 (2021-08-19) -### Bugs fixed +### Bug fixes -* [#1126](https://github.com/bbatsov/rubocop/pull/1126): Fix `--auto-gen-config` bug with `RegexpLiteral` where only the last file's results would be used. ([@ggilder][]) -* [#1104](https://github.com/bbatsov/rubocop/issues/1104): Fix `EachWithObject` with modifier if as body. ([@geniou][]) -* [#1106](https://github.com/bbatsov/rubocop/issues/1106): Fix `EachWithObject` with single method call as body. ([@geniou][]) -* Avoid the warning about ignoring syck YAML engine from JRuby. ([@jonas054][]) -* [#1111](https://github.com/bbatsov/rubocop/issues/1111): Fix problem in `EndOfLine` with reading non-UTF-8 encoded files. ([@jonas054][]) -* [#1115](https://github.com/bbatsov/rubocop/issues/1115): Fix `Next` to ignore super nodes. ([@geniou][]) -* [#1117](https://github.com/bbatsov/rubocop/issues/1117): Don't auto-correct indentation in scopes that contain block comments (`=begin`..`=end`). ([@jonas054][]) -* [#1123](https://github.com/bbatsov/rubocop/pull/1123): Support setter calls in safe assignment in `ParenthesesAroundCondition`. ([@jonas054][]) -* [#1090](https://github.com/bbatsov/rubocop/issues/1090): Correct handling of documentation vs annotation comment. ([@jonas054][]) -* [#1118](https://github.com/bbatsov/rubocop/issues/1118): Never write invalid ruby to a file in auto-correct. ([@jonas054][]) -* [#1120](https://github.com/bbatsov/rubocop/issues/1120): Don't change indentation of heredoc strings in auto-correct. ([@jonas054][]) -* [#1109](https://github.com/bbatsov/rubocop/issues/1109): Handle conditions with modifier ops in them in `ParenthesesAroundCondition`. ([@bbatsov][]) +* [#10017](https://github.com/rubocop/rubocop/pull/10017): Fix an error for `Layout/RescueEnsureAlignment` when using zsuper with block. ([@koic][]) +* [#10011](https://github.com/rubocop/rubocop/issues/10011): Fix a false positive for `Style/RedundantSelfAssignmentBranch` when using instance variable, class variable, and global variable. ([@koic][]) +* [#10010](https://github.com/rubocop/rubocop/issues/10010): Fix a false positive for `Style/DoubleNegation` when `!!` is used at return location and before `rescue` keyword. ([@koic][]) +* [#10014](https://github.com/rubocop/rubocop/issues/10014): Fix `Style/Encoding` to handle more situations properly. ([@dvandersluis][]) +* [#10016](https://github.com/rubocop/rubocop/issues/10016): Fix conflict between `Style/SoleNestedConditional` and `Style/NegatedIf`/`Style/NegatedUnless`. ([@dvandersluis][]) +* [#10024](https://github.com/rubocop/rubocop/issues/10024): Fix an incorrect auto-correct for `Style/RedundantSelfAssignmentBranch` when using multiline `if` / `else` conditional assignment. ([@koic][]) +* [#10004](https://github.com/rubocop/rubocop/issues/10004): Fix a false positive for `Style/RedundantBegin` when using one-liner with semicolon. ([@koic][]) -## 0.22.0 (20/05/2014) +## 1.19.0 (2021-08-12) ### New features -* [#974](https://github.com/bbatsov/rubocop/pull/974): New cop `CommentIndentation` checks indentation of comments. ([@jonas054][]) -* Add new cop `EachWithObject` to prefer `each_with_object` over `inject` or `reduce`. ([@geniou][]) -* [#1010](https://github.com/bbatsov/rubocop/issues/1010): New Cop `Next` check for conditions at the end of an iteration and propose to use `next` instead. ([@geniou][]) -* The `GuardClause` cop now also looks for unless and it is configurable how many lines the body of an if / unless needs to have to not be ignored. ([@geniou][]) -* [#835](https://github.com/bbatsov/rubocop/issues/835): New cop `UnneededPercentX` checks for `%x` when backquotes would do. ([@jonas054][]) -* Add auto-correct to `UnusedBlockArgument` and `UnusedMethodArgument` cops. ([@hannestyden][]) -* [#1074](https://github.com/bbatsov/rubocop/issues/1074): New cop `SpaceBeforeComment` checks for missing space between code and a comment on the same line. ([@jonas054][]) -* [#1089](https://github.com/bbatsov/rubocop/pull/1089): New option `-F`/`--fail-fast` inspects files in modification time order and stop after the first file with offenses. ([@jonas054][]) -* Add optional `require` directive to `.rubocop.yml` to load custom ruby files. ([@geniou][]) - -### Changes - -* `NonNilCheck` offense reporting and autocorrect are configurable to include semantic changes. ([@hannestyden][]) -* The parameters `AllCops/Excludes` and `AllCops/Includes` with final `s` only give a warning and don't halt `rubocop` execution. ([@jonas054][]) -* The `GuardClause` cop is no longer ignoring a one-line body by default - see configuration. ([@geniou][]) -* [#1050](https://github.com/bbatsov/rubocop/issues/1050): Rename `rubocop-todo.yml` file to `.rubocop_todo.yml`. ([@geniou][]) -* [#1064](https://github.com/bbatsov/rubocop/issues/1064): Adjust default max line length to 80. ([@bbatsov][]) - -### Bugs fixed - -* Allow assignment in `AlignParameters` cop. ([@tommeier][]) -* Fix `Void` and `SpaceAroundOperators` for short call syntax `lambda.()`. ([@biinari][]) -* Fix `Delegate` for delegation with assignment or constant. ([@geniou][]) -* [#1032](https://github.com/bbatsov/rubocop/issues/1032): Avoid duplicate reporting when code moves around due to `--auto-correct`. ([@jonas054][]) -* [#1036](https://github.com/bbatsov/rubocop/issues/1036): Handle strings like `__FILE__` in `LineEndConcatenation`. ([@bbatsov][]) -* [#1006](https://github.com/bbatsov/rubocop/issues/1006): Fix LineEndConcatenation to handle chained concatenations. ([@barunio][]) -* [#1066](https://github.com/bbatsov/rubocop/issues/1066): Fix auto-correct for `NegatedIf` when the condition has parentheses around it. ([@jonas054][]) -* Fix `AlignParameters` `with_fixed_indentation` for multi-line method calls. ([@molawson][]) -* Fix problem that appears in some installations when reading empty YAML files. ([@jonas054][]) -* [#1022](https://github.com/bbatsov/rubocop/issues/1022): A Cop will no longer auto-correct a file that's excluded through an `Exclude` setting in the cop's configuration. ([@jonas054][]) -* Fix paths in `Exclude` config section not being recognized on Windows. ([@wndhydrnt][]) -* [#1094](https://github.com/bbatsov/rubocop/issues/1094): Fix ClassAndModuleChildren for classes with a single method. ([@geniou][]) - -## 0.21.0 (24/04/2014) - -### New features - -* [#835](https://github.com/bbatsov/rubocop/issues/835): New cop `UnneededCapitalW` checks for `%W` when interpolation not necessary and `%w` would do. ([@sfeldon][]) -* [#934](https://github.com/bbatsov/rubocop/issues/934): New cop `UnderscorePrefixedVariableName` checks for `_`-prefixed variables that are actually used. ([@yujinakayama][]) -* [#934](https://github.com/bbatsov/rubocop/issues/934): New cop `UnusedMethodArgument` checks for unused method arguments. ([@yujinakayama][]) -* [#934](https://github.com/bbatsov/rubocop/issues/934): New cop `UnusedBlockArgument` checks for unused block arguments. ([@yujinakayama][]) -* [#964](https://github.com/bbatsov/rubocop/issues/964): `RedundantBegin` cop does auto-correction. ([@tamird][]) -* [#966](https://github.com/bbatsov/rubocop/issues/966): `RescueException` cop does auto-correction. ([@tamird][]) -* [#967](https://github.com/bbatsov/rubocop/issues/967): `TrivialAccessors` cop does auto-correction. ([@tamird][]) -* [#963](https://github.com/bbatsov/rubocop/issues/963): Add `AllowDSLWriters` options to `TrivialAccessors`. ([@tamird][]) -* [#969](https://github.com/bbatsov/rubocop/issues/969): Let the `Debugger` cop check for forgotten calls to byebug. ([@bquorning][]) -* [#971](https://github.com/bbatsov/rubocop/issues/971): Configuration format deprecation warnings include the path to the problematic config file. ([@bcobb][]) -* [#490](https://github.com/bbatsov/rubocop/issues/490): Add EnforcedStyle config option to TrailingBlankLines. ([@jonas054][]) -* Add `auto_correct` task to Rake integration. ([@irrationalfab][]) -* [#986](https://github.com/bbatsov/rubocop/issues/986): The `--only` option can take a comma-separated list of cops. ([@jonas054][]) -* New Rails cop `Delegate` that checks for delegations that could be replaced by the `delegate` method. ([@geniou][]) -* Add configuration to `Encoding` cop to only enforce encoding comment if there are non ASCII characters. ([@geniou][]) - -### Changes - -* Removed `FinalNewline` cop as its check is now performed by `TrailingBlankLines`. ([@jonas054][]) -* [#1011](https://github.com/bbatsov/rubocop/issues/1011): Pattern matching with `Dir#[]` for config parameters added. ([@jonas054][]) - -### Bugs fixed - -* Update description on `LineEndConcatenation` cop. ([@mockdeep][]) -* [#978](https://github.com/bbatsov/rubocop/issues/978): Fix regression in `IndentationWidth` handling method calls. ([@tamird][]) -* [#976](https://github.com/bbatsov/rubocop/issues/976): Fix `EndAlignment` not handling element assignment correctly. ([@tamird][]) -* [#976](https://github.com/bbatsov/rubocop/issues/976): Fix `IndentationWidth` not handling element assignment correctly. ([@tamird][]) -* [#800](https://github.com/bbatsov/rubocop/issues/800): Do not report `[Corrected]` in `--auto-correct` mode if correction wasn't done. ([@jonas054][]) -* [#968](https://github.com/bbatsov/rubocop/issues/968): Fix bug when running RuboCop with `-c .rubocop.yml`. ([@bquorning][]) -* [#975](https://github.com/bbatsov/rubocop/pull/975): Fix infinite correction in `IndentationWidth`. ([@jonas054][]) -* [#986](https://github.com/bbatsov/rubocop/issues/986): When `--lint` is used together with `--only`, all lint cops are run in addition to the given cops. ([@jonas054][]) -* [#997](https://github.com/bbatsov/rubocop/issues/997): Fix handling of file paths for matching against `Exclude` property when `rubocop .` is called. ([@jonas054][]) -* [#1000](https://github.com/bbatsov/rubocop/issues/1000): Support modifier (e.g., `private`) and `def` on the same line (Ruby >= 2.1) in `IndentationWidth`. ([@jonas054][]) -* [#1001](https://github.com/bbatsov/rubocop/issues/1001): Fix `--auto-gen-config` logic for `RegexpLiteral`. ([@jonas054][]) -* [#993](https://github.com/bbatsov/rubocop/issues/993): Do not report any offenses for the contents of an empty file. ([@jonas054][]) -* [#1016](https://github.com/bbatsov/rubocop/issues/1016): Fix a false positive in `ConditionPosition` regarding statement modifiers. ([@bbatsov][]) -* [#1014](https://github.com/bbatsov/rubocop/issues/1014): Fix handling of strings nested in `dstr` nodes. ([@bbatsov][]) - -## 0.20.1 (05/04/2014) - -### Bugs fixed - -* [#940](https://github.com/bbatsov/rubocop/issues/940): Fixed `UselessAccessModifier` not handling `attr_*` correctly. ([@fshowalter][]) -* `NegatedIf` properly handles negated `unless` condition. ([@bbatsov][]) -* `NegatedWhile` properly handles negated `until` condition. ([@bbatsov][]) -* [#925](https://github.com/bbatsov/rubocop/issues/925): Do not disable the `Syntax` cop in output from `--auto-gen-config`. ([@jonas054][]) -* [#943](https://github.com/bbatsov/rubocop/issues/943): Fix auto-correction interference problem between `SpaceAfterComma` and other cops. ([@jonas054][]) -* [#954](https://github.com/bbatsov/rubocop/pull/954): Fix auto-correction bug in `NilComparison`. ([@bbatsov][]) -* [#953](https://github.com/bbatsov/rubocop/pull/953): Fix auto-correction bug in `NonNilCheck`. ([@bbatsov][]) -* [#952](https://github.com/bbatsov/rubocop/pull/952): Handle implicit receiver in `StringConversionInInterpolation`. ([@bbatsov][]) -* [#956](https://github.com/bbatsov/rubocop/pull/956): Apply `ClassMethods` check only on `class`/`module` bodies. ([@bbatsov][]) -* [#945](https://github.com/bbatsov/rubocop/issues/945): Fix SpaceBeforeFirstArg cop for multiline argument and exclude assignments. ([@cschramm][]) -* [#948](https://github.com/bbatsov/rubocop/issues/948): `Blocks` cop avoids auto-correction if it would introduce a semantic change. ([@jonas054][]) -* [#946](https://github.com/bbatsov/rubocop/issues/946): Allow non-nil checks that are the final expressions of predicate method definitions in `NonNilCheck`. ([@bbatsov][]) -* [#957](https://github.com/bbatsov/rubocop/issues/957): Allow space + comment inside parentheses, braces, and square brackets. ([@jonas054][]) - -## 0.20.0 (02/04/2014) - -### New features - -* New cop `GuardClause` checks for conditionals that can be replaced by guard clauses. ([@bbatsov][]) -* New cop `EmptyInterpolation` checks for empty interpolation in double-quoted strings. ([@bbatsov][]) -* [#899](https://github.com/bbatsov/rubocop/issues/899): Make `LineEndConcatenation` cop `<<` aware. ([@mockdeep][]) -* [#896](https://github.com/bbatsov/rubocop/issues/896): New option `--fail-level` changes minimum severity for exit with error code. ([@hiroponz][]) -* [#893](https://github.com/bbatsov/rubocop/issues/893): New option `--force-exclusion` forces excluding files specified in the configuration `Exclude` even if they are explicitly passed as arguments. ([@yujinakayama][]) -* `VariableInterpolation` cop does auto-correction. ([@bbatsov][]) -* `Not` cop does auto-correction. ([@bbatsov][]) -* `ClassMethods` cop does auto-correction. ([@bbatsov][]) -* `StringConversionInInterpolation` cop does auto-correction. ([@bbatsov][]) -* `NilComparison` cop does auto-correction. ([@bbatsov][]) -* `NonNilComparison` cop does auto-correction. ([@bbatsov][]) -* `NegatedIf` cop does auto-correction. ([@bbatsov][]) -* `NegatedWhile` cop does auto-correction. ([@bbatsov][]) -* New lint cop `SpaceBeforeFirstArg` checks for space between the method name and the first argument in method calls without parentheses. ([@jonas054][]) -* New style cop `SingleSpaceBeforeFirstArg` checks that no more than one space is used between the method name and the first argument in method calls without parentheses. ([@jonas054][]) -* New formatter `disabled_lines` displays cops and line ranges disabled by inline comments. ([@fshowalter][]) -* New cop `UselessAccessModifiers` checks for access modifiers that have no effect. ([@fshowalter][]) - -### Changes - -* [#913](https://github.com/bbatsov/rubocop/issues/913): `FileName` accepts multiple extensions. ([@tamird][]) -* `AllCops/Excludes` and `AllCops/Includes` were renamed to `AllCops/Exclude` and `AllCops/Include` for consistency with standard cop params. ([@bbatsov][]) -* Extract `NonNilCheck` cop from `NilComparison`. ([@bbatsov][]) -* Renamed `FavorJoin` to `ArrayJoin`. ([@bbatsov][]) -* Renamed `FavorUnlessOverNegatedIf` to `NegatedIf`. ([@bbatsov][]) -* Renamed `FavorUntilOverNegatedWhile`to `NegatedWhile`. ([@bbatsov][]) -* Renamed `HashMethods` to `DeprecatedHashMethods`. ([@bbatsov][]) -* Renamed `ReadAttribute` to `ReadWriteAttribute` and extended it to check for uses of `write_attribute`. ([@bbatsov][]) -* Add experimental support for Ruby 2.2 (development version) by falling back to Ruby 2.1 parser. ([@yujinakayama][]) - -### Bugs fixed - -* [#926](https://github.com/bbatsov/rubocop/issues/926): Fixed `BlockNesting` not auto-generating correctly. ([@tmorris-fiksu][]) -* [#904](https://github.com/bbatsov/rubocop/issues/904): Fixed a NPE in `LiteralInInterpolation`. ([@bbatsov][]) -* [#904](https://github.com/bbatsov/rubocop/issues/904): Fixed a NPE in `StringConversionInInterpolation`. ([@bbatsov][]) -* [#892](https://github.com/bbatsov/rubocop/issues/892): Make sure `Include` and `Exclude` paths in a `.rubocop.yml` are interpreted as relative to the directory of that file. ([@jonas054][]) -* [#906](https://github.com/bbatsov/rubocop/issues/906): Fixed a false positive in `LiteralInInterpolation`. ([@bbatsov][]) -* [#909](https://github.com/bbatsov/rubocop/issues/909): Handle properly multiple `rescue` clauses in `SignalException`. ([@bbatsov][]) -* [#876](https://github.com/bbatsov/rubocop/issues/876): Do a deep merge of hashes when overriding default configuration in a `.rubocop.yml` file. ([@jonas054][]) -* [#912](https://github.com/bbatsov/rubocop/issues/912): Fix a false positive in `LineEndConcatenation` for `%` string literals. ([@bbatsov][]) -* [#912](https://github.com/bbatsov/rubocop/issues/912): Handle top-level constant resolution in `DeprecatedClassMethods` (e.g. `::File.exists?`). ([@bbatsov][]) -* [#914](https://github.com/bbatsov/rubocop/issues/914): Fixed rdoc error during gem installation. ([@bbatsov][]) -* The `--only` option now enables the given cop in case it is disabled in configuration. ([@jonas054][]) -* Fix path resolution so that the default exclusion of `vendor` directories works. ([@jonas054][]) -* [#908](https://github.com/bbatsov/rubocop/issues/908): Fixed hanging while auto correct for `SpaceAfterComma` and `SpaceInsideBrackets`. ([@hiroponz][]) -* [#919](https://github.com/bbatsov/rubocop/issues/919): Don't avoid auto-correction in `HashSyntax` when there is missing space around operator. ([@jonas054][]) -* Fixed handling of floats in `NumericLiterals`. ([@bbatsov][]) -* [#927](https://github.com/bbatsov/rubocop/issues/927): Let `--auto-gen-config` overwrite an existing `rubocop-todo.yml` file instead of asking the user to remove it. ([@jonas054][]) -* [#936](https://github.com/bbatsov/rubocop/issues/936): Allow `_other` as well as `other` in `OpMethod`. ([@bbatsov][]) - -## 0.19.1 (17/03/2014) - -### Bugs fixed - -* [#884](https://github.com/bbatsov/rubocop/issues/884): Fix --auto-gen-config for `NumericLiterals` so MinDigits is correct. ([@tmorris-fiksu][]) -* [#879](https://github.com/bbatsov/rubocop/issues/879): Fix --auto-gen-config for `RegexpLiteral` so we don't generate illegal values for `MaxSlashes`. ([@jonas054][]) -* Fix the name of the `Include` param in the default config of the Rails cops. ([@bbatsov][]) -* [#878](https://github.com/bbatsov/rubocop/pull/878): Blacklist `Rakefile`, `Gemfile` and `Capfile` by default in the `FileName` cop. ([@bbatsov][]) -* [#875](https://github.com/bbatsov/rubocop/issues/875): Handle `separator` style hashes in `IndentHash`. ([@jonas054][]) -* Fix a bug where multiple cli options that result in exit can be specified at once (e.g. `-vV`, `-v --show-cops`). ([@jkogara][]) -* [#889](https://github.com/bbatsov/rubocop/issues/889): Fix a false positive for `LiteralInCondition` when the condition is non-primitive array. ([@bbatsov][]) - -## 0.19.0 (13/03/2014) - -### New features - -* New cop `FileName` makes sure that source files have snake_case names. ([@bbatsov][]) -* New cop `DeprecatedClassMethods` checks for deprecated class methods. ([@bbatsov][]) -* New cop `StringConversionInInterpolation` checks for redundant `Object#to_s` in string interpolation. ([@bbatsov][]) -* New cop `LiteralInInterpolation` checks for interpolated string literals. ([@bbatsov][]) -* New cop `SelfAssignment` checks for places where the self-assignment shorthand should have been used. ([@bbatsov][]) -* New cop `DoubleNegation` checks for uses of `!!`. ([@bbatsov][]) -* New cop `PercentLiteralDelimiters` enforces consistent usage of `%`-literal delimiters. ([@hannestyden][]) -* New Rails cop `ActionFilter` enforces the use of `_filter` or `_action` action filter methods. ([@bbatsov][]) -* New Rails cop `ScopeArgs` makes sure you invoke the `scope` method properly. ([@bbatsov][]) -* Add `with_fixed_indentation` style to `AlignParameters` cop. ([@hannestyden][]) -* Add `IgnoreLastArgumentHash` option to `AlignHash` cop. ([@hannestyden][]) -* [#743](https://github.com/bbatsov/rubocop/issues/743): `SingleLineMethods` cop does auto-correction. ([@jonas054][]) -* [#743](https://github.com/bbatsov/rubocop/issues/743): `Semicolon` cop does auto-correction. ([@jonas054][]) -* [#743](https://github.com/bbatsov/rubocop/issues/743): `EmptyLineBetweenDefs` cop does auto-correction. ([@jonas054][]) -* [#743](https://github.com/bbatsov/rubocop/issues/743): `IndentationWidth` cop does auto-correction. ([@jonas054][]) -* [#743](https://github.com/bbatsov/rubocop/issues/743): `IndentationConsistency` cop does auto-correction. ([@jonas054][]) -* [#809](https://github.com/bbatsov/rubocop/issues/809): New formatter `fuubar` displays a progress bar and shows details of offenses as soon as they are detected. ([@yujinakayama][]) -* [#797](https://github.com/bbatsov/rubocop/issues/797): New cop `IndentHash` checks the indentation of the first key in multi-line hash literals. ([@jonas054][]) -* [#797](https://github.com/bbatsov/rubocop/issues/797): New cop `IndentArray` checks the indentation of the first element in multi-line array literals. ([@jonas054][]) -* [#806](https://github.com/bbatsov/rubocop/issues/806): Now excludes files in `vendor/**` by default. ([@jeremyolliver][]) -* [#795](https://github.com/bbatsov/rubocop/issues/795): `IfUnlessModifier` and `WhileUntilModifier` supports `MaxLineLength`, which is independent of `LineLength` parameter `Max`. ([@agrimm][]) -* [#868](https://github.com/bbatsov/rubocop/issues/868): New cop `ClassAndModuleChildren` checks the style of children definitions at classes and modules: nested / compact. ([@geniou][]) - -### Changes - -* [#793](https://github.com/bbatsov/rubocop/issues/793): Add printing total count when `rubocop --format offences`. ([@ma2gedev][]) -* Remove `Ignore` param from the Rails `Output` cop. The standard `Exclude/Include` should be used instead. ([@bbatsov][]) -* Renamed `FavorSprintf` to `FormatString` and made it configurable. ([@bbatsov][]) -* Renamed `Offence` to `Offense`. ([@bbatsov][]) -* Use `offense` in all messages instead of `offence`. ([@bbatsov][]) -* For indentation of `if`/`unless`/`while`/`until` bodies when the result is assigned to a variable, instead of supporting two styles simultaneously, `IndentationWidth` now supports one style of indentation at a time, specified by `EndAlignment`/`AlignWith`. ([@jonas054][]) -* Renamed `Style` param of `DotPosition` cop to `EnforcedStyle`. ([@bbatsov][]) -* Add `length` value to locations of offense in JSON formatter. ([@yujinakayama][]) -* `SpaceAroundBlockBraces` cop replaced by `SpaceBeforeBlockBraces` and `SpaceInsideBlockBraces`. ([@jonas054][]) -* `SpaceAroundEqualsInParameterDefault` cop is now configurable with the `EnforcedStyle` option. ([@jonas054][]) - -### Bugs fixed - -* [#790](https://github.com/bbatsov/rubocop/issues/790): Fix auto-correction interference problem between `MethodDefParentheses` and other cops. ([@jonas054][]) -* [#794](https://github.com/bbatsov/rubocop/issues/794): Fix handling of modifier keywords with required parentheses in `ParenthesesAroundCondition`. ([@bbatsov][]) -* [#804](https://github.com/bbatsov/rubocop/issues/804): Fix a false positive with operator assignments in a loop (including `begin..rescue..end` with `retry`) in `UselessAssignment`. ([@yujinakayama][]) -* [#815](https://github.com/bbatsov/rubocop/issues/815): Fix a false positive for heredocs with blank lines in them in `EmptyLines`. ([@bbatsov][]) -* Auto-correction is now more robust and less likely to die because of `RangeError` or "clobbering". ([@jonas054][]) -* Offenses always reported in order of position in file, also during `--auto-correct` runs. ([@jonas054][]) -* Fix problem with `[Corrected]` tag sometimes missing in output from `--auto-correct` runs. ([@jonas054][]) -* Fix message from `EndAlignment` cop when `AlignWith` is `keyword`. ([@jonas054][]) -* Handle `case` conditions in `LiteralInCondition`. ([@bbatsov][]) -* [#822](https://github.com/bbatsov/rubocop/issues/822): Fix a false positive in `DotPosition` when enforced style is set to `trailing`. ([@bbatsov][]) -* Handle properly dynamic strings in `LineEndConcatenation`. ([@bbatsov][]) -* [#832](https://github.com/bbatsov/rubocop/issues/832): Fix auto-correction interference problem between `BracesAroundHashParameters` and `SpaceInsideHashLiteralBraces`. ([@jonas054][]) -* Fix bug in auto-correction of alignment so that only space can be removed. ([@jonas054][]) -* Fix bug in `IndentationWidth` auto-correction so it doesn't correct things that `IndentationConsistency` should correct. ([@jonas054][]) -* [#847](https://github.com/bbatsov/rubocop/issues/847): Fix bug in `RegexpLiteral` concerning `--auto-gen-config`. ([@jonas054][]) -* [#848](https://github.com/bbatsov/rubocop/issues/848): Fix bug in `--show-cops` that made it print the default configuration rather than the current configuration. ([@jonas054][]) -* [#862](https://github.com/bbatsov/rubocop/issues/862): Fix a bug where single line `rubocop:disable` comments with indentations were treated as multiline cop disabling comments. ([@yujinakayama][]) -* Fix a bug where `rubocop:disable` comments with a cop name including `all` (e.g. `MethodCallParentheses`) were disabling all cops. ([@yujinakayama][]) -* Fix a bug where string and regexp literals including `# rubocop:disable` were confused with real comments. ([@yujinakayama][]) -* [#877](https://github.com/bbatsov/rubocop/issues/877): Fix bug in `PercentLiteralDelimiters` concerning auto-correct of regular expressions with interpolation. ([@hannestyden][]) - -## 0.18.1 (02/02/2014) - -### Bugs fixed - -* Remove double reporting in `EmptyLinesAroundBody` of empty line inside otherwise empty class/module/method that caused crash in autocorrect. ([@jonas054][]) -* [#779](https://github.com/bbatsov/rubocop/issues/779): Fix a false positive in `LineEndConcatenation`. ([@bbatsov][]) -* [#751](https://github.com/bbatsov/rubocop/issues/751): Fix `Documentation` cop so that a comment followed by an empty line and then a class definition is not considered to be class documentation. ([@jonas054][]) -* [#783](https://github.com/bbatsov/rubocop/issues/783): Fix a false positive in `ParenthesesAroundCondition` when the parentheses are actually required. ([@bbatsov][]) -* [#781](https://github.com/bbatsov/rubocop/issues/781): Fix problem with back-and-forth auto-correction in `AccessModifierIndentation`. ([@jonas054][]) -* [#785](https://github.com/bbatsov/rubocop/issues/785): Fix false positive on `%w` arrays in `TrailingComma`. ([@jonas054][]) -* [#782](https://github.com/bbatsov/rubocop/issues/782): Fix false positive in `AlignHash` for single line hashes. ([@jonas054][]) - -## 0.18.0 (30/01/2014) - -### New features - -* [#714](https://github.com/bbatsov/rubocop/issues/714): New cop `RequireParentheses` checks for method calls without parentheses together with a boolean operator indicating that a mistake about precedence may have been made. ([@jonas054][]) -* [#743](https://github.com/bbatsov/rubocop/issues/743): `WordArray` cop does auto-correction. ([@jonas054][]) -* [#743](https://github.com/bbatsov/rubocop/issues/743): `Proc` cop does auto-correction. ([@bbatsov][]) -* [#743](https://github.com/bbatsov/rubocop/issues/743): `AccessModifierIndentation` cop does auto-correction. ([@jonas054][]) -* [#768](https://github.com/bbatsov/rubocop/issues/768): Rake task now supports `requires` and `options`. ([@nevir][]) -* [#759](https://github.com/bbatsov/rubocop/issues/759): New cop `EndLineConcatenation` checks for string literal concatenation with `+` at line end. ([@bbatsov][]) - -### Changes - -* [#762](https://github.com/bbatsov/rubocop/issues/762): Support Rainbow gem both 1.99.x and 2.x. ([@yujinakayama][]) -* [#761](https://github.com/bbatsov/rubocop/issues/761): Relax `json` requirement to `>= 1.7.7`. ([@bbatsov][]) -* [#757](https://github.com/bbatsov/rubocop/issues/757): `Include/Exclude` supports relative globbing to some extent. ([@nevir][]) - -### Bugs fixed - -* [#764](https://github.com/bbatsov/rubocop/issues/764): Handle heredocs in `TrailingComma`. ([@jonas054][]) -* Guide for contributors now points to correct issues page. ([@scottmatthewman][]) - -## 0.17.0 (25/01/2014) - -### New features - -* New cop `ConditionPosition` checks for misplaced conditions in expressions like `if/unless/when/until`. ([@bbatsov][]) -* New cop `ElseLayout` checks for odd arrangement of code in the `else` branch of a conditional expression. ([@bbatsov][]) -* [#694](https://github.com/bbatsov/rubocop/issues/694): Support Ruby 1.9.2 until June 2014. ([@yujinakayama][]) -* [#702](https://github.com/bbatsov/rubocop/issues/702): Improve `rubocop-todo.yml` with comments about offence count, configuration parameters, and auto-correction support. ([@jonas054][]) -* Add new command-line flag `-D/--display-cop-names` to trigger the display of cop names in offence messages. ([@bbatsov][]) -* [#733](https://github.com/bbatsov/rubocop/pull/733): `NumericLiterals` cop does auto-correction. ([@dblock][]) -* [#713](https://github.com/bbatsov/rubocop/issues/713): New cop `TrailingComma` checks for comma after the last item in a hash, array, or method call parameter list. ([@jonas054][]) - -### Changes - -* [#581](https://github.com/bbatsov/rubocop/pull/581): Extracted a new cop `AmbiguousOperator` from `Syntax` cop. It checks for ambiguous operators in the first argument of a method invocation without parentheses. ([@yujinakayama][]) -* Extracted a new cop `AmbiguousRegexpLiteral` from `Syntax` cop. It checks for ambiguous regexp literals in the first argument of a method invocation without parentheses. ([@yujinakayama][]) -* Extracted a new cop `UselessElseWithoutRescue` from `Syntax` cop. It checks for useless `else` in `begin..end` without `rescue`. ([@yujinakayama][]) -* Extracted a new cop `InvalidCharacterLiteral` from `Syntax` cop. It checks for invalid character literals with a non-escaped whitespace character (e.g. `? `). ([@yujinakayama][]) -* Removed `Syntax` cop from the configuration. It no longer can be disabled and it reports only invalid syntax offences. ([@yujinakayama][]) -* [#688](https://github.com/bbatsov/rubocop/issues/688): Output from `rubocop --show-cops` now looks like a YAML configuration file. The `--show-cops` option takes a comma separated list of cops as optional argument. ([@jonas054][]) -* New cop `IndentationConsistency` extracted from `IndentationWidth`, which has checked two kinds of offences until now. ([@jonas054][]) - -### Bugs fixed - -* [#698](https://github.com/bbatsov/rubocop/pull/698): Support Windows paths on command-line. ([@rifraf][]) -* [#498](https://github.com/bbatsov/rubocop/issues/498): Disable terminal ANSI escape sequences when a formatter's output is not a TTY. ([@yujinakayama][]) -* [#703](https://github.com/bbatsov/rubocop/issues/703): BracesAroundHashParameters auto-correction broken with trailing comma. ([@jonas054][]) -* [#709](https://github.com/bbatsov/rubocop/issues/709): When `EndAlignment` has configuration `AlignWith: variable`, it now handles `@@a = if ...` and `a, b = if ...`. ([@jonas054][]) -* `SpaceAroundOperators` now reports an offence for `@@a=0`. ([@jonas054][]) -* [#707](https://github.com/bbatsov/rubocop/issues/707): Fix error on operator assignments in top level scope in `UselessAssignment`. ([@yujinakayama][]) -* Fix a bug where some offences were discarded when any cop that has specific target file path (by `Include` or `Exclude` under each cop configuration) had run. ([@yujinakayama][]) -* [#724](https://github.com/bbatsov/rubocop/issues/724): Accept colons denoting required keyword argument (a new feature in Ruby 2.1) without trailing space in `SpaceAfterColon`. ([@jonas054][]) -* The `--no-color` option works again. ([@jonas054][]) -* [#716](https://github.com/bbatsov/rubocop/issues/716): Fixed a regression in the auto-correction logic of `MethodDefParentheses`. ([@bbatsov][]) -* Inspected projects that lack a `.rubocop.yml` file, and therefore get their configuration from RuboCop's `config/default.yml`, no longer get configuration from RuboCop's `.rubocop.yml` and `rubocop-todo.yml`. ([@jonas054][]) -* [#730](https://github.com/bbatsov/rubocop/issues/730): `EndAlignment` now handles for example `private def some_method`, which is allowed in Ruby 2.1. It requires `end` to be aligned with `private`, not `def`, in such cases. ([@jonas054][]) -* [#744](https://github.com/bbatsov/rubocop/issues/744): Any new offences created by `--auto-correct` are now handled immediately and corrected when possible, so running `--auto-correct` once is enough. ([@jonas054][]) -* [#748](https://github.com/bbatsov/rubocop/pull/748): Auto-correction conflict between `EmptyLinesAroundBody` and `TrailingWhitespace` resolved. ([@jonas054][]) -* `ParenthesesAroundCondition` no longer crashes on parentheses around the condition in a ternary if. ([@jonas054][]) -* [#738](https://github.com/bbatsov/rubocop/issues/738): Fix a false positive in `StringLiterals`. ([@bbatsov][]) - -## 0.16.0 (25/12/2013) - -### New features - -* [#612](https://github.com/bbatsov/rubocop/pull/612): `BracesAroundHashParameters` cop does auto-correction. ([@dblock][]) -* [#614](https://github.com/bbatsov/rubocop/pull/614): `ParenthesesAroundCondition` cop does auto-correction. ([@dblock][]) -* [#624](https://github.com/bbatsov/rubocop/pull/624): `EmptyLines` cop does auto-correction. ([@dblock][]) -* New Rails cop `DefaultScope` ensures `default_scope` is called properly with a block argument. ([@bbatsov][]) -* All cops now support the `Include` param, which specifies the files on which they should operate. ([@bbatsov][]) -* All cops now support the `Exclude` param, which specifies the files on which they should not operate. ([@bbatsov][]) -* [#631](https://github.com/bbatsov/rubocop/issues/631): `IndentationWidth` cop now detects inconsistent indentation between lines that should have the same indentation. ([@jonas054][]) -* [#649](https://github.com/bbatsov/rubocop/pull/649): `EmptyLinesAroundBody` cop does auto-correction. ([@dblock][]) -* [#657](https://github.com/bbatsov/rubocop/pull/657): `Alias` cop does auto-correction. ([@dblock][]) -* Rake task now support setting formatters. ([@pmenglund][]) -* [#653](https://github.com/bbatsov/rubocop/issues/653): `CaseIndentation` cop is now configurable with parameters `IndentWhenRelativeTo` and `IndentOneStep`. ([@jonas054][]) -* [#654](https://github.com/bbatsov/rubocop/pull/654): `For` cop is now configurable to enforce either `each` (default) or `for`. ([@jonas054][]) -* [#661](https://github.com/bbatsov/rubocop/issues/661): `EndAlignment` cop is now configurable for alignment with `keyword` (default) or `variable`. ([@jonas054][]) -* Allow to overwrite the severity of a cop with the new `Severity` param. ([@codez][]) -* New cop `FlipFlop` checks for flip flops. ([@agrimm][]) -* [#577](https://github.com/bbatsov/rubocop/issues/577): Introduced `MethodDefParentheses` to allow for for requiring either parentheses or no parentheses in method definitions. Replaces `DefWithoutParentheses`. ([@skanev][]) -* [#693](https://github.com/bbatsov/rubocop/pull/693): Generation of parameter values (i.e., not only `Enabled: false`) in `rubocop-todo.yml` by the `--auto-gen-config` option is now supported for some cops. ([@jonas054][]) -* New cop `AccessorMethodName` checks accessor method names for non-idiomatic names like `get_attribute` and `set_attribute`. ([@bbatsov][]) -* New cop `PredicateName` checks the names of predicate methods for non-idiomatic names like `is_something`, `has_something`, etc. ([@bbatsov][]) -* Support Ruby 2.1 with Parser 2.1. ([@yujinakayama][]) - -### Changes - -* Removed `SymbolNames` as it was generating way too many false positives. ([@bbatsov][]) -* Renamed `ReduceArguments` to `SingleLineBlockParams` and made it configurable. ([@bbatsov][]) - -### Bugs fixed - -* Handle properly heredocs in `StringLiterals` cop. ([@bbatsov][]) -* Fix `SpaceAroundOperators` to not report missing space around operator for `def self.method *args`. ([@jonas054][]) -* Properly handle `['AllCops']['Includes']` and `['AllCops']['Excludes']` when passing config via `-c`. ([@fancyremarker][], [@codez][]) -* [#611](https://github.com/bbatsov/rubocop/pull/611): Fix crash when loading an empty config file. ([@sinisterchipmunk][]) -* Fix `DotPosition` cop with `trailing` style for method calls on same line. ([@vonTronje][]) -* [#627](https://github.com/bbatsov/rubocop/pull/627): Fix counting of slashes in complicated regexps in `RegexpLiteral` cop. ([@jonas054][]) -* [#638](https://github.com/bbatsov/rubocop/issues/638): Fix bug in auto-correct that changes `each{ |x|` to `each d o |x|`. ([@jonas054][]) -* [#418](https://github.com/bbatsov/rubocop/issues/418): Stop searching for configuration files above the work directory of the isolated environment when running specs. ([@jonas054][]) -* Fix error on implicit match conditionals (e.g. `if /pattern/; end`) in `MultilineIfThen`. ([@agrimm][]) -* [#651](https://github.com/bbatsov/rubocop/issues/651): Handle properly method arguments in `RedundantSelf`. ([@bbatsov][]) -* [#628](https://github.com/bbatsov/rubocop/issues/628): Allow `self.Foo` in `RedundantSelf` cop. ([@chulkilee][]) -* [#668](https://github.com/bbatsov/rubocop/issues/668): Fix crash in `EndOfLine` that occurs when default encoding is `US_ASCII` and an inspected file has non-ascii characters. ([@jonas054][]) -* [#664](https://github.com/bbatsov/rubocop/issues/664): Accept oneline while when condition has local variable assignment. ([@emou][]) -* Fix auto-correct for `MethodDefParentheses` when parentheses are required. ([@skanev][]) - -## 0.15.0 (06/11/2013) - -### New features - -* New cop `Output` checks for calls to print, puts, etc. in Rails. ([@daviddavis][]) -* New cop `EmptyLinesAroundBody` checks for empty lines around the bodies of class, method and module definitions. ([@bbatsov][]) -* `LeadingCommentSpace` cop does auto-correction. ([@jonas054][]) -* `SpaceAfterControlKeyword` cop does auto-correction. ([@jonas054][]) -* `SpaceAfterColon` cop does auto-correction. ([@jonas054][]) -* `SpaceAfterComma` cop does auto-correction. ([@jonas054][]) -* `SpaceAfterSemicolon` cop does auto-correction. ([@jonas054][]) -* `SpaceAfterMethodName` cop does auto-correction. ([@jonas054][]) -* `SpaceAroundBlockBraces` cop does auto-correction. ([@jonas054][]) -* `SpaceAroundEqualsInParameterDefault` cop does auto-correction. ([@jonas054][]) -* `SpaceAroundOperators` cop does auto-correction. ([@jonas054][]) -* `SpaceBeforeModifierKeyword` cop does auto-correction. ([@jonas054][]) -* `SpaceInsideHashLiteralBraces` cop does auto-correction. ([@jonas054][]) -* `SpaceInsideBrackets` cop does auto-correction. ([@jonas054][]) -* `SpaceInsideParens` cop does auto-correction. ([@jonas054][]) -* `TrailingWhitespace` cop does auto-correction. ([@jonas054][]) -* `TrailingBlankLines` cop does auto-correction. ([@jonas054][]) -* `FinalNewline` cop does auto-correction. ([@jonas054][]) -* New cop `CyclomaticComplexity` checks the cyclomatic complexity of methods against a configurable max value. ([@jonas054][]) -* [#594](https://github.com/bbatsov/rubocop/pull/594): New parameter `EnforcedStyleForEmptyBraces` with values `space` and `no_space` (default) added to `SpaceAroundBlockBraces`. ([@jonas054][]) -* [#603](https://github.com/bbatsov/rubocop/pull/603): New parameter `MinSize` added to `WordArray` to allow small string arrays, retaining the default (0). ([@claco][]) - -### Changes - -* [#557](https://github.com/bbatsov/rubocop/pull/557): Configuration files for excluded files are no longer loaded. ([@jonas054][]) -* [#571](https://github.com/bbatsov/rubocop/pull/571): The default rake task now runs RuboCop over itself! ([@nevir][]) -* Encoding errors are reported as fatal offences rather than printed with red text. ([@jonas054][]) -* `AccessControl` cop is now configurable with the `EnforcedStyle` option. ([@sds][]) -* Split `AccessControl` cop to `AccessModifierIndentation` and `EmptyLinesAroundAccessModifier`. ([@bbatsov][]) -* [#594](https://github.com/bbatsov/rubocop/pull/594): Add configuration parameter `EnforcedStyleForEmptyBraces` to `SpaceInsideHashLiteralBraces` cop, and change `EnforcedStyleIsWithSpaces` (values `true`, `false`) to `EnforcedStyle` (values `space`, `no_space`). ([@jonas054][]) -* Coverage builds linked from the README page are enabled again. ([@jonas054][]) - -### Bugs fixed - -* [#561](https://github.com/bbatsov/rubocop/pull/561): Handle properly negative literals in `NumericLiterals` cop. ([@bbatsov][]) -* [#567](https://github.com/bbatsov/rubocop/pull/567): Register an offence when the last hash parameter has braces in `BracesAroundHashParameters` cop. ([@dblock][]) -* `StringLiterals` cop no longer reports errors for character literals such as ?/. That should be done only by the `CharacterLiterals` cop. ([@jonas054][]) -* Made auto-correct much less likely to crash due to conflicting corrections ("clobbering"). ([@jonas054][]) -* [#565](https://github.com/bbatsov/rubocop/pull/565): `$GLOBAL_VAR from English library` should no longer be inserted when autocorrecting short-form global variables like `$!`. ([@nevir][]) -* [#566](https://github.com/bbatsov/rubocop/pull/566): Methods that just assign a splat to an ivar are no longer considered trivial writers. ([@nevir][]) -* [#585](https://github.com/bbatsov/rubocop/pull/585): `MethodCallParentheses` should allow methods starting with uppercase letter. ([@bbatsov][]) -* [#574](https://github.com/bbatsov/rubocop/issues/574): Fix error on multiple-assignment with non-array right hand side in `UselessSetterCall`. ([@yujinakayama][]) -* [#576](https://github.com/bbatsov/rubocop/issues/576): Output config validation warning to STDERR so that it won't be mixed up with formatter's output. ([@yujinakayama][]) -* [#599](https://github.com/bbatsov/rubocop/pull/599): `EndOfLine` cop is operational again. ([@jonas054][]) -* [#604](https://github.com/bbatsov/rubocop/issues/604): Fix error on implicit match conditionals (e.g. `if /pattern/; end`) in `FavorModifier`. ([@yujinakayama][]) -* [#600](https://github.com/bbatsov/rubocop/pull/600): Don't require an empty line for access modifiers at the beginning of class/module body. ([@bbatsov][]) -* [#608](https://github.com/bbatsov/rubocop/pull/608): `RescueException` no longer crashes when the namespace of a rescued class is in a local variable. ([@jonas054][]) -* [#173](https://github.com/bbatsov/rubocop/issues/173): Allow the use of `alias` in the body of an `instance_exec`. ([@bbatsov][]) -* [#554](https://github.com/bbatsov/rubocop/issues/554): Handle properly multi-line arrays with comments in them in `WordArray`. ([@bbatsov][]) - -## 0.14.1 (10/10/2013) - -### New features - -* [#551](https://github.com/bbatsov/rubocop/pull/551): New cop `BracesAroundHashParameters` checks for braces in function calls with hash parameters. ([@dblock][]) -* New cop `SpaceAfterNot` tracks redundant space after the `!` operator. ([@bbatsov][]) - -### Bugs fixed - -* Fix bug concerning table and separator alignment of multi-line hash with multiple keys on the same line. ([@jonas054][]) -* [#550](https://github.com/bbatsov/rubocop/pull/550): Fix a bug where `ClassLength` counted lines of inner classes/modules. ([@yujinakayama][]) -* [#550](https://github.com/bbatsov/rubocop/pull/550): Fix a false positive for namespace class in `Documentation`. ([@yujinakayama][]) -* [#556](https://github.com/bbatsov/rubocop/pull/556): Fix "Parser::Source::Range spans more than one line" bug in clang formatter. ([@yujinakayama][]) -* [#552](https://github.com/bbatsov/rubocop/pull/552): `RaiseArgs` allows exception constructor calls with more than one 1 argument. ([@bbatsov][]) - -## 0.14.0 (07/10/2013) - -### New features - -* [#491](https://github.com/bbatsov/rubocop/issues/491): New cop `MethodCalledOnDoEndBlock` keeps track of methods called on `do`...`end` blocks. -* [#456](https://github.com/bbatsov/rubocop/issues/456): New configuration parameter `AllCops`/`RunRailsCops` can be set to `true` for a project, removing the need to give the `-R`/`--rails` option with every invocation of `rubocop`. -* [#501](https://github.com/bbatsov/rubocop/issues/501): `simple`/`clang`/`progress`/`emacs` formatters now print `[Corrected]` along with offence message when the offence is automatically corrected. -* [#501](https://github.com/bbatsov/rubocop/issues/501): `simple`/`clang`/`progress` formatters now print count of auto-corrected offences in the final summary. -* [#501](https://github.com/bbatsov/rubocop/issues/501): `json` formatter now outputs `corrected` key with boolean value in offence objects whether the offence is automatically corrected. -* New cop `ClassLength` checks for overly long class definitions. -* New cop `Debugger` checks for forgotten calls to debugger or pry. -* New cop `RedundantException` checks for code like `raise RuntimeError, message`. -* [#526](https://github.com/bbatsov/rubocop/issues/526): New cop `RaiseArgs` checks the args passed to `raise/fail`. - -### Changes - -* Cop `MethodAndVariableSnakeCase` replaced by `MethodName` and `VariableName`, both having the configuration parameter `EnforcedStyle` with values `snake_case` (default) and `camelCase`. -* [#519](https://github.com/bbatsov/rubocop/issues/519): `HashSyntax` cop is now configurable and can enforce the use of the classic hash rockets syntax. -* [#520](https://github.com/bbatsov/rubocop/issues/520): `StringLiterals` cop is now configurable and can enforce either single-quoted or double-quoted strings. -* [#528](https://github.com/bbatsov/rubocop/issues/528): Added a config option to `RedundantReturn` to allow a `return` with multiple values. -* [#524](https://github.com/bbatsov/rubocop/issues/524): Added a config option to `Semicolon` to allow the use of `;` as an expression separator. -* [#525](https://github.com/bbatsov/rubocop/issues/525): `SignalException` cop is now configurable and can enforce the semantic rule or an exclusive use of `raise` or `fail`. -* `LambdaCall` is now configurable and enforce either `Proc#call` or `Proc#()`. -* [#529](https://github.com/bbatsov/rubocop/issues/529): Added config option `EnforcedStyle` to `SpaceAroundBraces`. -* [#529](https://github.com/bbatsov/rubocop/issues/529): Changed config option `NoSpaceBeforeBlockParameters` to `SpaceBeforeBlockParameters`. -* Support Parser 2.0.0 (non-beta). - -### Bugs fixed - -* [#514](https://github.com/bbatsov/rubocop/issues/514): Fix alignment of the hash containing different key lengths in one line. -* [#496](https://github.com/bbatsov/rubocop/issues/496): Fix corner case crash in `AlignHash` cop: single key/value pair when configuration is `table` for '=>' and `separator` for `:`. -* [#502](https://github.com/bbatsov/rubocop/issues/502): Don't check non-decimal literals with `NumericLiterals`. -* [#448](https://github.com/bbatsov/rubocop/issues/448): Fix auto-correction of parameters spanning more than one line in `AlignParameters` cop. -* [#493](https://github.com/bbatsov/rubocop/issues/493): Support disabling `Syntax` offences with `warning` severity. -* Fix bug appearing when there were different values for the `AllCops`/`RunRailsCops` configuration parameter in different directories. -* [#512](https://github.com/bbatsov/rubocop/issues/512): Fix bug causing crash in `AndOr` auto-correction. -* [#515](https://github.com/bbatsov/rubocop/issues/515): Fix bug causing `AlignParameters` and `AlignArray` auto-correction to destroy code. -* [#516](https://github.com/bbatsov/rubocop/issues/516): Fix bug causing `RedundantReturn` auto-correction to produce invalid code. -* [#527](https://github.com/bbatsov/rubocop/issues/527): Handle `!=` expressions in `EvenOdd` cop. -* `SignalException` cop now finds `raise` calls anywhere, not only in `begin` sections. -* [#538](https://github.com/bbatsov/rubocop/issues/538): Fix bug causing `Blocks` auto-correction to produce invalid code. +* [#4182](https://github.com/rubocop/rubocop/issues/4182): Add `Lint/AmbiguousRange` cop to check for ranges with ambiguous boundaries. ([@dvandersluis][]) +* [#10000](https://github.com/rubocop/rubocop/pull/10000): Parallel static analysis by default. ([@koic][]) +* [#9948](https://github.com/rubocop/rubocop/pull/9948): Support Ruby 2.7's pattern matching for `Style/ConditionalAssignment` cop. ([@koic][]) +* [#9999](https://github.com/rubocop/rubocop/pull/9999): Add new `Style/RedundantSelfAssignmentBranch` cop. ([@koic][]) + +### Bug fixes + +* [#9927](https://github.com/rubocop/rubocop/issues/9927): Indent hash values in `Layout/LineEndStringConcatenationIndentation`. ([@jonas054][]) +* [#9959](https://github.com/rubocop/rubocop/issues/9959): Make `Style/IdenticalConditionalBranches` able to handle ternary `if`s. ([@dvandersluis][]) +* [#9946](https://github.com/rubocop/rubocop/issues/9946): Avoid slow regexp matches in `Style/CommentedKeyword`. ([@jonas054][]) +* [#7422](https://github.com/rubocop/rubocop/issues/7422): Treat constant assignment like other assignment in `Layout/SpaceAroundOperators`. ([@dvandersluis][]) +* [#9953](https://github.com/rubocop/rubocop/issues/9953): Fix an infinite loop error and a false auto-correction behavior for `Layout/EndAlignment` when using a conditional statement in a method argument. ([@koic][]) +* [#9958](https://github.com/rubocop/rubocop/issues/9958): Prevent an infinite loop when a detected method has fewer arguments than expected. ([@dvandersluis][]) +* [#9977](https://github.com/rubocop/rubocop/issues/9977): Update `Layout/EmptyLineAfterGuardClause` to not register an offense if there is another expression following the guard clause on the same line. ([@dvandersluis][]) +* [#9980](https://github.com/rubocop/rubocop/issues/9980): Fix a false positive for `Style/IdenticalConditionalBranches` when assigning to a variable used in a condition. ([@koic][]) +* [#9975](https://github.com/rubocop/rubocop/issues/9975): Parentheses are always required for `Style/MethodDefParentheses` when a forwarding argument (`...`) is used. ([@dvandersluis][]) +* [#9984](https://github.com/rubocop/rubocop/pull/9984): Fix false negatives involving heredocs for `Layout/SpaceBeforeComma`, `Layout/SpaceBeforeComment`, `Layout/SpaceBeforeSemicolon` and `Layout/SpaceInsideParens`. ([@dvandersluis][]) +* [#9954](https://github.com/rubocop/rubocop/issues/9954): Fix infinite loop error for `Layout/HashAlignment` when `EnforcedStyle: with_fixed_indentation` is specified for `Layout/ArgumentAlignment`. ([@koic][]) +* [#10002](https://github.com/rubocop/rubocop/issues/10002): Fix an incorrect auto-correct for `Lint/AmbiguousRegexpLiteral` when using nested method arguments without parentheses. ([@koic][]) +* [#9952](https://github.com/rubocop/rubocop/pull/9952) [rubocop-rspec#1126](https://github.com/rubocop/rubocop-rspec/issues/1126): Fix `inherit_mode` for deeply nested configuration defined in extensions' default configuration. ([@pirj][]) +* [#9957](https://github.com/rubocop/rubocop/issues/9957): Add `WholeWord` configuration to `Naming/InclusiveLanguage`'s `FlaggedTerms` config. ([@dvandersluis][]) +* [#9970](https://github.com/rubocop/rubocop/pull/9970): Don't register an offense when sort method has arguments for `Style/RedundantSort` cop. ([@mtsmfm][]) +* [#4097](https://github.com/rubocop/rubocop/issues/4097): Add require English for special globals. ([@biinari][]) +* [#9955](https://github.com/rubocop/rubocop/issues/9955): Fix `Style/ExplicitBlockArgument` adding a second set of parentheses. ([@dvandersluis][]) +* [#9973](https://github.com/rubocop/rubocop/issues/9973): Fix a false positive for `Layout/RescueEnsureAlignment` when aligned `rescue` keyword and leading dot. ([@koic][]) +* [#9945](https://github.com/rubocop/rubocop/issues/9945): Fix auto-correction of lines in heredocs with only spaces in `Layout/TrailingWhitespace`. ([@jonas054][]) -## 0.13.1 (19/09/2013) +### Changes + +* [#9989](https://github.com/rubocop/rubocop/issues/9989): Mark `Style/CommentedKeyword` as unsafe auto-correction. ([@koic][]) +* [#9964](https://github.com/rubocop/rubocop/pull/9964): Make `Layout/LeadingCommentSpace` aware of `#:nodoc`. ([@koic][]) +* [#9985](https://github.com/rubocop/rubocop/pull/9985): Mark `Style/IdenticalConditionalBranches` as unsafe auto-correction. ([@koic][]) +* [#9962](https://github.com/rubocop/rubocop/issues/9962): Update `Style/WordArray` to register an offense in `percent` style if any values contain spaces. ([@dvandersluis][]) +* [#9979](https://github.com/rubocop/rubocop/pull/9979): Enable basic autocorrection for `Style/Semicolon`. ([@dvandersluis][]) + +## 1.18.4 (2021-07-23) ### New features -* `HashSyntax` cop does auto-correction. -* [#484](https://github.com/bbatsov/rubocop/pull/484): Allow calls to self to fix name clash with argument. -* Renamed `SpaceAroundBraces` to `SpaceAroundBlockBraces`. -* `SpaceAroundBlockBraces` now has a `NoSpaceBeforeBlockParameters` config option to enforce a style for blocks with parameters like `{|foo| puts }`. -* New cop `LambdaCall` tracks uses of the obscure `lambda.(...)` syntax. +* [#9930](https://github.com/rubocop/rubocop/pull/9930): Support Ruby 2.7's pattern matching for `Lint/DuplicateBranch` cop. ([@koic][]) + +### Bug fixes + +* [#9938](https://github.com/rubocop/rubocop/pull/9938): Fix an incorrect auto-correct for `Layout/LineLength` when a heredoc is used as the first element of an array. ([@koic][]) +* [#9940](https://github.com/rubocop/rubocop/issues/9940): Fix an incorrect auto-correct for `Style/HashTransformValues` when value is a hash literal for `_.to_h{...}`. ([@koic][]) +* [#9752](https://github.com/rubocop/rubocop/issues/9752): Improve error message for top level department used in configuration. ([@jonas054][]) +* [#9933](https://github.com/rubocop/rubocop/pull/9933): Fix GitHub Actions formatter when running in non-default directory. ([@ojab][]) +* [#9922](https://github.com/rubocop/rubocop/issues/9922): Make better auto-corrections in `Style/DoubleCopDisableDirective`. ([@jonas054][]) +* [#9848](https://github.com/rubocop/rubocop/issues/9848): Fix handling of comments in `Layout/ClassStructure` auto-correct. ([@jonas054][]) +* [#9926](https://github.com/rubocop/rubocop/pull/9926): Fix an incorrect auto-correct for `Style/SingleLineMethods` when method body is enclosed in parentheses. ([@koic][]) +* [#9928](https://github.com/rubocop/rubocop/issues/9928): Fix an infinite loop error and a false auto-correction behavior for `Layout/EndAlignment` when using operator methods and `EnforcedStyleAlignWith: variable`. ([@koic][]) +* [#9434](https://github.com/rubocop/rubocop/issues/9434): Fix false positive for setter calls in `Layout/FirstArgumentIndentation`. ([@jonas054][]) + +## 1.18.3 (2021-07-06) + +### Bug fixes + +* [#9891](https://github.com/rubocop/rubocop/issues/9891): Fix `--auto-gen-config` bug for `Style/HashSyntax`. ([@jonas054][]) +* [#9905](https://github.com/rubocop/rubocop/issues/9905): Fix false positive for single line concatenation in `Layout/LineEndStringConcatenationIndentation`. ([@jonas054][]) +* [#9907](https://github.com/rubocop/rubocop/issues/9907): Fix an incorrect auto-correct for `Lint/UselessTimes` when using block argument for `1.times`. ([@koic][]) +* [#9869](https://github.com/rubocop/rubocop/issues/9869): Fix reference to file in configuration override warning. ([@jonas054][]) +* [#9902](https://github.com/rubocop/rubocop/issues/9902): Fix an incorrect auto-correct for `Style/BlockDelimiters` when there is a comment after the closing brace. ([@koic][]) +* [#8469](https://github.com/rubocop/rubocop/issues/8469): Add inspection of `class <<` to `Layout/SpaceAroundOperators`. ([@jonas054][]) +* [#9909](https://github.com/rubocop/rubocop/pull/9909): This PR fixes an incorrect auto-correct for `Style/SingleLineMethods` when using `return`, `break`, or `next` for one line method body in Ruby 3.0. ([@koic][]) +* [#9914](https://github.com/rubocop/rubocop/issues/9914): Fix an error for `Layout/HashAlignment` when using aligned hash argument for `proc.()`. ([@koic][]) + +## 1.18.2 (2021-07-02) + +### Bug fixes + +* [#9894](https://github.com/rubocop/rubocop/issues/9894): Handle multiline string literals in `Layout/LineEndStringConcatenationIndentation`. ([@jonas054][]) +* [#9890](https://github.com/rubocop/rubocop/issues/9890): Make colon after comment annotation configurable. ([@gregfletch][]) + +## 1.18.1 (2021-06-30) + +### Bug fixes + +* [#9897](https://github.com/rubocop/rubocop/pull/9897): Fix an incorrect auto-correct for `Layout/HashAlignment` when setting `EnforcedStyle: with_fixed_indentation` of `Layout/ArgumentAlignment` and using misaligned keyword arguments. ([@koic][]) -### Bugs fixed +### Changes -* Fix crash on empty input file in `FinalNewline`. -* [#485](https://github.com/bbatsov/rubocop/issues/485): Fix crash on multiple-assignment and op-assignment in `UselessSetterCall`. -* [#497](https://github.com/bbatsov/rubocop/issues/497): Fix crash in `UselessComparison` and `NilComparison`. +* [#9895](https://github.com/rubocop/rubocop/issues/9895): Set `CheckStrings: false` and Remove `master` from `FlaggedTerms` for `Naming/InclusiveLanguage`. ([@koic][]) -## 0.13.0 (13/09/2013) +## 1.18.0 (2021-06-29) ### New features -* New configuration parameter `AllowAdjacentOneLineDefs` for `EmptyLineBetweenDefs`. -* New cop `MultilineBlockChain` keeps track of chained blocks spanning multiple lines. -* `RedundantSelf` cop does auto-correction. -* `AvoidPerlBackrefs` cop does auto-correction. -* `AvoidPerlisms` cop does auto-correction. -* `RedundantReturn` cop does auto-correction. -* `Blocks` cop does auto-correction. -* New cop `TrailingBlankLines` keeps track of extra blanks lines at the end of source file. -* New cop `AlignHash` keeps track of bad alignment in multi-line hash literals. -* New cop `AlignArray` keeps track of bad alignment in multi-line array literals. -* New cop `SpaceBeforeModifierKeyword` keeps track of missing space before a modifier keyword (`if`, `unless`, `while`, `until`). -* New cop `FinalNewline` keeps tracks of the required final newline in a source file. -* Highlightling corrected in `SpaceInsideHashLiteralBraces` and `SpaceAroundBraces` cops. +* [#9842](https://github.com/rubocop/rubocop/pull/9842): Add new `Naming/InclusiveLanguage` cop. ([@tjwp][]) + +### Bug fixes + +* [#9803](https://github.com/rubocop/rubocop/pull/9803): Fix `Bundler/GemVersion` cop not respecting git tags. ([@tejasbubane][], [@timlkelly][]) +* [#9882](https://github.com/rubocop/rubocop/pull/9882): Fix an incorrect auto-correct for `Layout/LineLength` when using heredoc as the first method argument and omitting parentheses. ([@koic][]) +* [#7592](https://github.com/rubocop/rubocop/pull/7592): Add cop `Layout/LineEndStringConcatenationIndentation`. ([@jonas054][]) +* [#9880](https://github.com/rubocop/rubocop/pull/9880): Fix a false positive for `Style/RegexpLiteral` when using a regexp starts with a blank as a method argument. ([@koic][]) +* [#9888](https://github.com/rubocop/rubocop/pull/9888): Fix a false positive for `Layout/ClosingParenthesisIndentation` when using keyword arguments. ([@koic][]) +* [#9886](https://github.com/rubocop/rubocop/pull/9886): Fix indentation in `Style/ClassAndModuleChildren`. ([@markburns][]) ### Changes -* [#447](https://github.com/bbatsov/rubocop/issues/447): `BlockAlignment` cop now allows `end` to be aligned with the start of the line containing `do`. -* `SymbolName` now has an `AllowDots` config option to allow symbols like `:'whatever.submit_button'`. -* [#469](https://github.com/bbatsov/rubocop/issues/469): Extracted useless setter call tracking part of `UselessAssignment` cop to `UselessSetterCall`. -* [#469](https://github.com/bbatsov/rubocop/issues/469): Merged `UnusedLocalVariable` cop into `UselessAssignment`. -* [#458](https://github.com/bbatsov/rubocop/issues/458): The merged `UselessAssignment` cop now has advanced logic that tracks not only assignment at the end of the method but also every assignment in every scope. -* [#466](https://github.com/bbatsov/rubocop/issues/466): Allow built-in JRuby global vars in `AvoidGlobalVars`. -* Added a config option `AllowedVariables` to `AvoidGlobalVars` to allow users to whitelist certain global variables. -* Renamed `AvoidGlobalVars` to `GlobalVars`. -* Renamed `AvoidPerlisms` to `SpecialGlobalVars`. -* Renamed `AvoidFor` to `For`. -* Renamed `AvoidClassVars` to `ClassVars`. -* Renamed `AvoidPerlBackrefs` to `PerlBackrefs`. -* `NumericLiterals` now accepts a config param `MinDigits` - the minimal number of digits in the integer portion of number for the cop to check it. +* [#9144](https://github.com/rubocop/rubocop/issues/9144): Add `aggressive` and `conservative` modes of operation for `Style/StringConcatenation` cop. ([@tejasbubane][]) + +## 1.17.0 (2021-06-15) + +### New features + +* [#9626](https://github.com/rubocop/rubocop/pull/9626): Disable all cop department with directive comment. ([@AndreiEres][]) +* [#9827](https://github.com/rubocop/rubocop/issues/9827): Add basic auth support to download raw yml config from private repo. ([@AirWick219][]) +* [#9873](https://github.com/rubocop/rubocop/pull/9873): Support one-line pattern matching syntax for `Layout/SpaceAroundKeyword` and `Layout/SpaceAroundOperators`. ([@koic][]) +* [#9857](https://github.com/rubocop/rubocop/pull/9857): Support Ruby 2.7's pattern matching for `Layout/IndentationWidth` cop. ([@koic][]) +* [#9877](https://github.com/rubocop/rubocop/pull/9877): Support Ruby 2.7's `in` pattern syntax for `Lint/LiteralAsCondition`. ([@koic][]) +* [#9855](https://github.com/rubocop/rubocop/pull/9855): Support Ruby 2.7's pattern matching for `Style/IdenticalConditionalBranches` cop. ([@koic][]) + +### Bug fixes + +* [#9874](https://github.com/rubocop/rubocop/issues/9874): Fix a false positive for `Style/RegexpLiteral` when using `%r` regexp literal with `EnforcedStyle: omit_parentheses` of `Style/MethodCallWithArgsParentheses`. ([@koic][]) +* [#9876](https://github.com/rubocop/rubocop/pull/9876): Fix empty line after guard clause with `and return` and heredoc. ([@AndreiEres][]) +* [#9861](https://github.com/rubocop/rubocop/issues/9861): Fix error in `Layout/HashAlignment` with an empty hash literal. ([@dvandersluis][]) +* [#9867](https://github.com/rubocop/rubocop/pull/9867): Fix an incorrect auto-correct for `Layout/DotPosition` when using only dot line. ([@koic][]) + +## 1.16.1 (2021-06-09) + +### Bug fixes + +* [#9843](https://github.com/rubocop/rubocop/issues/9843): Fix `Style/RedundantSelf` to allow conditional nodes to use `self` in the condition when a variable named is shadowed inside. ([@dvandersluis][]) +* [#9845](https://github.com/rubocop/rubocop/issues/9845): Fix `Style/QuotedSymbols` for hash-rocket hashes. ([@dvandersluis][]) +* [#9849](https://github.com/rubocop/rubocop/pull/9849): Fix a false negative for `Layout/HashAlignment` when setting `EnforcedStyle: with_fixed_indentation` of `Layout/ArgumentAlignment` and using misaligned keyword arguments. ([@koic][]) +* [#9854](https://github.com/rubocop/rubocop/pull/9854): Allow braced numeric blocks in `omit_parentheses` style of `Style/MethodCallWithArgsParentheses`. ([@gsamokovarov][]) +* [#9850](https://github.com/rubocop/rubocop/issues/9850): Fix missing `AllowComments` option for `Lint/EmptyInPattern`. ([@koic][]) + +## 1.16.0 (2021-06-01) + +### New features + +* [#9841](https://github.com/rubocop/rubocop/pull/9841): Support guard `if` and `unless` syntax keywords of Ruby 2.7's pattern matching for `Layout/SpaceAroundKeyword`. ([@koic][]) +* [#9812](https://github.com/rubocop/rubocop/pull/9812): Support auto-correction for `Style/IdenticalConditionalBranches`. ([@koic][]) +* [#9833](https://github.com/rubocop/rubocop/pull/9833): Add new `Style/InPatternThen` cop. ([@koic][]) +* [#9840](https://github.com/rubocop/rubocop/issues/9840): Adds `AllowedReceivers` option for `Style/HashEachMethods`. ([@koic][]) +* [#9818](https://github.com/rubocop/rubocop/pull/9818): Support Ruby 2.7's `in` pattern syntax for `Layout/CaseIndentation`. ([@koic][]) +* [#9838](https://github.com/rubocop/rubocop/pull/9838): Support Ruby 2.7's pattern matching syntax for `Layout/SpaceAroundKeyword`. ([@koic][]) +* [#9793](https://github.com/rubocop/rubocop/issues/9793): Add `Style/QuotedSymbols` to enforce consistency in quoted symbols. ([@dvandersluis][]) +* [#9825](https://github.com/rubocop/rubocop/pull/9825): Add new `Lint/EmptyInPattern` cop. ([@koic][]) +* [#9834](https://github.com/rubocop/rubocop/pull/9834): Add new `Style/MultilineInPatternThen` cop. ([@koic][]) + +### Bug fixes + +* [#9822](https://github.com/rubocop/rubocop/issues/9822): Fix a false directive comment range for `Lint/RedundantCopDisableDirective`. ([@koic][]) +* [#9819](https://github.com/rubocop/rubocop/issues/9819): Fix a false negative for `Style/TopLevelMethodDefinition` when defining a top-level method after a class definition. ([@koic][]) +* [#9836](https://github.com/rubocop/rubocop/issues/9836): Fix incorrect corrections for `Layout/HashAlignment` when a `kwsplat` node is on the same line as a `pair` node with table style. ([@dvandersluis][]) +* [#9805](https://github.com/rubocop/rubocop/pull/9805): Fix a false negative for `Layout/HashAlignment` when set `EnforcedStyle: with_fixed_indentation` of `ArgumentAlignment`. ([@koic][]) +* [#9811](https://github.com/rubocop/rubocop/issues/9811): Fix an error for `Layout/ArgumentAlignment` with `Layout/FirstHashElementIndentation` when setting `EnforcedStyle: with_fixed_indentation`. ([@koic][]) -### Bugs fixed +### Changes -* [#449](https://github.com/bbatsov/rubocop/issues/449): Remove whitespaces between condition and `do` with `WhileUntilDo` auto-correction. -* Continue with file inspection after parser warnings. Give up only on syntax errors. -* Don't trigger the HashSyntax cop on digit-starting keys. -* Fix crashes while inspecting class definition subclassing another class stored in a local variable in `UselessAssignment` (formerly of `UnusedLocalVariable`) and `ShadowingOuterLocalVariable` (like `clazz = Array; class SomeClass < clazz; end`). -* [#463](https://github.com/bbatsov/rubocop/issues/463): Do not warn if using destructuring in second `reduce` argument (`ReduceArguments`). +* [#9809](https://github.com/rubocop/rubocop/pull/9809): Change `Lint/SymbolConversion` to only quote with double quotes, since `Style/QuotedSymbols` can now correct those to the correct quotes as per configuration. ([@dvandersluis][]) -## 0.12.0 (23/08/2013) +## 1.15.0 (2021-05-17) ### New features -* [#439](https://github.com/bbatsov/rubocop/issues/439): Added formatter 'OffenceCount' which outputs a summary list of cops and their offence count. -* [#395](https://github.com/bbatsov/rubocop/issues/395): Added `--show-cops` option to show available cops. -* New cop `NilComparison` keeps track of comparisons like `== nil`. -* New cop `EvenOdd` keeps track of occasions where `Fixnum#even?` or `Fixnum#odd?` should have been used (like `x % 2 == 0`). -* New cop `IndentationWidth` checks for files using indentation that is not two spaces. -* New cop `SpaceAfterMethodName` keeps track of method definitions with a space between the method name and the opening parenthesis. -* New cop `ParenthesesAsGroupedExpression` keeps track of method calls with a space before the opening parenthesis. -* New cop `HashMethods` keeps track of uses of deprecated `Hash` methods. -* New Rails cop `HasAndBelongsToMany` checks for uses of `has_and_belongs_to_many`. -* New Rails cop `ReadAttribute` tracks uses of `read_attribute`. -* `Attr` cop does auto-correction. -* `CollectionMethods` cop does auto-correction. -* `SignalException` cop does auto-correction. -* `EmptyLiteral` cop does auto-correction. -* `MethodCallParentheses` cop does auto-correction. -* `DefWithParentheses` cop does auto-correction. -* `DefWithoutParentheses` cop does auto-correction. +* [#9734](https://github.com/rubocop/rubocop/pull/9734): Add `Style/TopLevelMethodDefinition` cop. ([@tejasbubane][]) +* [#9780](https://github.com/rubocop/rubocop/issues/9780): Support summary report for `JUnitFormatter`. ([@koic][]) +* [#9798](https://github.com/rubocop/rubocop/pull/9798): Make `Layout/ArgumentAlignment` aware of kwargs. ([@koic][]) + +### Bug fixes + +* [#9749](https://github.com/rubocop/rubocop/issues/9749): Fix autocorrection for `Layout/LineLength` to not move the first argument of an unparenthesized `send` node to the next line, which changes behaviour. ([@dvandersluis][]) +* [#9799](https://github.com/rubocop/rubocop/issues/9799): Fix invalid line splitting by `Layout/LineLength` for `send` nodes with heredoc arguments. ([@dvandersluis][]) +* [#9773](https://github.com/rubocop/rubocop/issues/9773): Fix `Style/EmptyLiteral` to not register offenses for `String.new` when `Style/FrozenStringLiteralComment` is enabled. ([@dvandersluis][]) +* [#9771](https://github.com/rubocop/rubocop/issues/9771): Change `AllowDSLWriters` to true by default for `Style/TrivialAccessors`. ([@koic][]) +* [#9777](https://github.com/rubocop/rubocop/pull/9777): Fix an incorrect auto-correct for `Style/RedundantBegin` when using multi-line `if` in `begin` block. ([@koic][]) +* [#9791](https://github.com/rubocop/rubocop/pull/9791): Fix a false negative for `Layout/IndentationWidth` when using `ensure` in `do` ... `end` block. ([@koic][]) +* [#9766](https://github.com/rubocop/rubocop/pull/9766): Fix a clobbering error for `Style/ClassAndModuleChildren` cop with compact style. ([@tejasbubane][]) +* [#9767](https://github.com/rubocop/rubocop/issues/9767): Fix `Style/ClassAndModuleChildren` cop to preserve comments. ([@tejasbubane][]) +* [#9792](https://github.com/rubocop/rubocop/issues/9792): Fix false positive for `Lint/Void` cop with ranges. ([@tejasbubane][]) ### Changes -* Dropped `-s`/`--silent` option. Now `progress`/`simple`/`clang` formatters always report summary and `emacs`/`files` formatters no longer report. -* Dropped the `LineContinuation` cop. +* [#9770](https://github.com/rubocop/rubocop/issues/9770): Update `Lint/EmptyBlock` to handle procs the same way as lambdas. ([@dvandersluis][]) +* [#9776](https://github.com/rubocop/rubocop/pull/9776): Update `Style/NilLambda` to handle procs as well. ([@dvandersluis][]) +* [#9744](https://github.com/rubocop/rubocop/pull/9744): The parallel flag will now be automatically ignored when combined with `--cache false`. Previously, an error was raised and execution stopped. ([@rrosenblum][]) + +## 1.14.0 (2021-05-05) + +### New features + +* [#7669](https://github.com/rubocop/rubocop/issues/7669): New cop `Bundler/GemVersion` requires or forbids specifying gem versions. ([@timlkelly][]) +* [#9758](https://github.com/rubocop/rubocop/pull/9758): Support `TargetRubyVersion 3.1` (experimental). ([@koic][]) +* [#9733](https://github.com/rubocop/rubocop/issues/9733): Add cop `Layout/SingleLineBlockChain`. ([@jonas054][]) -### Bugs fixed +### Bug fixes + +* [#9751](https://github.com/rubocop/rubocop/pull/9751): `Style/StringLiterals` doesn't autocorrect global variable interpolation. ([@etiennebarrie][]) +* [#9731](https://github.com/rubocop/rubocop/issues/9731): Fix two autocorrection issues for `Style/NegatedIfElseCondition`. ([@dvandersluis][]) +* [#9740](https://github.com/rubocop/rubocop/pull/9740): Fix an incorrect auto-correct for `Style/SingleLineMethods` when defining setter method. ([@koic][]) +* [#9757](https://github.com/rubocop/rubocop/pull/9757): Fix a false positive for `Lint/NumberConversion` when `:to_f` is one of multiple method arguments. ([@koic][]) +* [#9761](https://github.com/rubocop/rubocop/issues/9761): Fix `Style/ClassAndModuleChildren` false negative for `compact` style when a class/module is partially nested. ([@dvandersluis][]) +* [#9748](https://github.com/rubocop/rubocop/pull/9748): Prevent infinite loops during symlink traversal. ([@Tonkpils][]) +* [#9762](https://github.com/rubocop/rubocop/issues/9762): Update `VariableForce` to be able to handle `case-match` nodes. ([@dvandersluis][]) +* [#9729](https://github.com/rubocop/rubocop/issues/9729): Fix an error for `Style/IfUnlessModifier` when variable assignment is used in the branch body of if modifier. ([@koic][]) +* [#9750](https://github.com/rubocop/rubocop/issues/9750): Fix an incorrect auto-correct for `Style/SoleNestedConditional` when using nested `if` within `unless foo == bar`. ([@koic][]) +* [#9751](https://github.com/rubocop/rubocop/pull/9751): `Style/StringLiterals` autocorrects `'\\'` into `"\\"`. ([@etiennebarrie][]) +* [#9732](https://github.com/rubocop/rubocop/pull/9732): Support deprecated Socket.gethostbyaddr and Socket.gethostbyname. ([@AndreiEres][]) +* [#9713](https://github.com/rubocop/rubocop/issues/9713): Fix autocorrection for block local variables in `Lint/UnusedBlockArgument`. ([@tejasbubane][]) +* [#9746](https://github.com/rubocop/rubocop/pull/9746): Fix a false positive for `Lint/UnreachableLoop` when using conditional `next` in a loop. ([@koic][]) + +## 1.13.0 (2021-04-20) + +### New features -* [#432](https://github.com/bbatsov/rubocop/issues/432): Fix false positive for constant assignments when rhs is a method call with block in `ConstantName`. -* [#434](https://github.com/bbatsov/rubocop/issues/434): Support classes and modules defined with `Class.new`/`Module.new` in `AccessControl`. -* Fix which ranges are highlighted in reports from IfUnlessModifier, WhileUntilModifier, and MethodAndVariableSnakeCase cop. -* [#438](https://github.com/bbatsov/rubocop/issues/438): Accept setting attribute on method argument in `UselessAssignment`. +* [#7977](https://github.com/rubocop/rubocop/issues/7977): Add `Layout/RedundantLineBreak` cop. ([@jonas054][]) +* [#9691](https://github.com/rubocop/rubocop/issues/9691): Add configuration parameter `InspectBlocks` to `Layout/RedundantLineBreak`. ([@jonas054][]) +* [#9684](https://github.com/rubocop/rubocop/issues/9684): Support `IgnoredMethods` option for `Lint/AmbiguousBlockAssociation`. ([@gprado][]) +* [#9358](https://github.com/rubocop/rubocop/pull/9358): Support `restrictive_version_specifiers` option in `Bundler/GemComment` cop. ([@RobinDaugherty][]) -## 0.11.1 (12/08/2013) +### Bug fixes + +* [#5576](https://github.com/rubocop/rubocop/issues/5576): Fix problem with inherited `Include` parameters. ([@jonas054][]) +* [#9690](https://github.com/rubocop/rubocop/pull/9690): Fix an incorrect auto-correct for `Style/IfUnlessModifier` when using a method with heredoc argument. ([@koic][]) +* [#9681](https://github.com/rubocop/rubocop/issues/9681): Fix an incorrect auto-correct for `Style/RedundantBegin` when using modifier `if` single statement in `begin` block. ([@koic][]) +* [#9698](https://github.com/rubocop/rubocop/issues/9698): Fix an error for `Style/StructInheritance` when extending instance of `Struct` without `do` ... `end` and class body is empty and single line definition. ([@koic][]) +* [#9700](https://github.com/rubocop/rubocop/issues/9700): Avoid warning about Ruby version mismatch. ([@marcandre][]) +* [#9636](https://github.com/rubocop/rubocop/issues/9636): Resolve symlinks when excluding directories. ([@ob-stripe][]) +* [#9707](https://github.com/rubocop/rubocop/issues/9707): Fix false positive for `Style/MethodCallWithArgsParentheses` with `omit_parentheses` style on an endless `defs` node. ([@dvandersluis][]) +* [#9689](https://github.com/rubocop/rubocop/issues/9689): Treat parens around array items the same for children and deeper descendants. ([@dvandersluis][]) +* [#9676](https://github.com/rubocop/rubocop/issues/9676): Fix an error for `Style/StringChars` when using `split` without parentheses. ([@koic][]) +* [#9712](https://github.com/rubocop/rubocop/pull/9712): Fix an incorrect auto-correct for `Style/HashConversion` when `Hash[]` as a method argument without parentheses. ([@koic][]) +* [#9704](https://github.com/rubocop/rubocop/pull/9704): Fix an incorrect auto-correct for `Style/SingleLineMethods` when single line method call without parentheses. ([@koic][]) +* [#9683](https://github.com/rubocop/rubocop/issues/9683): Fix an incorrect auto-correct for `Style/HashConversion` when using `zip` method without argument in `Hash[]`. ([@koic][]) +* [#9715](https://github.com/rubocop/rubocop/pull/9715): Fix an incorrect auto-correct for `EnforcedStyle: require_parentheses` of `Style/MethodCallWithArgsParentheses` with `Style/RescueModifier`. ([@koic][]) ### Changes -* [#425](https://github.com/bbatsov/rubocop/issues/425): `ColonMethodCalls` now allows constructor methods (like `Nokogiri::HTML()` to be called with double colon. +* [#7544](https://github.com/rubocop/rubocop/pull/7544): Add --no-parallel (-P/--parallel cannot be combined with --auto-correct). ([@kwerle][]) +* [#9648](https://github.com/rubocop/rubocop/pull/9648): **(Compatibility)** Drop support for Ruby 2.4. ([@koic][]) +* [#9647](https://github.com/rubocop/rubocop/pull/9647): The parallel flag will now be automatically ignored when combined with `--auto-correct`, `--auto-gen-config`, or `-F/--fail-fast`. Previously, an error was raised and execution stopped. ([@rrosenblum][]) + +## 1.12.1 (2021-04-04) + +### Bug fixes + +* [#9649](https://github.com/rubocop/rubocop/pull/9649): Fix when highlights contain multibyte characters. ([@osyo-manga][]) +* [#9646](https://github.com/rubocop/rubocop/pull/9646): Fix an incorrect auto-correct for `EnforcedStyle: require_parentheses` of `Style/MethodCallWithArgsParentheses` with `EnforcedStyle: conditionals` of `Style/AndOr`. ([@koic][]) +* [#9608](https://github.com/rubocop/rubocop/issues/9608): Fix a false positive for `Layout/EmptyLineAfterGuardClause` when using guard clause is after `rubocop:enable` comment. ([@koic][]) +* [#9637](https://github.com/rubocop/rubocop/issues/9637): Allow parentheses for forwarded args in `Style/MethodCallWithArgsParentheses`'s `omit_parentheses` style to avoid endless range ambiguity. ([@gsamokovarov][]) +* [#9641](https://github.com/rubocop/rubocop/issues/9641): Fix `Layout/MultilineMethodCallIndentation` triggering on method calls that look like operators. ([@dvandersluis][]) +* [#9638](https://github.com/rubocop/rubocop/pull/9638): Fix an error for `Layout/LineLength` when over limit at right hand side of multiple assignment. ([@koic][]) +* [#9639](https://github.com/rubocop/rubocop/pull/9639): Fix `Style/RedundantBegin` removing comments on assignment statement correction. ([@marcotc][]) +* [#9671](https://github.com/rubocop/rubocop/pull/9671): Fix an incorrect auto-correct for `Lint/AmbiguousOperator` with `Style/MethodCallWithArgsParentheses`. ([@koic][]) +* [#9645](https://github.com/rubocop/rubocop/pull/9645): Fix an incorrect auto-correct for `Style/SingleLineMethods` when using single line class method definition. ([@koic][]) +* [#9644](https://github.com/rubocop/rubocop/pull/9644): Fix an error and an incorrect auto-correct for `Style/MultilineMethodSignature` when line break after opening parenthesis. ([@koic][]) +* [#9672](https://github.com/rubocop/rubocop/issues/9672): Fix an incorrect auto-correct for `Style/HashConversion` when using multi-argument `Hash[]` as a method argument. ([@koic][]) + +## 1.12.0 (2021-03-24) + +### New features + +* [#9615](https://github.com/rubocop/rubocop/pull/9615): Add new `Style/StringChars` cop. ([@koic][]) +* [#9629](https://github.com/rubocop/rubocop/issues/9629): Add `AllowParenthesesInStringInterpolation` configuration to `Style/MethodCallWithArgsParentheses` to allow parenthesized calls in string interpolation. ([@gsamokovarov][]) +* [#9219](https://github.com/rubocop/rubocop/pull/9219): Allow excluding some constants from `Style/Documentation`. ([@fsateler][]) +* Add `AllowNil` option for `Lint/SuppressedException` to allow/disallow `rescue nil`. ([@corroded][]) + +### Bug fixes -### Bugs fixed +* [#9560](https://github.com/rubocop/rubocop/pull/9560): Fix an error for `Style/ClassMethodsDefinitions` when defining class methods with `class << self` with comment only body. ([@koic][]) +* [#9551](https://github.com/rubocop/rubocop/issues/9551): Fix a false positive for `Style/UnlessLogicalOperators` when using `||` operator and invoked method name includes "or" in the conditional branch. ([@koic][]) +* [#9620](https://github.com/rubocop/rubocop/pull/9620): Allow parentheses in operator methods calls for `Style/MethodCallWithArgsParentheses` `EnforcedStyle: omit_parentheses`. ([@gsamokovarov][]) +* [#9622](https://github.com/rubocop/rubocop/issues/9622): Fixed `Style/BisectedAttrAccessor` autocorrection to handle multiple bisected attrs in the same macro. ([@dvandersluis][]) +* [#9606](https://github.com/rubocop/rubocop/issues/9606): Fix an error for `Layout/IndentationConsistency` when using access modifier at the top level. ([@koic][]) +* [#9619](https://github.com/rubocop/rubocop/pull/9619): Fix infinite loop between `Layout/IndentationWidth` and `Layout/RescueEnsureAlignment` autocorrection. ([@dvandersluis][]) +* [#9633](https://github.com/rubocop/rubocop/pull/9633): Fix an incorrect auto-correct for `Lint/NumberConversion` when `to_i` method in symbol form. ([@koic][]) +* [#9616](https://github.com/rubocop/rubocop/pull/9616): Fix an incorrect auto-correct for `Style/EvalWithLocation` when using `#instance_eval` with a string argument in parentheses. ([@koic][]) +* [#9429](https://github.com/rubocop/rubocop/issues/9429): Fix `Style/NegatedIfElseCondition` autocorrect to keep comments in correct branch. ([@tejasbubane][]) +* [#9631](https://github.com/rubocop/rubocop/issues/9631): Fix an incorrect auto-correct for `Style/RedundantReturn` when using `return` with splat argument. ([@koic][]) +* [#9627](https://github.com/rubocop/rubocop/issues/9627): Fix an incorrect auto-correct for `Style/StructInheritance` when extending instance of Struct without `do` ... `end` and class body is empty. ([@koic][]) +* [#5953](https://github.com/rubocop/rubocop/issues/5953): Fix a false positive for `Style/AccessModifierDeclarations` when using `module_function` with symbol. ([@koic][]) +* [#9593](https://github.com/rubocop/rubocop/issues/9593): Fix an error when processing a directory is named `{}`. ([@koic][]) +* [#9599](https://github.com/rubocop/rubocop/issues/9599): Fix an error for `Style/CaseLikeIf` when using `include?` without a receiver. ([@koic][]) +* [#9582](https://github.com/rubocop/rubocop/issues/9582): Fix incorrect auto-correct for `Style/ClassEqualityComparison` when comparing `Module#name` for equality. ([@koic][]) +* [#9603](https://github.com/rubocop/rubocop/issues/9603): Fix a false positive for `Style/SoleNestedConditional` when using nested modifier on value assigned in condition. ([@koic][]) +* [#9598](https://github.com/rubocop/rubocop/pull/9598): Fix RuboCop::MagicComment#valid_shareable_constant_value?. ([@kachick][]) +* [#9625](https://github.com/rubocop/rubocop/pull/9625): Allow parentheses in yield arguments with `Style/MethodCallWithArgsParentheses` `EnforcedStyle: omit_parentheses` to fix invalid Ruby auto-correction. ([@gsamokovarov][]) +* [#9558](https://github.com/rubocop/rubocop/issues/9558): Fix inconsistency when dealing with URIs that are wrapped in single quotes vs double quotes. ([@dvandersluis][]) +* [#9613](https://github.com/rubocop/rubocop/issues/9613): Fix a false positive for `Style/RedundantSelf` when a self receiver on an lvalue of mlhs arguments. ([@koic][]) +* [#9586](https://github.com/rubocop/rubocop/issues/9586): Update `Naming/RescuedExceptionsVariableName` to not register on inner rescues when nested. ([@dvandersluis][]) -* [#427](https://github.com/bbatsov/rubocop/issues/427): FavorUnlessOverNegatedIf triggered when using elsifs. -* [#429](https://github.com/bbatsov/rubocop/issues/429): Fix `LeadingCommentSpace` offence reporting. -* Fixed `AsciiComments` offence reporting. -* Fixed `BlockComments` offence reporting. +### Changes + +* [#9487](https://github.com/rubocop/rubocop/issues/9487): Mark `Naming/MemoizedInstanceVariableName` as unsafe. ([@marcandre][]) +* [#9601](https://github.com/rubocop/rubocop/issues/9601): Make `Style/RedundantBegin` aware of redundant `begin`/`end` blocks around memoization. ([@koic][]) +* [#9617](https://github.com/rubocop/rubocop/issues/9617): Disable suggested extensions when using the `--stdin` option. ([@dvandersluis][]) -## 0.11.0 (09/08/2013) +## 1.11.0 (2021-03-01) ### New features -* [#421](https://github.com/bbatsov/rubocop/issues/421): `TrivialAccessors` now ignores methods on user-configurable whitelist (such as `to_s` and `to_hash`). -* [#369](https://github.com/bbatsov/rubocop/issues/369): New option `--auto-gen-config` outputs RuboCop configuration that disables all cops that detect any offences. -* The list of annotation keywords recognized by the `CommentAnnotation` cop is now configurable. -* Configuration file names are printed as they are loaded in `--debug` mode. -* Auto-correct support added in `AlignParameters` cop. -* New cop `UselessComparison` checks for comparisons of the same arguments. -* New cop `UselessAssignment` checks for useless assignments to local variables. -* New cop `SignalException` checks for proper usage of `fail` and `raise`. -* New cop `ModuleFunction` checks for usage of `extend self` in modules. +* [#5388](https://github.com/rubocop/rubocop/issues/5388): Add new `Style/UnlessLogicalOperators` cop. ([@caalberts][]) +* [#9525](https://github.com/rubocop/rubocop/issues/9525): Add `AllowMethodsWithArguments` option to `Style/SymbolProc`. ([@koic][]) + +### Bug fixes + +* [#9520](https://github.com/rubocop/rubocop/issues/9520): Fix an incorrect auto-correct for `Style/MultipleComparison` when comparing a variable with multiple items in `if` and `elsif` conditions. ([@koic][]) +* [#9548](https://github.com/rubocop/rubocop/pull/9548): Fix a false positive for `Style/TrailingBodyOnMethodDefinition` when endless method definition body is after newline in opening parenthesis. ([@koic][]) +* [#9541](https://github.com/rubocop/rubocop/issues/9541): Fix `Style/HashConversion` when the correction needs to be wrapped in parens. ([@dvandersluis][]) +* [#9533](https://github.com/rubocop/rubocop/issues/9533): Make metrics length cops aware of multi-line kwargs. ([@koic][]) +* [#9523](https://github.com/rubocop/rubocop/issues/9523): Fix an error for `Style/TrailingMethodEndStatement` when endless method definition signature and body are on different lines. ([@koic][]) +* [#9482](https://github.com/rubocop/rubocop/issues/9482): Return minimal known ruby version from gemspecs `required_ruby_version`. ([@HeroProtagonist][]) +* [#9539](https://github.com/rubocop/rubocop/issues/9539): Fix an error for `Style/RedundantBegin` when using body of `begin` is empty. ([@koic][]) +* [#9542](https://github.com/rubocop/rubocop/pull/9542): Fix `Layout/FirstArgumentIndentation` for operator methods not called as operators. ([@dvandersluis][], [@TSMMark][]) -### Bugs fixed +### Changes -* [#374](https://github.com/bbatsov/rubocop/issues/374): Fixed error at post condition loop (`begin-end-while`, `begin-end-until`) in `UnusedLocalVariable` and `ShadowingOuterLocalVariable`. -* [#373](https://github.com/bbatsov/rubocop/issues/373) and [#376](https://github.com/bbatsov/rubocop/issues/376): Allow braces around multi-line blocks if `do`-`end` would change the meaning of the code. -* `RedundantSelf` now allows `self.` followed by any ruby keyword. -* [#391](https://github.com/bbatsov/rubocop/issues/391): Fix bug in counting slashes in a regexp. -* [#394](https://github.com/bbatsov/rubocop/issues/394): `DotPosition` cop handles correctly code like `l.(1)`. -* [#390](https://github.com/bbatsov/rubocop/issues/390): `CommentAnnotation` cop allows keywords (e.g. Review, Optimize) if they just begin a sentence. -* [#400](https://github.com/bbatsov/rubocop/issues/400): Fix bug concerning nested defs in `EmptyLineBetweenDefs` cop. -* [#399](https://github.com/bbatsov/rubocop/issues/399): Allow assignment inside blocks in `AssignmentInCondition` cop. -* Fix bug in favor_modifier.rb regarding missed offences after else etc. -* [#393](https://github.com/bbatsov/rubocop/issues/393): Retract support for multiline chaining of blocks (which fixed [#346](https://github.com/bbatsov/rubocop/issues/346)), thus rejecting issue 346. -* [#389](https://github.com/bbatsov/rubocop/issues/389): Ignore symbols that are arguments to Module#private_constant in `SymbolName` cop. -* [#387](https://github.com/bbatsov/rubocop/issues/387): Do autocorrect in `AndOr` cop only if it does not change the meaning of the code. -* [#398](https://github.com/bbatsov/rubocop/issues/398): Don't display blank lines in the output of the clang formatter. -* [#283](https://github.com/bbatsov/rubocop/issues/283): Refine `StringLiterals` string content check. +* [#9526](https://github.com/rubocop/rubocop/issues/9526): Add `AllowSplatArgument` option to `Style/HashConversion` and the option is true by default. ([@koic][]) -## 0.10.0 (17/07/2013) +## 1.10.0 (2021-02-15) ### New features -* New cop `RedundantReturn` tracks redundant `return`s in method bodies. -* New cop `RedundantBegin` tracks redundant `begin` blocks in method definitions. -* New cop `RedundantSelf` tracks redundant uses of `self`. -* New cop `EmptyEnsure` tracks empty `ensure` blocks. -* New cop `CommentAnnotation` tracks formatting of annotation comments such as TODO. -* Added custom rake task. -* New formatter `FileListFormatter` outputs just a list of files with offences in them (related to [#357](https://github.com/bbatsov/rubocop/issues/357)). +* [#9478](https://github.com/rubocop/rubocop/pull/9478): Add new `Style/HashConversion` cop. ([@zverok][]) +* [#9496](https://github.com/rubocop/rubocop/pull/9496): Add new `Gemspec/DateAssignment` cop. ([@koic][]) +* [#8724](https://github.com/rubocop/rubocop/issues/8724): Add `IgnoreModules` configuration to `Style/ConstantVisibility` to not register offense for module definitions. ([@tejasbubane][]) +* [#9403](https://github.com/rubocop/rubocop/issues/9403): Add autocorrect for `Style/EvalWithLocation` cop. ([@cteece][]) + +### Bug fixes + +* [#9500](https://github.com/rubocop/rubocop/issues/9500): Update `Lint/Debugger` so that only specific receivers for debug methods lead to offenses. ([@dvandersluis][]) +* [#9499](https://github.com/rubocop/rubocop/issues/9499): Fix a false positive for `Layout/SpaceBeforeBrackets` when multiple spaces are inserted inside the left bracket. ([@koic][]) +* [#9507](https://github.com/rubocop/rubocop/issues/9507): Fix an incorrect auto-correct for `Lint/RedundantSplatExpansion` when expanding `Array.new` call on method argument. ([@koic][]) +* [#9490](https://github.com/rubocop/rubocop/issues/9490): Fix incorrect auto-correct for `Layout/FirstArgumentIndentation` when specifying `EnforcedStyle: with_fixed_indentation` of `Layout/ArgumentAlignment` and `EnforcedStyle: consistent` of `Layout/FirstArgumentIndentation`. ([@koic][]) +* [#9497](https://github.com/rubocop/rubocop/issues/9497): Fix an error for `Style/ExplicitBlockArgument` when `yield` is inside block of `super`. ([@koic][]) +* [#9349](https://github.com/rubocop/rubocop/issues/9349): Fix a false positive for `Lint/MultipleComparison` when using `&`, `|`, and `^` set operation operators in multiple comparison. ([@koic][]) +* [#9511](https://github.com/rubocop/rubocop/pull/9511): Fix a false negative for `Lint/ElseLayout` when using multiple `elsif`s. ([@koic][]) +* [#9513](https://github.com/rubocop/rubocop/issues/9513): Fix an incorrect auto-correct for `Style/HashConversion` when using hash argument `Hash[]`. ([@koic][]) +* [#9492](https://github.com/rubocop/rubocop/issues/9492): Fix an incorrect auto-correct for `Lint/DeprecatedOpenSSLConstant` when using no argument algorithm. ([@koic][]) ### Changes -* `TrivialAccessors` now has an `ExactNameMatch` config option (related to [#308](https://github.com/bbatsov/rubocop/issues/308)). -* `TrivialAccessors` now has an `ExcludePredicates` config option (related to [#326](https://github.com/bbatsov/rubocop/issues/326)). -* Cops don't inherit from `Parser::AST::Rewriter` anymore. All 3rd party Cops should remove the call to `super` in their callbacks. If you implement your own processing you need to define the `#investigate` method instead of `#inspect`. Refer to the documentation of `Cop::Commissioner` and `Cop::Cop` classes for more information. -* `EndAlignment` cop split into `EndAlignment` and `BlockAlignment` cops. +* [#9405](https://github.com/rubocop/rubocop/pull/9405): Improve documentation for `Style/EvalWithLocation` cop. ([@taichi-ishitani][]) + +## 1.9.1 (2021-02-01) + +### New features + +* [#9459](https://github.com/rubocop/rubocop/issues/9459): Add `AllowedMethods` option to `Style/IfWithBooleanLiteralBranches` and set `nonzero?` as default value. ([@koic][]) -### Bugs fixed +### Bug fixes -* [#288](https://github.com/bbatsov/rubocop/issues/288): Work with absolute Excludes paths internally (2nd fix for this issue). -* `TrivialAccessors` now detects class attributes as well as instance attributes. -* [#338](https://github.com/bbatsov/rubocop/issues/338): Fix end alignment of blocks in chained assignments. -* [#345](https://github.com/bbatsov/rubocop/issues/345): Add `$SAFE` to the list of built-in global variables. -* [#340](https://github.com/bbatsov/rubocop/issues/340): Override config parameters rather than merging them. -* [#349](https://github.com/bbatsov/rubocop/issues/349): Fix false positive for `CharacterLiteral` (`%w(?)`). -* [#346](https://github.com/bbatsov/rubocop/issues/346): Support method chains for block end alignment checks. -* [#350](https://github.com/bbatsov/rubocop/issues/350): Support line breaks between variables on left hand side for block end alignment checks. -* [#356](https://github.com/bbatsov/rubocop/issues/356): Allow safe assignment in `ParenthesesAroundCondition`. +* [#9431](https://github.com/rubocop/rubocop/issues/9431): Fix an error for `Style/DisableCopsWithinSourceCodeDirective` when using leading source comment. ([@koic][]) +* [#9444](https://github.com/rubocop/rubocop/issues/9444): Fix error on colorization for offenses with `Severity: info`. ([@tejasbubane][]) +* [#9448](https://github.com/rubocop/rubocop/issues/9448): Fix an error for `Style/SoleNestedConditional` when using nested `unless` modifier with a single expression condition. ([@koic][]) +* [#9449](https://github.com/rubocop/rubocop/issues/9449): Fix an error for `Style/NilComparison` when using `x == nil` as a guard condition'. ([@koic][]) +* [#9440](https://github.com/rubocop/rubocop/issues/9440): Fix `Lint/SymbolConversion` for implicit `to_sym` without a receiver. ([@dvandersluis][]) +* [#9453](https://github.com/rubocop/rubocop/issues/9453): Fix infinite loop error for `Layout/FirstParameterIndentation` when `EnforcedStyle: with_fixed_indentation` is specified for `Layout/ArgumentAlignment`. ([@koic][]) +* [#9466](https://github.com/rubocop/rubocop/issues/9466): Don't correct `Style/SingleLineMethods` using endless methods if the target ruby is < 3.0. ([@dvandersluis][]) +* [#9455](https://github.com/rubocop/rubocop/issues/9455): Fix a false positive for `Lint/SymbolConversion` when hash keys that contain `":"`. ([@koic][]) +* [#9454](https://github.com/rubocop/rubocop/issues/9454): Fix an incorrect auto-correct for `Style/IfWithBooleanLiteralBranches` when using `elsif do_something?` with boolean literal branches. ([@koic][]) +* [#9438](https://github.com/rubocop/rubocop/issues/9438): Fix a false positive for `Layout/SpaceBeforeBrackets` when space is used in left bracket. ([@koic][]) +* [#9457](https://github.com/rubocop/rubocop/issues/9457): Fix a false positive for `Lint/SymbolConversion` when hash keys that end with `=`. ([@koic][]) +* [#9473](https://github.com/rubocop/rubocop/issues/9473): Fix an error for `Lint/DeprecatedConstants` when using `__ENCODING__`. ([@koic][]) +* [#9452](https://github.com/rubocop/rubocop/pull/9452): Fix `StyleGuideBaseURL` not functioning with nested departments. ([@tas50][]) +* [#9465](https://github.com/rubocop/rubocop/issues/9465): Update `Metrics/ParameterLists` to be able to write `MaxOptionalParameters` in rubocop_todo.yml. ([@dvandersluis][]) +* [#9433](https://github.com/rubocop/rubocop/issues/9433): Fix an error for `Style/EvalWithLocation` when using eval with block argument. ([@koic][]) -### Misc +### Changes -* Improved performance on Ruby 1.9 by about 20%. -* Improved overall performance by about 35%. +* [#9437](https://github.com/rubocop/rubocop/issues/9437): Improve offense message when there is an allowed range of empty lines. ([@dvandersluis][]) +* [#9476](https://github.com/rubocop/rubocop/pull/9476): Mark `Style/IfWithBooleanLiteralBranches` as unsafe auto-correction. ([@koic][]) -## 0.9.1 (05/07/2013) +## 1.9.0 (2021-01-28) ### New features -* Added `-l/--lint` option to allow doing only linting with no style checks (similar to running `ruby -wc`). +* [#9396](https://github.com/rubocop/rubocop/pull/9396): Add new `Style/IfWithBooleanLiteralBranches` cop. ([@koic][]) +* [#9402](https://github.com/rubocop/rubocop/pull/9402): Add new `Lint/TripleQuotes` cop. ([@dvandersluis][]) +* [#7827](https://github.com/rubocop/rubocop/pull/7827): Add pre-commit hook. ([@jdufresne][], [@adithyabsk][]) +* [#7452](https://github.com/rubocop/rubocop/issues/7452): Support `IgnoredMethods` option for `Style/FormatStringToken`. ([@koic][]) +* [#9340](https://github.com/rubocop/rubocop/pull/9340): Added `info` Severity level to allow offenses to be listed but not return a non-zero error code. ([@dvandersluis][]) +* [#9353](https://github.com/rubocop/rubocop/issues/9353): Add new `Lint/SymbolConversion` cop. ([@dvandersluis][]) +* [#9363](https://github.com/rubocop/rubocop/pull/9363): Add new cop `Lint/OrAssignmentToConstant`. ([@uplus][]) +* [#9326](https://github.com/rubocop/rubocop/pull/9326): Add new `Lint/NumberedParameterAssignment` cop. ([@koic][]) + +### Bug fixes + +* [#9366](https://github.com/rubocop/rubocop/issues/9366): Fix an incorrect auto-correct for `Style/SoleNestedConditional` when using method arguments without parentheses for outer condition. ([@koic][]) +* [#9372](https://github.com/rubocop/rubocop/issues/9372): Fix an error for `Style/IfInsideElse` when nested `if` branch code is empty. ([@koic][]) +* [#9374](https://github.com/rubocop/rubocop/issues/9374): Fix autocorrection for `Layout/LineLength` when the first argument to a send node is a overly long hash pair. ([@dvandersluis][]) +* [#9387](https://github.com/rubocop/rubocop/issues/9387): Fix incorrect auto-correct for `Style/NilComparison` when using `!x.nil?` and `EnforcedStyle: comparison`. ([@koic][]) +* [#9411](https://github.com/rubocop/rubocop/pull/9411): Fix false negatives for `Style/EvalWithLocation` for `Kernel.eval` and when given improper arguments. ([@dvandersluis][]) +* [#7766](https://github.com/rubocop/rubocop/issues/7766): Fix `Naming/RescuedExceptionsVariableName` autocorrection when the rescue body returns the exception variable. ([@asterite][]) +* [#7766](https://github.com/rubocop/rubocop/issues/7766): Fix `Naming/RescuedExceptionsVariableName` autocorrection to not change variables if the exception variable has been reassigned. ([@dvandersluis][]) +* [#9389](https://github.com/rubocop/rubocop/pull/9389): Fix an infinite loop error for `IncludeSemanticChanges: false` of `Style/NonNilCheck` with `EnforcedStyle: comparison` of `Style/NilComparison`. ([@koic][]) +* [#9384](https://github.com/rubocop/rubocop/pull/9384): Fix a suggestion message when not auto-correctable. ([@koic][]) +* [#9424](https://github.com/rubocop/rubocop/pull/9424): Fix an incorrect auto-correct for `Style/ClassMethodsDefinitions` when defining class methods with `class << self` and there is no blank line between method definition and attribute accessor. ([@koic][]) +* [#9370](https://github.com/rubocop/rubocop/issues/9370): Fix an incorrect auto-correct for `Style/SoleNestedConditional` when using nested `unless` modifier multiple conditional. ([@koic][]) +* [#9406](https://github.com/rubocop/rubocop/pull/9406): Fix rubocop_todo link injection when YAML doc start sigil exists. ([@dduugg][]) +* [#9229](https://github.com/rubocop/rubocop/pull/9229): Fix errors being reported with `rubocop -V` with an invalid config. ([@dvandersluis][]) +* [#9425](https://github.com/rubocop/rubocop/issues/9425): Fix error in `Layout/ClassStructure` when initializer comes after private attribute macro. ([@tejasbubane][]) ### Changes -* Removed the `BlockAlignSchema` configuration option from `EndAlignment`. We now support only the default alignment schema - `StartOfAssignment`. -* Made the preferred collection methods in `CollectionMethods` configurable. -* Made the `DotPosition` cop configurable - now both `leading` and `trailing` styles are supported. +* [#9415](https://github.com/rubocop/rubocop/issues/9415): Change `Layout/ClassStructure` to detect inline modifiers. ([@AndreiEres][]) +* [#9380](https://github.com/rubocop/rubocop/issues/9380): Mark `Style/FloatDivision` as unsafe. ([@koic][]) +* [#9345](https://github.com/rubocop/rubocop/issues/9345): Make `Style/AsciiComments` allow copyright notice by default. ([@koic][]) +* [#9399](https://github.com/rubocop/rubocop/issues/9399): Added `AllowedCops` configuration to `Style/DisableCopsWithinSourceCodeDirective`. ([@dvandersluis][]) +* [#9327](https://github.com/rubocop/rubocop/issues/9327): Change `Layout/EmptyLineAfterMagicComment` to accept top-level `shareable_constant_values` directive. ([@tejasbubane][]) +* [#7902](https://github.com/rubocop/rubocop/issues/7902): Change `Lint/NumberConversion` to detect symbol form of conversion methods. ([@tejasbubane][]) -### Bugs fixed +## 1.8.1 (2021-01-11) + +### Bug fixes -* [#318](https://github.com/bbatsov/rubocop/issues/318): Correct some special cases of block end alignment. -* [#317](https://github.com/bbatsov/rubocop/issues/317): Fix a false positive in `LiteralInCondition`. -* [#321](https://github.com/bbatsov/rubocop/issues/321): Ignore variables whose name start with `_` in `ShadowingOuterLocalVariable`. -* [#322](https://github.com/bbatsov/rubocop/issues/322): Fix exception of `UnusedLocalVariable` and `ShadowingOuterLocalVariable` when inspecting keyword splat argument. -* [#316](https://github.com/bbatsov/rubocop/issues/316): Correct nested postfix unless in `MultilineIfThen`. -* [#327](https://github.com/bbatsov/rubocop/issues/327): Fix false offences for block expression that span on two lines in `EndAlignment`. -* [#332](https://github.com/bbatsov/rubocop/issues/332): Fix exception of `UnusedLocalVariable` and `ShadowingOuterLocalVariable` when inspecting named captures. -* [#333](https://github.com/bbatsov/rubocop/issues/333): Fix a case that `EnsureReturn` throws an exception when ensure has no body. +* [#9342](https://github.com/rubocop/rubocop/issues/9342): Fix an error for `Lint/RedundantDirGlobSort` when using `collection.sort`. ([@koic][]) +* [#9304](https://github.com/rubocop/rubocop/issues/9304): Do not register an offense for `Style/ExplicitBlockArgument` when the `yield` arguments are not an exact match with the block arguments. ([@dvandersluis][]) +* [#8281](https://github.com/rubocop/rubocop/issues/8281): Fix `Style/WhileUntilModifier` handling comments and assignment when correcting to modifier form. ([@Darhazer][]) +* [#8229](https://github.com/rubocop/rubocop/issues/8229): Fix faulty calculation in UncommunicativeName. ([@ohbarye][]) +* [#9350](https://github.com/rubocop/rubocop/pull/9350): Wrap in parens before replacing `unless` with `if` and `!`. ([@magneland][]) +* [#9356](https://github.com/rubocop/rubocop/pull/9356): Fix duplicate extension cop versions when using `rubocop -V`. ([@koic][]) +* [#9355](https://github.com/rubocop/rubocop/issues/9355): Fix `Style/SingleLineMethods` autocorrection to endless method when the original code had parens. ([@dvandersluis][]) +* [#9346](https://github.com/rubocop/rubocop/pull/9346): Fix an incorrect auto-correct for `Style/StringConcatenation` when concat string include double quotes and interpolation. ([@k-karen][]) -## 0.9.0 (01/07/2013) +## 1.8.0 (2021-01-07) ### New features -* Introduced formatter feature, enables custom formatted output and multiple outputs. -* Added progress formatter and now it's the default. (`--format progress`). -* Added JSON formatter. (`--format json`). -* Added clang style formatter showing the offending source. code. (`--format clang`). The `clang` formatter marks a whole range rather than just the starting position, to indicate more clearly where the problem is. -* Added `-f`/`--format` option to specify formatter. -* Added `-o`/`--out` option to specify output file for each formatter. -* Added `-r/--require` option to inject external Ruby code into RuboCop. -* Added `-V/--verbose-version` option that displays Parser version and Ruby version as well. -* Added `-R/--rails` option that enables extra Rails-specific cops. -* Added support for auto-correction of some offences with `-a`/`--auto-correct`. -* New cop `CaseEquality` checks for explicit use of `===`. -* New cop `AssignmentInCondition` checks for assignment in conditions. -* New cop `EndAlignment` tracks misaligned `end` keywords. -* New cop `Void` tracks uses of literals/variables/operators in possibly void context. -* New cop `Documentation` checks for top level class/module doc comments. -* New cop `UnreachableCode` tracks unreachable code segments. -* New cop `MethodCallParentheses` tracks unwanted braces in method calls. -* New cop `UnusedLocalVariable` tracks unused local variables for each scope. -* New cop `ShadowingOuterLocalVariable` tracks use of the same name as outer local variables for block arguments or block local variables. -* New cop `WhileUntilDo` tracks uses of `do` with multi-line `while/until`. -* New cop `CharacterLiteral` tracks uses of character literals (`?x`). -* New cop `EndInMethod` tracks uses of `END` in method definitions. -* New cop `LiteralInCondition` tracks uses of literals in the conditions of `if/while/until`. -* New cop `BeginBlock` tracks uses of `BEGIN` blocks. -* New cop `EndBlock` tracks uses of `END` blocks. -* New cop `DotPosition` tracks the dot position in multi-line method calls. -* New cop `Attr` tracks uses of `Module#attr`. -* Add support for auto-correction of some offences with `-a`/`--auto-correct`. +* [#9324](https://github.com/rubocop/rubocop/pull/9324): Add new `Lint/DeprecatedConstants` cop. ([@koic][]) +* [#9319](https://github.com/rubocop/rubocop/pull/9319): Support asdf's .tool-versions file. ([@noon-ng][]) +* [#9301](https://github.com/rubocop/rubocop/pull/9301): Add new `Lint/RedundantDirGlobSort` cop. ([@koic][]) +* [#9281](https://github.com/rubocop/rubocop/pull/9281): Add new cop `Style/EndlessMethod`. ([@dvandersluis][]) +* [#9321](https://github.com/rubocop/rubocop/pull/9321): Add new `Lint/LambdaWithoutLiteralBlock` cop. ([@koic][]) + +### Bug fixes + +* [#9298](https://github.com/rubocop/rubocop/issues/9298): Fix an incorrect auto-correct for `Lint/RedundantCopDisableDirective` when there is a blank line before inline comment. ([@koic][]) +* [#9233](https://github.com/rubocop/rubocop/issues/9233): Fix `Style/SoleNestedConditional` copying non-relevant comments during auto-correction. ([@Darhazer][]) +* [#9312](https://github.com/rubocop/rubocop/issues/9312): Fix `Layout/FirstHashElementLineBreak` to apply to multi-line hashes with only a single element. ([@muirdm][]) +* [#9316](https://github.com/rubocop/rubocop/issues/9316): Fix `Style/EmptyLiteral` registering wrong offense when using a numbered block for Hash.new, i.e. `Hash.new { _1[_2] = [] }`. ([@agargiulo][]) +* [#9308](https://github.com/rubocop/rubocop/issues/9308): Fix an error for `Layout/EmptyLineBetweenDefs` when using endless class method. ([@koic][]) +* [#9314](https://github.com/rubocop/rubocop/issues/9314): Fix an incorrect auto-correct for `Style/RedundantReturn` when multiple return values have a parenthesized return value. ([@koic][]) +* [#9335](https://github.com/rubocop/rubocop/issues/9335): Fix an incorrect auto-correct for `EnforcedStyle: require_parentheses` of `Style/MethodCallWithArgsParentheses` with `Style/NestedParenthesizedCalls`. ([@koic][]) +* [#9290](https://github.com/rubocop/rubocop/issues/9290): Fix a false positive for `Layout/SpaceBeforeBrackets` when using array literal method argument. ([@koic][]) +* [#9333](https://github.com/rubocop/rubocop/issues/9333): Fix an error for `Style/IfInsideElse` when using a modifier `if` nested inside an `else` after `elsif`. ([@koic][]) +* [#9303](https://github.com/rubocop/rubocop/issues/9303): Fix an incorrect auto-correct for `Style/RaiseArgs` with `EnforcedStyle: compact` when using exception instantiation argument. ([@koic][]) ### Changes -* Deprecated `-e`/`--emacs` option. (Use `--format emacs` instead). -* Made `progress` formatter the default. -* Most formatters (`progress`, `simple` and `clang`) now print relative file paths if the paths are under the current working directory. -* Migrate all cops to new namespaces. `Rubocop::Cop::Lint` is for cops that emit warnings. `Rubocop::Cop::Style` is for cops that do not belong in other namespaces. -* Merge `FavorPercentR` and `PercentR` into one cop called `RegexpLiteral`, and add configuration parameter `MaxSlashes`. -* Add `CountKeywordArgs` configuration option to `ParameterLists` cop. +* [#9300](https://github.com/rubocop/rubocop/pull/9300): Make `Lint/NonDeterministicRequireOrder` not to register offense when using Ruby 3.0 or higher. ([@koic][]) +* [#9320](https://github.com/rubocop/rubocop/pull/9320): Support unicode-display_width v2. ([@dduugg][]) +* [#9288](https://github.com/rubocop/rubocop/pull/9288): Require Parser 3.0.0.0 or higher. ([@koic][]) +* [#9337](https://github.com/rubocop/rubocop/issues/9337): Add `AllowedIdentifiers` to `Naming/VariableName`. ([@dvandersluis][]) +* [#9295](https://github.com/rubocop/rubocop/pull/9295): Update `Style/SingleLineMethods` to correct to an endless method definition if they are allowed. ([@dvandersluis][]) +* [#9331](https://github.com/rubocop/rubocop/pull/9331): Mark `Style/MutableConstant` as unsafe. ([@koic][]) + +## 1.7.0 (2020-12-25) -### Bugs fixed +### New features + +* [#9260](https://github.com/rubocop/rubocop/pull/9260): Support auto-correction for `Style/MultilineMethodSignature`. ([@koic][]) +* [#9282](https://github.com/rubocop/rubocop/pull/9282): Make `Style/RedundantFreeze` and `Style/MutableConstant` cops aware of frozen regexp and range literals when using Ruby 3.0. ([@koic][]) +* [#9223](https://github.com/rubocop/rubocop/issues/9223): Add new `Lint/AmbiguousAssignment` cop. ([@fatkodima][]) +* [#9243](https://github.com/rubocop/rubocop/pull/9243): Support auto-correction for `Style/CommentedKeyword`. ([@koic][]) +* [#9283](https://github.com/rubocop/rubocop/pull/9283): Add new `Style/HashExcept` cop. ([@koic][]) +* [#9231](https://github.com/rubocop/rubocop/pull/9231): Add new `Layout/SpaceBeforeBrackets` cop. ([@koic][]) + +### Bug fixes -* [#239](https://github.com/bbatsov/rubocop/issues/239): Fixed double quotes false positives. -* [#233](https://github.com/bbatsov/rubocop/issues/233): Report syntax cop offences. -* Fix off-by-one error in favor_modifier. -* [#229](https://github.com/bbatsov/rubocop/issues/229): Recognize a line with CR+LF as a blank line in AccessControl cop. -* [#235](https://github.com/bbatsov/rubocop/issues/235): Handle multiple constant assignment in ConstantName cop. -* [#246](https://github.com/bbatsov/rubocop/issues/246): Correct handling of unicode escapes within double quotes. -* Fix crashes in Blocks, CaseEquality, CaseIndentation, ClassAndModuleCamelCase, ClassMethods, CollectionMethods, and ColonMethodCall. -* [#263](https://github.com/bbatsov/rubocop/issues/263): Do not check for space around operators called with method syntax. -* [#271](https://github.com/bbatsov/rubocop/issues/271): Always allow line breaks inside hash literal braces. -* [#270](https://github.com/bbatsov/rubocop/issues/270): Fixed a false positive in ParenthesesAroundCondition. -* [#288](https://github.com/bbatsov/rubocop/issues/288): Get config parameter AllCops/Excludes from highest config file in path. -* [#276](https://github.com/bbatsov/rubocop/issues/276): Let columns start at 1 instead of 0 in all output of column numbers. -* [#292](https://github.com/bbatsov/rubocop/issues/292): Don't check non-regular files (like sockets, etc). -* Fix crashes in WordArray on arrays of character literals such as `[?\r, ?\n]`. -* Fix crashes in Documentation on empty modules. +* [#9232](https://github.com/rubocop/rubocop/pull/9232): Fix `Style/SymbolProc` registering wrong offense when using a symbol numbered block argument greater than 1, i.e. `[[1, 2]].map { _2.succ }`. ([@tdeo][]) +* [#9274](https://github.com/rubocop/rubocop/issues/9274): Fix error in `Metrics/ClassLength` when the class only contains comments. ([@dvandersluis][]) +* [#9213](https://github.com/rubocop/rubocop/issues/9213): Fix a false positive for `Style/RedundantFreeze` when using `Array#*`. ([@koic][]) +* [#9279](https://github.com/rubocop/rubocop/pull/9279): Add support for endless methods to `Style/MethodCallWithArgsParentheses`. ([@dvandersluis][]) +* [#9245](https://github.com/rubocop/rubocop/issues/9245): Fix `Lint/AmbiguousRegexpLiteral` when given a `match_with_lvasgn` node. ([@dvandersluis][]) +* [#9276](https://github.com/rubocop/rubocop/pull/9276): Add support for endless methods to `Style/SingleLineMethods`. ([@dvandersluis][]) +* [#9225](https://github.com/rubocop/rubocop/issues/9225): Fix `Style/LambdaCall` ignoring further offenses after opposite style is detected. ([@sswander][]) +* [#9234](https://github.com/rubocop/rubocop/issues/9234): Fix the error for `Style/KeywordParametersOrder` and make it aware of block keyword parameters. ([@koic][]) +* [#8938](https://github.com/rubocop/rubocop/pull/8938): Fix some ConfigurableEnforcedStyle cops to output `Exclude` file lists in `--auto-gen-config` runs. ([@h-lame][]) +* [#9257](https://github.com/rubocop/rubocop/issues/9257): Fix false positive for `Style/SymbolProc` when the block uses a variable from outside the block. ([@dvandersluis][]) +* [#9251](https://github.com/rubocop/rubocop/issues/9251): Fix extracted cop warning when the extension is loaded using `--require`. ([@dvandersluis][]) +* [#9244](https://github.com/rubocop/rubocop/issues/9244): When a cop defined in an extension is explicitly enabled, ensure that it remains enabled. ([@dvandersluis][]) +* [#8046](https://github.com/rubocop/rubocop/issues/8046): Fix an error for `Layout/HeredocArgumentClosingParenthesis` when there is an argument between a heredoc argument and the closing parentheses. ([@koic][]) +* [#9261](https://github.com/rubocop/rubocop/pull/9261): Fix an incorrect auto-correct for `Style/MultilineWhenThen` when one line for multiple candidate values of `when` statement. ([@makicamel][]) +* [#9258](https://github.com/rubocop/rubocop/pull/9258): Fix calculation of cop department for nested departments. ([@mvz][]) +* [#9277](https://github.com/rubocop/rubocop/pull/9277): Fix `Layout/EmptyLineBetweenDefs` error with endless method definitions. ([@dvandersluis][]) +* [#9278](https://github.com/rubocop/rubocop/pull/9278): Update `Style/MethodDefParentheses` to ignore endless method definitions since parentheses are always required. ([@dvandersluis][]) -## 0.8.3 (18/06/2013) +### Changes + +* [#9212](https://github.com/rubocop/rubocop/pull/9212): Make `Style/RedundantArgument` aware of `String#chomp` and `String#chomp!`. ([@koic][]) +* [#8482](https://github.com/rubocop/rubocop/issues/8482): Allow simple math for `Lint/BinaryOperatorWithIdenticalOperands` cop. ([@fatkodima][]) +* [#9237](https://github.com/rubocop/rubocop/issues/9237): Add `IgnoredPatterns` configuration to `Lint/UnreachableLoop` to allow for block methods that share a name with an `Enumerable` method. ([@dvandersluis][]) +* [#9206](https://github.com/rubocop/rubocop/pull/9206): Allow extensions to disable cop obsoletions. ([@dvandersluis][]) +* [#9262](https://github.com/rubocop/rubocop/issues/9262): Update `Style/CollectionMethods` to be handle additional arguments and methods that accept a symbol instead of a block. ([@dvandersluis][]) +* [#9235](https://github.com/rubocop/rubocop/issues/9235): Allow `--only` and `--except` to be able to properly qualify cops added by require. ([@dvandersluis][]) +* [#9205](https://github.com/rubocop/rubocop/issues/9205): Update `Naming/MemoizedInstanceVariableName` to handle dynamically defined methods. ([@dvandersluis][]) +* [#9285](https://github.com/rubocop/rubocop/pull/9285): Add `AllowPercentLiteralArrayArgument` option for `Lint/RedundantSplatExpansion` to enable the option by default. ([@koic][]) +* [#9208](https://github.com/rubocop/rubocop/issues/9208): Use Array#bsearch instead of Array#include? to detect hidden files. ([@dark-panda][]) +* [#9228](https://github.com/rubocop/rubocop/pull/9228): Suppress any config warnings for `rubocop -V`. ([@dvandersluis][]) +* [#9193](https://github.com/rubocop/rubocop/pull/9193): Add `IgnoreLiteralBranches` and `IgnoreConstantBranches` options to `Lint/DuplicateBranch`. ([@dvandersluis][]) + +## 1.6.1 (2020-12-10) ### Bug fixes -* Lock Parser dependency to version 2.0.0.beta5. +* [#9196](https://github.com/rubocop/rubocop/issues/9196): Fix `ConfigObsoletion::ExtractedCop` raising errors for loaded features when bundler is not activated. ([@dvandersluis][]) -## 0.8.2 (06/05/2013) +## 1.6.0 (2020-12-09) ### New features -* New cop `BlockNesting` checks for excessive block nesting. +* [#9125](https://github.com/rubocop/rubocop/issues/9125): Allow ConfigObsoletion to be extended by other RuboCop libraries. ([@dvandersluis][]) +* [#9182](https://github.com/rubocop/rubocop/pull/9182): Support auto-correction for `Style/RedundantArgument`. ([@koic][]) +* [#9186](https://github.com/rubocop/rubocop/pull/9186): Support auto-correction for `Style/FloatDivision`. ([@koic][]) +* [#9167](https://github.com/rubocop/rubocop/pull/9167): Support auto-correct for `StyleSingleLineBlockParams`. ([@koic][]) + +### Bug fixes + +* [#9177](https://github.com/rubocop/rubocop/pull/9177): Remove back-ref related code from `Style/SpecialGlobalVars`. ([@r7kamura][]) +* [#9160](https://github.com/rubocop/rubocop/issues/9160): Fix an incorrect auto-correct for `Style/IfUnlessModifier` and `Style/SoleNestedConditional` when auto-correction conflicts for guard condition. ([@koic][]) +* [#9174](https://github.com/rubocop/rubocop/issues/9174): Handle send nodes with unparenthesized arguments in `Style/SoleNestedConditional`. ([@dvandersluis][]) +* [#9184](https://github.com/rubocop/rubocop/issues/9184): `Layout/EmptyLinesAroundAttributeAccessor` fails if the attr_accessor is the last line of the file. ([@tas50][]) + +### Changes + +* [#9171](https://github.com/rubocop/rubocop/pull/9171): Add "did you mean" message when failing due to invalid cops in configuration. ([@dvandersluis][]) +* [#8897](https://github.com/rubocop/rubocop/issues/8897): Change `Style/StringConcatenation` to accept line-end concatenation between two strings so that `Style/LineEndConcatenation` can handle it instead. ([@dvandersluis][]) +* [#9172](https://github.com/rubocop/rubocop/pull/9172): Add `Style/PerlBackrefs` targets and change message more detailed. ([@r7kamura][]) +* [#9187](https://github.com/rubocop/rubocop/pull/9187): Update formatters to output `[Correctable]` for correctable offenses. ([@dvandersluis][]) +* [#9169](https://github.com/rubocop/rubocop/pull/9169): Add obsoletion warnings for `Performance/*` and `Rails/*` which are in separate gems now. ([@dvandersluis][]) + +## 1.5.2 (2020-12-04) + +### Bug fixes + +* [#9152](https://github.com/rubocop/rubocop/issues/9152): Fix an incorrect auto-correct for `Style/SoleNestedConditional` when nested `||` operator modifier condition. ([@koic][]) +* [#9161](https://github.com/rubocop/rubocop/issues/9161): Fix a false positive for `Layout/HeredocArgumentClosingParenthesis` when using subsequence closing parentheses in the same line. ([@koic][]) +* [#9151](https://github.com/rubocop/rubocop/issues/9151): Fix `SuggestExtensions` to not suggest extensions that are installed but not direct dependencies. ([@dvandersluis][]) +* [#8985](https://github.com/rubocop/rubocop/issues/8985): Fix `Style/StringConcatenation` autocorrect generating invalid ruby. ([@tejasbubane][]) +* [#9155](https://github.com/rubocop/rubocop/issues/9155): Fix a false positive for `Layout/MultilineMethodCallIndentation` when multiline method chain has expected indent width and the method is preceded by splat for `EnforcedStyle: indented_relative_to_receiver`. ([@koic][]) + +### Changes + +* [#9080](https://github.com/rubocop/rubocop/issues/9080): Make `Lint/ShadowingOuterLocalVariable` aware of `Ractor`. ([@tejasbubane][]) +* [#9102](https://github.com/rubocop/rubocop/pull/9102): Relax regexp_parser requirement. ([@marcandre][]) + +## 1.5.1 (2020-12-02) ### Bug fixes -* Correct calculation of whether a modifier version of a conditional statement will fit. -* Fix an error in `MultilineIfThen` cop that occurred in some special cases. -* [#231](https://github.com/bbatsov/rubocop/issues/231): Fix a false positive for modifier if. +* [#8684](https://github.com/rubocop/rubocop/issues/8684): Fix an error for `Lint/InterpolationCheck` cop. ([@tejasbubane][]) +* [#9145](https://github.com/rubocop/rubocop/issues/9145): Fix issues with SuggestExtensions when bundler is not available, or when there is no gemfile. ([@dvandersluis][]) +* [#9140](https://github.com/rubocop/rubocop/issues/9140): Fix an error for `Layout/EmptyLinesAroundArguments` when multiline style argument for method call without selector. ([@koic][]) +* [#9136](https://github.com/rubocop/rubocop/pull/9136): Fix `AllowedIdentifiers` in `Naming/VariableNumber` to include variable assignments. ([@PhilCoggins][]) -## 0.8.1 (05/30/2013) +## 1.5.0 (2020-12-01) ### New features -* New cop `Proc` tracks uses of `Proc.new`. +* [#9112](https://github.com/rubocop/rubocop/pull/9112): Add new cop `Lint/UnexpectedBlockArity`. ([@dvandersluis][]) +* [#9010](https://github.com/rubocop/rubocop/pull/9010): `Metrics/ParameterLists` supports `MaxOptionalParameters` config parameter. ([@fatkodima][]) +* [#9114](https://github.com/rubocop/rubocop/pull/9114): Support auto-correction for `Style/SoleNestedConditional`. ([@koic][]) +* [#8564](https://github.com/rubocop/rubocop/issues/8564): `Metrics/AbcSize`: Add optional discount for repeated "attributes". ([@marcandre][]) + +### Bug fixes + +* [#8820](https://github.com/rubocop/rubocop/issues/8820): Fixes `IfWithSemicolon` autocorrection when `elsif` is present. ([@adrian-rivera][], [@dvandersluis][]) +* [#9113](https://github.com/rubocop/rubocop/pull/9113): Fix a false positive for `Style/MethodCallWithoutArgsParentheses` when assigning to a default argument with the same name. ([@koic][]) +* [#9115](https://github.com/rubocop/rubocop/issues/9115): Fix a false positive for `Layout/FirstArgumentIndentation` when argument has expected indent width and the method is preceded by splat for `EnforcedStyle: consistent_relative_to_receiver`. ([@koic][]) +* [#9128](https://github.com/rubocop/rubocop/issues/9128): Fix an incorrect auto-correct for `Style/ClassAndModuleChildren` when namespace is defined as a class in the same file. ([@koic][]) +* [#9105](https://github.com/rubocop/rubocop/issues/9105): Fix an incorrect auto-correct for `Style/RedundantCondition` when using operator method in `else`. ([@koic][]) +* [#9096](https://github.com/rubocop/rubocop/pull/9096): Fix #9095 use merged_config instead of config for pending new cop check. ([@ThomasKoppensteiner][]) +* [#8053](https://github.com/rubocop/rubocop/issues/8053): Fix an incorrect auto-correct for `Style/AndOr` when `or` precedes `and`. ([@koic][]) +* [#9097](https://github.com/rubocop/rubocop/issues/9097): Fix a false positive for `Layout/EmptyLinesAroundArguments` when blank line is inserted between method with arguments and receiver. ([@koic][]) ### Changes -* Renamed `NewLambdaLiteral` to `Lambda`. -* Aligned the `Lambda` cop more closely to the style guide - it now allows the use of `lambda` for multi-line blocks. +* [#9122](https://github.com/rubocop/rubocop/issues/9122): Added tip message if any gems are loaded that have RuboCop extensions. ([@dvandersluis][]) +* [#9104](https://github.com/rubocop/rubocop/issues/9104): Preset some stdlib method names for `Naming/VariableNumber`. ([@koic][]) +* [#9127](https://github.com/rubocop/rubocop/pull/9127): Update `Style/SymbolProc` to be aware of numblocks. ([@dvandersluis][]) +* [#9102](https://github.com/rubocop/rubocop/pull/9102): Upgrade regexp_parser to 2.0. ([@knu][]) +* [#9100](https://github.com/rubocop/rubocop/pull/9100): Update `ConfigObsoletion` so that parameters can be deprecated but still accepted. ([@dvandersluis][]) +* [#9108](https://github.com/rubocop/rubocop/pull/9108): Update `Lint/UnmodifiedReduceAccumulator` to handle numblocks and more than 2 arguments. ([@dvandersluis][]) +* [#9098](https://github.com/rubocop/rubocop/pull/9098): Update `Metrics/BlockLength` and `Metrics/MethodLength` to use `IgnoredMethods` instead of `ExcludedMethods` in configuration. The previous key is retained for backwards compatibility. ([@dvandersluis][]) +* [#9098](https://github.com/rubocop/rubocop/pull/9098): Update `IgnoredMethods` so that every cop that uses it will accept both strings and regexes in the configuration. ([@dvandersluis][]) -### Bugs fixed +## 1.4.2 (2020-11-25) -* [#210](https://github.com/bbatsov/rubocop/issues/210): Fix a false positive for double quotes in regexp literals. -* [#211](https://github.com/bbatsov/rubocop/issues/211): Fix a false positive for `initialize` method looking like a trivial writer. -* [#215](https://github.com/bbatsov/rubocop/issues/215): Fixed a lot of modifier `if/unless/while/until` issues. -* [#213](https://github.com/bbatsov/rubocop/issues/213): Make sure even disabled cops get their configuration set. -* [#214](https://github.com/bbatsov/rubocop/issues/214): Fix SpaceInsideHashLiteralBraces to handle string interpolation right. +### Bug fixes -## 0.8.0 (05/28/2013) +* [#9083](https://github.com/rubocop/rubocop/pull/9083): Fix `Style/RedundantArgument` cop raising offense for more than one argument. ([@tejasbubane][]) +* [#9089](https://github.com/rubocop/rubocop/issues/9089): Fix an incorrect auto-correct for `Style/FormatString` when using sprintf with second argument that uses an operator. ([@koic][]) +* [#7670](https://github.com/rubocop/rubocop/issues/7670): Handle offenses inside heredocs for `-a --disable-uncorrectable`. ([@jonas054][]) +* [#9070](https://github.com/rubocop/rubocop/issues/9070): Fix `Lint/UnmodifiedReduceAccumulator` error when the block does not have enough arguments. ([@dvandersluis][]) ### Changes -* Folded `ArrayLiteral` and `HashLiteral` into `EmptyLiteral` cop. -* The maximum number of params `ParameterLists` accepts in now configurable. -* Reworked `SymbolSnakeCase` into `SymbolName`, which has an option `AllowCamelCase` enabled by default. -* Migrated from `Ripper` to the portable [Parser](https://github.com/whitequark/parser). +* [#9091](https://github.com/rubocop/rubocop/pull/9091): Have `Naming/VariableNumber` accept _1, _2, ... ([@marcandre][]) +* [#9087](https://github.com/rubocop/rubocop/pull/9087): Deprecate `EnforceSuperclass` module. ([@koic][]) + +## 1.4.1 (2020-11-23) + +### Bug fixes + +* [#9082](https://github.com/rubocop/rubocop/pull/9082): Fix gemspec to include assets directory. ([@javierav][]) + +## 1.4.0 (2020-11-23) ### New features -* New cop `ConstantName` checks for constant which are not using `SCREAMING_SNAKE_CASE`. -* New cop `AccessControl` checks private/protected indentation and surrounding blank lines. -* New cop `Loop` checks for `begin/end/while(until)` and suggests the use of `Kernel#loop`. +* [#7737](https://github.com/rubocop/rubocop/issues/7737): Add new `Style/RedundantArgument` cop. ([@tejasbubane][]) +* [#9064](https://github.com/rubocop/rubocop/issues/9064): Add `EmptyLineBetweenMethodDefs`, `EmptyLineBetweenClassDefs` and `EmptyLineBetweenModuleDefs` config options for `Layout/EmptyLineBetweenDefs` cop. ([@tejasbubane][]) +* [#9043](https://github.com/rubocop/rubocop/pull/9043): Add `--stderr` to write all output to stderr except for the autocorrected source. ([@knu][]) + +### Bug fixes + +* [#9067](https://github.com/rubocop/rubocop/pull/9067): Fix an incorrect auto-correct for `Lint::AmbiguousRegexpLiteral` when passing in a regexp to a method with no receiver. ([@amatsuda][]) +* [#9060](https://github.com/rubocop/rubocop/issues/9060): Fix an error for `Layout/SpaceAroundMethodCallOperator` when using `__ENCODING__`. ([@koic][]) +* [#7338](https://github.com/rubocop/rubocop/issues/7338): Handle assignment with `[]=` in `MultilineMethodCallIndentation`. ([@jonas054][]) +* [#7726](https://github.com/rubocop/rubocop/issues/7726): Fix `MultilineMethodCallIndentation` indentation inside square brackets. ([@jonas054][]) +* [#8857](https://github.com/rubocop/rubocop/issues/8857): Improve how `Exclude` properties are generated by `--auto-gen-config`. ([@jonas054][]) + +### Changes -## 0.7.2 (05/13/2013) +* [#8788](https://github.com/rubocop/rubocop/issues/8788): Change `Style/Documentation` to not trigger offense with only macros. ([@tejasbubane][]) +* [#8993](https://github.com/rubocop/rubocop/issues/8993): Allow `ExcludedMethods` config of `Metrics/MethodLength` cop to contain regex. ([@tejasbubane][]) +* [#9073](https://github.com/rubocop/rubocop/issues/9073): Enable `Layout/LineLength`'s auto-correct by default. ([@bbatsov][]) +* [#9079](https://github.com/rubocop/rubocop/pull/9079): Improve the gemspec to load only the necessary files without the git utility. ([@piotrmurach][]) +* [#9059](https://github.com/rubocop/rubocop/pull/9059): Update `Lint/UnmodifiedReduceAccumulator` to accept blocks which return in the form `accumulator[element]`. ([@dvandersluis][]) +* [#9072](https://github.com/rubocop/rubocop/pull/9072): `Lint/MissingSuper`: exclude `method_missing` and `respond_to_missing?`. ([@marcandre][]) +* [#9074](https://github.com/rubocop/rubocop/pull/9074): Allow specifying a pull request ID when calling `rake changelog:*`. ([@marcandre][]) -### Bugs fixed +## 1.3.1 (2020-11-16) -* [#155](https://github.com/bbatsov/rubocop/issues/155): 'Do not use semicolons to terminate expressions.' is not implemented correctly. -* `OpMethod` now handles definition of unary operators without crashing. -* `SymbolSnakeCase` now handles aliasing of operators without crashing. -* `RescueException` now handles the splat operator `*` in a `rescue` clause without crashing. -* [#159](https://github.com/bbatsov/rubocop/issues/159): AvoidFor cop misses many violations. +### Bug fixes -## 0.7.1 (05/11/2013) +* [#9037](https://github.com/rubocop/rubocop/pull/9037): Fix `required_ruby_version` issue when using `Gem::Requirement`. ([@cetinajero][]) +* [#9039](https://github.com/rubocop/rubocop/pull/9039): Fix stack level too deep error if target directory contains `**`. ([@unasuke][]) +* [#6962](https://github.com/rubocop/rubocop/issues/6962): Limit `Layout/ClassStructure` constant order autocorrect to literal constants. ([@tejasbubane][]) +* [#9032](https://github.com/rubocop/rubocop/issues/9032): Fix an error for `Style/DocumentDynamicEvalDefinition` when using eval-type method with interpolated string that is not heredoc without comment doc. ([@koic][]) +* [#9049](https://github.com/rubocop/rubocop/issues/9049): Have `Lint/ToEnumArguments` accept `__callee__`. ([@marcandre][]) +* [#9050](https://github.com/rubocop/rubocop/issues/9050): Fix a false positive for `Style/NegatedIfElseCondition` when `if` with `!!` condition. ([@koic][]) +* [#9041](https://github.com/rubocop/rubocop/issues/9041): Fix a false positive for `Naming/VariableNumber` when using integer symbols. ([@koic][]) -### Bugs fixed +### Changes -* Added missing files to the gemspec. +* [#9045](https://github.com/rubocop/rubocop/pull/9045): Have `cut_release` handle "config/default" and generate cops doc. ([@marcandre][]) +* [#9036](https://github.com/rubocop/rubocop/pull/9036): Allow `enums` method by default for `Lint/ConstantDefinitionInBlock`. ([@koic][]) +* [#9035](https://github.com/rubocop/rubocop/issues/9035): Only complain about `SafeYAML` if it causes issues. ([@marcandre][]) -## 0.7.0 (05/11/2013) +## 1.3.0 (2020-11-12) ### New features -* Added ability to include or exclude files/directories through `.rubocop.yml`. -* Added option --only for running a single cop. -* Relax semicolon rule for one line methods, classes and modules. -* Configuration files, such as `.rubocop.yml`, can now include configuration from other files through the `inherit_from` directive. All configuration files implicitly inherit from `config/default.yml`. -* New cop `ClassMethods` checks for uses for class/module names in definitions of class/module methods. -* New cop `SingleLineMethods` checks for methods implemented on a single line. -* New cop `FavorJoin` checks for usages of `Array#*` with a string argument. -* New cop `BlockComments` tracks uses of block comments(`=begin/=end` comments). -* New cop `EmptyLines` tracks consecutive blank lines. -* New cop `WordArray` tracks arrays of words. -* [#108](https://github.com/bbatsov/rubocop/issues/108): New cop `SpaceInsideHashLiteralBraces` checks for spaces inside hash literal braces - style is configurable. -* New cop `LineContinuation` tracks uses of the line continuation character (`\`). -* New cop `SymbolArray` tracks arrays of symbols. -* Print warnings for unrecognized names in configuration files. -* New cop `TrivialAccessors` tracks method definitions that could be automatically generated with `attr_*` methods. -* New cop `LeadingCommentSpace` checks for missing space after `#` in comments. -* New cop `ColonMethodCall` tracks uses of `::` for method calls. -* New cop `AvoidGlobalVars` tracks uses of non built-in global variables. -* New cop `SpaceAfterControlKeyword` tracks missing spaces after `if/elsif/case/when/until/unless/while`. -* New cop `Not` tracks uses of the `not` keyword. -* New cop `Eval` tracks uses of the `eval` function. +* [#8761](https://github.com/rubocop/rubocop/issues/8761): Read `required_ruby_version` from gemspec file if it exists. ([@HeroProtagonist][]) +* [#9001](https://github.com/rubocop/rubocop/pull/9001): Add new `Lint/EmptyClass` cop. ([@fatkodima][]) +* [#9025](https://github.com/rubocop/rubocop/issues/9025): Add `AllowedMethods` option to `Lint/ConstantDefinitionInBlock`. ([@koic][]) +* [#9014](https://github.com/rubocop/rubocop/pull/9014): Support auto-correction for `Style/IfInsideElse`. ([@koic][]) +* [#8483](https://github.com/rubocop/rubocop/pull/8483): Add new `Style/StaticClass` cop. ([@fatkodima][]) +* [#9020](https://github.com/rubocop/rubocop/pull/9020): Add new `Style/NilLambda` cop to check for lambdas that always return nil. ([@dvandersluis][]) +* [#8404](https://github.com/rubocop/rubocop/pull/8404): Add new `Lint/DuplicateBranch` cop. ([@fatkodima][]) -### Bugs fixed +### Bug fixes -* [#101](https://github.com/bbatsov/rubocop/issues/101): `SpaceAroundEqualsInParameterDefault` doesn't work properly with empty string. -* Fix `BraceAfterPercent` for `%W`, `%i` and `%I` and added more tests. -* Fix a false positive in the `Alias` cop. `:alias` is no longer treated as keyword. -* `ArrayLiteral` now properly detects `Array.new`. -* `HashLiteral` now properly detects `Hash.new`. -* `VariableInterpolation` now detects regexp back references and doesn't crash. -* Don't generate pathnames like some/project//some.rb. -* [#151](https://github.com/bbatsov/rubocop/issues/151): Don't print the unrecognized cop warning several times for the same `.rubocop.yml`. +* [#8499](https://github.com/rubocop/rubocop/issues/8499): Fix `Style/IfUnlessModifier` and `Style/WhileUntilModifier` to prevent an offense if there are both first-line comment and code after `end` block. ([@dsavochkin][]) +* [#8996](https://github.com/rubocop/rubocop/issues/8996): Fix a false positive for `Style/MultipleComparison` when comparing two sides of the disjunction is unrelated. ([@koic][]) +* [#8975](https://github.com/rubocop/rubocop/issues/8975): Fix an infinite loop when autocorrecting `Layout/TrailingWhitespace` + `Lint/LiteralInInterpolation`. ([@fatkodima][]) +* [#8998](https://github.com/rubocop/rubocop/issues/8998): Fix an error for `Style/NegatedIfElseCondition` when using negated condition and `if` branch body is empty. ([@koic][]) +* [#9008](https://github.com/rubocop/rubocop/pull/9008): Mark `Style/InfiniteLoop` as unsafe. ([@marcandre][]) -### Misc +### Changes -* Renamed `Indentation` cop to `CaseIndentation` to avoid confusion. -* Renamed `EmptyLines` cop to `EmptyLineBetweenDefs` to avoid confusion. +* [#8978](https://github.com/rubocop/rubocop/issues/8978): Update `Layout/LineLength` autocorrection to be able to handle method calls with long argument lists. ([@dvandersluis][]) +* [#9015](https://github.com/rubocop/rubocop/issues/9015): Update `Lint/EmptyBlock` to allow for empty lambdas. ([@dvandersluis][]) +* [#9022](https://github.com/rubocop/rubocop/issues/9022): Add `NOTE` to keywords of `Style/CommentAnnotation`. ([@koic][]) +* [#9011](https://github.com/rubocop/rubocop/issues/9011): Mark autocorrection for `Lint/Loop` as unsafe. ([@dvandersluis][]) +* [#9026](https://github.com/rubocop/rubocop/issues/9026): Update `Style/DocumentDynamicEvalDefinition` to detect comment blocks that document the evaluation. ([@dvandersluis][]) +* [#9004](https://github.com/rubocop/rubocop/pull/9004): Remove obsolete gem `SafeYAML` compatibility. ([@marcandre][]) +* [#9023](https://github.com/rubocop/rubocop/issues/9023): Mark unsafe for `Style/CollectionCompact`. ([@koic][]) +* [#9012](https://github.com/rubocop/rubocop/issues/9012): Allow `AllowedIdentifiers` to be specified for `Naming/VariableNumber`. ([@dvandersluis][]) -## 0.6.1 (04/28/2013) +## 1.2.0 (2020-11-05) ### New features -* Split `AsciiIdentifiersAndComments` cop in two separate cops. +* [#8983](https://github.com/rubocop/rubocop/pull/8983): Support auto-correction for `Naming/HeredocDelimiterCase`. ([@koic][]) +* [#8004](https://github.com/rubocop/rubocop/issues/8004): Add new `GitHubActionsFormatter` formatter. ([@lautis][]) +* [#8175](https://github.com/rubocop/rubocop/pull/8175): Add new `AllowedCompactTypes` option for `Style/RaiseArgs`. ([@pdobb][]) +* [#8566](https://github.com/rubocop/rubocop/issues/8566): Add new `Style/CollectionCompact` cop. ([@fatkodima][]) +* [#8925](https://github.com/rubocop/rubocop/issues/8925): Add `--display-time` option for displaying elapsed time of `rubocop` command. ([@joshuapinter][]) +* [#8967](https://github.com/rubocop/rubocop/pull/8967): Add new `Style/NegatedIfElseCondition` cop. ([@fatkodima][]) +* [#8984](https://github.com/rubocop/rubocop/pull/8984): Support auto-correction for `Style/DoubleNegation`. ([@koic][]) +* [#8992](https://github.com/rubocop/rubocop/pull/8992): Support auto-correction for `Lint/ElseLayout`. ([@koic][]) +* [#8988](https://github.com/rubocop/rubocop/pull/8988): Support auto-correction for `Lint/UselessSetterCall`. ([@koic][]) +* [#8982](https://github.com/rubocop/rubocop/pull/8982): Support auto-correction for `Naming/BinaryOperatorParameterName`. ([@koic][]) -### Bugs fixed +### Bug fixes -* [#90](https://github.com/bbatsov/rubocop/issues/90): Two cops crash when scanning code using `super`. -* [#93](https://github.com/bbatsov/rubocop/issues/93): Issue with `whitespace?': undefined method`. -* [#97](https://github.com/bbatsov/rubocop/issues/97): Build fails. -* [#100](https://github.com/bbatsov/rubocop/issues/100): `OpMethod` cop doesn't work if method arg is not in braces. -* `SymbolSnakeCase` now tracks Ruby 1.9 hash labels as well as regular symbols. +* [#8989](https://github.com/rubocop/rubocop/pull/8989): Fix multibyte support in the regexp node handler that led `Style/RedundantRegexpEscape` to malfunction and corrupt a program in auto-correction. ([@knu][]) +* [#8912](https://github.com/rubocop/rubocop/pull/8912): Fix `Layout/ElseAlignment` for `rescue/else/ensure` inside `do/end` blocks with assignment. ([@miry][]) +* [#8971](https://github.com/rubocop/rubocop/issues/8971): Fix a false alarm for `# rubocop:disable Lint/EmptyBlock` inline comment with `Lint/RedundantCopDisableDirective`. ([@koic][]) +* [#8976](https://github.com/rubocop/rubocop/issues/8976): Fix an incorrect auto-correct for `Style/KeywordParametersOrder` when `kwoptarg` is before `kwarg` and argument parentheses omitted. ([@koic][]) +* [#8084](https://github.com/rubocop/rubocop/pull/8084): Fix a bug in how `Layout/SpaceAroundBlockParameters` handles block parameters with a trailing comma. ([@bquorning][]) +* [#8966](https://github.com/rubocop/rubocop/issues/8966): Fix `Layout/SpaceInsideParens` to enforce no spaces in empty parens for all styles. ([@joshuapinter][]) -### Misc +### Changes -* [#88](https://github.com/bbatsov/rubocop/issues/88): Abort gracefully when interrupted with Ctrl-C. -* No longer crashes on bugs within cops. Now problematic checks are skipped and a message is displayed. -* Replaced `Term::ANSIColor` with `Rainbow`. -* Add an option to disable colors in the output. -* Cop names are now displayed alongside messages when `-d/--debug` is passed. +* [#5717](https://github.com/rubocop/rubocop/issues/5717): Support `defined?`-based memoization for `Naming/MemoizedInstanceVariableName` cop. ([@fatkodima][]) +* [#8964](https://github.com/rubocop/rubocop/pull/8964): Extend `Naming/VariableNumber` cop to handle method names and symbols. ([@fatkodima][]) -## 0.6.0 (04/23/2013) +## 1.1.0 (2020-10-29) ### New features -* New cop `ReduceArguments` tracks argument names in reduce calls. -* New cop `MethodLength` tracks number of LOC (lines of code) in methods. -* New cop `RescueModifier` tracks uses of `rescue` in modifier form. -* New cop `PercentLiterals` tracks uses of `%q`, `%Q`, `%s` and `%x`. -* New cop `BraceAfterPercent` tracks uses of % literals with delimiters other than (). -* Support for disabling cops locally in a file with rubocop:disable comments. -* New cop `EnsureReturn` tracks usages of `return` in `ensure` blocks. -* New cop `HandleExceptions` tracks suppressed exceptions. -* New cop `AsciiIdentifiersAndComments` tracks uses of non-ascii characters in identifiers and comments. -* New cop `RescueException` tracks uses of rescuing the `Exception` class. -* New cop `ArrayLiteral` tracks uses of Array.new. -* New cop `HashLiteral` tracks uses of Hash.new. -* New cop `OpMethod` tracks the argument name in operator methods. -* New cop `PercentR` tracks uses of %r literals with zero or one slash in the regexp. -* New cop `FavorPercentR` tracks uses of // literals with more than one slash in the regexp. +* [#8896](https://github.com/rubocop/rubocop/pull/8896): Add new `Lint/DuplicateRegexpCharacterClassElement` cop. ([@owst][]) +* [#8895](https://github.com/rubocop/rubocop/pull/8895): Add new `Lint/EmptyBlock` cop. ([@fatkodima][]) +* [#8934](https://github.com/rubocop/rubocop/pull/8934): Add new `Style/SwapValues` cop. ([@fatkodima][]) +* [#7549](https://github.com/rubocop/rubocop/issues/7549): Add new `Style/ArgumentsForwarding` cop. ([@koic][]) +* [#8859](https://github.com/rubocop/rubocop/issues/8859): Add new `Lint/UnmodifiedReduceAccumulator` cop. ([@dvandersluis][]) +* [#8951](https://github.com/rubocop/rubocop/pull/8951): Support auto-correction for `Style/MultipleComparison`. ([@koic][]) +* [#8953](https://github.com/rubocop/rubocop/pull/8953): Add `AllowMethodComparison` option for `Lint/MultipleComparison`. ([@koic][]) +* [#8960](https://github.com/rubocop/rubocop/pull/8960): Add `Regexp::Expression#loc` and `#expression` to replace `parsed_tree_expr_loc`. ([@marcandre][]) +* [#8930](https://github.com/rubocop/rubocop/pull/8930): Add rake tasks for alternative way to specify Changelog entries. ([@marcandre][]) +* [#8940](https://github.com/rubocop/rubocop/pull/8940): Add new `Style/DocumentDynamicEvalDefinition` cop. ([@fatkodima][]) +* [#7753](https://github.com/rubocop/rubocop/issues/7753): Add new `Lint/ToEnumArguments` cop. ([@fatkodima][]) -### Bugs fixed +### Bug fixes -* [#62](https://github.com/bbatsov/rubocop/issues/62): Config files in ancestor directories are ignored if another exists in home directory. -* [#65](https://github.com/bbatsov/rubocop/issues/65): Suggests to convert symbols `:==`, `:<=>` and the like to snake_case. -* [#66](https://github.com/bbatsov/rubocop/issues/66): Does not crash on unreadable or unparseable files. -* [#70](https://github.com/bbatsov/rubocop/issues/70): Support `alias` with bareword arguments. -* [#64](https://github.com/bbatsov/rubocop/issues/64): Performance issue with Bundler. -* [#75](https://github.com/bbatsov/rubocop/issues/75): Make it clear that some global variables require the use of the English library. -* [#79](https://github.com/bbatsov/rubocop/issues/79): Ternary operator missing whitespace detection. +* [#8921](https://github.com/rubocop/rubocop/pull/8921): Prevent `Lint/LiteralInInterpolation` from removing necessary interpolation in `%W[]` and `%I[]` literals. ([@knu][]) +* [#8708](https://github.com/rubocop/rubocop/pull/8708): Fix bad regexp recognition in `Lint/OutOfRangeRegexpRef` when there are multiple regexps. ([@dvandersluis][]) +* [#8945](https://github.com/rubocop/rubocop/pull/8945): Fix changelog task to build a correct changelog item when `Fix #123` is encountered. ([@dvandersluis][]) +* [#8914](https://github.com/rubocop/rubocop/pull/8914): Fix autocorrection for `Layout/TrailingWhitespace` in heredocs. ([@marcandre][]) +* [#8913](https://github.com/rubocop/rubocop/pull/8913): Fix an incorrect auto-correct for `Style/RedundantRegexpCharacterClass` due to quantifier. ([@ysakasin][]) +* [#8917](https://github.com/rubocop/rubocop/issues/8917): Fix rubocop comment directives handling of cops with multiple levels in department name. ([@fatkodima][]) +* [#8918](https://github.com/rubocop/rubocop/issues/8918): Fix a false positives for `Bundler/DuplicatedGem` when a gem conditionally duplicated within `if-elsif` or `case-when` statements. ([@fatkodima][]) +* [#8933](https://github.com/rubocop/rubocop/pull/8933): Fix an error for `Layout/EmptyLinesAroundAccessModifier` when the first line is a comment. ([@matthieugendreau][]) +* [#8954](https://github.com/rubocop/rubocop/pull/8954): Fix autocorrection for `Style/RedundantRegexpCharacterClass` with %r. ([@ysakasin][]) -### Misc +### Changes -* Dropped Jeweler for gem release management since it's no longer actively maintained. -* Handle pluralization properly in the final summary. +* [#8920](https://github.com/rubocop/rubocop/pull/8920): Remove Capybara's `save_screenshot` from `Lint/Debugger`. ([@ybiquitous][]) +* [#8919](https://github.com/rubocop/rubocop/issues/8919): Require RuboCop AST 1.0.1 or higher. ([@koic][]) +* [#8939](https://github.com/rubocop/rubocop/pull/8939): Accept comparisons of multiple method calls for `Style/MultipleComparison`. ([@koic][]) +* [#8950](https://github.com/rubocop/rubocop/issues/8950): Add `IgnoredMethods` and `IgnoredClasses` to `Lint/NumberConversion`. ([@dvandersluis][]) -## 0.5.0 (04/17/2013) +## 1.0.0 (2020-10-21) ### New features -* New cop `FavorSprintf` that checks for usages of `String#%`. -* New cop `Semicolon` that checks for usages of `;` as expression separator. -* New cop `VariableInterpolation` that checks for variable interpolation in double quoted strings. -* New cop `Alias` that checks for uses of the keyword `alias`. -* Automatically detect extensionless Ruby files with shebangs when search for Ruby source files in a directory. +* [#7944](https://github.com/rubocop/rubocop/issues/7944): Add `MaxUnannotatedPlaceholdersAllowed` option to `Style/FormatStringToken` cop. ([@Tietew][]) +* [#8379](https://github.com/rubocop/rubocop/issues/8379): Handle redundant parentheses around an interpolated expression for `Style/RedundantParentheses` cop. ([@fatkodima][]) + +### Bug fixes + +* [#8892](https://github.com/rubocop/rubocop/issues/8892): Fix an error for `Style/StringConcatenation` when correcting nested concatenatable parts. ([@fatkodima][]) +* [#8781](https://github.com/rubocop/rubocop/issues/8781): Fix handling of comments in `Style/SafeNavigation` autocorrection. ([@dvandersluis][]) +* [#8907](https://github.com/rubocop/rubocop/pull/8907): Fix an incorrect auto-correct for `Layout/ClassStructure` when heredoc constant is defined after public method. ([@koic][]) +* [#8889](https://github.com/rubocop/rubocop/pull/8889): Cops can use new `after_` callbacks (only for nodes that may have children nodes, like `:send` and unlike `:sym`). ([@marcandre][]) +* [#8906](https://github.com/rubocop/rubocop/pull/8906): Fix a false positive for `Layout/SpaceAroundOperators` when upward alignment. ([@koic][]) +* [#8585](https://github.com/rubocop/rubocop/pull/8585): Fix false positive in `Style/RedundantSelf` cop with nested `self` access. ([@marcotc][]) +* [#8692](https://github.com/rubocop/rubocop/pull/8692): Fix `Layout/TrailingWhitespace` auto-correction in heredoc. ([@marcandre][]) + +### Changes -### Bugs fixed +* [#8882](https://github.com/rubocop/rubocop/pull/8882): **(Potentially breaking)** RuboCop assumes that Cop classes do not define new `on_` methods at runtime (e.g. via `extend` in `initialize`). ([@marcandre][]) +* [#7966](https://github.com/rubocop/rubocop/issues/7966): **(Breaking)** Enable all pending cops for RuboCop 1.0. ([@koic][]) +* [#8490](https://github.com/rubocop/rubocop/pull/8490): **(Breaking)** Change logic for cop department name computation. Cops inside deep namespaces (5 or more levels deep) now belong to departments with names that are calculated by joining module names starting from the third one with slashes as separators. For example, cop `RuboCop::Cop::Foo::Bar::Baz` now belongs to `Foo/Bar` department (previously it was `Bar`). ([@dsavochkin][]) +* [#8692](https://github.com/rubocop/rubocop/pull/8692): Default changed to disallow `Layout/TrailingWhitespace` in heredoc. ([@marcandre][]) +* [#8894](https://github.com/rubocop/rubocop/issues/8894): Make `Security/Open` aware of `URI.open`. ([@koic][]) +* [#8901](https://github.com/rubocop/rubocop/issues/8901): Fix false positive for `Naming/BinaryOperatorParameterName` when defining `=~`. ([@zajn][]) +* [#8908](https://github.com/rubocop/rubocop/pull/8908): Show extension cop versions when using `--verbose-version` option. ([@koic][]) -* [#59](https://github.com/bbatsov/rubocop/issues/59): Interpolated variables not enclosed in braces are not noticed. -* [#42](https://github.com/bbatsov/rubocop/issues/42): Received malformed format string ArgumentError from rubocop. +## [v0 CHANGELOG](https://github.com/rubocop/rubocop/blob/master/relnotes/CHANGELOG_v0.md) [@bbatsov]: https://github.com/bbatsov [@jonas054]: https://github.com/jonas054 @@ -1508,12 +3586,13 @@ [@pmenglund]: https://github.com/pmenglund [@chulkilee]: https://github.com/chulkilee [@codez]: https://github.com/codez +[@cyberdelia]: https://github.com/cyberdelia [@emou]: https://github.com/emou -[@skanev]: http://github.com/skanev -[@claco]: http://github.com/claco -[@rifraf]: http://github.com/rifraf +[@skanev]: https://github.com/skanev +[@claco]: https://github.com/claco +[@rifraf]: https://github.com/rifraf [@scottmatthewman]: https://github.com/scottmatthewman -[@ma2gedev]: http://github.com/ma2gedev +[@ma2gedev]: https://github.com/ma2gedev [@jeremyolliver]: https://github.com/jeremyolliver [@hannestyden]: https://github.com/hannestyden [@geniou]: https://github.com/geniou @@ -1613,3 +3692,565 @@ [@mrfoto]: https://github.com/mrfoto [@karreiro]: https://github.com/karreiro [@dreyks]: https://github.com/dreyks +[@hmadison]: https://github.com/hmadison +[@miquella]: https://github.com/miquella +[@jhansche]: https://github.com/jhansche +[@cornelius]: https://github.com/cornelius +[@eagletmt]: https://github.com/eagletmt +[@apiology]: https://github.com/apiology +[@alexdowad]: https://github.com/alexdowad +[@minustehbare]: https://github.com/minustehbare +[@tansaku]: https://github.com/tansaku +[@ptrippett]: https://github.com/ptrippett +[@br3nda]: https://github.com/br3nda +[@jujugrrr]: https://github.com/jujugrrr +[@sometimesfood]: https://github.com/sometimesfood +[@cgriego]: https://github.com/cgriego +[@savef]: https://github.com/savef +[@volmer]: https://github.com/volmer +[@domcleal]: https://github.com/domcleal +[@codebeige]: https://github.com/codebeige +[@weh]: https://github.com/weh +[@bfontaine]: https://github.com/bfontaine +[@jawshooah]: https://github.com/jawshooah +[@DNNX]: https://github.com/DNNX +[@mvidner]: https://github.com/mvidner +[@mattparlane]: https://github.com/mattparlane +[@drenmi]: https://github.com/drenmi +[@georgyangelov]: https://github.com/georgyangelov +[@owst]: https://github.com/owst +[@seikichi]: https://github.com/seikichi +[@madwort]: https://github.com/madwort +[@annih]: https://github.com/annih +[@mmcguinn]: https://github.com/mmcguinn +[@pocke]: https://github.com/pocke +[@prsimp]: https://github.com/prsimp +[@ptarjan]: https://github.com/ptarjan +[@jweir]: https://github.com/jweir +[@Fryguy]: https://github.com/Fryguy +[@mikegee]: https://github.com/mikegee +[@tbrisker]: https://github.com/tbrisker +[@necojackarc]: https://github.com/necojackarc +[@laurelfan]: https://github.com/laurelfan +[@amuino]: https://github.com/amuino +[@dylanahsmith]: https://github.com/dylanahsmith +[@gerrywastaken]: https://github.com/gerrywastaken +[@bolshakov]: https://github.com/bolshakov +[@jastkand]: https://github.com/jastkand +[@graemeboy]: https://github.com/graemeboy +[@akihiro17]: https://github.com/akihiro17 +[@magni-]: https://github.com/magni- +[@NobodysNightmare]: https://github.com/NobodysNightmare +[@gylaz]: https://github.com/gylaz +[@tjwp]: https://github.com/tjwp +[@neodelf]: https://github.com/neodelf +[@josh]: https://github.com/josh +[@natalzia-paperless]: https://github.com/natalzia-paperless +[@jules2689]: https://github.com/jules2689 +[@giannileggio]: https://github.com/giannileggio +[@deivid-rodriguez]: https://github.com/deivid-rodriguez +[@pclalv]: https://github.com/pclalv +[@flexoid]: https://github.com/flexoid +[@sgringwe]: https://github.com/sgringwe +[@Tei]: https://github.com/Tei +[@haziqhafizuddin]: https://github.com/haziqhafizuddin +[@dvandersluis]: https://github.com/dvandersluis +[@QuinnHarris]: https://github.com/QuinnHarris +[@sooyang]: https://github.com/sooyang +[@metcalf]: https://github.com/metcalf +[@annaswims]: https://github.com/annaswims +[@soutaro]: https://github.com/soutaro +[@nicklamuro]: https://github.com/nicklamuro +[@mikezter]: https://github.com/mikezter +[@joejuzl]: https://github.com/joejuzl +[@hedgesky]: https://github.com/hedgesky +[@tjwallace]: https://github.com/tjwallace +[@scottohara]: https://github.com/scottohara +[@koic]: https://github.com/koic +[@groddeck]: https://github.com/groddeck +[@b-t-g]: https://github.com/b-t-g +[@coorasse]: https://github.com/coorasse +[@tcdowney]: https://github.com/tcdowney +[@logicminds]: https://github.com/logicminds +[@abrom]: https://github.com/abrom +[@thegedge]: https://github.com/thegedge +[@jmks]: https://github.com/jmks/ +[@connorjacobsen]: https://github.com/connorjacobsen +[@legendetm]: https://github.com/legendetm +[@bronson]: https://github.com/bronson +[@albus522]: https://github.com/albus522 +[@sihu]: https://github.com/sihu +[@kamaradclimber]: https://github.com/kamaradclimber +[@swcraig]: https://github.com/swcraig +[@jessieay]: https://github.com/jessieay +[@tiagocasanovapt]: https://github.com/tiagocasanovapt +[@iGEL]: https://github.com/iGEL +[@tessi]: https://github.com/tessi +[@ivanovaleksey]: https://github.com/ivanovaleksey +[@Ana06]: https://github.com/Ana06 +[@aroben]: https://github.com/aroben +[@olliebennett]: https://github.com/olliebennett +[@aesthetikx]: https://github.com/aesthetikx +[@tdeo]: https://github.com/tdeo +[@AlexWayfer]: https://github.com/AlexWayfer +[@amogil]: https://github.com/amogil +[@kevindew]: https://github.com/kevindew +[@lucasuyezu]: https://github.com/lucasuyezu +[@breckenedge]: https://github.com/breckenedge +[@enriikke]: https://github.com/enriikke +[@iguchi1124]: https://github.com/iguchi1124 +[@vergenzt]: https://github.com/vergenzt +[@rahulcs]: https://github.com/rahulcs +[@dominh]: https://github.com/dominh +[@sue445]: https://github.com/sue445 +[@zverok]: https://github.com/zverok +[@backus]: https://github.com/backus +[@AdrienSldy]: https://github.com/adriensldy +[@pat]: https://github.com/pat +[@sinsoku]: https://github.com/sinsoku +[@nodo]: https://github.com/nodo +[@onk]: https://github.com/onk +[@dabroz]: https://github.com/dabroz +[@buenaventure]: https://github.com/buenaventure +[@dorian]: https://github.com/dorian +[@attilahorvath]: https://github.com/attilahorvath +[@droptheplot]: https://github.com/droptheplot +[@wkurniawan07]: https://github.com/wkurniawan07 +[@kddeisz]: https://github.com/kddeisz +[@ota42y]: https://github.com/ota42y +[@smakagon]: https://github.com/smakagon +[@musialik]: https://github.com/musialik +[@twe4ked]: https://github.com/twe4ked +[@maxbeizer]: https://github.com/maxbeizer +[@andriymosin]: https://github.com/andriymosin +[@brandonweiss]: https://github.com/brandonweiss +[@betesh]: https://github.com/betesh +[@dpostorivo]: https://github.com/dpostorivo +[@konto-andrzeja]: https://github.com/konto-andrzeja +[@sadovnik]: https://github.com/sadovnik +[@cjlarose]: https://github.com/cjlarose +[@alpaca-tc]: https://github.com/alpaca-tc +[@ilansh]: https://github.com/ilansh +[@mclark]: https://github.com/mclark +[@klesse413]: https://github.com/klesse413 +[@gprado]: https://github.com/gprado +[@yhirano55]: https://github.com/yhirano55 +[@hoshinotsuyoshi]: https://github.com/hoshinotsuyoshi +[@timrogers]: https://github.com/timrogers +[@harold-s]: https://github.com/harold-s +[@daniloisr]: https://github.com/daniloisr +[@promisedlandt]: https://github.com/promisedlandt +[@oboxodo]: https://github.com/oboxodo +[@gohdaniel15]: https://github.com/gohdaniel15 +[@barthez]: https://github.com/barthez +[@Envek]: https://github.com/Envek +[@petehamilton]: https://github.com/petehamilton +[@donjar]: https://github.com/donjar +[@highb]: https://github.com/highb +[@JoeCohen]: https://github.com/JoeCohen +[@theRealNG]: https://github.com/theRealNG +[@akhramov]: https://github.com/akhramov +[@jekuta]: https://github.com/jekuta +[@fujimura]: https://github.com/fujimura +[@kristjan]: https://github.com/kristjan +[@frodsan]: https://github.com/frodsan +[@erikdstock]: https://github.com/erikdstock +[@GauthamGoli]: https://github.com/GauthamGoli +[@nelsonjr]: https://github.com/nelsonjr +[@jonatas]: https://github.com/jonatas +[@jaredbeck]: https://www.jaredbeck.com +[@michniewicz]: https://github.com/michniewicz +[@bgeuken]: https://github.com/bgeuken +[@mtsmfm]: https://github.com/mtsmfm +[@bdewater]: https://github.com/bdewater +[@garettarrowood]: https://github.com/garettarrowood +[@sambostock]: https://github.com/sambostock +[@asherkach]: https://github.com/asherkach +[@tiagotex]: https://github.com/tiagotex +[@wata727]: https://github.com/wata727 +[@marcandre]: https://github.com/marcandre +[@walf443]: https://github.com/walf443 +[@reitermarkus]: https://github.com/reitermarkus +[@chrishulton]: https://github.com/chrishulton +[@siegfault]: https://github.com/siegfault +[@melch]: https://github.com/melch +[@nattfodd]: https://github.com/nattfodd +[@flyerhzm]: https://github.com/flyerhzm +[@ybiquitous]: https://github.com/ybiquitous +[@mame]: https://github.com/mame +[@dominicsayers]: https://github.com/dominicsayers +[@albertpaulp]: https://github.com/albertpaulp +[@orgads]: https://github.com/orgads +[@leklund]: https://github.com/leklund +[@untitaker]: https://github.com/untitaker +[@walinga]: https://github.com/walinga +[@georf]: https://github.com/georf +[@Edouard-chin]: https://github.com/Edouard-chin +[@eostrom]: https://github.com/eostrom +[@roberts1000]: https://github.com/roberts1000 +[@satyap]: https://github.com/satyap +[@unkmas]: https://github.com/unkmas +[@elebow]: https://github.com/elebow +[@colorbox]: https://github.com/colorbox +[@mmyoji]: https://github.com/mmyoji +[@unused]: https://github.com/unused +[@htwroclau]: https://github.com/htwroclau +[@hamada14]: https://github.com/hamada14 +[@anthony-robin]: https://github.com/anthony-robin +[@YukiJikumaru]: https://github.com/YukiJikumaru +[@jlfaber]: https://github.com/jlfaber +[@drewpterry]: https://github.com/drewpterry +[@mcfisch]: https://github.com/mcfisch +[@istateside]: https://github.com/istateside +[@parkerfinch]: https://github.com/parkerfinch +[@joshuapinter]: https://github.com/joshuapinter +[@Darhazer]: https://github.com/Darhazer +[@Wei-LiangChew]: https://github.com/Wei-LiangChew +[@svendittmer]: https://github.com/svendittmer +[@composerinteralia]: https://github.com/composerinteralia +[@PointlessOne]: https://github.com/PointlessOne +[@JacobEvelyn]: https://github.com/JacobEvelyn +[@shanecav84]: https://github.com/shanecav84 +[@thomasbrus]: https://github.com/thomasbrus +[@balbesina]: https://github.com/balbesina +[@cupakromer]: https://github.com/cupakromer +[@TikiTDO]: https://github.com/TikiTDO +[@EiNSTeiN-]: https://github.com/EiNSTeiN- +[@nroman-stripe]: https://github.com/nroman-stripe +[@sunny]: https://github.com/sunny +[@tatsuyafw]: https://github.com/tatsuyafw +[@alexander-lazarov]: https://github.com/alexander-lazarov +[@r7kamura]: https://github.com/r7kamura +[@Vasfed]: https://github.com/Vasfed +[@drn]: https://github.com/drn +[@maxh]: https://github.com/maxh +[@kenman345]: https://github.com/kenman345 +[@nijikon]: https://github.com/nijikon +[@mikeyhew]: https://github.com/mikeyhew +[@mkenyon]: https://github.com/mkenyon +[@repinel]: https://github.com/repinel +[@gmalette]: https://github.com/gmalette +[@MagedMilad]: https://github.com/MagedMilad +[@robotdana]: https://github.com/robotdana +[@bacchir]: https://github.com/bacchir +[@khiav223577]: https://github.com/khiav223577 +[@schneems]: https://github.com/schneems +[@ShockwaveNN]: https://github.com/ShockwaveNN +[@Knack]: https://github.com/Knack +[@akanoi]: https://github.com/akanoi +[@yensaki]: https://github.com/yensaki +[@ryanhageman]: https://github.com/ryanhageman +[@autopp]: https://github.com/autopp +[@lukasz-wojcik]: https://github.com/lukasz-wojcik +[@albaer]: https://github.com/albaer +[@Kevinrob]: https://github.com/Kevinrob +[@andrew-aladev]: https://github.com/andrew-aladev +[@y-yagi]: https://github.com/y-yagi +[@DiscoStarslayer]: https://github.com/DiscoStarslayer +[@davearonson]: https://github.com/davearonson +[@timon]: https://github.com/timon +[@gsamokovarov]: https://github.com/gsamokovarov +[@itsWill]: https://github.com/itsWill +[@xlts]: https://github.com/xlts +[@takaram]: https://github.com/takaram +[@gmcgibbon]: https://github.com/gmcgibbon +[@dduugg]: https://github.com/dduugg +[@mmedal]: https://github.com/mmedal +[@timmcanty]: https://github.com/timmcanty +[@tom-lord]: https://github.com/tom-lord +[@bayandin]: https://github.com/bayandin +[@rspeicher]: https://github.com/rspeicher +[@nadiyaka]: https://github.com/nadiyaka +[@allcentury]: https://github.com/allcentury +[@antonzaytsev]: https://github.com/antonzaytsev +[@amatsuda]: https://github.com/amatsuda +[@Intrepidd]: https://github.com/Intrepidd +[@Ruffeng]: https://github.com/Ruffeng +[@roooodcastro]: https://github.com/roooodcastro +[@rmm5t]: https://github.com/rmm5t +[@marcotc]: https://github.com/marcotc +[@dazuma]: https://github.com/dazuma +[@dischorde]: https://github.com/dischorde +[@mhelmetag]: https://github.com/mhelmetag +[@Bhacaz]: https://github.com/bhacaz +[@enkessler]: https://github.com/enkessler +[@dcluna]: https://github.com/dcluna +[@tagliala]: https://github.com/tagliala +[@unasuke]: https://github.com/unasuke +[@elmasantos]: https://github.com/elmasantos +[@luciamo]: https://github.com/luciamo +[@dirtyharrycallahan]: https://github.com/dirtyharrycallahan +[@ericsullivan]: https://github.com/ericsullivan +[@aeroastro]: https://github.com/aeroastro +[@anuja-joshi]: https://github.com/anuja-joshi +[@XrXr]: https://github.com/XrXr +[@thomthom]: https://github.com/thomthom +[@Blue-Pix]: https://github.com/Blue-Pix +[@diachini]: https://github.com/diachini +[@Mange]: https://github.com/Mange +[@jmanian]: https://github.com/jmanian +[@vfonic]: https://github.com/vfonic +[@andreaseger]: https://github.com/andreaseger +[@yakout]: https://github.com/yakout +[@RicardoTrindade]: https://github.com/RicardoTrindade +[@att14]: https://github.com/att14 +[@houli]: https://github.com/houli +[@lavoiesl]: https://github.com/lavoiesl +[@fwininger]: https://github.com/fwininger +[@stoivo]: https://github.com/stoivo +[@eugeneius]: https://github.com/eugeneius +[@malyshkosergey]: https://github.com/malyshkosergey +[@fwitzke]: https://github.com/fwitzke +[@okuramasafumi]: https://github.com/okuramasafumi +[@buehmann]: https://github.com/buehmann +[@halfwhole]: https://github.com/halfwhole +[@riley-klingler]: https://github.com/riley-klingler +[@prathamesh-sonpatki]: https://github.com/prathamesh-sonpatki +[@raymondfallon]: https://github.com/raymondfallon +[@crojasaragonez]: https://github.com/crojasaragonez +[@desheikh]: https://github.com/desheikh +[@laurenball]: https://github.com/laurenball +[@jfhinchcliffe]: https://github.com/jfhinchcliffe +[@jdkaplan]: https://github.com/jdkaplan +[@cstyles]: https://github.com/cstyles +[@avmnu-sng]: https://github.com/avmnu-sng +[@denys281]: https://github.com/denys281 +[@tyler-ball]: https://github.com/tyler-ball +[@ayacai115]: https://github.com/ayacai115 +[@ozydingo]: https://github.com/ozydingo +[@movermeyer]: https://github.com/movermeyer +[@jethroo]: https://github.com/jethroo +[@mangara]: https://github.com/mangara +[@pirj]: https://github.com/pirj +[@pawptart]: https://github.com/pawptart +[@cetinajero]: https://github.com/cetinajero +[@gfyoung]: https://github.com/gfyoung +[@Tietew]: https://github.com/Tietew +[@hanachin]: https://github.com/hanachin +[@masarakki]: https://github.com/masarakki +[@djudd]: https://github.com/djudd +[@jemmaissroff]: https://github.com/jemmaissroff +[@nikitasakov]: https://github.com/nikitasakov +[@dmolesUC]: https://github.com/dmolesUC +[@yuritomanek]: https://github.com/yuritomanek +[@egze]: https://github.com/egze +[@rafaelfranca]: https://github.com/rafaelfranca +[@knu]: https://github.com/knu +[@saurabhmaurya15]: https://github.com/saurabhmaurya15 +[@DracoAter]: https://github.com/DracoAter +[@diogoosorio]: https://github.com/diogoosorio +[@jeffcarbs]: https://github.com/jeffcarbs +[@jcfausto]: https://github.com/jcfausto +[@laurmurclar]: https://github.com/laurmurclar +[@jethrodaniel]: https://github.com/jethrodaniel +[@CvX]: https://github.com/CvX +[@jschneid]: https://github.com/jschneid +[@ric2b]: https://github.com/ric2b +[@burnettk]: https://github.com/burnettk +[@andrykonchin]: https://github.com/andrykonchin +[@avrusanov]: https://github.com/avrusanov +[@mauro-oto]: https://github.com/mauro-oto +[@fatkodima]: https://github.com/fatkodima +[@karlwithak]: https://github.com/karlwithak +[@CamilleDrapier]: https://github.com/CamilleDrapier +[@shekhar-patil]: https://github.com/shekhar-patil +[@knejad]: https://github.com/knejad +[@iamravitejag]: https://github.com/iamravitejag +[@volfgox]: https://github.com/volfgox +[@colszowka]: https://github.com/colszowka +[@dsavochkin]: https://github.com/dmytro-savochkin +[@sonalinavlakhe]: https://github.com/sonalinavlakhe +[@wcmonty]: https://github.com/wcmonty +[@nguyenquangminh0711]: https://github.com/nguyenquangminh0711 +[@chocolateboy]: https://github.com/chocolateboy +[@Lykos]: https://github.com/Lykos +[@jaimerave]: https://github.com/jaimerave +[@Skipants]: https://github.com/Skipants +[@sascha-wolf]: https://github.com/sascha-wolf +[@fsateler]: https://github.com/fsateler +[@iSarCasm]: https://github.com/iSarCasm +[@em-gazelle]: https://github.com/em-gazelle +[@tleish]: https://github.com/tleish +[@pbernays]: https://github.com/pbernays +[@rdunlop]: https://github.com/rdunlop +[@ghiculescu]: https://github.com/ghiculescu +[@hatkyinc2]: https://github.com/hatkyinc2 +[@AllanSiqueira]: https://github.com/allansiqueira +[@zajn]: https://github.com/zajn +[@ysakasin]: https://github.com/ysakasin +[@matthieugendreau]: https://github.com/matthieugendreau +[@miry]: https://github.com/miry +[@lautis]: https://github.com/lautis +[@pdobb]: https://github.com/pdobb +[@HeroProtagonist]: https://github.com/HeroProtagonist +[@piotrmurach]: https://github.com/piotrmurach +[@javierav]: https://github.com/javierav +[@adrian-rivera]: https://github.com/adrian-rivera +[@ThomasKoppensteiner]: https://github.com/ThomasKoppensteiner +[@PhilCoggins]: https://github.com/PhilCoggins +[@tas50]: https://github.com/tas50 +[@dark-panda]: https://github.com/dark-panda +[@sswander]: https://github.com/sswander +[@makicamel]: https://github.com/makicamel +[@h-lame]: https://github.com/h-lame +[@agargiulo]: https://github.com/agargiulo +[@muirdm]: https://github.com/muirdm +[@noon-ng]: https://github.com/noon-ng +[@ohbarye]: https://github.com/ohbarye +[@magneland]: https://github.com/magneland +[@k-karen]: https://github.com/k-karen +[@uplus]: https://github.com/uplus +[@asterite]: https://github.com/asterite +[@AndreiEres]: https://github.com/AndreiEres +[@jdufresne]: https://github.com/jdufresne +[@adithyabsk]: https://github.com/adithyabsk +[@cteece]: https://github.com/ceteece +[@taichi-ishitani]: https://github.com/taichi-ishitani +[@cteece]: https://github.com/cteece +[@TSMMark]: https://github.com/TSMMark +[@caalberts]: https://github.com/caalberts +[@kachick]: https://github.com/kachick +[@corroded]: https://github.com/corroded +[@osyo-manga]: https://github.com/osyo-manga +[@ob-stripe]: https://github.com/ob-stripe +[@kwerle]: https://github.com/kwerle +[@RobinDaugherty]: https://github.com/RobinDaugherty +[@etiennebarrie]: https://github.com/etiennebarrie +[@Tonkpils]: https://github.com/Tonkpils +[@timlkelly]: https://github.com/timlkelly +[@AirWick219]: https://github.com/AirWick219 +[@markburns]: https://github.com/markburns +[@gregfletch]: https://github.com/gregfletch +[@thearjunmdas]: https://github.com/thearjunmdas +[@DanielVartanov]: https://github.com/DanielVartanov +[@splattael]: https://github.com/splattael +[@byroot]: https://github.com/byroot +[@itay-grudev]: https://github.com/itay-grudev +[@lilisako]: https://github.com/lilisako +[@Hugo-Hache]: https://github.com/Hugo-Hache +[@franzliedke]: https://github.com/franzliedke +[@Drowze]: https://github.com/Drowze +[@hirasawayuki]: https://github.com/hirasawayuki +[@grosser]: https://github.com/grosser +[@mttkay]: https://github.com/mttkay +[@leoarnold]: https://github.com/leoarnold +[@danieldiekmeier]: https://github.com/danieldiekmeier +[@joergschiller]: https://github.com/joergschiller +[@berkos]: https://github.com/berkos +[@nickpellant]: https://github.com/nickpellant +[@friendlyantz]: https://github.com/friendlyantz +[@issyl0]: https://github.com/issyl0 +[@ydah]: https://github.com/ydah +[@chrisseaton]: https://github.com/chrisseaton +[@nobuyo]: https://github.com/nobuyo +[@johnny-miyake]: https://github.com/johnny-miyake +[@joe-sharp]: https://github.com/joe-sharp +[@henrahmagix]: https://github.com/henrahmagix +[@chris-hewitt]: https://github.com/chris-hewitt +[@rickselby]: https://github.com/rickselby +[@zachahn]: https://github.com/zachahn +[@kaitielth]: https://github.com/kaitielth +[@j-miyake]: https://github.com/j-miyake +[@FnControlOption]: https://github.com/FnControlOption +[@ccutrer]: https://github.com/ccutrer +[@Korri]: https://github.com/Korri +[@ChrisBr]: https://github.com/ChrisBr +[@mollerhoj]: https://github.com/mollerhoj +[@mattbearman]: https://github.com/mattbearman +[@wjwh]: https://github.com/wjwh +[@jcalvert]: https://github.com/jcalvert +[@tsugimoto]: https://github.com/tsugimoto +[@srcoley]: https://github.com/srcoley +[@rdeckard]: https://github.com/rdeckard +[@wildmaples]: https://github.com/wildmaples +[@hosamaly]: https://github.com/hosamaly +[@si-lens]: https://github.com/si-lens +[@akihikodaki]: https://github.com/akihikodaki +[@epaew]: https://github.com/epaew +[@isarcasm]: https://github.com/isarcasm +[@noelblaschke]: https://github.com/noelblaschke +[@KirIgor]: https://github.com/KirIgor +[@tjschuck]: https://github.com/tjschuck +[@dukaev]: https://github.com/dukaev +[@arika]: https://github.com/arika +[@soroktree]: https://github.com/soroktree +[@alexevanczuk]: https://github.com/alexevanczuk +[@such]: https://github.com/such +[@krishanbhasin-shopify]: https://github.com/krishanbhasin-shopify +[@f1sherman]: https://github.com/f1sherman +[@jaynetics]: https://github.com/jaynetics +[@SparLaimor]: https://github.com/SparLaimor +[@bfad]: https://github.com/bfad +[@istvanfazakas]: https://github.com/istvanfazakas +[@KessaPassa]: https://github.com/KessaPassa +[@jasondoc3]: https://github.com/jasondoc3 +[@ThHareau]: https://github.com/ThHareau +[@ktopolski]: https://github.com/ktopolski +[@Bhacaz]: https://github.com/Bhacaz +[@naveg]: https://github.com/naveg +[@lucthev]: https://github.com/lucthev +[@nevans]: https://github.com/nevans +[@iMacTia]: https://github.com/iMacTia +[@rwstauner]: https://github.com/rwstauner +[@catwomey]: https://github.com/catwomey +[@alexeyschepin]: https://github.com/alexeyschepin +[@meric426]: https://github.com/meric426 +[@loveo]: https://github.com/loveo +[@p0deje]: https://github.com/p0deje +[@bigzed]: https://github.com/bigzed +[@OwlKing]: https://github.com/OwlKing +[@ItsEcholot]: https://github.com/ItsEcholot +[@ymap]: https://github.com/ymap +[@aboutNisblee]: https://github.com/aboutNisblee +[@K-S-A]: https://github.com/K-S-A +[@earlopain]: https://github.com/earlopain +[@kpost]: https://github.com/kpost +[@marocchino]: https://github.com/marocchino +[@Strzesia]: https://github.com/Strzesia +[@maruth-stripe]: https://github.com/maruth-stripe +[@jenshenny]: https://github.com/jenshenny +[@davidrunger]: https://github.com/davidrunger +[@viralpraxis]: https://github.com/viralpraxis +[@artur-intech]: https://github.com/artur-intech +[@amomchilov]: https://github.com/amomchilov +[@Hiroto-Iizuka]: https://github.com/Hiroto-Iizuka +[@boardfish]: https://github.com/boardfish +[@muxcmux]: https://github.com/muxcmux +[@nekketsuuu]: https://github.com/nekketsuuu +[@pawelma]: https://github.com/pawelma +[@krororo]: https://github.com/krororo +[@ksss]: https://github.com/ksss +[@vlad-pisanov]: https://github.com/vlad-pisanov +[@protocol7]: https://github.com/protocol7 +[@zopolis4]: https://github.com/zopolis4 +[@tk0miya]: https://github.com/tk0miya +[@masato-bkn]: https://github.com/masato-bkn +[@pCosta99]: https://github.com/pCosta99 +[@kotaro0522]: https://github.com/kotaro0522 +[@gemmaro]: https://github.com/gemmaro +[@dak2]: https://github.com/dak2 +[@d4be4st]: https://github.com/d4be4st +[@lovro-bikic]: https://github.com/lovro-bikic +[@aduth]: https://github.com/aduth +[@isuckatcs]: https://github.com/isuckatcs +[@GabeIsman]: https://github.com/GabeIsman +[@mrzasa]: https://github.com/mrzasa +[@corsonknowles]: https://github.com/corsonknowles +[@elliottt]: https://github.com/elliottt +[@kyanagi]: https://github.com/kyanagi +[@capncavedan]: https://github.com/capncavedan +[@d4rky-pl]: https://github.com/d4rky-pl +[@vinistock]: https://github.com/vinistock +[@datpmt]: https://github.com/datpmt +[@jtannas]: https://github.com/jtannas +[@flavorjones]: https://github.com/flavorjones +[@sferik]: https://github.com/sferik +[@Morriar]: https://github.com/Morriar +[@daisuke]: https://github.com/daisuke +[@steiley]: https://github.com/steiley +[@ka8725]: https://github.com/ka8725 +[@ssagara00]: https://github.com/ssagara00 +[@niranjan-patil]: https://github.com/niranjan-patil +[@Yuhi-Sato]: https://github.com/Yuhi-Sato +[@5hun-s]: https://github.com/5hun-s +[@girasquid]: https://github.com/girasquid diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000000..f6fe800ad07a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,14 @@ +# The RuboCop Community Code of Conduct + +**Note:** We have picked the following code of conduct based on [Ruby's own code of conduct](https://www.ruby-lang.org/en/conduct/). + +This document provides a few simple community guidelines for a safe, respectful, +productive, and collaborative place for any person who is willing to contribute +to the RuboCop community. It applies to all "collaborative spaces", which are +defined as community communications channels (such as mailing lists, submitted +patches, commit comments, etc.). + +* Participants will be tolerant of opposing views. +* Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks. +* When interpreting the words and actions of others, participants should always assume good intentions. +* Behavior which can be reasonably considered harassment will not be tolerated. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 37c0251257ed..b80f42fa30b6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,54 +15,104 @@ do so. complete sentences. * Include the output of `rubocop -V`: -``` +```console $ rubocop -V -0.16.0 (using Parser 2.1.2, running on ruby 2.0.0 x86_64-darwin12.4.0) +1.79.0 (using Parser 3.3.5.0, rubocop-ast 1.32.3, analyzing as Ruby 3.3, running on ruby 3.3.5) [x86_64-linux] + - rubocop-performance 1.22.1 + - rubocop-rspec 3.1.0 ``` * Include any relevant code to the issue summary. ## Pull requests -* Read [how to properly contribute to open source projects on Github][2]. +* Read [how to properly contribute to open source projects on GitHub][2]. * Fork the project. +* If you're adding or making changes to cops, read the [Development docs](https://docs.rubocop.org/rubocop/development.html) * Use a topic/feature branch to easily amend a pull request later, if necessary. * Write [good commit messages][3]. * Use the same coding conventions as the rest of the project. * Commit and push until you are happy with your contribution. +* If your change has a corresponding open GitHub issue, prefix the commit message with `[Fix #github-issue-number]`. * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. -* Add an entry to the [Changelog](CHANGELOG.md) accordingly. See [changelog entry format](#changelog-entry-format). +* Add a changelog entry by creating a file `changelog/{type}_{some_description}.md`. See [changelog entry format](#changelog-entry-format) for details. * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. -* Make sure the test suite is passing ([including rbx and jruby][7]) and the code you wrote doesn't produce - RuboCop offenses. +* Make sure the test suite is passing and the code you wrote doesn't produce + RuboCop offenses (usually this is as simple as running `bundle exec rake`). * [Squash related commits together][5]. * Open a [pull request][4] that relates to *only* one subject with a clear title and description in grammatically correct, complete sentences. +### Spell Checking + +We are running [misspell](https://github.com/client9/misspell) which is mainly written in +[Golang](https://golang.org/) to check spelling with [GitHub Actions](https://github.com/rubocop/rubocop/blob/master/.github/workflows/spell_checking.yml). +Correct commonly misspelled English words quickly with `misspell`. `misspell` is different from most other spell checkers +because it doesn't use a custom dictionary. You can run `misspell` locally against all files with: + +```console +$ find . -type f | xargs ./misspell -i 'enviromnent' -error +``` + +Notable `misspell` help options or flags are: + +* `-i` string: ignore the following corrections, comma separated +* `-w`: Overwrite file with corrections (default is just to display) + +We also run [codespell](https://github.com/codespell-project/codespell) with GitHub Actions to check spelling and +[codespell](https://pypi.org/project/codespell/) runs against a [small custom dictionary](https://github.com/rubocop/rubocop/blob/master/.codespellrc). + +If you have `codespell` locally available in your `$PATH`, `bundle exec rake` will run it for you. + +### Linting YAML files + +We are running [yamllint](https://github.com/adrienverge/yamllint) for linting YAML files. This is also run by [GitHub Actions](https://github.com/rubocop/rubocop/blob/master/.github/workflows/linting.yml). +`yamllint` is written in [Python](https://www.python.org/) and you can run it with: + +```console +$ yamllint . +``` + +### Creating changelog entries + +Changelog entries are just files under the `changelog/` folder that will be merged +into `CHANGELOG.md` at release time. You can create new changelog entries like this: + +```console +$ bundle exec rake changelog:new +$ bundle exec rake changelog:fix +$ bundle exec rake changelog:change +``` + +Those commands correspond to "new feature", "bug-fix" and "changed" entries in the changelog. + +Of course, you can also create the changelog entries files manually as well. +Just make sure they are properly named. + ### Changelog entry format Here are a few examples: -``` -* [#716](https://github.com/bbatsov/rubocop/issues/716): Fixed a regression in the auto-correction logic of `MethodDefParentheses`. ([@bbatsov][]) -* New cop `ElseLayout` checks for odd arrangement of code in the `else` branch of a conditional expression. ([@bbatsov][]) +```markdown +* [#716](https://github.com/rubocop/rubocop/issues/716): Fixed a regression in the autocorrection logic of `MethodDefParentheses`. ([@bbatsov][]) +* [#7542](https://github.com/rubocop/rubocop/pull/7542): **(Breaking)** Move `LineLength` cop from `Metrics` department to `Layout` department. ([@koic][]) ``` +* Create one file `changelog/{type}_{some_description}.md`, where `type` is `new` (New feature), `fix` or `change`, and `some_description` is unique to avoid conflicts. Task `changelog:fix` (or `:new` or `:change`) can help you. * Mark it up in [Markdown syntax][6]. -* The entry line should start with `* ` (an asterisk and a space). -* If the change has a related GitHub issue (e.g. a bug fix for a reported issue), put a link to the issue as `[#123](https://github.com/bbatsov/rubocop/issues/123): `. +* The entry should be a single line, starting with `* ` (an asterisk and a space). +* If the change has a related GitHub issue (e.g. a bug fix for a reported issue), put a link to the issue as `[#123](https://github.com/rubocop/rubocop/issues/123): `. * Describe the brief of the change. The sentence should end with a punctuation. +* If this is a breaking change, mark it with `**(Breaking)**`. * At the end of the entry, add an implicit link to your GitHub user page as `([@username][])`. -* If this is your first contribution to RuboCop project, add a link definition for the implicit link to the bottom of the changelog as `[@username]: https://github.com/username`. -[1]: https://github.com/bbatsov/rubocop/issues -[2]: http://gun.io/blog/how-to-github-fork-branch-and-pull-request -[3]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html -[4]: https://help.github.com/articles/using-pull-requests +[1]: https://github.com/rubocop/rubocop/issues +[2]: https://www.gun.io/blog/how-to-github-fork-branch-and-pull-request +[3]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html +[4]: https://help.github.com/articles/about-pull-requests [5]: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html -[6]: http://daringfireball.net/projects/markdown/syntax -[7]: http://blog.stwrt.ca/2013/09/06/installing-rubinius-with-rbenv +[6]: https://daringfireball.net/projects/markdown/syntax diff --git a/Gemfile b/Gemfile index c90bc0a595a6..b58437810048 100644 --- a/Gemfile +++ b/Gemfile @@ -1,16 +1,33 @@ -# encoding: utf-8 +# frozen_string_literal: true source 'https://rubygems.org' gemspec +gem 'asciidoctor' +gem 'bump', require: false +gem 'bundler', '>= 1.15.0', '< 3.0' +gem 'fiddle', platform: :windows if RUBY_VERSION >= '3.4' +gem 'irb' +gem 'memory_profiler', '!= 1.0.2', platform: :mri +gem 'rake', '~> 13.0' +gem 'rspec', '~> 3.7' +gem 'rubocop-performance', '~> 1.25.0' +gem 'rubocop-rake', '~> 0.7.0' +gem 'rubocop-rspec', '~> 3.6.0' +# Ruby LSP supports Ruby 3.0+. +gem 'ruby-lsp', '~> 0.24', platform: :mri if RUBY_VERSION >= '3.0' +gem 'simplecov', '~> 0.20' +gem 'stackprof', platform: :mri +gem 'test-queue' +gem 'yard', '~> 0.9' + group :test do - gem 'coveralls', require: false - gem 'safe_yaml', require: false + gem 'webmock', require: false end -local_gemfile = 'Gemfile.local' +local_ast = File.expand_path('../rubocop-ast', __dir__) +gem 'rubocop-ast', path: local_ast if Dir.exist? local_ast -if File.exist?(local_gemfile) - eval(File.read(local_gemfile)) # rubocop:disable Lint/Eval -end +local_gemfile = File.expand_path('Gemfile.local', __dir__) +eval_gemfile local_gemfile if File.exist?(local_gemfile) diff --git a/LICENSE.txt b/LICENSE.txt index c07ee63434fe..314ec16a9508 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2012-14 Bozhidar Batsov +Copyright (c) 2012-25 Bozhidar Batsov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index a8f61dff6428..6e890e3db3f3 100644 --- a/README.md +++ b/README.md @@ -1,950 +1,137 @@ -[![Gem Version](https://badge.fury.io/rb/rubocop.svg)](http://badge.fury.io/rb/rubocop) -[![Dependency Status](https://gemnasium.com/bbatsov/rubocop.svg)](https://gemnasium.com/bbatsov/rubocop) -[![Build Status](https://travis-ci.org/bbatsov/rubocop.svg?branch=master)](https://travis-ci.org/bbatsov/rubocop) -[![Coverage Status](http://img.shields.io/coveralls/bbatsov/rubocop/master.svg)](https://coveralls.io/r/bbatsov/rubocop) -[![Code Climate](https://codeclimate.com/github/bbatsov/rubocop/badges/gpa.svg)](https://codeclimate.com/github/bbatsov/rubocop) -[![Inline docs](http://inch-ci.org/github/bbatsov/rubocop.svg)](http://inch-ci.org/github/bbatsov/rubocop) -

- RuboCop Logo + RuboCop Logo

+---------- +[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop) +[![Gem Version](https://badge.fury.io/rb/rubocop.svg)](https://badge.fury.io/rb/rubocop) +[![CI](https://github.com/rubocop/rubocop/actions/workflows/rubocop.yml/badge.svg)](https://github.com/rubocop/rubocop/actions/workflows/rubocop.yml) +[![Test Coverage](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/test_coverage)](https://codeclimate.com/github/rubocop/rubocop/test_coverage) +[![Maintainability](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/maintainability)](https://codeclimate.com/github/rubocop/rubocop/maintainability) +[![Discord](https://img.shields.io/badge/chat-on%20discord-7289da.svg?sanitize=true)](https://discord.gg/wJjWvGRDmm) + > Role models are important.
> -- Officer Alex J. Murphy / RoboCop -**RuboCop** is a Ruby static code analyzer. Out of the box it will -enforce many of the guidelines outlined in the community -[Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide). - -Most aspects of its behavior can be tweaked via various -[configuration options](https://github.com/bbatsov/rubocop/blob/master/config/default.yml). - -Apart from reporting problems in your code, RuboCop can also -automatically fix some of the problems for you. - -[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bbatsov/rubocop?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -You can support my work on RuboCop via -[Salt](https://salt.bountysource.com/teams/rubocop) and -[Gratipay](https://www.gratipay.com/rubocop). - -[![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/rubocop) - -**This documentation tracks the `master` branch of RuboCop. Some of -the features and settings discussed here might not be available in -older releases (including the current stable release). Please, consult -the relevant git tag (e.g. v0.30.0) if you need documentation for a -specific RuboCop release.** - -- [Installation](#installation) -- [Basic Usage](#basic-usage) - - [Cops](#cops) - - [Style](#style) - - [Lint](#lint) - - [Metrics](#metrics) - - [Rails](#rails) -- [Configuration](#configuration) - - [Inheritance](#inheritance) - - [Defaults](#defaults) - - [Including/Excluding files](#includingexcluding-files) - - [Generic configuration parameters](#generic-configuration-parameters) - - [Automatically Generated Configuration](#automatically-generated-configuration) -- [Disabling Cops within Source Code](#disabling-cops-within-source-code) -- [Formatters](#formatters) - - [Progress Formatter (default)](#progress-formatter-default) - - [Clang Style Formatter](#clang-style-formatter) - - [Fuubar Style Formatter](#fuubar-style-formatter) - - [Emacs Style Formatter](#emacs-style-formatter) - - [Simple Formatter](#simple-formatter) - - [File List Formatter](#file-list-formatter) - - [JSON Formatter](#json-formatter) - - [Offense Count Formatter](#offense-count-formatter) - - [HTML Formatter](#html-formatter) -- [Compatibility](#compatibility) -- [Editor integration](#editor-integration) - - [Emacs](#emacs) - - [Vim](#vim) - - [Sublime Text](#sublime-text) - - [Brackets](#brackets) - - [TextMate2](#textmate2) - - [Atom](#atom) - - [LightTable](#lighttable) - - [RubyMine](#rubymine) - - [Other Editors](#other-editors) -- [Git pre-commit hook integration](#git-pre-commit-hook-integration) -- [Guard integration](#guard-integration) -- [Rake integration](#rake-integration) -- [Caching](#caching) - - [Cache Validity](#cache-validity) - - [Enabling and Disabling the Cache](#enabling-and-disabling-the-cache) - - [Cache Path](#cache-path) - - [Cache Pruning](#cache-pruning) -- [Extensions](#extensions) - - [Loading Extensions](#loading-extensions) - - [Custom Cops](#custom-cops) - - [Known Custom Cops](#known-custom-cops) - - [Custom Formatters](#custom-formatters) - - [Creating Custom Formatter](#creating-custom-formatter) - - [Using Custom Formatter in Command Line](#using-custom-formatter-in-command-line) -- [Team](#team) -- [Logo](#logo) -- [Contributors](#contributors) -- [Mailing List](#mailing-list) -- [Changelog](#changelog) -- [Copyright](#copyright) - -## Installation - -**RuboCop**'s installation is pretty standard: - -``` -$ gem install rubocop -``` - -If you'd rather install RuboCop using `bundler`, don't require it in your `Gemfile`: - -``` -gem 'rubocop', require: false -``` - -## Basic Usage - -Running `rubocop` with no arguments will check all Ruby source files -in the current directory: - -``` -$ rubocop -``` - -Alternatively you can pass `rubocop` a list of files and directories to check: - -``` -$ rubocop app spec lib/something.rb -``` - -Here's RuboCop in action. Consider the following Ruby source code: - -```ruby -def badName - if something - test - end -end -``` - -Running RuboCop on it (assuming it's in a file named `test.rb`) would produce the following report: - -``` -Inspecting 1 file -W - -Offenses: - -test.rb:1:5: C: Use snake_case for method names. -def badName - ^^^^^^^ -test.rb:2:3: C: Use a guard clause instead of wrapping the code inside a conditional expression. - if something - ^^ -test.rb:2:3: C: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||. - if something - ^^ -test.rb:4:5: W: end at 4, 4 is not aligned with if at 2, 2 - end - ^^^ - -1 file inspected, 4 offenses detected -``` - -For more details check the available command-line options: - -``` -$ rubocop -h -``` - -Command flag | Description ---------------------------|------------------------------------------------------------ -`-v/--version` | Displays the current version and exits. -`-V/--verbose-version` | Displays the current version plus the version of Parser and Ruby. -`-L/--list-target-files` | List all files RuboCop will inspect. -`-F/--fail-fast` | Inspects in modification time order and stops after first file with offenses. -`-C/--cache` | Store and reuse results for faster operation. -`-d/--debug` | Displays some extra debug output. -`-D/--display-cop-names` | Displays cop names in offense messages. -`-c/--config` | Run with specified config file. -`-f/--format` | Choose a formatter. -`-o/--out` | Write output to a file instead of STDOUT. -`-r/--require` | Require Ruby file (see [Loading Extensions](#loading-extensions)). -`-R/--rails` | Run extra Rails cops. -`-l/--lint` | Run only lint cops. -`-a/--auto-correct` | Auto-correct certain offenses. *Note:* Experimental - use with caution. -`--only` | Run only the specified cop(s) and/or cops in the specified departments. -`--except` | Run all cops enabled by configuration except the specified cop(s) and/or departments. -`--auto-gen-config` | Generate a configuration file acting as a TODO list. -`--exclude-limit` | Limit how many individual files `--auto-gen-config` can list in `Exclude` parameters, default is 15. -`--show-cops` | Shows available cops and their configuration. -`--fail-level` | Minimum [severity](#severity) for exit with error code. Full severity name or upper case initial can be given. Normally, auto-corrected offenses are ignored. Use `A` or `autocorrect` if you'd like them to trigger failure. -`-s/--stdin` | Pipe source from STDIN. This is useful for editor integration. - -### Cops - -In RuboCop lingo the various checks performed on the code are called cops. There are several cop departments. - -You can also load [custom cops](#custom-cops). - -#### Style - -Most of the cops in RuboCop are so called style cops that check for -stylistics problems in your code. Almost all of the them are based on -the Ruby Style Guide. Many of the style cops have configurations -options allowing them to support different popular coding -conventions. - -#### Lint - -Lint cops check for possible errors and very bad practices in your -code. RuboCop implements in a portable way all built-in MRI lint -checks (`ruby -wc`) and adds a lot of extra lint checks of its -own. You can run only the lint cops like this: - -``` -$ rubocop -l -``` - -The `-l`/`--lint` option can be used together with `--only` to run all the -enabled lint cops plus a selection of other cops. - -Disabling any of the lint cops is generally a bad idea. - -#### Metrics - -Metrics cops deal with properties of the source code that can be measured, -such as class length, method length, etc. Generally speaking, they have a -configuration parameter called `Max` and when running -`rubocop --auto-gen-config`, this parameter will be set to the highest value -found for the inspected code. - -#### Rails - -Rails cops are specific to the Ruby on Rails framework. Unlike style -and lint cops they are not used by default and you have to request them -specifically: - -``` -$ rubocop -R -``` - -or add the following directive to your `.rubocop.yml`: - -```yaml -AllCops: - RunRailsCops: true -``` - -## Configuration - -The behavior of RuboCop can be controlled via the -[.rubocop.yml](https://github.com/bbatsov/rubocop/blob/master/.rubocop.yml) -configuration file. It makes it possible to enable/disable certain cops -(checks) and to alter their behavior if they accept any parameters. The file -can be placed either in your home directory or in some project directory. - -RuboCop will start looking for the configuration file in the directory -where the inspected file is and continue its way up to the root directory. - -The file has the following format: - -```yaml -inherit_from: ../.rubocop.yml - -Style/Encoding: - Enabled: false - -Metrics/LineLength: - Max: 99 -``` - -**Note**: Qualifying cop name with its type, e.g., `Style`, is recommended, - but not necessary as long as the cop name is unique across all types. - -### Inheritance - -The optional `inherit_from` directive is used to include configuration -from one or more files. This makes it possible to have the common -project settings in the `.rubocop.yml` file at the project root, and -then only the deviations from those rules in the subdirectories. The -files can be given with absolute paths or paths relative to the file -where they are referenced. The settings after an `inherit_from` -directive override any settings in the file(s) inherited from. When -multiple files are included, the first file in the list has the lowest -precedence and the last one has the highest. The format for multiple -inheritance is: - -```yaml -inherit_from: - - ../.rubocop.yml - - ../conf/.rubocop.yml -``` - -### Defaults - -The file -[config/default.yml](https://github.com/bbatsov/rubocop/blob/master/config/default.yml) -under the RuboCop home directory contains the default settings that -all configurations inherit from. Project and personal `.rubocop.yml` -files need only make settings that are different from the default -ones. If there is no `.rubocop.yml` file in the project or home -directory, `config/default.yml` will be used. - -### Including/Excluding files - -RuboCop checks all files found by a recursive search starting from the -directory it is run in, or directories given as command line -arguments. However, it only recognizes files ending with `.rb` or -extensionless files with a `#!.*ruby` declaration as Ruby files. -Hidden directories (i.e., directories whose names start with a dot) -are not searched by default. If you'd like it to check files that are -not included by default, you'll need to pass them in on the command -line, or to add entries for them under `AllCops`/`Include`. Files and -directories can also be ignored through `AllCops`/`Exclude`. - -Here is an example that might be used for a Rails project: - -```yaml -AllCops: - Include: - - '**/Rakefile' - - '**/config.ru' - Exclude: - - 'db/**/*' - - 'config/**/*' - - 'script/**/*' - - !ruby/regexp /old_and_unused\.rb$/ - -# other configuration -# ... -``` - -Files and directories are specified relative to the `.rubocop.yml` file. - -**Note**: Patterns that are just a file name, e.g. `Rakefile`, will match -that file name in any directory, but this pattern style deprecated. The -correct way to match the file in any directory, including the current, is -`**/Rakefile`. - -**Note**: The pattern `config/**` will match any file recursively under -`config`, but this pattern style is deprecated and should be replaced by -`config/**/*`. - -**Note**: The `Include` and `Exclude` parameters are special. They are -valid for the directory tree starting where they are defined. They are not -shadowed by the setting of `Include` and `Exclude` in other `.rubocop.yml` -files in subdirectories. This is different from all other parameters, who -follow RuboCop's general principle that configuration for an inspected file -is taken from the nearest `.rubocop.yml`, searching upwards. - -Cops can be run only on specific sets of files when that's needed (for -instance you might want to run some Rails model checks only on files whose -paths match `app/models/*.rb`). All cops support the -`Include` param. - -```yaml -Rails/DefaultScope: - Include: - - app/models/*.rb -``` - -Cops can also exclude only specific sets of files when that's needed (for -instance you might want to run some cop only on a specific file). All cops support the -`Exclude` param. - -```yaml -Rails/DefaultScope: - Exclude: - - app/models/problematic.rb -``` - -### Generic configuration parameters - -In addition to `Include` and `Exclude`, the following parameters are available -for every cop. - -#### Enabled - -Specific cops can be disabled by setting `Enabled` to `false` for that specific cop. - -```yaml -Metrics/LineLength: - Enabled: false -``` - -Most cops are enabled by default. Some cops, configured in [config/disabled.yml](https://github.com/bbatsov/rubocop/blob/master/config/disabled.yml), are disabled by default. The cop enabling process can be altered by setting `DisabledByDefault` to `true`. - -```yaml -AllCops: - DisabledByDefault: true -``` - -All cops are then disabled by default, and only cops appearing in user configuration files are enabled. `Enabled: true` does not have to be set for cops in user configuration. They will be enabled anyway. - -#### Severity - -Each cop has a default severity level based on which department it belongs -to. The level is `warning` for `Lint` and `convention` for all the others. -Cops can customize their severity level. Allowed params are `refactor`, -`convention`, `warning`, `error` and `fatal`. - -There is one exception from the general rule above and that is `Lint/Syntax`, a -special cop that checks for syntax errors before the other cops are invoked. It -can not be disabled and its severity (`fatal`) can not be changed in -configuration. - -```yaml -Metrics/CyclomaticComplexity: - Severity: warning -``` - -#### AutoCorrect - -Cops that support the `--auto-correct` option can have that support -disabled. For example: - -```yaml -Style/PerlBackrefs: - AutoCorrect: false -``` - -### Automatically Generated Configuration - -If you have a code base with an overwhelming amount of offenses, it can -be a good idea to use `rubocop --auto-gen-config` and add an -`inherit_from: .rubocop_todo.yml` in your `.rubocop.yml`. The generated -file `.rubocop_todo.yml` contains configuration to disable cops that -currently detect an offense in the code by excluding the offending -files, or disabling the cop altogether once a file count limit has been -reached. - -By adding the option `--exclude-limit COUNT`, e.g., `rubocop ---auto-gen-config --exclude-limit 5`, you can change how many files are -excluded before the cop is entirely disabled. The default COUNT is 15. - -Then you can start removing the entries in the generated -`.rubocop_todo.yml` file one by one as you work through all the offenses -in the code. - -## Disabling Cops within Source Code - -One or more individual cops can be disabled locally in a section of a -file by adding a comment such as - -```ruby -# rubocop:disable Metrics/LineLength, Style/StringLiterals -[...] -# rubocop:enable Metrics/LineLength, Style/StringLiterals -``` - -You can also disable *all* cops with - -```ruby -# rubocop:disable all -[...] -# rubocop:enable all -``` - -One or more cops can be disabled on a single line with an end-of-line -comment. - -```ruby -for x in (0..19) # rubocop:disable Style/AvoidFor -``` - -## Formatters +**RuboCop** is a Ruby static code analyzer (a.k.a. `linter`) and code formatter. Out of the box it +will enforce many of the guidelines outlined in the community [Ruby Style +Guide](https://rubystyle.guide). Apart from reporting the problems discovered in your code, +RuboCop can also automatically fix many of them for you. -You can change the output format of RuboCop by specifying formatters with the `-f/--format` option. -RuboCop ships with several built-in formatters, and also you can create your custom formatter. +RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various +[configuration options](https://github.com/rubocop/rubocop/blob/master/config/default.yml). -Additionally the output can be redirected to a file instead of `$stdout` with the `-o/--out` option. +---------- +[![Patreon](https://img.shields.io/badge/patreon-donate-orange.svg)](https://www.patreon.com/bbatsov) +[![OpenCollective](https://opencollective.com/rubocop/backers/badge.svg)](#open-collective-for-individuals) +[![OpenCollective](https://opencollective.com/rubocop/sponsors/badge.svg)](#open-collective-for-organizations) +[![Tidelift](https://tidelift.com/badges/package/rubygems/rubocop)](https://tidelift.com/subscription/pkg/rubygems-rubocop?utm_source=rubygems-rubocop&utm_medium=referral&utm_campaign=readme) -Some of the built-in formatters produce **machine-parsable** output -and they are considered public APIs. -The rest of the formatters are for humans, so parsing their outputs is discouraged. +Working on RuboCop is often fun, but it also requires a great deal of time and energy. -You can enable multiple formatters at the same time by specifying `-f/--format` multiple times. -The `-o/--out` option applies to the previously specified `-f/--format`, -or the default `progress` format if no `-f/--format` is specified before the `-o/--out` option. +**Please consider [financially supporting its ongoing development](#funding).** -```bash -# Simple format to $stdout. -$ rubocop --format simple - -# Progress (default) format to the file result.txt. -$ rubocop --out result.txt - -# Both progress and offense count formats to $stdout. -# The offense count formatter outputs only the final summary, -# so you'll mostly see the outputs from the progress formatter, -# and at the end the offense count summary will be outputted. -$ rubocop --format progress --format offenses - -# Progress format to $stdout, and JSON format to the file rubocop.json. -$ rubocop --format progress --format json --out rubocop.json -# ~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ -# | |_______________| -# $stdout - -# Progress format to result.txt, and simple format to $stdout. -$ rubocop --output result.txt --format simple -# ~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ -# | | -# default format $stdout -``` - -You can also load [custom formatters](#custom-formatters). - -### Progress Formatter (default) - -The default `progress` formatter outputs a character for each inspected file, -and at the end it displays all detected offenses in the `clang` format. -A `.` represents a clean file, and each of the capital letters means -the severest offense (convention, warning, error or fatal) found in a file. - -``` -$ rubocop -Inspecting 26 files -..W.C....C..CWCW.C...WC.CC - -Offenses: - -lib/foo.rb:6:5: C: Missing top-level class documentation comment. - class Foo - ^^^^^ - -... - -26 files inspected, 46 offenses detected -``` - -### Clang Style Formatter - -The `clang` formatter displays the offenses in a manner similar to `clang`: - -``` -$ rubocop test.rb -Inspecting 1 file -W - -Offenses: - -test.rb:1:5: C: Use snake_case for method names. -def badName - ^^^^^^^ -test.rb:2:3: C: Use a guard clause instead of wrapping the code inside a conditional expression. - if something - ^^ -test.rb:2:3: C: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||. - if something - ^^ -test.rb:4:5: W: end at 4, 4 is not aligned with if at 2, 2 - end - ^^^ - -1 file inspected, 4 offenses detected -``` - -### Fuubar Style Formatter - -The `fuubar` style formatter displays a progress bar -and shows details of offenses in the `clang` format as soon as they are detected. -This is inspired by the [Fuubar](https://github.com/jeffkreeftmeijer/fuubar) formatter for RSpec. - -``` -$ rubocop --format fuubar -lib/foo.rb.rb:1:1: C: Use snake_case for methods and variables. -def badName - ^^^^^^^ -lib/bar.rb:13:14: W: File.exists? is deprecated in favor of File.exist?. - File.exists?(path) - ^^^^^^^ - 22/53 files |======== 43 ========> | ETA: 00:00:02 -``` - -### Emacs Style Formatter - -**Machine-parsable** - -The `emacs` formatter displays the offenses in a format suitable for consumption by `Emacs` (and possibly other tools). - -``` -$ rubocop --format emacs test.rb -/Users/bozhidar/projects/test.rb:1:1: C: Use snake_case for methods and variables. -/Users/bozhidar/projects/test.rb:2:3: C: Favor modifier if/unless usage when you have a single-line body. Another good alternative is the usage of control flow &&/||. -/Users/bozhidar/projects/test.rb:4:5: W: end at 4, 4 is not aligned with if at 2, 2 -``` - -### Simple Formatter - -The name of the formatter says it all :-) - -``` -$ rubocop --format simple test.rb -== test.rb == -C: 1: 5: Use snake_case for method names. -C: 2: 3: Use a guard clause instead of wrapping the code inside a conditional expression. -C: 2: 3: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||. -W: 4: 5: end at 4, 4 is not aligned with if at 2, 2 - -1 file inspected, 4 offenses detected -``` - -### File List Formatter - - **Machine-parsable** - -Sometimes you might want to just open all files with offenses in your -favorite editor. This formatter outputs just the names of the files -with offenses in them and makes it possible to do something like: - -``` -$ rubocop --format files | xargs vim -``` - -### JSON Formatter - -**Machine-parsable** - -You can get RuboCop's inspection result in JSON format by passing `--format json` option in command line. -The JSON structure is like the following example: - -```javascript -{ - "metadata": { - "rubocop_version": "0.9.0", - "ruby_engine": "ruby", - "ruby_version": "2.0.0", - "ruby_patchlevel": "195", - "ruby_platform": "x86_64-darwin12.3.0" - }, - "files": [{ - "path": "lib/foo.rb", - "offenses": [] - }, { - "path": "lib/bar.rb", - "offenses": [{ - "severity": "convention", - "message": "Line is too long. [81/80]", - "cop_name": "LineLength", - "corrected": true, - "location": { - "line": 546, - "column": 80, - "length": 4 - } - }, { - "severity": "warning", - "message": "Unreachable code detected.", - "cop_name": "UnreachableCode", - "corrected": false, - "location": { - "line": 15, - "column": 9, - "length": 10 - } - } - ] - } - ], - "summary": { - "offense_count": 2, - "target_file_count": 2, - "inspected_file_count": 2 - } -} -``` - -### Offense Count Formatter - -Sometimes when first applying RuboCop to a codebase, it's nice to be able to -see where most of your style cleanup is going to be spent. +## Installation -With this in mind, you can use the offense count formatter to outline the offended -cops and the number of offenses found for each by running: +**RuboCop**'s installation is pretty standard: -``` -$ rubocop --format offenses - -87 Documentation -12 DotPosition -8 AvoidGlobalVars -7 EmptyLines -6 AssignmentInCondition -4 Blocks -4 CommentAnnotation -3 BlockAlignment -1 IndentationWidth -1 AvoidPerlBackrefs -1 ColonMethodCall --- -134 Total +```sh +gem install rubocop ``` -### HTML Formatter +If you'd rather install RuboCop using `bundler`, add a line for it in your +`Gemfile` (but set the `require` option to `false`, as it is a standalone tool): -Useful for CI environments. It will create an HTML report like [this](http://f.cl.ly/items/0M3029412x3O091a1X1R/expected.html). - -``` -$ rubocop --format html -o rubocop.html +```rb +gem 'rubocop', require: false ``` -## Compatibility - -RuboCop supports the following Ruby implementations: - -* MRI 1.9.3 -* MRI 2.0 -* MRI 2.1 -* MRI 2.2 -* JRuby in 1.9 mode -* Rubinius 2.0+ - -## Editor integration - -### Emacs - -[rubocop.el](https://github.com/bbatsov/rubocop-emacs) is a simple -Emacs interface for RuboCop. It allows you to run RuboCop inside Emacs -and quickly jump between problems in your code. - -[flycheck](https://github.com/lunaryorn/flycheck) > 0.9 also supports -RuboCop and uses it by default when available. - -### Vim - -The [vim-rubocop](https://github.com/ngmy/vim-rubocop) plugin runs -RuboCop and displays the results in Vim. - -There's also a RuboCop checker in -[syntastic](https://github.com/scrooloose/syntastic). - -### Sublime Text - -If you're a ST user you might find the -[Sublime RuboCop plugin](https://github.com/pderichs/sublime_rubocop) -useful. - -### Brackets - -The [brackets-rubocop](https://github.com/smockle/brackets-rubocop) -extension displays RuboCop results in Brackets. -It can be installed via the extension manager in Brackets. - -### TextMate2 - -The [textmate2-rubocop](https://github.com/mrdougal/textmate2-rubocop) -bundle displays formatted RuboCop results in a new window. -Installation instructions can be found [here](https://github.com/mrdougal/textmate2-rubocop#installation). - -### Atom - -The [atom-lint](https://github.com/yujinakayama/atom-lint) package -runs RuboCop and highlights the offenses in Atom. - -You can also use the [linter-rubocop](https://github.com/AtomLinter/linter-rubocop) -plugin for Atom's [linter](https://github.com/AtomLinter/Linter). - -### LightTable - -The [lt-rubocop](https://github.com/seancaffery/lt-rubocop) plugin -provides LightTable integration. - -### RubyMine +RuboCop is stable between minor versions, both in terms of API and cop configuration. +We aim to ease the maintenance of RuboCop extensions and the upgrades between RuboCop +releases. All big changes are reserved for major releases. +To prevent an unwanted RuboCop update you might want to use a conservative version lock +in your `Gemfile`: -The [rubocop-for-rubymine](https://github.com/sirlantis/rubocop-for-rubymine) plugin -provides basic RuboCop integration for RubyMine/IntelliJ IDEA. - -### Other Editors - -Here's one great opportunity to contribute to RuboCop - implement -RuboCop integration for your favorite editor. - -## Git pre-commit hook integration - -[overcommit](https://github.com/brigade/overcommit) is a fully configurable and -extendable Git commit hook manager. To use RuboCop with overcommit, add the -following to your `.overcommit.yml` file: - -```yaml -PreCommit: - RuboCop: - enabled: true +```rb +gem 'rubocop', '~> 1.79', require: false ``` -## Guard integration - -If you're fond of [Guard](https://github.com/guard/guard) you might -like -[guard-rubocop](https://github.com/yujinakayama/guard-rubocop). It -allows you to automatically check Ruby code style with RuboCop when -files are modified. - +See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details. -## Rake integration +## Quickstart -To use RuboCop in your `Rakefile` add the following: - -```ruby -require 'rubocop/rake_task' - -RuboCop::RakeTask.new -``` - -If you run `rake -T`, the following two RuboCop tasks should show up: +Just type `rubocop` in a Ruby project's folder and watch the magic happen. ```sh -rake rubocop # Run RuboCop -rake rubocop:auto_correct # Auto-correct RuboCop offenses +cd my/cool/ruby/project +rubocop ``` -The above will use default values +> [!TIP] +> +> You can also use this magic in your favorite editor with RuboCop's +> [built-in LSP server](https://docs.rubocop.org/rubocop/usage/lsp.html). -```ruby -require 'rubocop/rake_task' +## Documentation -desc 'Run RuboCop on the lib directory' -RuboCop::RakeTask.new(:rubocop) do |task| - task.patterns = ['lib/**/*.rb'] - # only show the files with failures - task.formatters = ['files'] - # don't abort rake on failure - task.fail_on_error = false -end -``` +You can read a lot more about RuboCop in its [official docs](https://docs.rubocop.org). -## Caching - -Large projects containing hundreds or even thousands of files can take -a really long time to inspect, but RuboCop has functionality to -mitigate this problem. There's a caching mechanism that stores -information about offenses found in inspected files. - -### Cache Validity - -Later runs will be able to retrieve this information and present the -stored information instead of inspecting the file again. This will be -done if the cache for the file is still valid, which it is if there -are no changes in: -* the contents of the inspected file -* RuboCop configuration for the file -* the options given to `rubocop`, with some exceptions that have no - bearing on which offenses are reported -* version of the `rubocop` program (or to be precise, anything in the - source code of the invoked `rubocop` program) - -### Enabling and Disabling the Cache - -The caching functionality is enabled if the configuration parameter -`AllCops: UseCache` is `true`, which it is by default. The command -line option `--cache false` can be used to turn off caching, thus -overriding the configuration parameter. If `AllCops: UseCache` is set -to `false` in the local `.rubocop.yml`, then it's `--cache true` that -overrides the setting. - -### Cache Path - -By default, the cache is stored in in a subdirectory of the temporary -directory, `/tmp/rubocop_cache/` on Unix-like systems. The -configuration parameter `AllCops: CacheRootDirectory` can be used to -set it to a different path. One reason to use this option could be -that there's a network disk where users on different machines want to -have a common RuboCop cache. Another could be that a Continuous -Integration system allows directories, but not a temporary directory, -to be saved between runs. - -### Cache Pruning - -Each time a file has changed, its offenses will be stored under a new -key in the cache. This means that the cache will continue to grow -until we do something to stop it. The configuration parameter -`AllCops: MaxFilesInCache` sets a limit, and when the number of files -in the cache exceeds that limit, the oldest files will be automatially -removed from the cache. - -## Extensions - -It's possible to extend RuboCop with custom cops and formatters. - -### Loading Extensions - -Besides the `--require` command line option you can also specify ruby -files that should be loaded with the optional `require` directive in the -`.rubocop.yml` file: - -```yaml -require: - - ../my/custom/file.rb - - rubocop-extension -``` - -Note: The paths are directly passed to `Kernel.require`. If your -extension file is not in `$LOAD_PATH`, you need to specify the path as -relative path prefixed with `./` explicitly, or absolute path. - -### Custom Cops - -You can configure the custom cops in your `.rubocop.yml` just like any -other cop. +## Compatibility -#### Known Custom Cops +RuboCop officially supports the following runtime Ruby implementations: -* [rubocop-rspec](https://github.com/nevir/rubocop-rspec) - - RSpec-specific analysis +* MRI 2.7+ +* JRuby 9.4+ -### Custom Formatters +It targets Ruby 2.0+ for code analysis. -You can customize RuboCop's output format with custom formatters. +See the [compatibility documentation](https://docs.rubocop.org/rubocop/compatibility.html) for further details. -#### Creating Custom Formatter +## Readme Badge -To implement a custom formatter, you need to subclass -`RuboCop::Formatter::BaseFormatter` and override some methods, -or implement all formatter API methods by duck typing. +If you use RuboCop in your project, you can include one of these badges in your readme to let people know that your code is written following the community Ruby Style Guide. -Please see the documents below for more formatter API details. +[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop) -* [RuboCop::Formatter::BaseFormatter](http://rubydoc.info/gems/rubocop/RuboCop/Formatter/BaseFormatter) -* [RuboCop::Cop::Offense](http://rubydoc.info/gems/rubocop/RuboCop/Cop/Offense) -* [Parser::Source::Range](http://rubydoc.info/github/whitequark/parser/Parser/Source/Range) +[![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide) -#### Using Custom Formatter in Command Line +Here are the Markdown snippets for the two badges: -You can tell RuboCop to use your custom formatter with a combination of -`--format` and `--require` option. -For example, when you have defined `MyCustomFormatter` in -`./path/to/my_custom_formatter.rb`, you would type this command: +``` markdown +[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop) -``` -$ rubocop --require ./path/to/my_custom_formatter --format MyCustomFormatter +[![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide) ``` ## Team Here's a list of RuboCop's core developers: -* [Bozhidar Batsov](https://github.com/bbatsov) +* [Bozhidar Batsov](https://github.com/bbatsov) (author & head maintainer) * [Jonas Arvidsson](https://github.com/jonas054) -* [Yuji Nakayama](https://github.com/yujinakayama) -* [Evgeni Dzhelyov](https://github.com/edzhelyov) +* [Yuji Nakayama](https://github.com/yujinakayama) (retired) +* [Evgeni Dzhelyov](https://github.com/edzhelyov) (retired) +* [Ted Johansson](https://github.com/drenmi) +* [Masataka Kuwabara](https://github.com/pocke) (retired) +* [Koichi Ito](https://github.com/koic) +* [Maxim Krizhanovski](https://github.com/darhazer) +* [Benjamin Quorning](https://github.com/bquorning) +* [Marc-André Lafortune](https://github.com/marcandre) +* [Daniel Vandersluis](https://github.com/dvandersluis) + +See the [team page](https://docs.rubocop.org/rubocop/about/team.html) for more details. ## Logo RuboCop's logo was created by [Dimiter Petrov](https://www.chadomoto.com/). You can find the logo in various -formats [here](https://github.com/bbatsov/rubocop/tree/master/logo). +formats [here](https://github.com/rubocop/rubocop/tree/master/logo). The logo is licensed under a -[Creative Commons Attribution-NonCommercial 4.0 International License](http://creativecommons.org/licenses/by-nc/4.0/deed.en_GB). +[Creative Commons Attribution-NonCommercial 4.0 International License](https://creativecommons.org/licenses/by-nc/4.0/deed.en_GB). ## Contributors -Here's a [list](https://github.com/bbatsov/rubocop/contributors) of +Here's a [list](https://github.com/rubocop/rubocop/graphs/contributors) of all the people who have contributed to the development of RuboCop. I'm extremely grateful to each and every one of them! @@ -959,27 +146,112 @@ priority right now. Writing a new cop is a great way to dive into RuboCop! Of course, bug reports and suggestions for improvements are always welcome. GitHub pull requests are even better! :-) -You can also support my work on RuboCop via -[Salt](https://salt.bountysource.com/teams/rubocop) and -[Gratipay](https://www.gratipay.com/rubocop). - -[![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/rubocop) - -## Mailing List - -If you're interested in everything regarding RuboCop's development, -consider joining its -[Google Group](https://groups.google.com/forum/?fromgroups#!forum/rubocop). - -## Freenode - -If you're into IRC you can visit the `#rubocop` channel on Freenode. - -## Changelog - -RuboCop's changelog is available [here](CHANGELOG.md). +## Funding + +While RuboCop is free software and will always be, the project would benefit immensely from some funding. +Raising a monthly budget of a couple of thousand dollars would make it possible to pay people to work on +certain complex features, fund other development related stuff (e.g. hardware, conference trips) and so on. +Raising a monthly budget of over $5000 would open the possibility of someone working full-time on the project +which would speed up the pace of development significantly. + +We welcome both individual and corporate sponsors! We also offer a +wide array of funding channels to account for your preferences +(although +currently [Open Collective](https://opencollective.com/rubocop) is our +preferred funding platform). + +**If you're working in a company that's making significant use of RuboCop we'd +appreciate it if you suggest to your company to become a RuboCop sponsor.** + +You can support the development of RuboCop via +[GitHub Sponsors](https://github.com/sponsors/bbatsov), +[Patreon](https://www.patreon.com/bbatsov), +[PayPal](https://paypal.me/bbatsov), +[Open Collective](https://opencollective.com/rubocop) +and [Tidelift](https://tidelift.com/subscription/pkg/rubygems-rubocop?utm_source=rubygems-rubocop&utm_medium=referral&utm_campaign=readme) +. + +> [!NOTE] +> +> If doing a sponsorship in the form of donation is problematic for your company +> from an accounting standpoint, we'd recommend the use of Tidelift, where you +> can get a support-like subscription instead. + +### Open Collective for Individuals + +Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/rubocop#backer)] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +### Open Collective for Organizations + +Become a sponsor and get your logo on our README on GitHub with a link to your site. [[Become a sponsor](https://opencollective.com/rubocop#sponsor)] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## Release Notes + +RuboCop's release notes are available [here](https://github.com/rubocop/rubocop/releases). ## Copyright -Copyright (c) 2012-2015 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for +Copyright (c) 2012-2025 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for further details. diff --git a/Rakefile b/Rakefile index 1ddcf4bf1dc5..94168d20fcdb 100644 --- a/Rakefile +++ b/Rakefile @@ -1,48 +1,90 @@ -# encoding: utf-8 +# frozen_string_literal: true + +# For code coverage measurements to work properly, `SimpleCov` should be loaded +# and started before any application code is loaded. +require 'simplecov' if ENV['COVERAGE'] + +desc 'Check for no pending changelog entries before release' +task release: 'changelog:check_clean' # Before task is required -require 'rubygems' require 'bundler' require 'bundler/gem_tasks' begin Bundler.setup(:default, :development) rescue Bundler::BundlerError => e - $stderr.puts e.message - $stderr.puts 'Run `bundle install` to install missing gems' + warn e.message + warn 'Run `bundle install` to install missing gems' exit e.status_code end require 'rake' -require 'rspec/core' -require 'rspec/core/rake_task' require 'rubocop/rake_task' -RSpec::Core::RakeTask.new(:spec) -desc 'Run RSpec with code coverage' -task :coverage do - ENV['COVERAGE'] = 'true' - Rake::Task['spec'].execute -end +Dir['tasks/**/*.rake'].each { |t| load t } desc 'Run RuboCop over itself' RuboCop::RakeTask.new(:internal_investigation) -task default: [:spec, :internal_investigation] +# The `ascii_spec` task has not been failing for a while, so it will not be run by default. +# However, `ascii_spec` task will continue to be checked in CI. If there are any failures +# originating from `ascii_spec` in CI, please run `bundle exec ascii_spec` to investigate. +task default: %i[codespell documentation_syntax_check spec prism_spec internal_investigation] require 'yard' YARD::Rake::YardocTask.new -begin - require 'coveralls/rake/task' - Coveralls::RakeTask.new -rescue LoadError - warn 'Coveralls rake task is not loaded. Only for test' -end +desc 'Syntax check for the documentation comments' +task documentation_syntax_check: :yard_for_generate_documentation do + require 'parser/ruby25' + require 'parser/ruby26' + require 'parser/ruby27' + + ok = true + YARD::Registry.load! + cops = RuboCop::Cop::Registry.global + cops.each do |cop| + next if %i[RSpec Capybara FactoryBot].include?(cop.department) + + examples = YARD::Registry.all(:class).find do |code_object| + next unless RuboCop::Cop::Badge.for(code_object.to_s) == cop.badge + + break code_object.tags('example') + end + + examples.each do |example| + buffer = Parser::Source::Buffer.new('', 1) + buffer.source = example.text + + # Ruby 2.6 or higher does not support a syntax used in + # `Lint/UselessElseWithoutRescue` cop's example. + parser = if cop == RuboCop::Cop::Lint::UselessElseWithoutRescue + Parser::Ruby25.new(RuboCop::AST::Builder.new) + # Ruby 2.7 raises a syntax error in + # `Lint/CircularArgumentReference` cop's example. + elsif cop == RuboCop::Cop::Lint::CircularArgumentReference + Parser::Ruby26.new(RuboCop::AST::Builder.new) + # Ruby 3.0 raises a syntax error in + # `Lint/NumberedParameterAssignment` cop's example. + elsif cop == RuboCop::Cop::Lint::NumberedParameterAssignment + Parser::Ruby27.new(RuboCop::AST::Builder.new) + else + Prism::Translation::Parser35.new(RuboCop::AST::BuilderPrism.new) + end + parser.diagnostics.all_errors_are_fatal = true + parser.parse(buffer) + rescue Parser::SyntaxError => e + path = example.object.file + line, column = buffer.decompose_position(e.diagnostic.location.begin_pos) + indentation = ' ' * column + highlight = '^' * Unicode::DisplayWidth.of(e.diagnostic.location.source) -RuboCop::RakeTask.new + warn Rainbow(<<~MESSAGE).red + #{path}:#{line}:#{column} Syntax Error in an example: #{e} + #{buffer.source_lines[line - 1]} + #{indentation + highlight} + MESSAGE -task :console do - require 'irb' - require 'irb/completion' - require 'rubocop' - ARGV.clear - IRB.start + ok = false + end + end + abort unless ok end diff --git a/assets/output.css.erb b/assets/output.css.erb new file mode 100644 index 000000000000..71e12cc2ffbc --- /dev/null +++ b/assets/output.css.erb @@ -0,0 +1,159 @@ +* { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +body, html { + font-size: 62.5%; +} +body { + background-color: #ecedf0; + font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; + margin: 0; +} +code { + font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; + font-size: 85%; +} +#header { + background: #f9f9f9; + color: #333; + border-bottom: 3px solid #ccc; + height: 50px; + padding: 0; +} +#header .logo { + float: left; + margin: 5px 12px 7px 20px; + width: 38px; + height: 38px; +} +#header .title { + display: inline-block; + float: left; + height: 50px; + font-size: 2.4rem; + letter-spacing: normal; + line-height: 50px; + margin: 0; +} + +.information, #offenses { + width: 100%; + padding: 20px; + color: #333; +} +#offenses { + padding: 0 20px; +} + +.information .infobox { + border-left: 3px solid; + border-radius: 4px; + background-color: #fff; + -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); + padding: 15px; + border-color: #0088cc; + font-size: 1.4rem; +} +.information .infobox .info-title { + font-size: 1.8rem; + line-height: 2.2rem; + margin: 0 0 0.5em; +} +.information .offenses-list li { + line-height: 1.8rem +} +.information .offenses-list { + padding-left: 20px; + margin-bottom: 0; +} + +#offenses .offense-box { + border-radius: 4px; + margin-bottom: 20px; + background-color: #fff; + -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); +} +.fixed .box-title { + position: fixed; + top: 0; + z-index: 10; + width: 100%; +} +.box-title-placeholder { + display: none; +} +.fixed .box-title-placeholder { + display: block; +} +#offenses .offense-box .box-title h3, #offenses .offense-box .box-title-placeholder h3 { + color: #33353f; + background-color: #f6f6f6; + font-size: 2rem; + line-height: 2rem; + display: block; + padding: 15px; + border-radius: 5px; + margin: 0; +} +#offenses .offense-box .offense-reports { + padding: 0 15px; +} +#offenses .offense-box .offense-reports .report { + border-bottom: 1px dotted #ddd; + padding: 15px 0px; + position: relative; + font-size: 1.3rem; +} +#offenses .offense-box .offense-reports .report:last-child { + border-bottom: none; +} +#offenses .offense-box .offense-reports .report pre code { + display: block; + background: #000; + color: #fff; + padding: 10px 15px; + border-radius: 5px; + line-height: 1.6rem; +} +#offenses .offense-box .offense-reports .report .location { + font-weight: bold; +} +#offenses .offense-box .offense-reports .report .message code { + padding: 0.3em; + background-color: rgba(0,0,0,0.07); + border-radius: 3px; +} +.severity { + text-transform: capitalize; + font-weight: bold; +} +.highlight { + padding: 2px; + border-radius: 2px; + font-weight: bold; +} +<%- SEVERITY_COLORS.each do |severity, color| %> +.severity.<%= severity %> { + color: <%= color %>; +} +.highlight.<%= severity %> { + background-color: <%= color.fade_out(0.4) %>; + border: 1px solid <%= color.fade_out(0.6) %>; +} +<%- end %> +footer { + margin-bottom: 20px; + margin-right: 20px; + font-size: 1.3rem; + color: #777; + text-align: right; +} +.extra-code { + color: #ED9C28 +} + diff --git a/assets/output.html.erb b/assets/output.html.erb index 94129454744b..02d0c78306be 100644 --- a/assets/output.html.erb +++ b/assets/output.html.erb @@ -3,153 +3,49 @@ RuboCop Inspection Report - <%# TODO: Clean up the messy markup and style definitions. %> +
- <%= pluralize(files.count, 'file') %> inspected, - <%= pluralize(summary.offense_count, 'offense', no_for_zero: true) %> detected +
+ <%= pluralize(files.count, 'file') %> inspected, + <%= pluralize(summary.offense_count, 'offense', no_for_zero: true) %> detected: +
+
<% files.each do |file| %> <% if file.offenses.any? %> -
+
+

 

<%= relative_path(file.path) %> - <%= pluralize(file.offenses.count, 'offense') %>

<% file.offenses.each do |offense| %> @@ -186,7 +95,7 @@ <% end %>
- Generated by RuboCop + Generated by RuboCop <%= RuboCop::Version::STRING %>
diff --git a/bin/console b/bin/console new file mode 100755 index 000000000000..a85f2f8207f7 --- /dev/null +++ b/bin/console @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'bundler/setup' +require 'irb' +require 'rubocop' +require 'rubocop/server' + +ARGV.clear + +IRB.start(__FILE__) diff --git a/bin/rubocop b/bin/rubocop deleted file mode 100755 index 4a2a61e84124..000000000000 --- a/bin/rubocop +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env ruby -# encoding: utf-8 - -$LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib') - -require 'rubocop' -require 'benchmark' - -cli = RuboCop::CLI.new -result = 0 - -time = Benchmark.realtime do - result = cli.run -end - -puts "Finished in #{time} seconds" if cli.options[:debug] -exit result diff --git a/bin/setup b/bin/setup new file mode 100755 index 000000000000..54e9ac36d7a4 --- /dev/null +++ b/bin/setup @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install diff --git a/changelog/.gitkeep b/changelog/.gitkeep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/changelog/fix_false_positives_for_lint_useless_assignment.md b/changelog/fix_false_positives_for_lint_useless_assignment.md new file mode 100644 index 000000000000..db0a079b3bab --- /dev/null +++ b/changelog/fix_false_positives_for_lint_useless_assignment.md @@ -0,0 +1 @@ +* [#14383](https://github.com/rubocop/rubocop/issues/14383): Fix false positives for `Lint/UselessAssignment` when duplicate assignments in `if` branch inside a loop. ([@koic][]) diff --git a/config/default.yml b/config/default.yml index cb41ba153bb9..8da5bab53461 100644 --- a/config/default.yml +++ b/config/default.yml @@ -1,75 +1,915 @@ -# This is the default configuration file. Enabling and disabling is configured -# in separate files. This file adds all other parameters apart from Enabled. - -inherit_from: - - enabled.yml - - disabled.yml - # Common configuration. + AllCops: + RubyInterpreters: + - ruby + - macruby + - rake + - jruby + - rbx # Include common Ruby source files. Include: + - '**/*.rb' + - '**/*.arb' + - '**/*.axlsx' + - '**/*.builder' + - '**/*.fcgi' + - '**/*.gemfile' - '**/*.gemspec' - - '**/*.podspec' + - '**/*.god' + - '**/*.jb' - '**/*.jbuilder' - - '**/*.rake' + - '**/*.mspec' - '**/*.opal' - - '**/config.ru' - - '**/Gemfile' - - '**/Rakefile' + - '**/*.pluginspec' + - '**/*.podspec' + - '**/*.rabl' + - '**/*.rake' + - '**/*.rbuild' + - '**/*.rbw' + - '**/*.rbx' + - '**/*.ru' + - '**/*.ruby' + - '**/*.schema' + - '**/*.spec' + - '**/*.thor' + - '**/*.watchr' + - '**/.irbrc' + - '**/.pryrc' + - '**/.simplecov' + - '**/buildfile' + - '**/Appraisals' + - '**/Berksfile' + - '**/Brewfile' + - '**/Buildfile' - '**/Capfile' + - '**/Cheffile' + - '**/Dangerfile' + - '**/Deliverfile' + - '**/Fastfile' + - '**/*Fastfile' + - '**/Gemfile' - '**/Guardfile' + - '**/Jarfile' + - '**/Mavenfile' - '**/Podfile' + - '**/Puppetfile' + - '**/Rakefile' + - '**/rakefile' + - '**/Schemafile' + - '**/Snapfile' + - '**/Steepfile' - '**/Thorfile' - - '**/Vagrantfile' - - '**/Berksfile' - - '**/Cheffile' - '**/Vagabondfile' + - '**/Vagrantfile' Exclude: + - 'node_modules/**/*' + - 'tmp/**/*' - 'vendor/**/*' - # By default, the rails cops are not run. Override in project or home - # directory .rubocop.yml files, or by giving the -R/--rails option. - RunRailsCops: false - # Cop names are not displayed in offense messages by default. Change behavior - # by overriding DisplayCopNames, or by giving the -D/--display-cop-names + - '.git/**/*' + # Default formatter will be used if no `-f/--format` option is given. + DefaultFormatter: progress + # Cop names are displayed in offense messages by default. Change behavior + # by overriding DisplayCopNames, or by giving the `--no-display-cop-names` # option. - DisplayCopNames: false + DisplayCopNames: true # Style guide URLs are not displayed in offense messages by default. Change - # behavior by overriding DisplayStyleGuide, or by giving the - # -S/--display-style-guide option. + # behavior by overriding `DisplayStyleGuide`, or by giving the + # `-S/--display-style-guide` option. DisplayStyleGuide: false + # When specifying style guide URLs, any paths and/or fragments will be + # evaluated relative to the base URL. + StyleGuideBaseURL: https://rubystyle.guide + # Documentation URLs will be constructed using the base URL. + DocumentationBaseURL: https://docs.rubocop.org/rubocop + # Documentation URLs will end with this extension. + DocumentationExtension: .html + # Extra details are not displayed in offense messages by default. Change + # behavior by overriding ExtraDetails, or by giving the + # `-E/--extra-details` option. + ExtraDetails: false # Additional cops that do not reference a style guide rule may be enabled by - # default. Change behavior by overriding StyleGuideCopsOnly, or by giving - # the --only-guide-cops option. + # default. Change behavior by overriding `StyleGuideCopsOnly`, or by giving + # the `--only-guide-cops` option. StyleGuideCopsOnly: false - # All cops except the ones in disabled.yml are enabled by default. Change - # this behavior by overriding DisabledByDefault. When DisabledByDefault is - # true, all cops in the default configuration are disabled, and and only cops - # in user configuration are enabled. This makes cops opt-in instead of - # opt-out. Note that when DisabledByDefault is true, cops in user - # configuration will be enabled even if they don't set the Enabled parameter. + # All cops except the ones configured `Enabled: false` in this file are enabled by default. + # Change this behavior by overriding either `DisabledByDefault` or `EnabledByDefault`. + # When `DisabledByDefault` is `true`, all cops in the default configuration + # are disabled, and only cops in user configuration are enabled. This makes + # cops opt-in instead of opt-out. Note that when `DisabledByDefault` is `true`, + # cops in user configuration will be enabled even if they don't set the + # Enabled parameter. + # When `EnabledByDefault` is `true`, all cops, even those configured `Enabled: false` + # in this file are enabled by default. Cops can still be disabled in user configuration. + # Note that it is invalid to set both EnabledByDefault and DisabledByDefault + # to true in the same configuration. + EnabledByDefault: false DisabledByDefault: false - # Enables the result cache if true. Can be overridden by the --cache command + # New cops introduced between major versions are set to a special pending status + # and are not enabled by default with warning message. + # Change this behavior by overriding either `NewCops: enable` or `NewCops: disable`. + # When `NewCops` is `enable`, pending cops are enabled in bulk. Can be overridden by + # the `--enable-pending-cops` command-line option. + # When `NewCops` is `disable`, pending cops are disabled in bulk. Can be overridden by + # the `--disable-pending-cops` command-line option. + NewCops: pending + # Enables the result cache if `true`. Can be overridden by the `--cache` command # line option. UseCache: true # Threshold for how many files can be stored in the result cache before some # of the files are automatically removed. MaxFilesInCache: 20000 - # The cache will be stored in "rubocop_cache" under this directory. The name - # "/tmp" is special and will be converted to the system temporary directory, - # which is "/tmp" on Unix-like systems, but could be something else on other - # systems. - CacheRootDirectory: /tmp - -# Indent private/protected/public as deep as method definitions -Style/AccessModifierIndentation: + # The cache will be stored in "rubocop_cache" under this directory. If + # CacheRootDirectory is ~ (nil), which it is by default, the root will be + # taken from the environment variable `$XDG_CACHE_HOME` if it is set, or if + # `$XDG_CACHE_HOME` is not set, it will be `$HOME/.cache/`. + # The CacheRootDirectory can be overwritten by passing the `--cache-root` command + # line option or by setting `$RUBOCOP_CACHE_ROOT` environment variable. + CacheRootDirectory: ~ + # It is possible for a malicious user to know the location of RuboCop's cache + # directory by looking at CacheRootDirectory, and create a symlink in its + # place that could cause RuboCop to overwrite unintended files, or read + # malicious input. If you are certain that your cache location is secure from + # this kind of attack, and wish to use a symlinked cache location, set this + # value to "true". + AllowSymlinksInCacheRootDirectory: false + # What MRI version of the Ruby interpreter is the inspected code intended to + # run on? (If there is more than one, set this to the lowest version.) + # If a value is specified for TargetRubyVersion then it is used. Acceptable + # values are specified as a float (i.e. 3.0); the teeny version of Ruby + # should not be included. If the project specifies a Ruby version in the + # .tool-versions or .ruby-version files, Gemfile or gems.rb file, RuboCop will + # try to determine the desired version of Ruby by inspecting the + # .tool-versions file first, then .ruby-version, followed by the Gemfile.lock + # or gems.locked file. (Although the Ruby version is specified in the Gemfile + # or gems.rb file, RuboCop reads the final value from the lock file.) If the + # Ruby version is still unresolved, RuboCop will use the oldest officially + # supported Ruby version (currently Ruby 2.7). + TargetRubyVersion: ~ + # RuboCop choses the parser engine automatically but you can also specify it yourself. + # These options are available: + # - `default` + # - `parser_whitequark` ... https://github.com/whitequark/parser + # - `parser_prism` ... https://github.com/ruby/prism (`Prism::Translation::Parser`) + # Not every parser engine can handle every `TargetRubyVersion`. `parser_whitequark` + # only works with versions 3.4 and below, `parser_prism` with versions 3.3 and above. + ParserEngine: default + # Determines if a notification for extension libraries should be shown when + # rubocop is run. Keys are the name of the extension, and values are an array + # of gems in the Gemfile that the extension is suggested for, if not already + # included. + SuggestExtensions: + rubocop-rails: [rails] + rubocop-rspec: [rspec, rspec-rails] + rubocop-minitest: [minitest] + rubocop-sequel: [sequel] + rubocop-rake: [rake] + rubocop-graphql: [graphql] + rubocop-capybara: [capybara] + rubocop-factory_bot: [factory_bot, factory_bot_rails] + rubocop-rspec_rails: [rspec-rails] + # Enable/Disable checking the methods extended by Active Support. + ActiveSupportExtensionsEnabled: false + # Future version of Ruby will freeze string literals by default. + # This allows to opt in early, for example when enabled through RUBYOPT. + # For now this will behave as if set to false but in future ruby versions + # (likely 4.0) it will be true by default. + StringLiteralsFrozenByDefault: ~ + +#################### Bundler ############################### + +Bundler/DuplicatedGem: + Description: 'Checks for duplicate gem entries in Gemfile.' + Enabled: true + Severity: warning + VersionAdded: '0.46' + VersionChanged: '1.40' + Include: + - '**/*.gemfile' + - '**/Gemfile' + - '**/gems.rb' + +Bundler/DuplicatedGroup: + Description: 'Checks for duplicate group entries in Gemfile.' + Enabled: true + Severity: warning + VersionAdded: '1.56' + Include: + - '**/*.gemfile' + - '**/Gemfile' + - '**/gems.rb' + +Bundler/GemComment: + Description: 'Add a comment describing each gem.' + Enabled: false + VersionAdded: '0.59' + VersionChanged: '0.85' + Include: + - '**/*.gemfile' + - '**/Gemfile' + - '**/gems.rb' + IgnoredGems: [] + OnlyFor: [] + +Bundler/GemFilename: + Description: 'Enforces the filename for managing gems.' + Enabled: true + VersionAdded: '1.20' + EnforcedStyle: 'Gemfile' + SupportedStyles: + - 'Gemfile' + - 'gems.rb' + Include: + - '**/Gemfile' + - '**/gems.rb' + - '**/Gemfile.lock' + - '**/gems.locked' + +Bundler/GemVersion: + Description: 'Requires or forbids specifying gem versions.' + Enabled: false + VersionAdded: '1.14' + EnforcedStyle: 'required' + SupportedStyles: + - 'required' + - 'forbidden' + Include: + - '**/*.gemfile' + - '**/Gemfile' + - '**/gems.rb' + AllowedGems: [] + +Bundler/InsecureProtocolSource: + Description: >- + The source `:gemcutter`, `:rubygems` and `:rubyforge` are deprecated + because HTTP requests are insecure. Please change your source to + 'https://rubygems.org' if possible, or 'http://rubygems.org' if not. + Enabled: true + Severity: warning + VersionAdded: '0.50' + VersionChanged: '1.40' + AllowHttpProtocol: true + Include: + - '**/*.gemfile' + - '**/Gemfile' + - '**/gems.rb' + +Bundler/OrderedGems: + Description: >- + Gems within groups in the Gemfile should be alphabetically sorted. + Enabled: true + VersionAdded: '0.46' + VersionChanged: '0.47' + TreatCommentsAsGroupSeparators: true + # By default, "-" and "_" are ignored for order purposes. + # This can be overridden by setting this parameter to true. + ConsiderPunctuation: false + Include: + - '**/*.gemfile' + - '**/Gemfile' + - '**/gems.rb' + +#################### Gemspec ############################### + +Gemspec/AddRuntimeDependency: + Description: 'Prefer `add_dependency` over `add_runtime_dependency`.' + StyleGuide: '#add_dependency_vs_add_runtime_dependency' + References: + - https://github.com/rubygems/rubygems/issues/7799#issuecomment-2192720316 + Enabled: pending + VersionAdded: '1.65' + Include: + - '**/*.gemspec' + +Gemspec/AttributeAssignment: + Description: 'Use consistent style for Gemspec attributes assignment.' + Enabled: pending + VersionAdded: '1.77' + Include: + - '**/*.gemspec' + +Gemspec/DependencyVersion: + Description: 'Requires or forbids specifying gem dependency versions.' + Enabled: false + VersionAdded: '1.29' + EnforcedStyle: 'required' + SupportedStyles: + - 'required' + - 'forbidden' + Include: + - '**/*.gemspec' + AllowedGems: [] + +Gemspec/DeprecatedAttributeAssignment: + Description: Checks that deprecated attribute assignments are not set in a gemspec file. + Enabled: pending + Severity: warning + VersionAdded: '1.30' + VersionChanged: '1.40' + Include: + - '**/*.gemspec' + +Gemspec/DevelopmentDependencies: + Description: Checks that development dependencies are specified in Gemfile rather than gemspec. + Enabled: pending + VersionAdded: '1.44' + EnforcedStyle: Gemfile + SupportedStyles: + - Gemfile + - gems.rb + - gemspec + AllowedGems: [] + Include: + - '**/*.gemspec' + - '**/Gemfile' + - '**/gems.rb' + +Gemspec/DuplicatedAssignment: + Description: 'An attribute assignment method calls should be listed only once in a gemspec.' + Enabled: true + Severity: warning + VersionAdded: '0.52' + VersionChanged: '1.40' + Include: + - '**/*.gemspec' + +Gemspec/OrderedDependencies: + Description: >- + Dependencies in the gemspec should be alphabetically sorted. + Enabled: true + VersionAdded: '0.51' + TreatCommentsAsGroupSeparators: true + # By default, "-" and "_" are ignored for order purposes. + # This can be overridden by setting this parameter to true. + ConsiderPunctuation: false + Include: + - '**/*.gemspec' + +Gemspec/RequireMFA: + Description: 'Checks that the gemspec has metadata to require Multi-Factor Authentication from RubyGems.' + Enabled: pending + Severity: warning + VersionAdded: '1.23' + VersionChanged: '1.40' + References: + - https://guides.rubygems.org/mfa-requirement-opt-in/ + Include: + - '**/*.gemspec' + +Gemspec/RequiredRubyVersion: + Description: 'Checks that `required_ruby_version` of gemspec is specified and equal to `TargetRubyVersion` of .rubocop.yml.' + Enabled: true + Severity: warning + VersionAdded: '0.52' + VersionChanged: '1.40' + Include: + - '**/*.gemspec' + +Gemspec/RubyVersionGlobalsUsage: + Description: Checks usage of RUBY_VERSION in gemspec. + StyleGuide: '#no-ruby-version-in-the-gemspec' + Enabled: true + Severity: warning + VersionAdded: '0.72' + VersionChanged: '1.40' + Include: + - '**/*.gemspec' + +#################### Layout ########################### + +Layout/AccessModifierIndentation: + Description: Checks indentation of private/protected visibility modifiers. + StyleGuide: '#indent-public-private-protected' + Enabled: true + VersionAdded: '0.49' EnforcedStyle: indent SupportedStyles: - outdent - indent + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + IndentationWidth: ~ + +Layout/ArgumentAlignment: + Description: >- + Align the arguments of a method call if they span more + than one line. + StyleGuide: '#no-double-indent' + Enabled: true + VersionAdded: '0.68' + VersionChanged: '0.77' + # Alignment of arguments in multi-line method calls. + # + # The `with_first_argument` style aligns the following lines along the same + # column as the first parameter. + # + # method_call(a, + # b) + # + # The `with_fixed_indentation` style aligns the following lines with one + # level of indentation relative to the start of the line with the method call. + # + # method_call(a, + # b) + EnforcedStyle: with_first_argument + SupportedStyles: + - with_first_argument + - with_fixed_indentation + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + IndentationWidth: ~ + +Layout/ArrayAlignment: + Description: >- + Align the elements of an array literal if they span more than + one line. + StyleGuide: '#no-double-indent' + Enabled: true + VersionAdded: '0.49' + VersionChanged: '0.77' + # Alignment of elements of a multi-line array. + # + # The `with_first_parameter` style aligns the following lines along the same + # column as the first element. + # + # array = [1, 2, 3, + # 4, 5, 6] + # + # The `with_fixed_indentation` style aligns the following lines with one + # level of indentation relative to the start of the line with start of array. + # + # array = [1, 2, 3, + # 4, 5, 6] + EnforcedStyle: with_first_element + SupportedStyles: + - with_first_element + - with_fixed_indentation + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + IndentationWidth: ~ + +Layout/AssignmentIndentation: + Description: >- + Checks the indentation of the first line of the + right-hand-side of a multi-line assignment. + Enabled: true + VersionAdded: '0.49' + VersionChanged: '1.45' + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + IndentationWidth: ~ + +Layout/BeginEndAlignment: + Description: 'Align ends corresponding to begins correctly.' + Enabled: true + VersionAdded: '0.91' + # The value `start_of_line` means that `end` should be aligned the start of the line + # where the `begin` keyword is. + # The value `begin` means that `end` should be aligned with the `begin` keyword. + EnforcedStyleAlignWith: start_of_line + SupportedStylesAlignWith: + - start_of_line + - begin + Severity: warning + +Layout/BlockAlignment: + Description: 'Align block ends correctly.' + Enabled: true + VersionAdded: '0.53' + # The value `start_of_block` means that the `end` should be aligned with line + # where the `do` keyword appears. + # The value `start_of_line` means it should be aligned with the whole + # expression's starting line. + # The value `either` means both are allowed. + EnforcedStyleAlignWith: either + SupportedStylesAlignWith: + - either + - start_of_block + - start_of_line + +Layout/BlockEndNewline: + Description: 'Put end statement of multiline block on its own line.' + Enabled: true + VersionAdded: '0.49' + +Layout/CaseIndentation: + Description: 'Indentation of when in a case/(when|in)/[else/]end.' + StyleGuide: '#indent-when-to-case' + Enabled: true + VersionAdded: '0.49' + VersionChanged: '1.16' + EnforcedStyle: case + SupportedStyles: + - case + - end + IndentOneStep: false + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + # This only matters if `IndentOneStep` is `true`. + IndentationWidth: ~ + +Layout/ClassStructure: + Description: 'Enforces a configured order of definitions within a class body.' + StyleGuide: '#consistent-classes' + Enabled: false + SafeAutoCorrect: false + VersionAdded: '0.52' + VersionChanged: '1.53' + Categories: + module_inclusion: + - include + - prepend + - extend + ExpectedOrder: + - module_inclusion + - constants + - public_class_methods + - initializer + - public_methods + - protected_methods + - private_methods + +Layout/ClosingHeredocIndentation: + Description: 'Checks the indentation of here document closings.' + Enabled: true + VersionAdded: '0.57' + +Layout/ClosingParenthesisIndentation: + Description: 'Checks the indentation of hanging closing parentheses.' + Enabled: true + VersionAdded: '0.49' + +Layout/CommentIndentation: + Description: 'Indentation of comments.' + Enabled: true + # When true, allows comments to have extra indentation if that aligns them + # with a comment on the preceding line. + AllowForAlignment: false + VersionAdded: '0.49' + VersionChanged: '1.24' + +Layout/ConditionPosition: + Description: >- + Checks for condition placed in a confusing position relative to + the keyword. + StyleGuide: '#same-line-condition' + Enabled: true + VersionAdded: '0.53' + VersionChanged: '0.83' + +Layout/DefEndAlignment: + Description: 'Align ends corresponding to defs correctly.' + Enabled: true + VersionAdded: '0.53' + # The value `def` means that `end` should be aligned with the def keyword. + # The value `start_of_line` means that `end` should be aligned with method + # calls like `private`, `public`, etc, if present in front of the `def` + # keyword on the same line. + EnforcedStyleAlignWith: start_of_line + SupportedStylesAlignWith: + - start_of_line + - def + Severity: warning + +Layout/DotPosition: + Description: 'Checks the position of the dot in multi-line method calls.' + StyleGuide: '#consistent-multi-line-chains' + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: leading + SupportedStyles: + - leading + - trailing -# Align the elements of a hash literal if they span more than one line. -Style/AlignHash: +Layout/ElseAlignment: + Description: 'Align elses and elsifs correctly.' + Enabled: true + VersionAdded: '0.49' + +Layout/EmptyComment: + Description: 'Checks empty comment.' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.53' + VersionChanged: '1.61' + AllowBorderComment: true + AllowMarginComment: true + +Layout/EmptyLineAfterGuardClause: + Description: 'Add empty line after guard clause.' + Enabled: true + VersionAdded: '0.56' + VersionChanged: '0.59' + +Layout/EmptyLineAfterMagicComment: + Description: 'Add an empty line after magic comments to separate them from code.' + StyleGuide: '#separate-magic-comments-from-code' + Enabled: true + VersionAdded: '0.49' + +Layout/EmptyLineAfterMultilineCondition: + Description: 'Enforces empty line after multiline condition.' + # This is disabled, because this style is not very common in practice. + Enabled: false + VersionAdded: '0.90' + References: + - https://github.com/airbnb/ruby#multiline-if-newline + +Layout/EmptyLineBetweenDefs: + Description: 'Use empty lines between class/module/method defs.' + StyleGuide: '#empty-lines-between-methods' + Enabled: true + VersionAdded: '0.49' + VersionChanged: '1.23' + EmptyLineBetweenMethodDefs: true + EmptyLineBetweenClassDefs: true + EmptyLineBetweenModuleDefs: true + # `DefLikeMacros` takes the name of any macro that you want to treat like a def. + DefLikeMacros: [] + # `AllowAdjacentOneLineDefs` means that single line method definitions don't + # need an empty line between them. `true` by default. + AllowAdjacentOneLineDefs: true + # Can be array to specify minimum and maximum number of empty lines, e.g. [1, 2] + NumberOfEmptyLines: 1 + +Layout/EmptyLines: + Description: "Don't use several empty lines in a row." + StyleGuide: '#two-or-more-empty-lines' + Enabled: true + VersionAdded: '0.49' + +Layout/EmptyLinesAfterModuleInclusion: + Description: 'Keeps track of empty lines after module inclusion methods.' + StyleGuide: '#empty-lines-after-module-inclusion' + Enabled: pending + VersionAdded: '1.79' + +Layout/EmptyLinesAroundAccessModifier: + Description: "Keep blank lines around access modifiers." + StyleGuide: '#empty-lines-around-access-modifier' + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: around + SupportedStyles: + - around + - only_before + References: + # A reference to `EnforcedStyle: only_before`. + - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions + +Layout/EmptyLinesAroundArguments: + Description: "Keeps track of empty lines around method arguments." + Enabled: true + VersionAdded: '0.52' + +Layout/EmptyLinesAroundAttributeAccessor: + Description: "Keep blank lines around attribute accessors." + StyleGuide: '#empty-lines-around-attribute-accessor' + Enabled: true + VersionAdded: '0.83' + VersionChanged: '0.84' + AllowAliasSyntax: true + AllowedMethods: + - alias_method + - public + - protected + - private + +Layout/EmptyLinesAroundBeginBody: + Description: "Keeps track of empty lines around begin-end bodies." + StyleGuide: '#empty-lines-around-bodies' + Enabled: true + VersionAdded: '0.49' + +Layout/EmptyLinesAroundBlockBody: + Description: "Keeps track of empty lines around block bodies." + StyleGuide: '#empty-lines-around-bodies' + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: no_empty_lines + SupportedStyles: + - empty_lines + - no_empty_lines + +Layout/EmptyLinesAroundClassBody: + Description: "Keeps track of empty lines around class bodies." + StyleGuide: '#empty-lines-around-bodies' + Enabled: true + VersionAdded: '0.49' + VersionChanged: '0.53' + EnforcedStyle: no_empty_lines + SupportedStyles: + - empty_lines + - empty_lines_except_namespace + - empty_lines_special + - no_empty_lines + - beginning_only + - ending_only + +Layout/EmptyLinesAroundExceptionHandlingKeywords: + Description: "Keeps track of empty lines around exception handling keywords." + StyleGuide: '#empty-lines-around-bodies' + Enabled: true + VersionAdded: '0.49' + +Layout/EmptyLinesAroundMethodBody: + Description: "Keeps track of empty lines around method bodies." + StyleGuide: '#empty-lines-around-bodies' + Enabled: true + VersionAdded: '0.49' + +Layout/EmptyLinesAroundModuleBody: + Description: "Keeps track of empty lines around module bodies." + StyleGuide: '#empty-lines-around-bodies' + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: no_empty_lines + SupportedStyles: + - empty_lines + - empty_lines_except_namespace + - empty_lines_special + - no_empty_lines + +Layout/EndAlignment: + Description: 'Align ends correctly.' + Enabled: true + VersionAdded: '0.53' + # The value `keyword` means that `end` should be aligned with the matching + # keyword (`if`, `while`, etc.). + # The value `variable` means that in assignments, `end` should be aligned + # with the start of the variable on the left hand side of `=`. In all other + # situations, `end` should still be aligned with the keyword. + # The value `start_of_line` means that `end` should be aligned with the start + # of the line which the matching keyword appears on. + EnforcedStyleAlignWith: keyword + SupportedStylesAlignWith: + - keyword + - variable + - start_of_line + Severity: warning + +Layout/EndOfLine: + Description: 'Use Unix-style line endings.' + StyleGuide: '#crlf' + Enabled: true + VersionAdded: '0.49' + # The `native` style means that CR+LF (Carriage Return + Line Feed) is + # enforced on Windows, and LF is enforced on other platforms. The other styles + # mean LF and CR+LF, respectively. + EnforcedStyle: native + SupportedStyles: + - native + - lf + - crlf + +Layout/ExtraSpacing: + Description: 'Do not use unnecessary spacing.' + Enabled: true + VersionAdded: '0.49' + # When true, allows most uses of extra spacing if the intent is to align + # things with the previous or next line, not counting empty lines or comment + # lines. + AllowForAlignment: true + # When true, allows things like 'obj.meth(arg) # comment', + # rather than insisting on 'obj.meth(arg) # comment'. + # If done for alignment, either this OR AllowForAlignment will allow it. + AllowBeforeTrailingComments: false + # When true, forces the alignment of `=` in assignments on consecutive lines. + ForceEqualSignAlignment: false + +Layout/FirstArgumentIndentation: + Description: 'Checks the indentation of the first argument in a method call.' + Enabled: true + VersionAdded: '0.68' + VersionChanged: '0.77' + EnforcedStyle: special_for_inner_method_call_in_parentheses + SupportedStyles: + # The first parameter should always be indented one step more than the + # preceding line. + - consistent + # The first parameter should always be indented one level relative to the + # parent that is receiving the parameter + - consistent_relative_to_receiver + # The first parameter should normally be indented one step more than the + # preceding line, but if it's a parameter for a method call that is itself + # a parameter in a method call, then the inner parameter should be indented + # relative to the inner method. + - special_for_inner_method_call + # Same as `special_for_inner_method_call` except that the special rule only + # applies if the outer method call encloses its arguments in parentheses. + - special_for_inner_method_call_in_parentheses + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + IndentationWidth: ~ + +Layout/FirstArrayElementIndentation: + Description: >- + Checks the indentation of the first element in an array + literal. + Enabled: true + VersionAdded: '0.68' + VersionChanged: '0.77' + # The value `special_inside_parentheses` means that array literals with + # brackets that have their opening bracket on the same line as a surrounding + # opening round parenthesis, shall have their first element indented relative + # to the first position inside the parenthesis. + # + # The value `consistent` means that the indentation of the first element shall + # always be relative to the first position of the line where the opening + # bracket is. + # + # The value `align_brackets` means that the indentation of the first element + # shall always be relative to the position of the opening bracket. + EnforcedStyle: special_inside_parentheses + SupportedStyles: + - special_inside_parentheses + - consistent + - align_brackets + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + IndentationWidth: ~ + +Layout/FirstArrayElementLineBreak: + Description: >- + Checks for a line break before the first element in a + multi-line array. + Enabled: false + VersionAdded: '0.49' + AllowMultilineFinalElement: false + +Layout/FirstHashElementIndentation: + Description: 'Checks the indentation of the first key in a hash literal.' + Enabled: true + VersionAdded: '0.68' + VersionChanged: '0.77' + # The value `special_inside_parentheses` means that hash literals with braces + # that have their opening brace on the same line as a surrounding opening + # round parenthesis, shall have their first key indented relative to the + # first position inside the parenthesis. + # + # The value `consistent` means that the indentation of the first key shall + # always be relative to the first position of the line where the opening + # brace is. + # + # The value `align_braces` means that the indentation of the first key shall + # always be relative to the position of the opening brace. + EnforcedStyle: special_inside_parentheses + SupportedStyles: + - special_inside_parentheses + - consistent + - align_braces + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + IndentationWidth: ~ + +Layout/FirstHashElementLineBreak: + Description: >- + Checks for a line break before the first element in a + multi-line hash. + Enabled: false + VersionAdded: '0.49' + AllowMultilineFinalElement: false + +Layout/FirstMethodArgumentLineBreak: + Description: >- + Checks for a line break before the first argument in a + multi-line method call. + Enabled: false + VersionAdded: '0.49' + AllowMultilineFinalElement: false + AllowedMethods: [] + +Layout/FirstMethodParameterLineBreak: + Description: >- + Checks for a line break before the first parameter in a + multi-line method parameter definition. + Enabled: false + VersionAdded: '0.49' + AllowMultilineFinalElement: false + +Layout/FirstParameterIndentation: + Description: >- + Checks the indentation of the first parameter in a + method definition. + Enabled: true + VersionAdded: '0.49' + VersionChanged: '0.77' + EnforcedStyle: consistent + SupportedStyles: + - consistent + - align_parentheses + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + IndentationWidth: ~ + +Layout/HashAlignment: + Description: >- + Align the elements of a hash literal if they span more than + one line. + Enabled: true + AllowMultipleStyles: true + VersionAdded: '0.49' + VersionChanged: '1.16' # Alignment of entries using hash rocket as separator. Valid values are: # # key - left alignment of keys @@ -82,6 +922,10 @@ Style/AlignHash: # 'a' => 2 # 'bb' => 3 EnforcedHashRocketStyle: key + SupportedHashRocketStyles: + - key + - separator + - table # Alignment of entries using colon as separator. Valid values are: # # key - left alignment of keys @@ -94,6 +938,10 @@ Style/AlignHash: # a: 0 # bb: 1 EnforcedColonStyle: key + SupportedColonStyles: + - key + - separator + - table # Select whether hashes that are the last argument in a method call should be # inspected? Valid values are: # @@ -132,42 +980,2441 @@ Style/AlignHash: - ignore_implicit - ignore_explicit -Style/AlignParameters: - # Alignment of parameters in multi-line method calls. - # - # The `with_first_parameter` style aligns the following lines along the same - # column as the first parameter. - # - # method_call(a, - # b) - # - # The `with_fixed_indentation` style aligns the following lines with one - # level of indentation relative to the start of the line with the method call. - # - # method_call(a, - # b) - EnforcedStyle: with_first_parameter +Layout/HeredocArgumentClosingParenthesis: + Description: >- + Checks for the placement of the closing parenthesis in a + method call that passes a HEREDOC string as an argument. + Enabled: false + StyleGuide: '#heredoc-argument-closing-parentheses' + VersionAdded: '0.68' + +Layout/HeredocIndentation: + Description: 'Checks the indentation of the here document bodies.' + StyleGuide: '#squiggly-heredocs' + Enabled: true + VersionAdded: '0.49' + VersionChanged: '0.85' + +Layout/IndentationConsistency: + Description: 'Keep indentation straight.' + StyleGuide: '#spaces-indentation' + Enabled: true + VersionAdded: '0.49' + # The difference between `indented` and `normal` is that the `indented_internal_methods` + # style prescribes that in classes and modules the `protected` and `private` + # modifier keywords shall be indented the same as public methods and that + # protected and private members shall be indented one step more than the + # modifiers. Other than that, both styles mean that entities on the same + # logical depth shall have the same indentation. + EnforcedStyle: normal + SupportedStyles: + - normal + - indented_internal_methods + References: + # A reference to `EnforcedStyle: indented_internal_methods`. + - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions + +Layout/IndentationStyle: + Description: 'Consistent indentation either with tabs only or spaces only.' + StyleGuide: '#spaces-indentation' + Enabled: true + VersionAdded: '0.49' + VersionChanged: '0.82' + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + # It is used during autocorrection to determine how many spaces should + # replace each tab. + IndentationWidth: ~ + EnforcedStyle: spaces + SupportedStyles: + - spaces + - tabs + +Layout/IndentationWidth: + Description: 'Use 2 spaces for indentation.' + StyleGuide: '#spaces-indentation' + Enabled: true + VersionAdded: '0.49' + # Number of spaces for each indentation level. + Width: 2 + AllowedPatterns: [] + +Layout/InitialIndentation: + Description: >- + Checks the indentation of the first non-blank non-comment line in a file. + Enabled: true + VersionAdded: '0.49' + +Layout/LeadingCommentSpace: + Description: 'Comments should start with a space.' + StyleGuide: '#hash-space' + Enabled: true + VersionAdded: '0.49' + VersionChanged: '0.73' + AllowDoxygenCommentStyle: false + AllowGemfileRubyComment: false + AllowRBSInlineAnnotation: false + AllowSteepAnnotation: false + +Layout/LeadingEmptyLines: + Description: Checks for unnecessary blank lines at the beginning of a file. + Enabled: true + VersionAdded: '0.57' + VersionChanged: '0.77' + +Layout/LineContinuationLeadingSpace: + Description: >- + Use trailing spaces instead of leading spaces in strings + broken over multiple lines (by a backslash). + Enabled: pending + VersionAdded: '1.31' + VersionChanged: '1.45' + EnforcedStyle: trailing + SupportedStyles: + - leading + - trailing + +Layout/LineContinuationSpacing: + Description: 'Checks the spacing in front of backslash in line continuations.' + Enabled: pending + VersionAdded: '1.31' + EnforcedStyle: space + SupportedStyles: + - space + - no_space + +Layout/LineEndStringConcatenationIndentation: + Description: >- + Checks the indentation of the next line after a line that + ends with a string literal and a backslash. + Enabled: pending + VersionAdded: '1.18' + EnforcedStyle: aligned + SupportedStyles: + - aligned + - indented + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + IndentationWidth: ~ + +Layout/LineLength: + Description: 'Checks that line length does not exceed the configured limit.' + StyleGuide: '#max-line-length' + Enabled: true + VersionAdded: '0.25' + VersionChanged: '1.69' + Max: 120 + AllowHeredoc: true + # To make it possible to copy or click on URIs in the code, we allow lines + # containing a URI to be longer than Max. + AllowURI: true + AllowQualifiedName: true + URISchemes: + - http + - https + # The IgnoreCopDirectives option causes the LineLength rule to ignore cop + # directives like '# rubocop: enable ...' when calculating a line's length. + IgnoreCopDirectives: true + # The AllowedPatterns option is a list of !ruby/regexp and/or string + # elements. Strings will be converted to Regexp objects. A line that matches + # any regular expression listed in this option will be ignored by LineLength. + AllowedPatterns: [] + # If SplitStrings is true, long strings will be split using continuations + SplitStrings: false + +Layout/MultilineArrayBraceLayout: + Description: >- + Checks that the closing brace in an array literal is + either on the same line as the last array element, or + a new line. + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: symmetrical + SupportedStyles: + # symmetrical: closing brace is positioned in same way as opening brace + # new_line: closing brace is always on a new line + # same_line: closing brace is always on the same line as last element + - symmetrical + - new_line + - same_line + +Layout/MultilineArrayLineBreaks: + Description: >- + Checks that each item in a multi-line array literal + starts on a separate line. + Enabled: false + VersionAdded: '0.67' + AllowMultilineFinalElement: false + +Layout/MultilineAssignmentLayout: + Description: 'Checks for a newline after the assignment operator in multi-line assignments.' + StyleGuide: '#indent-conditional-assignment' + Enabled: false + VersionAdded: '0.49' + # The types of assignments which are subject to this rule. + SupportedTypes: + - block + - case + - class + - if + - kwbegin + - module + EnforcedStyle: new_line + SupportedStyles: + # Ensures that the assignment operator and the rhs are on the same line for + # the set of supported types. + - same_line + # Ensures that the assignment operator and the rhs are on separate lines + # for the set of supported types. + - new_line + +Layout/MultilineBlockLayout: + Description: 'Ensures newlines after multiline block do statements.' + Enabled: true + VersionAdded: '0.49' + +Layout/MultilineHashBraceLayout: + Description: >- + Checks that the closing brace in a hash literal is + either on the same line as the last hash element, or + a new line. + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: symmetrical + SupportedStyles: + # symmetrical: closing brace is positioned in same way as opening brace + # new_line: closing brace is always on a new line + # same_line: closing brace is always on same line as last element + - symmetrical + - new_line + - same_line + +Layout/MultilineHashKeyLineBreaks: + Description: >- + Checks that each item in a multi-line hash literal + starts on a separate line. + Enabled: false + VersionAdded: '0.67' + AllowMultilineFinalElement: false + +Layout/MultilineMethodArgumentLineBreaks: + Description: >- + Checks that each argument in a multi-line method call + starts on a separate line. + Enabled: false + VersionAdded: '0.67' + AllowMultilineFinalElement: false + +Layout/MultilineMethodCallBraceLayout: + Description: >- + Checks that the closing brace in a method call is + either on the same line as the last method argument, or + a new line. + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: symmetrical + SupportedStyles: + # symmetrical: closing brace is positioned in same way as opening brace + # new_line: closing brace is always on a new line + # same_line: closing brace is always on the same line as last argument + - symmetrical + - new_line + - same_line + +Layout/MultilineMethodCallIndentation: + Description: >- + Checks indentation of method calls with the dot operator + that span more than one line. + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: aligned + SupportedStyles: + - aligned + - indented + - indented_relative_to_receiver + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + IndentationWidth: ~ + +Layout/MultilineMethodDefinitionBraceLayout: + Description: >- + Checks that the closing brace in a method definition is + either on the same line as the last method parameter, or + a new line. + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: symmetrical + SupportedStyles: + # symmetrical: closing brace is positioned in same way as opening brace + # new_line: closing brace is always on a new line + # same_line: closing brace is always on the same line as last parameter + - symmetrical + - new_line + - same_line + +Layout/MultilineMethodParameterLineBreaks: + Description: >- + Checks that each parameter in a multi-line method definition + starts on a separate line. + Enabled: false + VersionAdded: '1.32' + AllowMultilineFinalElement: false + +Layout/MultilineOperationIndentation: + Description: >- + Checks indentation of binary operations that span more than + one line. + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: aligned + SupportedStyles: + - aligned + - indented + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + IndentationWidth: ~ + +Layout/ParameterAlignment: + Description: >- + Align the parameters of a method definition if they span more + than one line. + StyleGuide: '#no-double-indent' + Enabled: true + VersionAdded: '0.49' + VersionChanged: '0.77' + # Alignment of parameters in multi-line method calls. + # + # The `with_first_parameter` style aligns the following lines along the same + # column as the first parameter. + # + # def method_foo(a, + # b) + # + # The `with_fixed_indentation` style aligns the following lines with one + # level of indentation relative to the start of the line with the method call. + # + # def method_foo(a, + # b) + EnforcedStyle: with_first_parameter + SupportedStyles: + - with_first_parameter + - with_fixed_indentation + # By default the indentation width from `Layout/IndentationWidth` is used, + # but it can be overridden by setting this parameter. + IndentationWidth: ~ + +Layout/RedundantLineBreak: + Description: >- + Do not break up an expression into multiple lines when it fits + on a single line. + Enabled: false + InspectBlocks: false + VersionAdded: '1.13' + +Layout/RescueEnsureAlignment: + Description: 'Align rescues and ensures correctly.' + Enabled: true + VersionAdded: '0.49' + +Layout/SingleLineBlockChain: + Description: 'Put method call on a separate line if chained to a single line block.' + Enabled: false + VersionAdded: '1.14' + +Layout/SpaceAfterColon: + Description: 'Use spaces after colons.' + StyleGuide: '#spaces-operators' + Enabled: true + VersionAdded: '0.49' + +Layout/SpaceAfterComma: + Description: 'Use spaces after commas.' + StyleGuide: '#spaces-operators' + Enabled: true + VersionAdded: '0.49' + +Layout/SpaceAfterMethodName: + Description: >- + Do not put a space between a method name and the opening + parenthesis in a method definition. + StyleGuide: '#parens-no-spaces' + Enabled: true + VersionAdded: '0.49' + +Layout/SpaceAfterNot: + Description: Tracks redundant space after the ! operator. + StyleGuide: '#no-space-bang' + Enabled: true + VersionAdded: '0.49' + +Layout/SpaceAfterSemicolon: + Description: 'Use spaces after semicolons.' + StyleGuide: '#spaces-operators' + Enabled: true + VersionAdded: '0.49' + +Layout/SpaceAroundBlockParameters: + Description: 'Checks the spacing inside and after block parameters pipes.' + Enabled: true + VersionAdded: '0.49' + EnforcedStyleInsidePipes: no_space + SupportedStylesInsidePipes: + - space + - no_space + +Layout/SpaceAroundEqualsInParameterDefault: + Description: >- + Checks that the equals signs in parameter default assignments + have or don't have surrounding space depending on + configuration. + StyleGuide: '#spaces-around-equals' + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: space + SupportedStyles: + - space + - no_space + +Layout/SpaceAroundKeyword: + Description: 'Use a space around keywords if appropriate.' + Enabled: true + VersionAdded: '0.49' + +Layout/SpaceAroundMethodCallOperator: + Description: 'Checks method call operators to not have spaces around them.' + Enabled: true + VersionAdded: '0.82' + +Layout/SpaceAroundOperators: + Description: 'Use a single space around operators.' + StyleGuide: '#spaces-operators' + Enabled: true + VersionAdded: '0.49' + # 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. + AllowForAlignment: true + EnforcedStyleForExponentOperator: no_space + SupportedStylesForExponentOperator: + - space + - no_space + EnforcedStyleForRationalLiterals: no_space + SupportedStylesForRationalLiterals: + - space + - no_space + +Layout/SpaceBeforeBlockBraces: + Description: >- + Checks that the left block brace has or doesn't have space + before it. + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: space + SupportedStyles: + - space + - no_space + EnforcedStyleForEmptyBraces: space + SupportedStylesForEmptyBraces: + - space + - no_space + VersionChanged: '0.52' + +Layout/SpaceBeforeBrackets: + Description: 'Checks for receiver with a space before the opening brackets.' + StyleGuide: '#space-in-brackets-access' + Enabled: pending + VersionAdded: '1.7' + +Layout/SpaceBeforeComma: + Description: 'No spaces before commas.' + Enabled: true + VersionAdded: '0.49' + +Layout/SpaceBeforeComment: + Description: >- + Checks for missing space between code and a comment on the + same line. + Enabled: true + VersionAdded: '0.49' + +Layout/SpaceBeforeFirstArg: + Description: >- + Checks that exactly one space is used between a method name + and the first argument for method calls without parentheses. + Enabled: true + VersionAdded: '0.49' + # When `true`, allows most uses of extra spacing if the intent is to align + # things with the previous or next line, not counting empty lines or comment + # lines. + AllowForAlignment: true + +Layout/SpaceBeforeSemicolon: + Description: 'No spaces before semicolons.' + Enabled: true + VersionAdded: '0.49' + +Layout/SpaceInLambdaLiteral: + Description: 'Checks for spaces in lambda literals.' + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: require_no_space + SupportedStyles: + - require_no_space + - require_space + +Layout/SpaceInsideArrayLiteralBrackets: + Description: 'Checks the spacing inside array literal brackets.' + Enabled: true + VersionAdded: '0.52' + EnforcedStyle: no_space + SupportedStyles: + - space + - no_space + # 'compact' normally requires a space inside the brackets, with the exception + # that successive left brackets or right brackets are collapsed together + - compact + EnforcedStyleForEmptyBrackets: no_space + SupportedStylesForEmptyBrackets: + - space + - no_space + +Layout/SpaceInsideArrayPercentLiteral: + Description: 'No unnecessary additional spaces between elements in %i/%w literals.' + Enabled: true + VersionAdded: '0.49' + +Layout/SpaceInsideBlockBraces: + Description: >- + Checks that block braces have or don't have surrounding space. + For blocks taking parameters, checks that the left brace has + or doesn't have trailing space. + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: space + SupportedStyles: + - space + - no_space + EnforcedStyleForEmptyBraces: no_space + SupportedStylesForEmptyBraces: + - space + - no_space + # Space between `{` and `|`. Overrides `EnforcedStyle` if there is a conflict. + SpaceBeforeBlockParameters: true + +Layout/SpaceInsideHashLiteralBraces: + Description: "Use spaces inside hash literal braces - or don't." + StyleGuide: '#spaces-braces' + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: space + SupportedStyles: + - space + - no_space + # 'compact' normally requires a space inside hash braces, with the exception + # that successive left braces or right braces are collapsed together + - compact + EnforcedStyleForEmptyBraces: no_space + SupportedStylesForEmptyBraces: + - space + - no_space + +Layout/SpaceInsideParens: + Description: 'No spaces after ( or before ).' + StyleGuide: '#spaces-braces' + Enabled: true + VersionAdded: '0.49' + VersionChanged: '1.22' + EnforcedStyle: no_space + SupportedStyles: + - space + - compact + - no_space + +Layout/SpaceInsidePercentLiteralDelimiters: + Description: 'No unnecessary spaces inside delimiters of %i/%w/%x literals.' + Enabled: true + VersionAdded: '0.49' + +Layout/SpaceInsideRangeLiteral: + Description: 'No spaces inside range literals.' + StyleGuide: '#no-space-inside-range-literals' + Enabled: true + VersionAdded: '0.49' + +Layout/SpaceInsideReferenceBrackets: + Description: 'Checks the spacing inside referential brackets.' + Enabled: true + VersionAdded: '0.52' + VersionChanged: '0.53' + EnforcedStyle: no_space + SupportedStyles: + - space + - no_space + EnforcedStyleForEmptyBrackets: no_space + SupportedStylesForEmptyBrackets: + - space + - no_space + +Layout/SpaceInsideStringInterpolation: + Description: 'Checks for padding/surrounding spaces inside string interpolation.' + StyleGuide: '#string-interpolation' + Enabled: true + VersionAdded: '0.49' + EnforcedStyle: no_space + SupportedStyles: + - space + - no_space + +Layout/TrailingEmptyLines: + Description: 'Checks trailing blank lines and final newline.' + StyleGuide: '#newline-eof' + Enabled: true + VersionAdded: '0.49' + VersionChanged: '0.77' + EnforcedStyle: final_newline + SupportedStyles: + - final_newline + - final_blank_line + +Layout/TrailingWhitespace: + Description: 'Avoid trailing whitespace.' + StyleGuide: '#no-trailing-whitespace' + Enabled: true + VersionAdded: '0.49' + VersionChanged: '1.0' + AllowInHeredoc: false + +#################### Lint ################################## +### Warnings + +Lint/AmbiguousAssignment: + Description: 'Checks for mistyped shorthand assignments.' + Enabled: pending + VersionAdded: '1.7' + +Lint/AmbiguousBlockAssociation: + Description: >- + Checks for ambiguous block association with method when param passed without + parentheses. + Enabled: true + VersionAdded: '0.48' + VersionChanged: '1.13' + AllowedMethods: [] + AllowedPatterns: [] + +Lint/AmbiguousOperator: + Description: >- + Checks for ambiguous operators in the first argument of a + method invocation without parentheses. + StyleGuide: '#method-invocation-parens' + Enabled: true + VersionAdded: '0.17' + VersionChanged: '0.83' + +Lint/AmbiguousOperatorPrecedence: + Description: >- + Checks for expressions containing multiple binary operations with + ambiguous precedence. + Enabled: pending + VersionAdded: '1.21' + +Lint/AmbiguousRange: + Description: Checks for ranges with ambiguous boundaries. + Enabled: pending + VersionAdded: '1.19' + SafeAutoCorrect: false + RequireParenthesesForMethodChains: false + +Lint/AmbiguousRegexpLiteral: + Description: >- + Checks for ambiguous regexp literals in the first argument of + a method invocation without parentheses. + Enabled: true + VersionAdded: '0.17' + VersionChanged: '0.83' + +Lint/ArrayLiteralInRegexp: + Description: 'Checks for an array literal interpolated inside a regexp.' + Enabled: pending + VersionAdded: '1.71' + SafeAutoCorrect: false + +Lint/AssignmentInCondition: + Description: "Don't use assignment in conditions." + StyleGuide: '#safe-assignment-in-condition' + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.9' + VersionChanged: '1.45' + AllowSafeAssignment: true + +Lint/BigDecimalNew: + Description: '`BigDecimal.new()` is deprecated. Use `BigDecimal()` instead.' + Enabled: true + VersionAdded: '0.53' + +Lint/BinaryOperatorWithIdenticalOperands: + Description: 'Checks for places where binary operator has identical operands.' + Enabled: true + Safe: false + VersionAdded: '0.89' + VersionChanged: '1.69' + +Lint/BooleanSymbol: + Description: 'Checks for `:true` and `:false` symbols.' + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.50' + VersionChanged: '1.22' + +Lint/CircularArgumentReference: + Description: "Default values in optional keyword arguments and optional ordinal arguments should not refer back to the name of the argument." + Enabled: true + VersionAdded: '0.33' + +Lint/ConstantDefinitionInBlock: + Description: 'Do not define constants within a block.' + StyleGuide: '#no-constant-definition-in-block' + Enabled: true + VersionAdded: '0.91' + VersionChanged: '1.3' + # `enums` for Typed Enums via T::Enum in Sorbet. + # https://sorbet.org/docs/tenum + AllowedMethods: + - enums + +Lint/ConstantOverwrittenInRescue: + Description: 'Checks for overwriting an exception with an exception result by use `rescue =>`.' + Enabled: pending + VersionAdded: '1.31' + +Lint/ConstantReassignment: + Description: 'Checks for constant reassignments.' + Enabled: pending + VersionAdded: '1.70' + +Lint/ConstantResolution: + Description: 'Checks that constants are fully qualified with `::`.' + Enabled: false + VersionAdded: '0.86' + # Restrict this cop to only looking at certain names + Only: [] + # Restrict this cop from only looking at certain names + Ignore: [] + +Lint/CopDirectiveSyntax: + Description: 'Checks that `# rubocop:` directives are strictly formatted.' + Enabled: pending + VersionAdded: '1.72' + +Lint/Debugger: + Description: 'Checks for debugger calls.' + Enabled: true + VersionAdded: '0.14' + VersionChanged: '1.63' + DebuggerMethods: + # Groups are available so that a specific group can be disabled in + # a user's configuration, but are otherwise not significant. + Kernel: + - binding.irb + - Kernel.binding.irb + Byebug: + - byebug + - remote_byebug + - Kernel.byebug + - Kernel.remote_byebug + Capybara: + - page.save_and_open_page + - page.save_and_open_screenshot + - page.save_page + - page.save_screenshot + - save_and_open_page + - save_and_open_screenshot + - save_page + - save_screenshot + debug.rb: + - binding.b + - binding.break + - Kernel.binding.b + - Kernel.binding.break + Pry: + - binding.pry + - binding.remote_pry + - binding.pry_remote + - Kernel.binding.pry + - Kernel.binding.remote_pry + - Kernel.binding.pry_remote + - Pry.rescue + - pry + Rails: + - debugger + - Kernel.debugger + RubyJard: + - jard + WebConsole: + - binding.console + DebuggerRequires: + debug.rb: + - debug/open + - debug/start + +Lint/DeprecatedClassMethods: + Description: 'Checks for deprecated class method calls.' + Enabled: true + VersionAdded: '0.19' + +Lint/DeprecatedConstants: + Description: 'Checks for deprecated constants.' + Enabled: pending + VersionAdded: '1.8' + VersionChanged: '1.40' + # You can configure deprecated constants. + # If there is an alternative method, you can set alternative value as `Alternative`. + # And you can set the deprecated version as `DeprecatedVersion`. + # These options can be omitted if they are not needed. + # + # DeprecatedConstants: + # 'DEPRECATED_CONSTANT': + # Alternative: 'alternative_value' + # DeprecatedVersion: 'deprecated_version' + # + DeprecatedConstants: + 'NIL': + Alternative: 'nil' + DeprecatedVersion: '2.4' + 'TRUE': + Alternative: 'true' + DeprecatedVersion: '2.4' + 'FALSE': + Alternative: 'false' + DeprecatedVersion: '2.4' + 'Net::HTTPServerException': + Alternative: 'Net::HTTPClientException' + DeprecatedVersion: '2.6' + 'Random::DEFAULT': + Alternative: 'Random.new' + DeprecatedVersion: '3.0' + 'Struct::Group': + Alternative: 'Etc::Group' + DeprecatedVersion: '3.0' + 'Struct::Passwd': + Alternative: 'Etc::Passwd' + DeprecatedVersion: '3.0' + +Lint/DeprecatedOpenSSLConstant: + Description: "Don't use algorithm constants for `OpenSSL::Cipher` and `OpenSSL::Digest`." + Enabled: true + VersionAdded: '0.84' + +Lint/DisjunctiveAssignmentInConstructor: + Description: 'In constructor, plain assignment is preferred over disjunctive.' + Enabled: true + Safe: false + VersionAdded: '0.62' + VersionChanged: '0.88' + +Lint/DuplicateBranch: + Description: Checks that there are no repeated bodies within `if/unless`, `case-when` and `rescue` constructs. + Enabled: pending + VersionAdded: '1.3' + VersionChanged: '1.7' + IgnoreLiteralBranches: false + IgnoreConstantBranches: false + IgnoreDuplicateElseBranch: false + +Lint/DuplicateCaseCondition: + Description: 'Do not repeat values in case conditionals.' + Enabled: true + VersionAdded: '0.45' + +Lint/DuplicateElsifCondition: + Description: 'Do not repeat conditions used in if `elsif`.' + Enabled: true + VersionAdded: '0.88' + +Lint/DuplicateHashKey: + Description: 'Checks for duplicate keys in hash literals.' + Enabled: true + VersionAdded: '0.34' + VersionChanged: '0.77' + +Lint/DuplicateMagicComment: + Description: 'Checks for duplicated magic comments.' + Enabled: pending + VersionAdded: '1.37' + +Lint/DuplicateMatchPattern: + Description: 'Do not repeat patterns in `in` keywords.' + Enabled: pending + VersionAdded: '1.50' + +Lint/DuplicateMethods: + Description: 'Checks for duplicate method definitions.' + Enabled: true + VersionAdded: '0.29' + +Lint/DuplicateRegexpCharacterClassElement: + Description: 'Checks for duplicate elements in Regexp character classes.' + Enabled: pending + VersionAdded: '1.1' + +Lint/DuplicateRequire: + Description: 'Checks for duplicate `require`s and `require_relative`s.' + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.90' + VersionChanged: '1.28' + +Lint/DuplicateRescueException: + Description: 'Checks that there are no repeated exceptions used in `rescue` expressions.' + Enabled: true + VersionAdded: '0.89' + +Lint/DuplicateSetElement: + Description: 'Checks for duplicate elements in Set.' + Enabled: pending + VersionAdded: '1.67' + +Lint/EachWithObjectArgument: + Description: 'Checks for immutable argument given to each_with_object.' + Enabled: true + VersionAdded: '0.31' + +Lint/ElseLayout: + Description: 'Checks for odd code arrangement in an else block.' + Enabled: true + VersionAdded: '0.17' + VersionChanged: '1.2' + +Lint/EmptyBlock: + Description: 'Checks for blocks without a body.' + Enabled: pending + VersionAdded: '1.1' + VersionChanged: '1.15' + AllowComments: true + AllowEmptyLambdas: true + +Lint/EmptyClass: + Description: 'Checks for classes and metaclasses without a body.' + Enabled: pending + VersionAdded: '1.3' + AllowComments: false + +Lint/EmptyConditionalBody: + Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.' + Enabled: true + AutoCorrect: contextual + AllowComments: true + VersionAdded: '0.89' + VersionChanged: '1.73' + +Lint/EmptyEnsure: + Description: 'Checks for empty ensure block.' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.10' + VersionChanged: '1.61' + +Lint/EmptyExpression: + Description: 'Checks for empty expressions.' + Enabled: true + VersionAdded: '0.45' + +Lint/EmptyFile: + Description: 'Enforces that Ruby source files are not empty.' + Enabled: true + AllowComments: true + VersionAdded: '0.90' + +Lint/EmptyInPattern: + Description: 'Checks for the presence of `in` pattern branches without a body.' + Enabled: pending + AllowComments: true + VersionAdded: '1.16' + +Lint/EmptyInterpolation: + Description: 'Checks for empty string interpolation.' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.20' + VersionChanged: '1.76' + +Lint/EmptyWhen: + Description: 'Checks for `when` branches with empty bodies.' + Enabled: true + AllowComments: true + VersionAdded: '0.45' + VersionChanged: '0.83' + +Lint/EnsureReturn: + Description: 'Do not use return in an ensure block.' + StyleGuide: '#no-return-ensure' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.83' + +Lint/ErbNewArguments: + Description: 'Use `:trim_mode` and `:eoutvar` keyword arguments to `ERB.new`.' + Enabled: true + VersionAdded: '0.56' + +Lint/FlipFlop: + Description: 'Checks for flip-flops.' + StyleGuide: '#no-flip-flops' + Enabled: true + VersionAdded: '0.16' + +Lint/FloatComparison: + Description: 'Checks for the presence of precise comparison of floating point numbers.' + StyleGuide: '#float-comparison' + Enabled: true + VersionAdded: '0.89' + +Lint/FloatOutOfRange: + Description: >- + Catches floating-point literals too large or small for Ruby to + represent. + Enabled: true + VersionAdded: '0.36' + +Lint/FormatParameterMismatch: + Description: 'The number of parameters to format/sprint must match the fields.' + Enabled: true + VersionAdded: '0.33' + +Lint/HashCompareByIdentity: + Description: 'Prefer using `Hash#compare_by_identity` than using `object_id` for keys.' + StyleGuide: '#identity-comparison' + Enabled: true + Safe: false + VersionAdded: '0.93' + +Lint/HashNewWithKeywordArgumentsAsDefault: + Description: 'Checks for the deprecated use of keyword arguments for hash default in `Hash.new`.' + Enabled: pending + VersionAdded: '1.69' + +Lint/HeredocMethodCallPosition: + Description: >- + Checks for the ordering of a method call where + the receiver of the call is a HEREDOC. + Enabled: false + StyleGuide: '#heredoc-method-calls' + VersionAdded: '0.68' + +Lint/IdentityComparison: + Description: 'Prefer `equal?` over `==` when comparing `object_id`.' + Enabled: true + StyleGuide: '#identity-comparison' + VersionAdded: '0.91' + +Lint/ImplicitStringConcatenation: + Description: >- + Checks for adjacent string literals on the same line, which + could better be represented as a single string literal. + Enabled: true + VersionAdded: '0.36' + +Lint/IncompatibleIoSelectWithFiberScheduler: + Description: 'Checks for `IO.select` that is incompatible with Fiber Scheduler.' + Enabled: pending + SafeAutoCorrect: false + VersionAdded: '1.21' + VersionChanged: '1.24' + +Lint/IneffectiveAccessModifier: + Description: >- + Checks for attempts to use `private` or `protected` to set + the visibility of a class method, which does not work. + Enabled: true + VersionAdded: '0.36' + +Lint/InheritException: + Description: 'Avoid inheriting from the `Exception` class.' + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.41' + VersionChanged: '1.26' + # The default base class in favour of `Exception`. + EnforcedStyle: standard_error + SupportedStyles: + - standard_error + - runtime_error + +Lint/InterpolationCheck: + Description: 'Checks for interpolation in a single quoted string.' + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.50' + VersionChanged: '1.40' + +Lint/ItWithoutArgumentsInBlock: + Description: 'Checks uses of `it` calls without arguments in block.' + References: + - 'https://bugs.ruby-lang.org/issues/18980' + Enabled: pending + VersionAdded: '1.59' + +Lint/LambdaWithoutLiteralBlock: + Description: 'Checks uses of lambda without a literal block.' + Enabled: pending + VersionAdded: '1.8' + +Lint/LiteralAsCondition: + Description: 'Checks of literals used in conditions.' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.51' + +Lint/LiteralAssignmentInCondition: + Description: 'Checks for literal assignments in the conditions.' + Enabled: pending + VersionAdded: '1.58' + +Lint/LiteralInInterpolation: + Description: 'Checks for literals used in interpolation.' + Enabled: true + VersionAdded: '0.19' + VersionChanged: '0.32' + +Lint/Loop: + Description: >- + Use Kernel#loop with break rather than begin/end/until or + begin/end/while for post-loop tests. + StyleGuide: '#loop-with-break' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '1.3' + Safe: false + +Lint/MissingCopEnableDirective: + Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.' + Enabled: true + VersionAdded: '0.52' + # Maximum number of consecutive lines the cop can be disabled for. + # 0 allows only single-line disables + # 1 would mean the maximum allowed is the following: + # # rubocop:disable SomeCop + # a = 1 + # # rubocop:enable SomeCop + # .inf for any size + MaximumRangeSize: .inf + +Lint/MissingSuper: + Description: >- + Checks for the presence of constructors and lifecycle callbacks + without calls to `super`. + Enabled: true + AllowedParentClasses: [] + VersionAdded: '0.89' + VersionChanged: '1.4' + +Lint/MixedCaseRange: + Description: 'Checks for mixed-case character ranges since they include likely unintended characters.' + Enabled: pending + SafeAutoCorrect: false + VersionAdded: '1.53' + +Lint/MixedRegexpCaptureTypes: + Description: 'Do not mix named captures and numbered captures in a Regexp literal.' + Enabled: true + VersionAdded: '0.85' + +Lint/MultipleComparison: + Description: "Use `&&` operator to compare multiple values." + Enabled: true + VersionAdded: '0.47' + VersionChanged: '1.1' + +Lint/NestedMethodDefinition: + Description: 'Do not use nested method definitions.' + StyleGuide: '#no-nested-methods' + Enabled: true + AllowedMethods: [] + AllowedPatterns: [] + VersionAdded: '0.32' + +Lint/NestedPercentLiteral: + Description: 'Checks for nested percent literals.' + Enabled: true + VersionAdded: '0.52' + +Lint/NextWithoutAccumulator: + Description: >- + Do not omit the accumulator when calling `next` + in a `reduce`/`inject` block. + Enabled: true + VersionAdded: '0.36' + +Lint/NoReturnInBeginEndBlocks: + Description: 'Do not `return` inside `begin..end` blocks in assignment contexts.' + Enabled: pending + VersionAdded: '1.2' + +Lint/NonAtomicFileOperation: + Description: Checks for non-atomic file operations. + StyleGuide: '#atomic-file-operations' + Enabled: pending + VersionAdded: '1.31' + SafeAutoCorrect: false + +Lint/NonDeterministicRequireOrder: + Description: 'Always sort arrays returned by Dir.glob when requiring files.' + Enabled: true + VersionAdded: '0.78' + Safe: false + +Lint/NonLocalExitFromIterator: + Description: 'Do not use return in iterator to cause non-local exit.' + Enabled: true + VersionAdded: '0.30' + +Lint/NumberConversion: + Description: 'Checks unsafe usage of number conversion methods.' + Enabled: false + VersionAdded: '0.53' + VersionChanged: '1.1' + SafeAutoCorrect: false + AllowedMethods: [] + AllowedPatterns: [] + IgnoredClasses: + - Time + - DateTime + +Lint/NumberedParameterAssignment: + Description: 'Checks for uses of numbered parameter assignment.' + Enabled: pending + VersionAdded: '1.9' + +Lint/NumericOperationWithConstantResult: + Description: 'Checks for numeric operations with constant results.' + Enabled: pending + VersionAdded: '1.69' + +Lint/OrAssignmentToConstant: + Description: 'Checks unintended or-assignment to constant.' + Enabled: pending + Safe: false + VersionAdded: '1.9' + +Lint/OrderedMagicComments: + Description: 'Checks the proper ordering of magic comments and whether a magic comment is not placed before a shebang.' + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.53' + VersionChanged: '1.37' + +Lint/OutOfRangeRegexpRef: + Description: 'Checks for out of range reference for Regexp because it always returns nil.' + Enabled: true + Safe: false + VersionAdded: '0.89' + +Lint/ParenthesesAsGroupedExpression: + Description: >- + Checks for method calls with a space before the opening + parenthesis. + StyleGuide: '#parens-no-spaces' + Enabled: true + VersionAdded: '0.12' + VersionChanged: '0.83' + +Lint/PercentStringArray: + Description: >- + Checks for unwanted commas and quotes in %w/%W literals. + Enabled: true + Safe: false + VersionAdded: '0.41' + +Lint/PercentSymbolArray: + Description: >- + Checks for unwanted commas and colons in %i/%I literals. + Enabled: true + VersionAdded: '0.41' + +Lint/RaiseException: + Description: Checks for `raise` or `fail` statements which are raising `Exception` class. + StyleGuide: '#raise-exception' + Enabled: true + Safe: false + VersionAdded: '0.81' + VersionChanged: '0.86' + AllowedImplicitNamespaces: + - 'Gem' + +Lint/RandOne: + Description: >- + Checks for `rand(1)` calls. Such calls always return `0` + and most likely a mistake. + Enabled: true + VersionAdded: '0.36' + +Lint/RedundantCopDisableDirective: + Description: >- + Checks for rubocop:disable comments that can be removed. + Note: this cop is not disabled when disabling all cops. + It must be explicitly disabled. + Enabled: true + VersionAdded: '0.76' + +Lint/RedundantCopEnableDirective: + Description: Checks for rubocop:enable comments that can be removed. + Enabled: true + VersionAdded: '0.76' + +Lint/RedundantDirGlobSort: + Description: 'Checks for redundant `sort` method to `Dir.glob` and `Dir[]`.' + Enabled: pending + VersionAdded: '1.8' + VersionChanged: '1.26' + SafeAutoCorrect: false + +Lint/RedundantRegexpQuantifiers: + Description: 'Checks for redundant quantifiers in Regexps.' + Enabled: pending + VersionAdded: '1.53' + +Lint/RedundantRequireStatement: + Description: 'Checks for unnecessary `require` statement.' + Enabled: true + VersionAdded: '0.76' + VersionChanged: '1.73' + +Lint/RedundantSafeNavigation: + Description: 'Checks for redundant safe navigation calls.' + Enabled: true + VersionAdded: '0.93' + VersionChanged: '1.79' + AllowedMethods: + - instance_of? + - kind_of? + - is_a? + - eql? + - respond_to? + - equal? + InferNonNilReceiver: false + AdditionalNilMethods: + - present? + - blank? + - try + - try! + Safe: false + +Lint/RedundantSplatExpansion: + Description: 'Checks for splat unnecessarily being called on literals.' + Enabled: true + VersionAdded: '0.76' + VersionChanged: '1.7' + AllowPercentLiteralArrayArgument: true + +Lint/RedundantStringCoercion: + Description: 'Checks for Object#to_s usage in string interpolation.' + StyleGuide: '#no-to-s' + Enabled: true + VersionAdded: '0.19' + VersionChanged: '0.77' + +Lint/RedundantTypeConversion: + Description: 'Checks for redundantly converting a literal to the same type.' + Enabled: pending + VersionAdded: '1.72' + +Lint/RedundantWithIndex: + Description: 'Checks for redundant `with_index`.' + Enabled: true + VersionAdded: '0.50' + +Lint/RedundantWithObject: + Description: 'Checks for redundant `with_object`.' + Enabled: true + VersionAdded: '0.51' + +Lint/RefinementImportMethods: + Description: 'Use `Refinement#import_methods` when using `include` or `prepend` in `refine` block.' + Enabled: pending + SafeAutoCorrect: false + VersionAdded: '1.27' + +Lint/RegexpAsCondition: + Description: >- + Do not use regexp literal as a condition. + The regexp literal matches `$_` implicitly. + Enabled: true + VersionAdded: '0.51' + VersionChanged: '0.86' + +Lint/RequireParentheses: + Description: >- + Use parentheses in the method call to avoid confusion + about precedence. + Enabled: true + VersionAdded: '0.18' + +Lint/RequireRangeParentheses: + Description: 'Checks that a range literal is enclosed in parentheses when the end of the range is at a line break.' + Enabled: pending + VersionAdded: '1.32' + +Lint/RequireRelativeSelfPath: + Description: 'Checks for uses a file requiring itself with `require_relative`.' + Enabled: pending + VersionAdded: '1.22' + +Lint/RescueException: + Description: 'Avoid rescuing the Exception class.' + StyleGuide: '#no-blind-rescues' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.27' + +Lint/RescueType: + Description: 'Avoid rescuing from non constants that could result in a `TypeError`.' + Enabled: true + VersionAdded: '0.49' + +Lint/ReturnInVoidContext: + Description: 'Checks for return in void context.' + Enabled: true + VersionAdded: '0.50' + +Lint/SafeNavigationChain: + Description: 'Do not chain ordinary method call after safe navigation operator.' + Enabled: true + VersionAdded: '0.47' + VersionChanged: '0.77' + AllowedMethods: + - present? + - blank? + - presence + - try + - try! + - in? + +Lint/SafeNavigationConsistency: + Description: >- + Check to make sure that if safe navigation is used in an `&&` or `||` condition, + consistent and appropriate safe navigation, without excess or deficiency, + is used for all method calls on the same object. + Enabled: true + VersionAdded: '0.55' + VersionChanged: '0.77' + AllowedMethods: + - present? + - blank? + - presence + - try + - try! + +Lint/SafeNavigationWithEmpty: + Description: 'Avoid `foo&.empty?` in conditionals.' + Enabled: true + VersionAdded: '0.62' + VersionChanged: '0.87' + +Lint/ScriptPermission: + Description: 'Grant script file execute permission.' + Enabled: true + VersionAdded: '0.49' + VersionChanged: '0.50' + +Lint/SelfAssignment: + Description: 'Checks for self-assignments.' + Enabled: true + VersionAdded: '0.89' + AllowRBSInlineAnnotation: false + +Lint/SendWithMixinArgument: + Description: 'Checks for `send` method when using mixin.' + Enabled: true + VersionAdded: '0.75' + +Lint/ShadowedArgument: + Description: 'Avoid reassigning arguments before they were used.' + Enabled: true + VersionAdded: '0.52' + IgnoreImplicitReferences: false + +Lint/ShadowedException: + Description: >- + Avoid rescuing a higher level exception + before a lower level exception. + Enabled: true + VersionAdded: '0.41' + +Lint/ShadowingOuterLocalVariable: + Description: >- + Do not use the same name as outer local variable + for block arguments or block local variables. + Enabled: false + VersionAdded: '0.9' + VersionChanged: '1.76' + +Lint/SharedMutableDefault: + Description: 'Checks for mutable literals used as default arguments during Hash initialization.' + StyleGuide: '#no-mutable-defaults' + Enabled: pending + VersionAdded: '1.70' + +Lint/StructNewOverride: + Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.' + Enabled: true + VersionAdded: '0.81' + +Lint/SuppressedException: + Description: "Don't suppress exceptions." + StyleGuide: '#dont-hide-exceptions' + Enabled: true + AllowComments: true + AllowNil: true + VersionAdded: '0.9' + VersionChanged: '1.12' + +Lint/SuppressedExceptionInNumberConversion: + Description: 'Checks for cases where exceptions unrelated to the numeric constructors may be unintentionally swallowed.' + Enabled: pending + SafeAutoCorrect: false + VersionAdded: '1.72' + +Lint/SymbolConversion: + Description: 'Checks for unnecessary symbol conversions.' + Enabled: pending + VersionAdded: '1.9' + VersionChanged: '1.16' + EnforcedStyle: strict + SupportedStyles: + - strict + - consistent + +Lint/Syntax: + Description: 'Checks for syntax errors.' + Enabled: true + VersionAdded: '0.9' + +Lint/ToEnumArguments: + Description: 'Ensures that `to_enum`/`enum_for`, called for the current method, has correct arguments.' + Enabled: pending + VersionAdded: '1.1' + +Lint/ToJSON: + Description: 'Ensure #to_json includes an optional argument.' + Enabled: true + VersionAdded: '0.66' + +Lint/TopLevelReturnWithArgument: + Description: 'Detects top level return statements with argument.' + Enabled: true + VersionAdded: '0.89' + # These codes are `eval`-ed in method and their return values may be used. + Exclude: + - '**/*.jb' + +Lint/TrailingCommaInAttributeDeclaration: + Description: 'Checks for trailing commas in attribute declarations.' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.90' + VersionChanged: '1.61' + +Lint/TripleQuotes: + Description: 'Checks for useless triple quote constructs.' + Enabled: pending + VersionAdded: '1.9' + +Lint/UnderscorePrefixedVariableName: + Description: 'Do not use prefix `_` for a variable that is used.' + Enabled: true + VersionAdded: '0.21' + AllowKeywordBlockArguments: false + +Lint/UnescapedBracketInRegexp: + Description: 'Checks for unescaped literal `]` in Regexp.' + Enabled: pending + VersionAdded: '1.68' + +Lint/UnexpectedBlockArity: + Description: 'Looks for blocks that have fewer arguments that the calling method expects.' + Enabled: pending + Safe: false + VersionAdded: '1.5' + Methods: + chunk_while: 2 + each_with_index: 2 + each_with_object: 2 + inject: 2 + max: 2 + min: 2 + minmax: 2 + reduce: 2 + slice_when: 2 + sort: 2 + +Lint/UnifiedInteger: + Description: 'Use Integer instead of Fixnum or Bignum.' + Enabled: true + VersionAdded: '0.43' + +Lint/UnmodifiedReduceAccumulator: + Description: Checks for `reduce` or `inject` blocks that do not update the accumulator each iteration. + Enabled: pending + VersionAdded: '1.1' + VersionChanged: '1.5' + +Lint/UnreachableCode: + Description: 'Unreachable code.' + Enabled: true + VersionAdded: '0.9' + +Lint/UnreachableLoop: + Description: 'Checks for loops that will have at most one iteration.' + Enabled: true + VersionAdded: '0.89' + VersionChanged: '1.7' + AllowedPatterns: + # RSpec uses `times` in its message expectations + # eg. `exactly(2).times` + - !ruby/regexp /(exactly|at_least|at_most)\(\d+\)\.times/ + +Lint/UnusedBlockArgument: + Description: 'Checks for unused block arguments.' + StyleGuide: '#underscore-unused-vars' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.21' + VersionChanged: '1.61' + IgnoreEmptyBlocks: true + AllowUnusedKeywordArguments: false + +Lint/UnusedMethodArgument: + Description: 'Checks for unused method arguments.' + StyleGuide: '#underscore-unused-vars' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.21' + VersionChanged: '1.69' + AllowUnusedKeywordArguments: false + IgnoreEmptyMethods: true + IgnoreNotImplementedMethods: true + NotImplementedExceptions: + - NotImplementedError + +Lint/UriEscapeUnescape: + Description: >- + `URI.escape` method is obsolete and should not be used. Instead, use + `CGI.escape`, `URI.encode_www_form` or `URI.encode_www_form_component` + depending on your specific use case. + Also `URI.unescape` method is obsolete and should not be used. Instead, use + `CGI.unescape`, `URI.decode_www_form` or `URI.decode_www_form_component` + depending on your specific use case. + Enabled: true + VersionAdded: '0.50' + +Lint/UriRegexp: + Description: 'Use `URI::DEFAULT_PARSER.make_regexp` instead of `URI.regexp`.' + Enabled: true + VersionAdded: '0.50' + +Lint/UselessAccessModifier: + Description: 'Checks for useless access modifiers.' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.20' + VersionChanged: '1.61' + ContextCreatingMethods: [] + MethodCreatingMethods: [] + +Lint/UselessAssignment: + Description: 'Checks for useless assignment to a local variable.' + StyleGuide: '#underscore-unused-vars' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.11' + VersionChanged: '1.66' + +Lint/UselessConstantScoping: + Description: 'Checks for useless constant scoping.' + Enabled: pending + VersionAdded: '1.72' + +Lint/UselessDefaultValueArgument: + Description: 'Checks for usage of `fetch` or `Array.new` with default value argument and block.' + Enabled: pending + VersionAdded: '1.76' + Safe: false + AllowedReceivers: [] + +Lint/UselessDefined: + Description: 'Checks for calls to `defined?` with strings and symbols. The result of such a call will always be truthy.' + Enabled: pending + VersionAdded: '1.69' + +Lint/UselessElseWithoutRescue: + Description: 'Checks for useless `else` in `begin..end` without `rescue`.' + Enabled: true + VersionAdded: '0.17' + VersionChanged: '1.31' + +Lint/UselessMethodDefinition: + Description: 'Checks for useless method definitions.' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.90' + VersionChanged: '1.61' + Safe: false + +Lint/UselessNumericOperation: + Description: 'Checks for useless numeric operations.' + Enabled: pending + VersionAdded: '1.66' + +Lint/UselessOr: + Description: 'Checks for useless OR expressions.' + Enabled: pending + VersionAdded: '1.76' + +Lint/UselessRescue: + Description: 'Checks for useless `rescue`s.' + Enabled: pending + VersionAdded: '1.43' + +Lint/UselessRuby2Keywords: + Description: 'Finds unnecessary uses of `ruby2_keywords`.' + Enabled: pending + VersionAdded: '1.23' + +Lint/UselessSetterCall: + Description: 'Checks for useless setter call to a local variable.' + Enabled: true + Safe: false + VersionAdded: '0.13' + VersionChanged: '1.2' + +Lint/UselessTimes: + Description: 'Checks for useless `Integer#times` calls.' + Enabled: true + Safe: false + AutoCorrect: contextual + VersionAdded: '0.91' + VersionChanged: '1.61' + +Lint/Void: + Description: 'Possible use of operator/literal/variable in void context.' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.9' + VersionChanged: '1.61' + CheckForMethodsWithNoSideEffects: false + +#################### Metrics ############################### + +Metrics/AbcSize: + Description: >- + A calculated magnitude based on number of assignments, + branches, and conditions. + References: + - https://wiki.c2.com/?AbcMetric + - https://en.wikipedia.org/wiki/ABC_Software_Metric + Enabled: true + VersionAdded: '0.27' + VersionChanged: '1.5' + # The ABC size is a calculated magnitude, so this number can be an Integer or + # a Float. + AllowedMethods: [] + AllowedPatterns: [] + CountRepeatedAttributes: true + Max: 17 + +Metrics/BlockLength: + Description: 'Avoid long blocks with many lines.' + Enabled: true + VersionAdded: '0.44' + VersionChanged: '1.5' + CountComments: false # count full line comments? + Max: 25 + CountAsOne: [] + AllowedMethods: + # By default, exclude the `#refine` method, as it tends to have larger + # associated blocks. + - refine + AllowedPatterns: [] + Exclude: + - '**/*.gemspec' + +Metrics/BlockNesting: + Description: 'Avoid excessive block nesting.' + StyleGuide: '#three-is-the-number-thou-shalt-count' + Enabled: true + VersionAdded: '0.25' + VersionChanged: '1.65' + CountBlocks: false + CountModifierForms: false + Max: 3 + +Metrics/ClassLength: + Description: 'Avoid classes longer than 100 lines of code.' + Enabled: true + VersionAdded: '0.25' + VersionChanged: '0.87' + CountComments: false # count full line comments? + Max: 100 + CountAsOne: [] + +Metrics/CollectionLiteralLength: + Description: 'Checks for `Array` or `Hash` literals with many entries.' + Enabled: pending + VersionAdded: '1.47' + LengthThreshold: 250 + +# Avoid complex methods. +Metrics/CyclomaticComplexity: + Description: >- + A complexity metric that is strongly correlated to the number + of test cases needed to validate a method. + Enabled: true + VersionAdded: '0.25' + VersionChanged: '0.81' + AllowedMethods: [] + AllowedPatterns: [] + Max: 7 + +Metrics/MethodLength: + Description: 'Avoid methods longer than 10 lines of code.' + StyleGuide: '#short-methods' + Enabled: true + VersionAdded: '0.25' + VersionChanged: '1.5' + CountComments: false # count full line comments? + Max: 10 + CountAsOne: [] + AllowedMethods: [] + AllowedPatterns: [] + +Metrics/ModuleLength: + Description: 'Avoid modules longer than 100 lines of code.' + Enabled: true + VersionAdded: '0.31' + VersionChanged: '0.87' + CountComments: false # count full line comments? + Max: 100 + CountAsOne: [] + +Metrics/ParameterLists: + Description: 'Avoid parameter lists longer than three or four parameters.' + StyleGuide: '#too-many-params' + Enabled: true + VersionAdded: '0.25' + VersionChanged: '1.5' + Max: 5 + CountKeywordArgs: true + MaxOptionalParameters: 3 + +Metrics/PerceivedComplexity: + Description: >- + A complexity metric geared towards measuring complexity for a + human reader. + Enabled: true + VersionAdded: '0.25' + VersionChanged: '0.81' + AllowedMethods: [] + AllowedPatterns: [] + Max: 8 + +################## Migration ############################# + +Migration/DepartmentName: + Description: >- + Check that cop names in rubocop:disable (etc) comments are + given with department name. + Enabled: true + VersionAdded: '0.75' + +#################### Naming ############################## + +Naming/AccessorMethodName: + Description: Checks the naming of accessor methods for get_/set_. + StyleGuide: '#accessor_mutator_method_names' + Enabled: true + VersionAdded: '0.50' + +Naming/AsciiIdentifiers: + Description: 'Use only ascii symbols in identifiers and constants.' + StyleGuide: '#english-identifiers' + Enabled: true + VersionAdded: '0.50' + VersionChanged: '0.87' + AsciiConstants: true + +Naming/BinaryOperatorParameterName: + Description: 'When defining binary operators, name the argument other.' + StyleGuide: '#other-arg' + Enabled: true + VersionAdded: '0.50' + VersionChanged: '1.2' + +Naming/BlockForwarding: + Description: 'Use anonymous block forwarding.' + StyleGuide: '#block-forwarding' + Enabled: pending + VersionAdded: '1.24' + EnforcedStyle: anonymous + SupportedStyles: + - anonymous + - explicit + BlockForwardingName: block + +Naming/BlockParameterName: + Description: >- + Checks for block parameter names that contain capital letters, + end in numbers, or do not meet a minimal length. + Enabled: true + VersionAdded: '0.53' + VersionChanged: '0.77' + # Parameter names may be equal to or greater than this value + MinNameLength: 1 + AllowNamesEndingInNumbers: true + # Allowed names that will not register an offense + AllowedNames: [] + # Forbidden names that will register an offense + ForbiddenNames: [] + +Naming/ClassAndModuleCamelCase: + Description: 'Use CamelCase for classes and modules.' + StyleGuide: '#camelcase-classes' + Enabled: true + VersionAdded: '0.50' + VersionChanged: '0.85' + # Allowed class/module names can be specified here. + # These can be full or part of the name. + AllowedNames: + - module_parent + +Naming/ConstantName: + Description: 'Constants should use SCREAMING_SNAKE_CASE.' + StyleGuide: '#screaming-snake-case' + Enabled: true + VersionAdded: '0.50' + +Naming/FileName: + Description: 'Use snake_case for source file names.' + StyleGuide: '#snake-case-files' + Enabled: true + VersionAdded: '0.50' + VersionChanged: '1.23' + # Camel case file names listed in `AllCops:Include` and all file names listed + # in `AllCops:Exclude` are excluded by default. Add extra excludes here. + Exclude: + - Rakefile.rb + # When `true`, requires that each source file should define a class or module + # with a name which matches the file name (converted to ... case). + # It further expects it to be nested inside modules which match the names + # of subdirectories in its path. + ExpectMatchingDefinition: false + # When `false`, changes the behavior of ExpectMatchingDefinition to match only + # whether each source file's class or module name matches the file name -- + # not whether the nested module hierarchy matches the subdirectory path. + CheckDefinitionPathHierarchy: true + # paths that are considered root directories, for example "lib" in most ruby projects + # or "app/models" in rails projects + CheckDefinitionPathHierarchyRoots: + - lib + - spec + - test + - src + # If non-`nil`, expect all source file names to match the following regex. + # Only the file name itself is matched, not the entire file path. + # Use anchors as necessary if you want to match the entire name rather than + # just a part of it. + Regex: ~ + # With `IgnoreExecutableScripts` set to `true`, this cop does not + # report offending filenames for executable scripts (i.e. source + # files with a shebang in the first line). + IgnoreExecutableScripts: true + AllowedAcronyms: + - CLI + - DSL + - ACL + - API + - ASCII + - CPU + - CSS + - DNS + - EOF + - GUID + - HTML + - HTTP + - HTTPS + - ID + - IP + - JSON + - LHS + - QPS + - RAM + - RHS + - RPC + - SLA + - SMTP + - SQL + - SSH + - TCP + - TLS + - TTL + - UDP + - UI + - UID + - UUID + - URI + - URL + - UTF8 + - VM + - XML + - XMPP + - XSRF + - XSS + +Naming/HeredocDelimiterCase: + Description: 'Use configured case for heredoc delimiters.' + StyleGuide: '#heredoc-delimiters' + Enabled: true + VersionAdded: '0.50' + VersionChanged: '1.2' + EnforcedStyle: uppercase + SupportedStyles: + - lowercase + - uppercase + +Naming/HeredocDelimiterNaming: + Description: 'Use descriptive heredoc delimiters.' + StyleGuide: '#heredoc-delimiters' + Enabled: true + VersionAdded: '0.50' + ForbiddenDelimiters: + - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/i' + +Naming/InclusiveLanguage: + Description: 'Recommend the use of inclusive language instead of problematic terms.' + Enabled: false + VersionAdded: '1.18' + VersionChanged: '1.49' + CheckIdentifiers: true + CheckConstants: true + CheckVariables: true + CheckStrings: false + CheckSymbols: true + CheckComments: true + CheckFilepaths: true + FlaggedTerms: + whitelist: + Regex: !ruby/regexp '/white[-_\s]?list/' + Suggestions: + - allowlist + - permit + blacklist: + Regex: !ruby/regexp '/black[-_\s]?list/' + Suggestions: + - denylist + - block + slave: + WholeWord: true + Suggestions: ['replica', 'secondary', 'follower'] + +Naming/MemoizedInstanceVariableName: + Description: >- + Memoized method name should match memo instance variable name. + Enabled: true + VersionAdded: '0.53' + VersionChanged: '1.2' + EnforcedStyleForLeadingUnderscores: disallowed + SupportedStylesForLeadingUnderscores: + - disallowed + - required + - optional + Safe: false + +Naming/MethodName: + Description: 'Use the configured style when naming methods.' + StyleGuide: '#snake-case-symbols-methods-vars' + Enabled: true + VersionAdded: '0.50' + VersionChanged: '1.75' + EnforcedStyle: snake_case + SupportedStyles: + - snake_case + - camelCase + # Method names matching patterns are always allowed. + # + # AllowedPatterns: + # - '\A\s*onSelectionBulkChange\s*' + # - '\A\s*onSelectionCleared\s*' + # + AllowedPatterns: [] + ForbiddenIdentifiers: + - __id__ + - __send__ + ForbiddenPatterns: [] + +Naming/MethodParameterName: + Description: >- + Checks for method parameter names that contain capital letters, + end in numbers, or do not meet a minimal length. + Enabled: true + VersionAdded: '0.53' + VersionChanged: '0.77' + # Parameter names may be equal to or greater than this value + MinNameLength: 3 + AllowNamesEndingInNumbers: true + # Allowed names that will not register an offense + AllowedNames: + - as + - at + - by + - cc + - db + - id + - if + - in + - io + - ip + - of + - 'on' + - os + - pp + - to + # Forbidden names that will register an offense + ForbiddenNames: [] + +Naming/PredicateMethod: + Description: 'Checks that predicate methods end with `?` and non-predicate methods do not.' + Enabled: pending + VersionAdded: '1.76' + VersionChanged: '1.78' + # In `aggressive` mode, the cop will register an offense for predicate methods that + # may return a non-boolean value. + # In `conservative` mode, the cop will *not* register an offense for predicate methods + # that may return a non-boolean value. + Mode: conservative + AllowedMethods: + - call + AllowedPatterns: [] + AllowBangMethods: false + # Methods that are known to not return a boolean value, despite ending in `?`. + WaywardPredicates: + - nonzero? + +Naming/PredicatePrefix: + Description: 'Predicate method names should not be prefixed and end with a `?`.' + StyleGuide: '#bool-methods-qmark' + Enabled: true + VersionAdded: '0.50' + VersionChanged: '1.75' + # Predicate name prefixes. + NamePrefix: + - is_ + - has_ + - have_ + - does_ + # Predicate name prefixes that should be removed. + ForbiddenPrefixes: + - is_ + - has_ + - have_ + - does_ + # Predicate names which, despite having a forbidden prefix, or no `?`, + # should still be accepted + AllowedMethods: + - is_a? + # Method definition macros for dynamically generated methods. + MethodDefinitionMacros: + - define_method + - define_singleton_method + # Use Sorbet's T::Boolean return type to detect predicate methods. + UseSorbetSigs: false + # Exclude Rspec specs because there is a strong convention to write spec + # helpers in the form of `have_something` or `be_something`. + Exclude: + - 'spec/**/*' + +Naming/RescuedExceptionsVariableName: + Description: 'Use consistent rescued exceptions variables naming.' + Enabled: true + VersionAdded: '0.67' + VersionChanged: '0.68' + PreferredName: e + +Naming/VariableName: + Description: 'Use the configured style when naming variables.' + StyleGuide: '#snake-case-symbols-methods-vars' + Enabled: true + VersionAdded: '0.50' + VersionChanged: '1.73' + EnforcedStyle: snake_case + SupportedStyles: + - snake_case + - camelCase + AllowedIdentifiers: [] + AllowedPatterns: [] + ForbiddenIdentifiers: [] + ForbiddenPatterns: [] + +Naming/VariableNumber: + Description: 'Use the configured style when numbering symbols, methods and variables.' + StyleGuide: '#snake-case-symbols-methods-vars-with-numbers' + Enabled: true + VersionAdded: '0.50' + VersionChanged: '1.4' + EnforcedStyle: normalcase + SupportedStyles: + - snake_case + - normalcase + - non_integer + CheckMethodNames: true + CheckSymbols: true + AllowedIdentifiers: + - TLS1_1 # OpenSSL::SSL::TLS1_1_VERSION + - TLS1_2 # OpenSSL::SSL::TLS1_2_VERSION + - capture3 # Open3.capture3 + - iso8601 # Time#iso8601 + - rfc1123_date # CGI.rfc1123_date + - rfc822 # Time#rfc822 + - rfc2822 # Time#rfc2822 + - rfc3339 # DateTime.rfc3339 + - x86_64 # Allowed by default as an underscore separated CPU architecture name + AllowedPatterns: [] + +#################### Security ############################## + +Security/CompoundHash: + Description: 'When overwriting Object#hash to combine values, prefer delegating to Array#hash over writing a custom implementation.' + Enabled: pending + Safe: false + VersionAdded: '1.28' + VersionChanged: '1.51' + +Security/Eval: + Description: 'The use of eval represents a serious security risk.' + Enabled: true + VersionAdded: '0.47' + +Security/IoMethods: + Description: >- + Checks for the first argument to `IO.read`, `IO.binread`, `IO.write`, `IO.binwrite`, + `IO.foreach`, and `IO.readlines`. + Enabled: pending + Safe: false + VersionAdded: '1.22' + +Security/JSONLoad: + Description: >- + Prefer usage of `JSON.parse` over `JSON.load` due to potential + security issues. See reference for more information. + References: + - 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load' + Enabled: true + VersionAdded: '0.43' + VersionChanged: '1.22' + # Autocorrect here will change to a method that may cause crashes depending + # on the value of the argument. + SafeAutoCorrect: false + +Security/MarshalLoad: + Description: >- + Avoid using of `Marshal.load` or `Marshal.restore` due to potential + security issues. See reference for more information. + References: + - 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations' + Enabled: true + VersionAdded: '0.47' + +Security/Open: + Description: 'The use of `Kernel#open` and `URI.open` represent a serious security risk.' + Enabled: true + VersionAdded: '0.53' + VersionChanged: '1.0' + Safe: false + +Security/YAMLLoad: + Description: >- + Prefer usage of `YAML.safe_load` over `YAML.load` due to potential + security issues. See reference for more information. + References: + - 'https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security' + Enabled: true + VersionAdded: '0.47' + SafeAutoCorrect: false + +#################### Style ############################### + +Style/AccessModifierDeclarations: + Description: 'Checks style of how access modifiers are used.' + Enabled: true + VersionAdded: '0.57' + VersionChanged: '1.70' + EnforcedStyle: group SupportedStyles: - - with_first_parameter - - with_fixed_indentation + - inline + - group + AllowModifiersOnSymbols: true + AllowModifiersOnAttrs: true + AllowModifiersOnAliasMethod: true + SafeAutoCorrect: false + +Style/AccessorGrouping: + Description: 'Checks for grouping of accessors in `class` and `module` bodies.' + Enabled: true + VersionAdded: '0.87' + EnforcedStyle: grouped + SupportedStyles: + # separated: each accessor goes in a separate statement. + # grouped: accessors are grouped into a single statement. + - separated + - grouped + +Style/Alias: + Description: 'Use alias instead of alias_method.' + StyleGuide: '#alias-method-lexically' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.36' + EnforcedStyle: prefer_alias + SupportedStyles: + - prefer_alias + - prefer_alias_method + +Style/AmbiguousEndlessMethodDefinition: + Description: 'Checks for endless methods inside operators of lower precedence.' + StyleGuide: '#ambiguous-endless-method-defintions' + Enabled: pending + VersionAdded: '1.68' Style/AndOr: + Description: 'Use &&/|| instead of and/or.' + StyleGuide: '#no-and-or-or' + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.9' + VersionChanged: '1.21' # Whether `and` and `or` are banned only in conditionals (conditionals) # or completely (always). - EnforcedStyle: always + EnforcedStyle: conditionals SupportedStyles: - always - conditionals +Style/ArgumentsForwarding: + Description: 'Use arguments forwarding.' + StyleGuide: '#arguments-forwarding' + Enabled: pending + AllowOnlyRestArgument: true + UseAnonymousForwarding: true + RedundantRestArgumentNames: + - args + - arguments + RedundantKeywordRestArgumentNames: + - kwargs + - options + - opts + RedundantBlockArgumentNames: + - blk + - block + - proc + VersionAdded: '1.1' + VersionChanged: '1.58' + +Style/ArrayCoercion: + Description: >- + Use Array() instead of explicit Array check or [*var], when dealing + with a variable you want to treat as an Array, but you're not certain it's an array. + StyleGuide: '#array-coercion' + Safe: false + Enabled: false + VersionAdded: '0.88' + +Style/ArrayFirstLast: + Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.' + References: + - '#first-and-last' + Enabled: false + VersionAdded: '1.58' + Safe: false + +Style/ArrayIntersect: + Description: 'Use `array1.intersect?(array2)` instead of `(array1 & array2).any?`.' + Enabled: 'pending' + Safe: false + VersionAdded: '1.40' + +Style/ArrayJoin: + Description: 'Use Array#join instead of Array#*.' + StyleGuide: '#array-join' + Enabled: true + VersionAdded: '0.20' + VersionChanged: '0.31' + +Style/AsciiComments: + Description: 'Use only ascii symbols in comments.' + StyleGuide: '#english-comments' + Enabled: false + VersionAdded: '0.9' + VersionChanged: '1.21' + AllowedChars: + - © + +Style/Attr: + Description: 'Checks for uses of Module#attr.' + StyleGuide: '#attr' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.12' + +Style/AutoResourceCleanup: + Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).' + Enabled: false + VersionAdded: '0.30' -# Checks if usage of %() or %Q() matches configuration. Style/BarePercentLiterals: + Description: 'Checks if usage of %() or %Q() matches configuration.' + StyleGuide: '#percent-q-shorthand' + Enabled: true + VersionAdded: '0.25' EnforcedStyle: bare_percent SupportedStyles: - percent_q - bare_percent +Style/BeginBlock: + Description: 'Avoid the use of BEGIN blocks.' + StyleGuide: '#no-BEGIN-blocks' + Enabled: true + VersionAdded: '0.9' + +Style/BisectedAttrAccessor: + Description: >- + Checks for places where `attr_reader` and `attr_writer` + for the same method can be combined into single `attr_accessor`. + Enabled: true + VersionAdded: '0.87' + +Style/BitwisePredicate: + Description: 'Prefer bitwise predicate methods over direct comparison operations.' + StyleGuide: '#bitwise-predicate-methods' + Enabled: pending + Safe: false + VersionAdded: '1.68' + +Style/BlockComments: + Description: 'Do not use block comments.' + StyleGuide: '#no-block-comments' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.23' + Style/BlockDelimiters: + Description: >- + Avoid using {...} for multi-line blocks (multiline chaining is + always ugly). + Prefer {...} over do...end for single-line blocks. + StyleGuide: '#single-line-blocks' + Enabled: true + VersionAdded: '0.30' + VersionChanged: '0.35' EnforcedStyle: line_count_based SupportedStyles: # The `line_count_based` style enforces braces around single line blocks and @@ -175,14 +3422,22 @@ Style/BlockDelimiters: - line_count_based # The `semantic` style enforces braces around functional blocks, where the # primary purpose of the block is to return a value and do..end for - # procedural blocks, where the primary purpose of the block is its - # side-effects. + # multi-line procedural blocks, where the primary purpose of the block is + # its side-effects. Single-line procedural blocks may only use do-end, + # unless AllowBracesOnProceduralOneLiners has a truthy value (see below). # # This looks at the usage of a block's method to determine its type (e.g. is # the result of a `map` assigned to a variable or passed to another # method) but exceptions are permitted in the `ProceduralMethods`, - # `FunctionalMethods` and `IgnoredMethods` sections below. + # `FunctionalMethods` and `AllowedMethods` sections below. - semantic + # The `braces_for_chaining` style enforces braces around single line blocks + # and do..end around multi-line blocks, except for multi-line blocks whose + # return value is being chained with another method (in which case braces + # are enforced). + - braces_for_chaining + # The `always_braces` style always enforces braces. + - always_braces ProceduralMethods: # Methods that are known to be procedural in nature but look functional from # their usage, e.g. @@ -215,7 +3470,7 @@ Style/BlockDelimiters: - let! - subject - watch - IgnoredMethods: + AllowedMethods: # Methods that can be either procedural or functional and cannot be # categorised from their usage alone, e.g. # @@ -232,31 +3487,89 @@ Style/BlockDelimiters: - lambda - proc - it + AllowedPatterns: [] + # The AllowBracesOnProceduralOneLiners option is ignored unless the + # EnforcedStyle is set to `semantic`. If so: + # + # If AllowBracesOnProceduralOneLiners is unspecified, or set to any + # falsey value, then semantic purity is maintained, so one-line + # procedural blocks must use do-end, not braces. + # + # # bad + # collection.each { |element| puts element } + # + # # good + # collection.each do |element| puts element end + # + # If AllowBracesOnProceduralOneLiners is set to any truthy value, + # then one-line procedural blocks may use either style. + # + # # good + # collection.each { |element| puts element } + # + # # also good + # collection.each do |element| puts element end + AllowBracesOnProceduralOneLiners: false + # The BracesRequiredMethods overrides all other configurations except + # AllowedMethods. It can be used to enforce that all blocks for specific + # methods use braces. For example, you can use this to enforce Sorbet + # signatures use braces even when the rest of your codebase enforces + # the `line_count_based` style. + BracesRequiredMethods: [] -Style/BracesAroundHashParameters: - EnforcedStyle: no_braces - SupportedStyles: - # The `braces` style enforces braces around all method parameters that are - # hashes. - - braces - # The `no_braces` style checks that the last parameter doesn't have braces - # around it. - - no_braces - # The `context_dependent` style checks that the last parameter doesn't have - # braces around it, but requires braces if the second to last parameter is - # also a hash literal. - - context_dependent +Style/CaseEquality: + Description: 'Avoid explicit use of the case equality operator(===).' + StyleGuide: '#no-case-equality' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.89' + # If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of + # the case equality operator is a constant. + # + # # bad + # /string/ === "string" + # + # # good + # String === "string" + AllowOnConstant: false + # If `AllowOnSelfClass` option is enabled, the cop will ignore violations when the receiver of + # the case equality operator is `self.class`. + # + # # bad + # some_class === object + # + # # good + # self.class === object + AllowOnSelfClass: false -# Indentation of `when`. -Style/CaseIndentation: - IndentWhenRelativeTo: case - SupportedStyles: - - case - - end - IndentOneStep: false +Style/CaseLikeIf: + Description: 'Identifies places where `if-elsif` constructions can be replaced with `case-when`.' + StyleGuide: '#case-vs-if-else' + Enabled: true + Safe: false + VersionAdded: '0.88' + VersionChanged: '1.48' + # `MinBranchesCount` defines the number of branches `if` needs to have to trigger this cop. + MinBranchesCount: 3 + +Style/CharacterLiteral: + Description: 'Checks for uses of character literals.' + StyleGuide: '#no-character-literals' + Enabled: true + VersionAdded: '0.9' Style/ClassAndModuleChildren: - # Checks the style of children definitions at classes and modules. + Description: 'Checks style of children classes and modules.' + StyleGuide: '#namespace-definition' + # Moving from compact to nested children requires knowledge of whether the + # outer parent is a module or a class. Moving from nested to compact requires + # verification that the outer parent is defined elsewhere. RuboCop does not + # have the knowledge to perform either operation safely and thus requires + # manual oversight. + SafeAutoCorrect: false + Enabled: true + VersionAdded: '0.19' + VersionChanged: '1.74' # # Basically there are two different styles: # @@ -270,63 +3583,238 @@ Style/ClassAndModuleChildren: # class Foo::Bar # end # - # The compact style is only forced, for classes / modules with one child. + # The compact style is only forced, for classes or modules with one child. EnforcedStyle: nested - SupportedStyles: + SupportedStyles: &supported_styles + - nested + - compact + # Configure classes separately, if desired. If not set, or set to `nil`, + # the `EnforcedStyle` value will be used. + EnforcedStyleForClasses: ~ + SupportedStylesForClasses: + - ~ + - nested + - compact + # Configure modules separately, if desired. If not set, or set to `nil`, + # the `EnforcedStyle` value will be used. + EnforcedStyleForModules: ~ + SupportedStylesForModules: + - ~ - nested - compact Style/ClassCheck: + Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.' + StyleGuide: '#is-a-vs-kind-of' + Enabled: true + VersionAdded: '0.24' EnforcedStyle: is_a? SupportedStyles: - is_a? - kind_of? +Style/ClassEqualityComparison: + Description: 'Enforces the use of `Object#instance_of?` instead of class comparison for equality.' + StyleGuide: '#instance-of-vs-class-comparison' + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.93' + VersionChanged: '1.57' + AllowedMethods: + - == + - equal? + - eql? + AllowedPatterns: [] + +Style/ClassMethods: + Description: 'Use self when defining module/class methods.' + StyleGuide: '#def-self-class-methods' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.20' + +Style/ClassMethodsDefinitions: + Description: 'Enforces using `def self.method_name` or `class << self` to define class methods.' + StyleGuide: '#def-self-class-methods' + Enabled: false + VersionAdded: '0.89' + EnforcedStyle: def_self + SupportedStyles: + - def_self + - self_class + +Style/ClassVars: + Description: 'Avoid the use of class variables.' + StyleGuide: '#no-class-vars' + Enabled: true + VersionAdded: '0.13' + +Style/CollectionCompact: + Description: 'Use `{Array,Hash}#{compact,compact!}` instead of custom logic to reject nils.' + Enabled: pending + Safe: false + VersionAdded: '1.2' + VersionChanged: '1.3' + AllowedReceivers: [] + # Align with the style guide. Style/CollectionMethods: - # Mapping from undesired method to desired_method + Description: 'Preferred collection methods.' + StyleGuide: '#map-find-select-reduce-include-size' + Enabled: false + VersionAdded: '0.9' + VersionChanged: '1.7' + Safe: false + # Mapping from undesired method to desired method # e.g. to use `detect` over `find`: # - # CollectionMethods: + # Style/CollectionMethods: # PreferredMethods: # find: detect PreferredMethods: collect: 'map' collect!: 'map!' + collect_concat: 'flat_map' inject: 'reduce' detect: 'find' find_all: 'select' + member?: 'include?' + # Methods in this array accept a final symbol as an implicit block + # eg. `inject(:+)` + MethodsAcceptingSymbol: + - inject + - reduce + +Style/CollectionQuerying: + Description: 'Prefer `Enumerable` predicate methods over expressions with `count`.' + StyleGuide: '#collection-querying' + Enabled: pending + VersionAdded: '1.77' + Safe: false + +Style/ColonMethodCall: + Description: 'Do not use :: for method call.' + StyleGuide: '#double-colons' + Enabled: true + VersionAdded: '0.9' + +Style/ColonMethodDefinition: + Description: 'Do not use :: for defining class methods.' + StyleGuide: '#colon-method-definition' + Enabled: true + VersionAdded: '0.52' + +Style/CombinableDefined: + Description: 'Checks successive `defined?` calls that can be combined into a single call.' + Enabled: pending + VersionAdded: '1.68' + +Style/CombinableLoops: + Description: >- + Checks for places where multiple consecutive loops over the same data + can be combined into a single loop. + Enabled: true + Safe: false + VersionAdded: '0.90' -# Use ` or %x around command literals. Style/CommandLiteral: + Description: 'Use `` or %x around command literals.' + StyleGuide: '#percent-x' + Enabled: true + VersionAdded: '0.30' EnforcedStyle: backticks # backticks: Always use backticks. - # percent_x: Always use %x. - # mixed: Use backticks on single-line commands, and %x on multi-line commands. + # percent_x: Always use `%x`. + # mixed: Use backticks on single-line commands, and `%x` on multi-line commands. SupportedStyles: - backticks - percent_x - mixed - # If false, the cop will always recommend using %x if one or more backticks + # If `false`, the cop will always recommend using `%x` if one or more backticks # are found in the command string. AllowInnerBackticks: false # Checks formatting of special comments Style/CommentAnnotation: + Description: >- + Checks formatting of special comments + (TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE). + StyleGuide: '#annotate-keywords' + Enabled: true + VersionAdded: '0.10' + VersionChanged: '1.20' Keywords: - TODO - FIXME - OPTIMIZE - HACK - REVIEW + - NOTE + RequireColon: true + +Style/CommentedKeyword: + Description: 'Do not place comments on the same line as certain keywords.' + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.51' + VersionChanged: '1.19' + +Style/ComparableBetween: + Description: 'Enforces the use of `Comparable#between?` instead of logical comparison.' + Enabled: pending + Safe: false + VersionAdded: '1.74' + VersionChanged: '1.75' + StyleGuide: '#ranges-or-between' + +Style/ComparableClamp: + Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.' + Enabled: pending + VersionAdded: '1.44' + +Style/ConcatArrayLiterals: + Description: 'Enforces the use of `Array#push(item)` instead of `Array#concat([item])` to avoid redundant array literals.' + Enabled: pending + Safe: false + VersionAdded: '1.41' + +Style/ConditionalAssignment: + Description: >- + Use the return value of `if` and `case` statements for + assignment to a variable and variable comparison instead + of assigning that variable inside of each branch. + Enabled: true + VersionAdded: '0.36' + VersionChanged: '0.47' + EnforcedStyle: assign_to_condition + SupportedStyles: + - assign_to_condition + - assign_inside_condition + # When configured to `assign_to_condition`, `SingleLineConditionsOnly` + # will only register an offense when all branches of a condition are + # a single line. + # When configured to `assign_inside_condition`, `SingleLineConditionsOnly` + # will only register an offense for assignment to a condition that has + # at least one multiline branch. + SingleLineConditionsOnly: true + IncludeTernaryExpressions: true + +Style/ConstantVisibility: + Description: >- + Check that class- and module constants have + visibility declarations. + Enabled: false + VersionAdded: '0.66' + VersionChanged: '1.10' + IgnoreModules: false # Checks that you have put a copyright in a comment before any code. # # You can override the default Notice in your .rubocop.yml file. # # In order to use autocorrect, you must supply a value for the -# AutocorrectNotice key that matches the regexp Notice. A blank -# AutocorrectNotice will cause an error during autocorrect. +# `AutocorrectNotice` key that matches the regexp Notice. A blank +# `AutocorrectNotice` will cause an error during autocorrect. # # Autocorrect will add a copyright notice in a comment at the top # of the file immediately after any shebang or encoding comments. @@ -339,172 +3827,1118 @@ Style/CommentAnnotation: # AutocorrectNotice: '# Copyright (c) 2015 Yahoo! Inc.' # Style/Copyright: + Description: 'Include a copyright notice in each file before any code.' + Enabled: false + VersionAdded: '0.30' Notice: '^Copyright (\(c\) )?2[0-9]{3} .+' AutocorrectNotice: '' -# Multi-line method chaining should be done with leading dots. -Style/DotPosition: - EnforcedStyle: leading +Style/DataInheritance: + Description: 'Checks for inheritance from Data.define.' + StyleGuide: '#no-extend-data-define' + Enabled: pending + SafeAutoCorrect: false + VersionAdded: '1.49' + VersionChanged: '1.51' + +Style/DateTime: + Description: 'Use Time over DateTime.' + StyleGuide: '#date-time' + Enabled: false + VersionAdded: '0.51' + VersionChanged: '0.92' + SafeAutoCorrect: false + AllowCoercion: false + +Style/DefWithParentheses: + Description: 'Use def with parentheses when there are arguments.' + StyleGuide: '#method-parens' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.12' + +Style/DigChain: + Description: 'Use `dig` with multiple parameters instead of chaining multiple calls.' + Enabled: pending + Safe: false + VersionAdded: '1.69' + +Style/Dir: + Description: >- + Use the `__dir__` method to retrieve the canonicalized + absolute path to the current file. + Enabled: true + VersionAdded: '0.50' + +Style/DirEmpty: + Description: >- + Prefer to use `Dir.empty?('path/to/dir')` when checking if a directory is empty. + Enabled: pending + VersionAdded: '1.48' + +Style/DisableCopsWithinSourceCodeDirective: + Description: >- + Forbids disabling/enabling cops within source code. + Enabled: false + VersionAdded: '0.82' + VersionChanged: '1.9' + AllowedCops: [] + +Style/DocumentDynamicEvalDefinition: + Description: >- + When using `class_eval` (or other `eval`) with string interpolation, + add a comment block showing its appearance if interpolated. + StyleGuide: '#eval-comment-docs' + Enabled: pending + VersionAdded: '1.1' + VersionChanged: '1.3' + +Style/Documentation: + Description: 'Document classes and non-namespace modules.' + Enabled: true + VersionAdded: '0.9' + AllowedConstants: [] + Exclude: + - 'spec/**/*' + - 'test/**/*' + +Style/DocumentationMethod: + Description: 'Checks for missing documentation comment for public methods.' + Enabled: false + VersionAdded: '0.43' + AllowedMethods: [] + Exclude: + - 'spec/**/*' + - 'test/**/*' + RequireForNonPublicMethods: false + +Style/DoubleCopDisableDirective: + Description: 'Checks for double rubocop:disable comments on a single line.' + Enabled: true + VersionAdded: '0.73' + +Style/DoubleNegation: + Description: 'Checks for uses of double negation (!!).' + StyleGuide: '#no-bang-bang' + Enabled: true + VersionAdded: '0.19' + VersionChanged: '1.2' + EnforcedStyle: allowed_in_returns + SafeAutoCorrect: false SupportedStyles: - - leading - - trailing + - allowed_in_returns + - forbidden + +Style/EachForSimpleLoop: + Description: >- + Use `Integer#times` for a simple loop which iterates a fixed + number of times. + Enabled: true + VersionAdded: '0.41' + +Style/EachWithObject: + Description: 'Prefer `each_with_object` over `inject` or `reduce`.' + Enabled: true + VersionAdded: '0.22' + VersionChanged: '0.42' + +Style/EmptyBlockParameter: + Description: 'Omit pipes for empty block parameters.' + Enabled: true + VersionAdded: '0.52' + +Style/EmptyCaseCondition: + Description: 'Avoid empty condition in case statements.' + Enabled: true + VersionAdded: '0.40' -# Warn on empty else statements -# empty - warn only on empty else -# nil - warn on else with nil in it -# both - warn on empty else and else with nil in it Style/EmptyElse: + Description: 'Avoid empty else-clauses.' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.28' + VersionChanged: '1.61' EnforcedStyle: both + # empty - warn only on empty `else` + # nil - warn on `else` with nil in it + # both - warn on empty `else` and `else` with `nil` in it SupportedStyles: - empty - nil - both + AllowComments: false -# Use empty lines between defs. -Style/EmptyLineBetweenDefs: - # If true, this parameter means that single line method definitions don't - # need an empty line between them. - AllowAdjacentOneLineDefs: false +Style/EmptyHeredoc: + Description: 'Checks for using empty heredoc to reduce redundancy.' + Enabled: pending + AutoCorrect: contextual + VersionAdded: '1.32' + VersionChanged: '1.61' -Style/EmptyLinesAroundBlockBody: - EnforcedStyle: no_empty_lines - SupportedStyles: - - empty_lines - - no_empty_lines +Style/EmptyLambdaParameter: + Description: 'Omit parens for empty lambda parameters.' + Enabled: true + VersionAdded: '0.52' -Style/EmptyLinesAroundClassBody: - EnforcedStyle: no_empty_lines +Style/EmptyLiteral: + Description: 'Prefer literals to Array.new/Hash.new/String.new.' + StyleGuide: '#literal-array-hash' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.12' + +Style/EmptyMethod: + Description: 'Checks the formatting of empty method definitions.' + StyleGuide: '#no-single-line-methods' + Enabled: true + AutoCorrect: contextual + VersionAdded: '0.46' + VersionChanged: '1.61' + EnforcedStyle: compact SupportedStyles: - - empty_lines - - no_empty_lines + - compact + - expanded -Style/EmptyLinesAroundModuleBody: - EnforcedStyle: no_empty_lines +Style/EmptyStringInsideInterpolation: + Description: 'Checks for empty strings being assigned inside string interpolation.' + StyleGuide: '#empty-strings-in-interpolation' + Enabled: pending + EnforcedStyle: trailing_conditional SupportedStyles: - - empty_lines - - no_empty_lines + - trailing_conditional + - ternary + VersionAdded: '1.76' -# Checks whether the source file has a utf-8 encoding comment or not -# AutoCorrectEncodingComment must match the regex -# /#.*coding\s?[:=]\s?(?:UTF|utf)-8/ Style/Encoding: - EnforcedStyle: always + Description: 'Use UTF-8 as the source file encoding.' + StyleGuide: '#utf-8' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.50' + +Style/EndBlock: + Description: 'Avoid the use of END blocks.' + StyleGuide: '#no-END-blocks' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.81' + +Style/EndlessMethod: + Description: 'Avoid the use of multi-lined endless method definitions.' + StyleGuide: '#endless-methods' + Enabled: pending + VersionAdded: '1.8' + EnforcedStyle: allow_single_line SupportedStyles: - - when_needed - - always - AutoCorrectEncodingComment: '# encoding: utf-8' + - allow_single_line + - allow_always + - disallow + - require_single_line + - require_always -Style/ExtraSpacing: - # When true, allows most uses of extra spacing if the intent is to align - # things with the previous or next line, not counting empty lines or comment - # lines. - AllowForAlignment: true +Style/EnvHome: + Description: "Checks for consistent usage of `ENV['HOME']`." + Enabled: pending + Safe: false + VersionAdded: '1.29' -Style/FileName: - # File names listed in AllCops:Include are excluded by default. Add extra - # excludes here. - Exclude: [] +Style/EvalWithLocation: + Description: 'Pass `__FILE__` and `__LINE__` to `eval` method, as they are used by backtraces.' + Enabled: true + VersionAdded: '0.52' -Style/FirstParameterIndentation: - EnforcedStyle: special_for_inner_method_call_in_parentheses +Style/EvenOdd: + Description: 'Favor the use of `Integer#even?` && `Integer#odd?`.' + StyleGuide: '#predicate-methods' + Enabled: true + VersionAdded: '0.12' + VersionChanged: '0.29' + +Style/ExactRegexpMatch: + Description: 'Checks for exact regexp match inside Regexp literals.' + Enabled: pending + VersionAdded: '1.51' + +Style/ExpandPathArguments: + Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`." + Enabled: true + VersionAdded: '0.53' + +Style/ExplicitBlockArgument: + Description: >- + Consider using explicit block argument to avoid writing block literal + that just passes its arguments to another block. + StyleGuide: '#block-argument' + Enabled: true + VersionAdded: '0.89' + VersionChanged: '1.8' + +Style/ExponentialNotation: + Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).' + StyleGuide: '#exponential-notation' + Enabled: true + VersionAdded: '0.82' + EnforcedStyle: scientific SupportedStyles: - # The first parameter should always be indented one step more than the - # preceding line. - - consistent - # The first parameter should normally be indented one step more than the - # preceding line, but if it's a parameter for a method call that is itself - # a parameter in a method call, then the inner parameter should be indented - # relative to the inner method. - - special_for_inner_method_call - # Same as special_for_inner_method_call except that the special rule only - # applies if the outer method call encloses its arguments in parentheses. - - special_for_inner_method_call_in_parentheses + - scientific + - engineering + - integral + +Style/FetchEnvVar: + Description: >- + Suggests `ENV.fetch` for the replacement of `ENV[]`. + References: + - https://rubystyle.guide/#hash-fetch-defaults + Enabled: pending + VersionAdded: '1.28' + # Environment variables to be excluded from the inspection. + AllowedVars: [] + # When `true`, autocorrects `ENV["key"]` to `ENV.fetch("key", nil)`. + # When `false`, autocorrects `ENV["key"]` to `ENV.fetch("key")`. + DefaultToNil: true + +Style/FileEmpty: + Description: >- + Prefer to use `File.empty?('path/to/file')` when checking if a file is empty. + Enabled: pending + Safe: false + VersionAdded: '1.48' + +Style/FileNull: + Description: 'Use `File::NULL` instead of hardcoding "dev/null".' + Enabled: pending + SafeAutoCorrect: false + VersionAdded: '1.69' + +Style/FileRead: + Description: 'Favor `File.(bin)read` convenience methods.' + StyleGuide: '#file-read' + Enabled: pending + VersionAdded: '1.24' + +Style/FileTouch: + Description: 'Favor `FileUtils.touch` for touching files.' + Enabled: pending + VersionAdded: '1.69' + SafeAutoCorrect: false + +Style/FileWrite: + Description: 'Favor `File.(bin)write` convenience methods.' + StyleGuide: '#file-write' + Enabled: pending + VersionAdded: '1.24' + +Style/FloatDivision: + Description: 'For performing float division, coerce one side only.' + StyleGuide: '#float-division' + References: + - 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html' + Enabled: true + VersionAdded: '0.72' + VersionChanged: '1.9' + Safe: false + EnforcedStyle: single_coerce + SupportedStyles: + - left_coerce + - right_coerce + - single_coerce + - fdiv -# Checks use of for or each in multiline loops. Style/For: + Description: 'Checks use of for or each in multiline loops.' + StyleGuide: '#no-for-loops' + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.13' + VersionChanged: '1.26' EnforcedStyle: each SupportedStyles: - - for - each + - for -# Enforce the method used for string formatting. Style/FormatString: + Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.' + StyleGuide: '#sprintf' + Enabled: true + VersionAdded: '0.19' + VersionChanged: '0.49' EnforcedStyle: format SupportedStyles: - format - sprintf - percent -# Built-in global variables are allowed by default. +Style/FormatStringToken: + Description: 'Use a consistent style for format string tokens.' + Enabled: true + EnforcedStyle: annotated + SupportedStyles: + # Prefer tokens which contain a sprintf like type annotation like + # `%s`, `%d`, `%f` + - annotated + # Prefer simple looking "template" style tokens like `%{name}`, `%{age}` + - template + - unannotated + # `MaxUnannotatedPlaceholdersAllowed` defines the number of `unannotated` + # style token in a format string to be allowed when enforced style is not + # `unannotated`. + MaxUnannotatedPlaceholdersAllowed: 1 + # The mode the cop operates in. Two values are allowed: + # * aggressive (default): all strings are considered + # * conservative: + # only register offenses for strings given to `printf`, `sprintf`, + # format` and `%` methods. Other strings are not considered. + Mode: aggressive + VersionAdded: '0.49' + VersionChanged: '1.74' + AllowedMethods: [] + AllowedPatterns: [] + +Style/FrozenStringLiteralComment: + Description: >- + Add the frozen_string_literal comment to the top of files + to help transition to frozen string literals by default. + Enabled: true + VersionAdded: '0.36' + VersionChanged: '0.79' + EnforcedStyle: always + SupportedStyles: + # `always` will always add the frozen string literal comment to a file + # regardless of the Ruby version or if `freeze` or `<<` are called on a + # string literal. It is possible that this will create errors. + - always + # `always_true` will add the frozen string literal comment to a file, + # similarly to the `always` style, but will also change any disabled + # comments (e.g. `# frozen_string_literal: false`) to be enabled. + - always_true + # `never` will enforce that the frozen string literal comment does not + # exist in a file. + - never + SafeAutoCorrect: false + Exclude: + # Prevent the Ruby warning: `'frozen_string_literal' is ignored after any tokens` when using Active Admin. + - '**/*.arb' + +Style/GlobalStdStream: + Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.' + StyleGuide: '#global-stdout' + Enabled: true + VersionAdded: '0.89' + SafeAutoCorrect: false + Style/GlobalVars: + Description: 'Do not introduce global variables.' + StyleGuide: '#instance-vars' + References: + - 'https://www.zenspider.com/ruby/quickref.html' + Enabled: true + VersionAdded: '0.13' + # Built-in global variables are allowed by default. AllowedVariables: [] -# `MinBodyLength` defines the number of lines of the a body of an if / unless -# needs to have to trigger this cop Style/GuardClause: + Description: 'Checks for conditionals that can be replaced with guard clauses.' + StyleGuide: '#no-nested-conditionals' + Enabled: true + VersionAdded: '0.20' + VersionChanged: '1.31' + # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless` + # needs to have to trigger this cop MinBodyLength: 1 + AllowConsecutiveConditionals: false + +Style/HashAsLastArrayItem: + Description: >- + Checks for presence or absence of braces around hash literal as a last + array item depending on configuration. + StyleGuide: '#hash-literal-as-last-array-item' + Enabled: true + VersionAdded: '0.88' + EnforcedStyle: braces + SupportedStyles: + - braces + - no_braces + +Style/HashConversion: + Description: 'Avoid Hash[] in favor of ary.to_h or literal hashes.' + StyleGuide: '#avoid-hash-constructor' + Enabled: pending + SafeAutoCorrect: false + VersionAdded: '1.10' + VersionChanged: '1.55' + AllowSplatArgument: true + +Style/HashEachMethods: + Description: 'Use Hash#each_key and Hash#each_value.' + StyleGuide: '#hash-each' + Enabled: true + Safe: false + VersionAdded: '0.80' + VersionChanged: '1.16' + AllowedReceivers: + - Thread.current + +Style/HashExcept: + Description: >- + Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods + that can be replaced with `Hash#except` method. + Enabled: pending + Safe: false + VersionAdded: '1.7' + VersionChanged: '1.39' + +Style/HashFetchChain: + Description: 'Use `Hash#dig` instead of chained `fetch` calls.' + Enabled: pending + Safe: false + VersionAdded: '1.75' + +Style/HashLikeCase: + Description: >- + Checks for places where `case-when` represents a simple 1:1 + mapping and can be replaced with a hash lookup. + Enabled: true + VersionAdded: '0.88' + # `MinBranchesCount` defines the number of branches `case` needs to have + # to trigger this cop + MinBranchesCount: 3 + +Style/HashSlice: + Description: >- + Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods + that can be replaced with `Hash#slice` method. + Enabled: pending + Safe: false + VersionAdded: '1.71' Style/HashSyntax: + Description: >- + Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax + { :a => 1, :b => 2 }. + StyleGuide: '#hash-literals' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '1.67' EnforcedStyle: ruby19 SupportedStyles: + # checks for 1.9 syntax (e.g. {a: 1}) for all symbol keys - ruby19 - - ruby19_no_mixed_keys + # checks for hash rocket syntax for all hashes - hash_rockets -# Force hashes that have a symbol value to use hash rockets + # forbids mixed key syntaxes (e.g. {a: 1, :b => 2}) + - no_mixed_keys + # enforces both ruby19 and no_mixed_keys styles + - ruby19_no_mixed_keys + # Force hashes that have a hash value omission + EnforcedShorthandSyntax: either + SupportedShorthandSyntax: + # forces use of the 3.1 syntax (e.g. {foo:}) when the hash key and value are the same. + - always + # forces use of explicit hash literal value. + - never + # accepts both shorthand and explicit use of hash literal value. + - either + # forces use of the 3.1 syntax only if all values can be omitted in the hash. + - consistent + # allow either (implicit or explicit) syntax but enforce consistency within a single hash + - either_consistent + # Force hashes that have a symbol value to use hash rockets UseHashRocketsWithSymbolValues: false + # Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style + PreferHashRocketsForNonAlnumEndingSymbols: false + +Style/HashTransformKeys: + Description: 'Prefer `transform_keys` over `each_with_object`, `map`, or `to_h`.' + Enabled: true + VersionAdded: '0.80' + VersionChanged: '0.90' + Safe: false + +Style/HashTransformValues: + Description: 'Prefer `transform_values` over `each_with_object`, `map`, or `to_h`.' + Enabled: true + VersionAdded: '0.80' + VersionChanged: '0.90' + Safe: false + +Style/IdenticalConditionalBranches: + Description: >- + Checks that conditional statements do not have an identical + line at the end of each branch, which can validly be moved + out of the conditional. + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.36' + VersionChanged: '1.19' + +Style/IfInsideElse: + Description: 'Finds if nodes inside else, which can be converted to elsif.' + Enabled: true + AllowIfModifier: false + VersionAdded: '0.36' + VersionChanged: '1.3' Style/IfUnlessModifier: - MaxLineLength: 80 + Description: >- + Favor modifier if/unless usage when you have a + single-line body. + StyleGuide: '#if-as-a-modifier' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.30' -Style/IndentationConsistency: - # The difference between `rails` and `normal` is that the `rails` style - # prescribes that in classes and modules the `protected` and `private` - # modifier keywords shall be indented the same as public methods and that - # protected and private members shall be indented one step more than the - # modifiers. Other than that, both styles mean that entities on the same - # logical depth shall have the same indentation. - EnforcedStyle: normal +Style/IfUnlessModifierOfIfUnless: + Description: >- + Avoid modifier if/unless usage on conditionals. + Enabled: true + VersionAdded: '0.39' + VersionChanged: '0.87' + +Style/IfWithBooleanLiteralBranches: + Description: 'Checks for redundant `if` with boolean literal branches.' + Enabled: pending + VersionAdded: '1.9' + SafeAutoCorrect: false + AllowedMethods: + - nonzero? + +Style/IfWithSemicolon: + Description: 'Do not use if x; .... Use the ternary operator instead.' + StyleGuide: '#no-semicolon-ifs' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.83' + +Style/ImplicitRuntimeError: + Description: >- + Use `raise` or `fail` with an explicit exception class and + message, rather than just a message. + Enabled: false + VersionAdded: '0.41' + +Style/InPatternThen: + Description: 'Checks for `in;` uses in `case` expressions.' + StyleGuide: '#no-in-pattern-semicolons' + Enabled: pending + VersionAdded: '1.16' + +Style/InfiniteLoop: + Description: >- + Use Kernel#loop for infinite loops. + This cop is unsafe if the body may raise a `StopIteration` exception. + Safe: false + StyleGuide: '#infinite-loop' + Enabled: true + VersionAdded: '0.26' + VersionChanged: '0.61' + +Style/InlineComment: + Description: 'Avoid trailing inline comments.' + Enabled: false + VersionAdded: '0.23' + +Style/InverseMethods: + Description: >- + Use the inverse method instead of `!.method` + if an inverse method is defined. + Enabled: true + Safe: false + VersionAdded: '0.48' + # `InverseMethods` are methods that can be inverted by a not (`not` or `!`) + # The relationship of inverse methods only needs to be defined in one direction. + # Keys and values both need to be defined as symbols. + InverseMethods: + :any?: :none? + :even?: :odd? + :==: :!= + :=~: :!~ + :<: :>= + :>: :<= + # `InverseBlocks` are methods that are inverted by inverting the return + # of the block that is passed to the method + InverseBlocks: + :select: :reject + :select!: :reject! + +Style/InvertibleUnlessCondition: + Description: 'Favor `if` with inverted condition over `unless`.' + Enabled: false + Safe: false + VersionAdded: '1.44' + VersionChanged: '1.50' + # `InverseMethods` are methods that can be inverted in a `unless` condition. + # The relationship of inverse methods needs to be defined in both directions. + # Keys and values both need to be defined as symbols. + InverseMethods: + :!=: :== + :>: :<= + :<=: :> + :<: :>= + :>=: :< + :!~: :=~ + :zero?: :nonzero? + :nonzero?: :zero? + :any?: :none? + :none?: :any? + :even?: :odd? + :odd?: :even? + +Style/IpAddresses: + Description: "Don't include literal IP addresses in code." + Enabled: false + VersionAdded: '0.58' + VersionChanged: '0.91' + # Allow addresses to be permitted + AllowedAddresses: + - "::" + # :: is a valid IPv6 address, but could potentially be legitimately in code + Exclude: + - '**/*.gemfile' + - '**/Gemfile' + - '**/gems.rb' + - '**/*.gemspec' + +Style/ItAssignment: + Description: 'Checks for local variables and method parameters named `it`.' + Enabled: pending + VersionAdded: '1.70' + +Style/ItBlockParameter: + Description: 'Checks for blocks with one argument where `it` block parameter can be used.' + Enabled: pending + EnforcedStyle: allow_single_line SupportedStyles: - - normal - - rails + - allow_single_line + - only_numbered_parameters + - always + - disallow + VersionAdded: '1.75' + VersionChanged: '1.76' -Style/IndentationWidth: - # Number of spaces for each indentation level. - Width: 2 +Style/KeywordArgumentsMerging: + Description: >- + When passing an existing hash as keyword arguments, provide additional arguments + directly rather than using `merge`. + StyleGuide: '#merging-keyword-arguments' + Enabled: pending + VersionAdded: '1.68' -# Checks the indentation of the first key in a hash literal. -Style/IndentHash: - # The value `special_inside_parentheses` means that hash literals with braces - # that have their opening brace on the same line as a surrounding opening - # round parenthesis, shall have their first key indented relative to the - # first position inside the parenthesis. - # The value `consistent` means that the indentation of the first key shall - # always be relative to the first position of the line where the opening - # brace is. - EnforcedStyle: special_inside_parentheses +Style/KeywordParametersOrder: + Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.' + StyleGuide: '#keyword-parameters-order' + Enabled: true + VersionAdded: '0.90' + VersionChanged: '1.7' + +Style/Lambda: + Description: 'Use the new lambda literal syntax for single-line blocks.' + StyleGuide: '#lambda-multi-line' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.40' + EnforcedStyle: line_count_dependent SupportedStyles: - - special_inside_parentheses - - consistent + - line_count_dependent + - lambda + - literal + +Style/LambdaCall: + Description: 'Use lambda.call(...) instead of lambda.(...).' + StyleGuide: '#proc-call' + Enabled: true + VersionAdded: '0.13' + VersionChanged: '0.14' + EnforcedStyle: call + SupportedStyles: + - call + - braces + +Style/LineEndConcatenation: + Description: >- + Use \ instead of + or << to concatenate two string literals at + line end. + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.18' + VersionChanged: '0.64' + +Style/MagicCommentFormat: + Description: 'Use a consistent style for magic comments.' + Enabled: pending + VersionAdded: '1.35' + EnforcedStyle: snake_case + SupportedStyles: + # `snake` will enforce the magic comment is written + # in snake case (words separated by underscores). + # Eg: froze_string_literal: true + - snake_case + # `kebab` will enforce the magic comment is written + # in kebab case (words separated by hyphens). + # Eg: froze-string-literal: true + - kebab_case + DirectiveCapitalization: lowercase + ValueCapitalization: ~ + SupportedCapitalizations: + - lowercase + - uppercase + +Style/MapCompactWithConditionalBlock: + Description: 'Prefer `select` or `reject` over `map { ... }.compact`.' + Enabled: pending + VersionAdded: '1.30' + +Style/MapIntoArray: + Description: 'Checks for usages of `each` with `<<`, `push`, or `append` which can be replaced by `map`.' + StyleGuide: '#functional-code' + Enabled: pending + VersionAdded: '1.63' + VersionChanged: '1.67' + Safe: false + +Style/MapToHash: + Description: 'Prefer `to_h` with a block over `map.to_h`.' + Enabled: pending + VersionAdded: '1.24' + Safe: false + +Style/MapToSet: + Description: 'Prefer `to_set` with a block over `map.to_set`.' + Enabled: pending + Safe: false + VersionAdded: '1.42' + +Style/MethodCallWithArgsParentheses: + Description: 'Use parentheses for method calls with arguments.' + StyleGuide: '#method-invocation-parens' + Enabled: false + VersionAdded: '0.47' + VersionChanged: '1.7' + IgnoreMacros: true + AllowedMethods: [] + AllowedPatterns: [] + IncludedMacros: [] + AllowParenthesesInMultilineCall: false + AllowParenthesesInChaining: false + AllowParenthesesInCamelCaseMethod: false + AllowParenthesesInStringInterpolation: false + EnforcedStyle: require_parentheses + SupportedStyles: + - require_parentheses + - omit_parentheses + +Style/MethodCallWithoutArgsParentheses: + Description: 'Do not use parentheses for method calls with no arguments.' + StyleGuide: '#method-invocation-parens' + Enabled: true + AllowedMethods: [] + AllowedPatterns: [] + VersionAdded: '0.47' + VersionChanged: '0.55' + +Style/MethodCalledOnDoEndBlock: + Description: 'Avoid chaining a method call on a do...end block.' + StyleGuide: '#single-line-blocks' + Enabled: false + VersionAdded: '0.14' + +Style/MethodDefParentheses: + Description: >- + Checks if the method definitions have or don't have + parentheses. + StyleGuide: '#method-parens' + Enabled: true + VersionAdded: '0.16' + VersionChanged: '1.7' + EnforcedStyle: require_parentheses + SupportedStyles: + - require_parentheses + - require_no_parentheses + - require_no_parentheses_except_multiline + +Style/MinMax: + Description: >- + Use `Enumerable#minmax` instead of `Enumerable#min` + and `Enumerable#max` in conjunction. + Enabled: true + VersionAdded: '0.50' + +Style/MinMaxComparison: + Description: 'Enforces the use of `max` or `min` instead of comparison for greater or less.' + Enabled: pending + Safe: false + VersionAdded: '1.42' + +Style/MissingElse: + Description: >- + Require if/case expressions to have an else branches. + If enabled, it is recommended that + Style/UnlessElse and Style/EmptyElse be enabled. + This will conflict with Style/EmptyElse if + Style/EmptyElse is configured to style "both". + Enabled: false + VersionAdded: '0.30' + VersionChanged: '0.38' + EnforcedStyle: both + SupportedStyles: + # if - warn when an if expression is missing an else branch + # case - warn when a case expression is missing an else branch + # both - warn when an if or case expression is missing an else branch + - if + - case + - both + +Style/MissingRespondToMissing: + Description: >- + Checks if `method_missing` is implemented + without implementing `respond_to_missing`. + StyleGuide: '#no-method-missing' + Enabled: true + VersionAdded: '0.56' + +Style/MixinGrouping: + Description: 'Checks for grouping of mixins in `class` and `module` bodies.' + StyleGuide: '#mixin-grouping' + Enabled: true + VersionAdded: '0.48' + VersionChanged: '0.49' + EnforcedStyle: separated + SupportedStyles: + # separated: each mixed in module goes in a separate statement. + # grouped: mixed in modules are grouped into a single statement. + - separated + - grouped + +Style/MixinUsage: + Description: 'Checks that `include`, `extend` and `prepend` exists at the top level.' + Enabled: true + VersionAdded: '0.51' + +Style/ModuleFunction: + Description: 'Checks for usage of `extend self` in modules.' + StyleGuide: '#module-function' + Enabled: true + VersionAdded: '0.11' + VersionChanged: '0.65' + EnforcedStyle: module_function + SupportedStyles: + - module_function + - extend_self + - forbidden + Autocorrect: false + SafeAutoCorrect: false + +Style/MultilineBlockChain: + Description: 'Avoid multi-line chains of blocks.' + StyleGuide: '#single-line-blocks' + Enabled: true + VersionAdded: '0.13' + +Style/MultilineIfModifier: + Description: 'Only use if/unless modifiers on single line statements.' + StyleGuide: '#no-multiline-if-modifiers' + Enabled: true + VersionAdded: '0.45' + +Style/MultilineIfThen: + Description: 'Do not use then for multi-line if/unless.' + StyleGuide: '#no-then' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.26' + +Style/MultilineInPatternThen: + Description: 'Do not use `then` for multi-line `in` statement.' + StyleGuide: '#no-then' + Enabled: pending + VersionAdded: '1.16' + +Style/MultilineMemoization: + Description: 'Wrap multiline memoizations in a `begin` and `end` block.' + Enabled: true + VersionAdded: '0.44' + VersionChanged: '0.48' + EnforcedStyle: keyword + SupportedStyles: + - keyword + - braces + +Style/MultilineMethodSignature: + Description: 'Avoid multi-line method signatures.' + Enabled: false + VersionAdded: '0.59' + VersionChanged: '1.7' + +Style/MultilineTernaryOperator: + Description: >- + Avoid multi-line ?: (the ternary operator); + use if/unless instead. + StyleGuide: '#no-multiline-ternary' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.86' + +Style/MultilineWhenThen: + Description: 'Do not use then for multi-line when statement.' + StyleGuide: '#no-then' + Enabled: true + VersionAdded: '0.73' + +Style/MultipleComparison: + Description: >- + Avoid comparing a variable with multiple items in a conditional, + use Array#include? instead. + Enabled: true + VersionAdded: '0.49' + VersionChanged: '1.1' + AllowMethodComparison: true + ComparisonsThreshold: 2 + +Style/MutableConstant: + Description: 'Do not assign mutable objects to constants.' + Enabled: true + VersionAdded: '0.34' + VersionChanged: '1.8' + SafeAutoCorrect: false + EnforcedStyle: literals + SupportedStyles: + # literals: freeze literals assigned to constants + # strict: freeze all constants + # Strict mode is considered an experimental feature. It has not been updated + # with an exhaustive list of all methods that will produce frozen objects so + # there is a decent chance of getting some false positives. Luckily, there is + # no harm in freezing an already frozen object. + - literals + - strict + +Style/NegatedIf: + Description: >- + Favor unless over if for negative conditions + (or control flow or). + StyleGuide: '#unless-for-negatives' + Enabled: true + VersionAdded: '0.20' + VersionChanged: '0.48' + EnforcedStyle: both + SupportedStyles: + # both: prefix and postfix negated `if` should both use `unless` + # prefix: only use `unless` for negated `if` statements positioned before the body of the statement + # postfix: only use `unless` for negated `if` statements positioned after the body of the statement + - both + - prefix + - postfix -Style/LambdaCall: - EnforcedStyle: call +Style/NegatedIfElseCondition: + Description: >- + Checks for uses of `if-else` and ternary operators with a negated condition + which can be simplified by inverting condition and swapping branches. + Enabled: pending + VersionAdded: '1.2' + +Style/NegatedUnless: + Description: 'Favor if over unless for negative conditions.' + StyleGuide: '#if-for-negatives' + Enabled: true + VersionAdded: '0.69' + EnforcedStyle: both SupportedStyles: - - call - - braces + # both: prefix and postfix negated `unless` should both use `if` + # prefix: only use `if` for negated `unless` statements positioned before the body of the statement + # postfix: only use `if` for negated `unless` statements positioned after the body of the statement + - both + - prefix + - postfix + +Style/NegatedWhile: + Description: 'Favor until over while for negative conditions.' + StyleGuide: '#until-for-negatives' + Enabled: true + VersionAdded: '0.20' + +Style/NestedFileDirname: + Description: 'Checks for nested `File.dirname`.' + Enabled: pending + VersionAdded: '1.26' + +Style/NestedModifier: + Description: 'Avoid using nested modifiers.' + StyleGuide: '#no-nested-modifiers' + Enabled: true + VersionAdded: '0.35' + +Style/NestedParenthesizedCalls: + Description: >- + Parenthesize method calls which are nested inside the + argument list of another parenthesized method call. + Enabled: true + VersionAdded: '0.36' + VersionChanged: '0.77' + AllowedMethods: + - be + - be_a + - be_an + - be_between + - be_falsey + - be_kind_of + - be_instance_of + - be_truthy + - be_within + - eq + - eql + - end_with + - include + - match + - raise_error + - respond_to + - start_with + +Style/NestedTernaryOperator: + Description: 'Use one expression per branch in a ternary operator.' + StyleGuide: '#no-nested-ternary' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.86' Style/Next: + Description: 'Use `next` to skip iteration instead of a condition at the end.' + StyleGuide: '#no-nested-conditionals' + Enabled: true + VersionAdded: '0.22' + VersionChanged: '1.75' # With `always` all conditions at the end of an iteration needs to be # replaced by next - with `skip_modifier_ifs` the modifier if like this one # are ignored: [1, 2].each { |a| return 'yes' if a == 1 } EnforcedStyle: skip_modifier_ifs - # `MinBodyLength` defines the number of lines of the a body of an if / unless + # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless` # needs to have to trigger this cop MinBodyLength: 3 + AllowConsecutiveConditionals: false SupportedStyles: - skip_modifier_ifs - always +Style/NilComparison: + Description: 'Prefer x.nil? to x == nil.' + StyleGuide: '#predicate-methods' + Enabled: true + VersionAdded: '0.12' + VersionChanged: '0.59' + EnforcedStyle: predicate + SupportedStyles: + - predicate + - comparison + +Style/NilLambda: + Description: 'Prefer `-> {}` to `-> { nil }`.' + Enabled: pending + VersionAdded: '1.3' + VersionChanged: '1.15' + Style/NonNilCheck: + Description: 'Checks for redundant nil checks.' + StyleGuide: '#no-non-nil-checks' + Enabled: true + VersionAdded: '0.20' + VersionChanged: '0.22' # With `IncludeSemanticChanges` set to `true`, this cop reports offenses for # `!x.nil?` and autocorrects that and `x != nil` to solely `x`, which is # **usually** OK, but might change behavior. @@ -513,28 +4947,122 @@ Style/NonNilCheck: # offenses for `!x.nil?` and does no changes that might change behavior. IncludeSemanticChanges: false -Style/MethodDefParentheses: - EnforcedStyle: require_parentheses - SupportedStyles: - - require_parentheses - - require_no_parentheses +Style/Not: + Description: 'Use ! instead of not.' + StyleGuide: '#bang-not-not' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.20' -Style/MethodName: - EnforcedStyle: snake_case +Style/NumberedParameters: + Description: 'Restrict the usage of numbered parameters.' + Enabled: pending + VersionAdded: '1.22' + EnforcedStyle: allow_single_line SupportedStyles: - - snake_case - - camelCase + - allow_single_line + - disallow -Style/MultilineOperationIndentation: - EnforcedStyle: aligned - SupportedStyles: - - aligned - - indented +Style/NumberedParametersLimit: + Description: 'Avoid excessive numbered params in a single block.' + Enabled: pending + VersionAdded: '1.22' + Max: 1 + +Style/NumericLiteralPrefix: + Description: 'Use smallcase prefixes for numeric literals.' + StyleGuide: '#numeric-literal-prefixes' + Enabled: true + VersionAdded: '0.41' + EnforcedOctalStyle: zero_with_o + SupportedOctalStyles: + - zero_with_o + - zero_only Style/NumericLiterals: + Description: >- + Add underscores to large numeric literals to improve their + readability. + StyleGuide: '#underscores-in-numerics' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.48' MinDigits: 5 + Strict: false + # You can specify allowed numbers. (e.g. port number 3000, 8080, and etc) + AllowedNumbers: [] + AllowedPatterns: [] + +Style/NumericPredicate: + Description: >- + Checks for the use of predicate- or comparison methods for + numeric comparisons. + StyleGuide: '#predicate-methods' + # This will change to a new method call which isn't guaranteed to be on the + # object. Switching these methods has to be done with knowledge of the types + # of the variables which rubocop doesn't have. + Safe: false + Enabled: true + VersionAdded: '0.42' + VersionChanged: '0.59' + EnforcedStyle: predicate + SupportedStyles: + - predicate + - comparison + AllowedMethods: [] + AllowedPatterns: [] + # Exclude RSpec specs because assertions like `expect(1).to be > 0` cause + # false positives. + Exclude: + - 'spec/**/*' + +Style/ObjectThen: + Description: 'Enforces the use of consistent method names `Object#yield_self` or `Object#then`.' + StyleGuide: '#object-yield-self-vs-object-then' + Enabled: pending + VersionAdded: '1.28' + # Use `Object#yield_self` or `Object#then`? + # Prefer `Object#yield_self` to `Object#then` (yield_self) + # Prefer `Object#then` to `Object#yield_self` (then) + EnforcedStyle: 'then' + SupportedStyles: + - then + - yield_self + +Style/OneLineConditional: + Description: >- + Favor the ternary operator (?:) or multi-line constructs over + single-line if/then/else/end constructs. + StyleGuide: '#ternary-operator' + Enabled: true + AlwaysCorrectToMultiline: false + VersionAdded: '0.9' + VersionChanged: '0.90' + +Style/OpenStructUse: + Description: >- + Avoid using OpenStruct. As of Ruby 3.0, use is officially discouraged due to performance, + version compatibility, and potential security issues. + References: + - https://docs.ruby-lang.org/en/3.0/OpenStruct.html#class-OpenStruct-label-Caveats + + Enabled: pending + Safe: false + VersionAdded: '1.23' + VersionChanged: '1.51' + +Style/OperatorMethodCall: + Description: 'Checks for redundant dot before operator method call.' + StyleGuide: '#operator-method-call' + Enabled: pending + VersionAdded: '1.37' Style/OptionHash: + Description: "Don't use option hashes when you can use keyword arguments." + StyleGuide: '#keyword-arguments-vs-option-hashes' + Enabled: false + VersionAdded: '0.33' + VersionChanged: '0.34' # A list of parameter names that will be flagged by this cop. SuspiciousParamNames: - options @@ -542,101 +5070,667 @@ Style/OptionHash: - args - params - parameters + Allowlist: [] + +Style/OptionalArguments: + Description: >- + Checks for optional arguments that do not appear at the end + of the argument list. + StyleGuide: '#optional-arguments' + Enabled: true + Safe: false + VersionAdded: '0.33' + VersionChanged: '0.83' + +Style/OptionalBooleanParameter: + Description: 'Use keyword arguments when defining method with boolean argument.' + StyleGuide: '#boolean-keyword-arguments' + Enabled: true + Safe: false + VersionAdded: '0.89' + AllowedMethods: + - respond_to_missing? + +Style/OrAssignment: + Description: 'Recommend usage of double pipe equals (||=) where applicable.' + StyleGuide: '#double-pipe-for-uninit' + Enabled: true + VersionAdded: '0.50' + +Style/ParallelAssignment: + Description: >- + Check for simple usages of parallel assignment. + It will only warn when the number of variables + matches on both sides of the assignment. + StyleGuide: '#parallel-assignment' + Enabled: true + VersionAdded: '0.32' -# Allow safe assignment in conditions. Style/ParenthesesAroundCondition: + Description: >- + Don't use parentheses around the condition of an + if/unless/while. + StyleGuide: '#no-parens-around-condition' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.56' AllowSafeAssignment: true + AllowInMultilineConditions: false Style/PercentLiteralDelimiters: + Description: 'Use `%`-literal delimiters consistently.' + StyleGuide: '#percent-literal-braces' + Enabled: true + VersionAdded: '0.19' + # Specify the default preferred delimiter for all types with the 'default' key + # Override individual delimiters (even with default specified) by specifying + # an individual key PreferredDelimiters: - '%': () - '%i': () - '%q': () - '%Q': () + default: () + '%i': '[]' + '%I': '[]' '%r': '{}' - '%s': () - '%w': () - '%W': () - '%x': () + '%w': '[]' + '%W': '[]' + VersionChanged: '0.48' Style/PercentQLiterals: + Description: 'Checks if uses of %Q/%q match the configured preference.' + Enabled: true + VersionAdded: '0.25' EnforcedStyle: lower_case_q SupportedStyles: - - lower_case_q # Use %q when possible, %Q when necessary - - upper_case_q # Always use %Q + - lower_case_q # Use `%q` when possible, `%Q` when necessary + - upper_case_q # Always use `%Q` -Style/PredicateName: - # Predicate name prefices. - NamePrefix: - - is_ - - has_ - - have_ - # Predicate name prefices that should be removed. - NamePrefixBlacklist: - - is_ - - has_ - - have_ +Style/PerlBackrefs: + Description: 'Avoid Perl-style regex back references.' + StyleGuide: '#no-perl-regexp-last-matchers' + Enabled: true + VersionAdded: '0.13' + +Style/PreferredHashMethods: + Description: 'Checks use of `has_key?` and `has_value?` Hash methods.' + StyleGuide: '#hash-key' + Enabled: true + Safe: false + VersionAdded: '0.41' + VersionChanged: '0.70' + EnforcedStyle: short + SupportedStyles: + - short + - verbose + +Style/Proc: + Description: 'Use proc instead of Proc.new.' + StyleGuide: '#proc' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.18' + +Style/QuotedSymbols: + Description: 'Use a consistent style for quoted symbols.' + Enabled: pending + VersionAdded: '1.16' + EnforcedStyle: same_as_string_literals + SupportedStyles: + - same_as_string_literals + - single_quotes + - double_quotes Style/RaiseArgs: + Description: 'Checks the arguments passed to raise/fail.' + StyleGuide: '#exception-class-messages' + Enabled: true + Safe: false + VersionAdded: '0.14' + VersionChanged: '1.61' EnforcedStyle: exploded SupportedStyles: - compact # raise Exception.new(msg) - exploded # raise Exception, msg + AllowedCompactTypes: [] + +Style/RandomWithOffset: + Description: >- + Prefer to use ranges when generating random numbers instead of + integers with offsets. + StyleGuide: '#random-numbers' + Enabled: true + VersionAdded: '0.52' + +Style/RedundantArgument: + Description: 'Checks for a redundant argument passed to certain methods.' + Enabled: pending + Safe: false + VersionAdded: '1.4' + VersionChanged: '1.55' + Methods: + # Array#join + join: '' + # Array#sum + sum: 0 + # Kernel.#exit + exit: true + # Kernel.#exit! + exit!: false + # String#split + split: ' ' + # String#chomp + chomp: "\n" + # String#chomp! + chomp!: "\n" + +Style/RedundantArrayConstructor: + Description: 'Checks for the instantiation of array using redundant `Array` constructor.' + Enabled: pending + VersionAdded: '1.52' + +Style/RedundantArrayFlatten: + Description: 'Checks for redundant calls of `Array#flatten`.' + Enabled: pending + Safe: false + VersionAdded: '1.76' + +Style/RedundantAssignment: + Description: 'Checks for redundant assignment before returning.' + Enabled: true + VersionAdded: '0.87' + +Style/RedundantBegin: + Description: "Don't use begin blocks when they are not needed." + StyleGuide: '#begin-implicit' + Enabled: true + VersionAdded: '0.10' + VersionChanged: '0.21' + +Style/RedundantCapitalW: + Description: 'Checks for %W when interpolation is not needed.' + Enabled: true + VersionAdded: '0.76' + +Style/RedundantCondition: + Description: 'Checks for unnecessary conditional expressions.' + Enabled: true + VersionAdded: '0.76' + VersionChanged: '1.73' + AllowedMethods: + - nonzero? + +Style/RedundantConditional: + Description: "Don't return true/false from a conditional." + Enabled: true + VersionAdded: '0.50' + +Style/RedundantConstantBase: + Description: Avoid redundant `::` prefix on constant. + Enabled: pending + VersionAdded: '1.40' + +Style/RedundantCurrentDirectoryInPath: + Description: 'Checks for a redundant current directory in a path given to `require_relative`.' + Enabled: pending + VersionAdded: '1.53' + +Style/RedundantDoubleSplatHashBraces: + Description: 'Checks for redundant uses of double splat hash braces.' + Enabled: pending + VersionAdded: '1.41' + +Style/RedundantEach: + Description: 'Checks for redundant `each`.' + Enabled: pending + Safe: false + VersionAdded: '1.38' + +Style/RedundantException: + Description: "Checks for an obsolete RuntimeException argument in raise/fail." + StyleGuide: '#no-explicit-runtimeerror' + Enabled: true + VersionAdded: '0.14' + VersionChanged: '0.29' + +Style/RedundantFetchBlock: + Description: >- + Use `fetch(key, value)` instead of `fetch(key) { value }` + when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant. + References: + - 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code' + Enabled: true + Safe: false + # If enabled, this cop will autocorrect usages of + # `fetch` being called with block returning a constant. + # This can be dangerous since constants will not be defined at that moment. + SafeForConstants: false + VersionAdded: '0.86' + +Style/RedundantFileExtensionInRequire: + Description: >- + Checks for the presence of superfluous `.rb` extension in + the filename provided to `require` and `require_relative`. + StyleGuide: '#no-explicit-rb-to-require' + Enabled: true + VersionAdded: '0.88' + +Style/RedundantFilterChain: + Description: >- + Identifies usages of `any?`, `empty?`, `none?` or `one?` predicate methods chained to + `select`/`filter`/`find_all` and change them to use predicate method instead. + Enabled: pending + SafeAutoCorrect: false + VersionAdded: '1.52' + VersionChanged: '1.57' + +Style/RedundantFormat: + Description: 'Checks for usages of `Kernel#format` or `Kernel#sprintf` with only a single argument.' + Enabled: pending + SafeAutoCorrect: false + VersionAdded: '1.72' + VersionChanged: '1.72' + +Style/RedundantFreeze: + Description: "Checks usages of Object#freeze on immutable objects." + Enabled: true + VersionAdded: '0.34' + VersionChanged: '0.66' + +Style/RedundantHeredocDelimiterQuotes: + Description: 'Checks for redundant heredoc delimiter quotes.' + Enabled: pending + VersionAdded: '1.45' + +Style/RedundantInitialize: + Description: 'Checks for redundant `initialize` methods.' + Enabled: pending + AutoCorrect: contextual + Safe: false + AllowComments: true + VersionAdded: '1.27' + VersionChanged: '1.61' + +Style/RedundantInterpolation: + Description: 'Checks for strings that are just an interpolated expression.' + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.76' + VersionChanged: '1.30' + +Style/RedundantInterpolationUnfreeze: + Description: 'Checks for redundant unfreezing of interpolated strings.' + Enabled: pending + VersionAdded: '1.66' + +Style/RedundantLineContinuation: + Description: 'Checks for redundant line continuation.' + Enabled: pending + VersionAdded: '1.49' + +Style/RedundantParentheses: + Description: "Checks for parentheses that seem not to serve any purpose." + Enabled: true + VersionAdded: '0.36' + +Style/RedundantPercentQ: + Description: 'Checks for %q/%Q when single quotes or double quotes would do.' + StyleGuide: '#percent-q' + Enabled: true + VersionAdded: '0.76' + +Style/RedundantRegexpArgument: + Description: 'Identifies places where argument can be replaced from a deterministic regexp to a string.' + Enabled: pending + VersionAdded: '1.53' + +Style/RedundantRegexpCharacterClass: + Description: 'Checks for unnecessary single-element Regexp character classes.' + Enabled: true + VersionAdded: '0.85' + +Style/RedundantRegexpConstructor: + Description: 'Checks for the instantiation of regexp using redundant `Regexp.new` or `Regexp.compile`.' + Enabled: pending + VersionAdded: '1.52' + +Style/RedundantRegexpEscape: + Description: 'Checks for redundant escapes in Regexps.' + Enabled: true + VersionAdded: '0.85' Style/RedundantReturn: - # When true allows code like `return x, y`. + Description: "Don't use return where it's not required." + StyleGuide: '#no-explicit-return' + Enabled: true + VersionAdded: '0.10' + VersionChanged: '0.14' + # When `true` allows code like `return x, y`. AllowMultipleReturnValues: false -# Use / or %r around regular expressions. +Style/RedundantSelf: + Description: "Don't use self where it's not needed." + StyleGuide: '#no-self-unless-required' + Enabled: true + VersionAdded: '0.10' + VersionChanged: '0.13' + +Style/RedundantSelfAssignment: + Description: 'Checks for places where redundant assignments are made for in place modification methods.' + Enabled: true + Safe: false + VersionAdded: '0.90' + +Style/RedundantSelfAssignmentBranch: + Description: 'Checks for places where conditional branch makes redundant self-assignment.' + Enabled: pending + VersionAdded: '1.19' + +Style/RedundantSort: + Description: >- + Use `min` instead of `sort.first`, + `max_by` instead of `sort_by...last`, etc. + Enabled: true + VersionAdded: '0.76' + VersionChanged: '1.22' + Safe: false + +Style/RedundantSortBy: + Description: 'Use `sort` instead of `sort_by { |x| x }`.' + Enabled: true + VersionAdded: '0.36' + +Style/RedundantStringEscape: + Description: 'Checks for redundant escapes in string literals.' + Enabled: pending + VersionAdded: '1.37' + Style/RegexpLiteral: + Description: 'Use / or %r around regular expressions.' + StyleGuide: '#percent-r' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.30' EnforcedStyle: slashes # slashes: Always use slashes. - # percent_r: Always use %r. - # mixed: Use slashes on single-line regexes, and %r on multi-line regexes. + # percent_r: Always use `%r`. + # mixed: Use slashes on single-line regexes, and `%r` on multi-line regexes. SupportedStyles: - slashes - percent_r - mixed - # If false, the cop will always recommend using %r if one or more slashes + # If `false`, the cop will always recommend using `%r` if one or more slashes # are found in the regexp string. AllowInnerSlashes: false +Style/RequireOrder: + Description: Sort `require` and `require_relative` in alphabetical order. + Enabled: false + SafeAutoCorrect: false + VersionAdded: '1.40' + +Style/RescueModifier: + Description: 'Avoid using rescue in its modifier form.' + StyleGuide: '#no-rescue-modifiers' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.34' + +Style/RescueStandardError: + Description: 'Avoid rescuing without specifying an error class.' + Enabled: true + VersionAdded: '0.52' + EnforcedStyle: explicit + # implicit: Do not include the error class, `rescue` + # explicit: Require an error class `rescue StandardError` + SupportedStyles: + - implicit + - explicit + +Style/ReturnNil: + Description: 'Use return instead of return nil.' + Enabled: false + EnforcedStyle: return + SupportedStyles: + - return + - return_nil + VersionAdded: '0.50' + +Style/ReturnNilInPredicateMethodDefinition: + Description: 'Checks if uses of `return` or `return nil` in predicate method definition.' + StyleGuide: '#bool-methods-qmark' + Enabled: pending + SafeAutoCorrect: false + AllowedMethods: [] + AllowedPatterns: [] + VersionAdded: '1.53' + VersionChanged: '1.67' + +Style/SafeNavigation: + Description: >- + Transforms usages of a method call safeguarded by + a check for the existence of the object to + safe navigation (`&.`). + Autocorrection is unsafe as it assumes the object will + be `nil` or truthy, but never `false`. + Enabled: true + VersionAdded: '0.43' + VersionChanged: '1.67' + # Safe navigation may cause a statement to start returning `nil` in addition + # to whatever it used to return. + ConvertCodeThatCanStartToReturnNil: false + AllowedMethods: + - present? + - blank? + - presence + - try + - try! + SafeAutoCorrect: false + # Maximum length of method chains for register an offense. + MaxChainLength: 2 + +Style/SafeNavigationChainLength: + Description: 'Enforces safe navigation chains length to not exceed the configured maximum.' + StyleGuide: '#safe-navigation' + Enabled: pending + VersionAdded: '1.68' + Max: 2 + +Style/Sample: + Description: >- + Use `sample` instead of `shuffle.first`, + `shuffle.last`, and `shuffle[Integer]`. + References: + - 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code' + Enabled: true + VersionAdded: '0.30' + +Style/SelectByRegexp: + Description: 'Prefer grep/grep_v to select/reject with a regexp match.' + Enabled: pending + SafeAutoCorrect: false + VersionAdded: '1.22' + +Style/SelfAssignment: + Description: >- + Checks for places where self-assignment shorthand should have + been used. + StyleGuide: '#self-assignment' + Enabled: true + VersionAdded: '0.19' + VersionChanged: '0.29' + Style/Semicolon: - # Allow ; to separate several expressions on the same line. + Description: "Don't use semicolons to terminate expressions." + StyleGuide: '#no-semicolon' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.19' + # Allow `;` to separate several expressions on the same line. AllowAsExpressionSeparator: false +Style/Send: + Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.' + StyleGuide: '#prefer-public-send' + Enabled: false + VersionAdded: '0.33' + +Style/SendWithLiteralMethodName: + Description: 'Detects the use of the `public_send` method with a static method name argument.' + Enabled: pending + Safe: false + AllowSend: true + VersionAdded: '1.64' + Style/SignalException: - EnforcedStyle: semantic + Description: 'Checks for proper usage of fail and raise.' + StyleGuide: '#prefer-raise-over-fail' + Enabled: true + VersionAdded: '0.11' + VersionChanged: '0.37' + EnforcedStyle: only_raise SupportedStyles: - only_raise - only_fail - semantic +Style/SingleArgumentDig: + Description: 'Avoid using single argument dig method.' + Enabled: true + VersionAdded: '0.89' + Safe: false + Style/SingleLineBlockParams: + Description: 'Enforces the names of some block params.' + Enabled: false + VersionAdded: '0.16' + VersionChanged: '1.6' Methods: - reduce: - - a - - e + - acc + - elem - inject: - - a - - e + - acc + - elem + +Style/SingleLineDoEndBlock: + Description: 'Checks for single-line `do`...`end` blocks.' + StyleGuide: '#single-line-do-end-block' + Enabled: pending + VersionAdded: '1.57' Style/SingleLineMethods: + Description: 'Avoid single-line methods.' + StyleGuide: '#no-single-line-methods' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '1.8' AllowIfMethodIsEmpty: true +Style/SlicingWithRange: + Description: 'Checks array slicing is done with redundant, endless, and beginless ranges when suitable.' + StyleGuide: '#slicing-with-ranges' + Enabled: true + VersionAdded: '0.83' + Safe: false + +Style/SoleNestedConditional: + Description: >- + Finds sole nested conditional nodes + which can be merged into outer conditional node. + Enabled: true + VersionAdded: '0.89' + VersionChanged: '1.5' + AllowModifier: false + +Style/SpecialGlobalVars: + Description: 'Avoid Perl-style global variables.' + StyleGuide: '#no-cryptic-perlisms' + Enabled: true + VersionAdded: '0.13' + VersionChanged: '0.36' + SafeAutoCorrect: false + RequireEnglish: true + EnforcedStyle: use_english_names + SupportedStyles: + - use_perl_names + - use_english_names + - use_builtin_english_names + +Style/StabbyLambdaParentheses: + Description: 'Checks for the usage of parentheses around stabby lambda arguments.' + StyleGuide: '#stabby-lambda-with-args' + Enabled: true + VersionAdded: '0.35' + EnforcedStyle: require_parentheses + SupportedStyles: + - require_parentheses + - require_no_parentheses + +Style/StaticClass: + Description: 'Prefer modules to classes with only class methods.' + StyleGuide: '#modules-vs-classes' + Enabled: false + Safe: false + VersionAdded: '1.3' + +Style/StderrPuts: + Description: 'Use `warn` instead of `$stderr.puts`.' + StyleGuide: '#warn' + Enabled: true + VersionAdded: '0.51' + +Style/StringChars: + Description: 'Checks for uses of `String#split` with empty string or regexp literal argument.' + StyleGuide: '#string-chars' + Enabled: pending + Safe: false + VersionAdded: '1.12' + +Style/StringConcatenation: + Description: 'Checks for places where string concatenation can be replaced with string interpolation.' + StyleGuide: '#string-interpolation' + Enabled: true + Safe: false + VersionAdded: '0.89' + VersionChanged: '1.18' + Mode: aggressive + +Style/StringHashKeys: + Description: 'Prefer symbols instead of strings as hash keys.' + StyleGuide: '#symbols-as-keys' + Enabled: false + VersionAdded: '0.52' + VersionChanged: '0.75' + Safe: false + Style/StringLiterals: + Description: 'Checks if uses of quotes match the configured preference.' + StyleGuide: '#consistent-string-literals' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.36' EnforcedStyle: single_quotes SupportedStyles: - single_quotes - double_quotes + # If `true`, strings which span multiple lines using `\` for continuation must + # use the same type of quotes on each line. + ConsistentQuotesInMultiline: false Style/StringLiteralsInInterpolation: + Description: >- + Checks if uses of quotes inside expressions in interpolated + strings match the configured preference. + Enabled: true + VersionAdded: '0.27' EnforcedStyle: single_quotes SupportedStyles: - single_quotes - double_quotes Style/StringMethods: + Description: 'Checks if configured preferred methods are used over non-preferred.' + Enabled: false + VersionAdded: '0.34' + VersionChanged: '0.34' # Mapping from undesired method to desired_method # e.g. to use `to_sym` over `intern`: # @@ -646,79 +5740,180 @@ Style/StringMethods: PreferredMethods: intern: to_sym -Style/SpaceAroundBlockParameters: - EnforcedStyleInsidePipes: no_space - SupportedStyles: - - space - - no_space +Style/Strip: + Description: 'Use `strip` instead of `lstrip.rstrip`.' + Enabled: true + VersionAdded: '0.36' -Style/SpaceAroundEqualsInParameterDefault: - EnforcedStyle: space - SupportedStyles: - - space - - no_space +Style/StructInheritance: + Description: 'Checks for inheritance from Struct.new.' + StyleGuide: '#no-extend-struct-new' + Enabled: true + SafeAutoCorrect: false + VersionAdded: '0.29' + VersionChanged: '1.20' -Style/SpaceAroundOperators: - MultiSpaceAllowedForOperators: - - '=' - - '=>' +Style/SuperArguments: + Description: 'Call `super` without arguments and parentheses when the signature is identical.' + Enabled: pending + VersionAdded: '1.64' -Style/SpaceBeforeBlockBraces: - EnforcedStyle: space - SupportedStyles: - - space - - no_space +Style/SuperWithArgsParentheses: + Description: 'Use parentheses for `super` with arguments.' + StyleGuide: '#super-with-args' + Enabled: pending + VersionAdded: '1.58' -Style/SpaceInsideBlockBraces: - EnforcedStyle: space - SupportedStyles: - - space - - no_space - # Valid values are: space, no_space - EnforcedStyleForEmptyBraces: no_space - # Space between { and |. Overrides EnforcedStyle if there is a conflict. - SpaceBeforeBlockParameters: true +Style/SwapValues: + Description: 'Enforces the use of shorthand-style swapping of 2 variables.' + StyleGuide: '#values-swapping' + Enabled: pending + VersionAdded: '1.1' + SafeAutoCorrect: false -Style/SpaceInsideHashLiteralBraces: - EnforcedStyle: space - EnforcedStyleForEmptyBraces: no_space +Style/SymbolArray: + Description: 'Use %i or %I for arrays of symbols.' + StyleGuide: '#percent-i' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.49' + EnforcedStyle: percent + MinSize: 2 SupportedStyles: - - space - - no_space + - percent + - brackets -Style/SpaceInsideStringInterpolation: - EnforcedStyle: no_space - SupportedStyles: - - space - - no_space +Style/SymbolLiteral: + Description: 'Use plain symbols instead of string symbols when possible.' + Enabled: true + VersionAdded: '0.30' Style/SymbolProc: - # A list of method names to be ignored by the check. + Description: 'Use symbols as procs instead of blocks when possible.' + Enabled: true + Safe: false + VersionAdded: '0.26' + VersionChanged: '1.64' + AllowMethodsWithArguments: false + # A list of method names to be always allowed by the check. # The names should be fairly unique, otherwise you'll end up ignoring lots of code. - IgnoredMethods: - - respond_to + AllowedMethods: + - define_method + AllowedPatterns: [] + AllowComments: false -Style/TrailingBlankLines: - EnforcedStyle: final_newline +Style/TernaryParentheses: + Description: 'Checks for use of parentheses around ternary conditions.' + Enabled: true + VersionAdded: '0.42' + VersionChanged: '0.46' + EnforcedStyle: require_no_parentheses SupportedStyles: - - final_newline - - final_blank_line + - require_parentheses + - require_no_parentheses + - require_parentheses_when_complex + AllowSafeAssignment: true + +Style/TopLevelMethodDefinition: + Description: 'Looks for top-level method definitions.' + StyleGuide: '#top-level-methods' + Enabled: false + VersionAdded: '1.15' + +Style/TrailingBodyOnClass: + Description: 'Class body goes below class statement.' + Enabled: true + VersionAdded: '0.53' -Style/TrailingComma: - # If EnforcedStyleForMultiline is comma, the cop requires a comma after the - # last item of a list, but only for lists where each item is on its own line. - # If EnforcedStyleForMultiline is consistent_comma, the cop requires a comma - # after the last item of a list, for all lists. +Style/TrailingBodyOnMethodDefinition: + Description: 'Method body goes below definition.' + Enabled: true + VersionAdded: '0.52' + +Style/TrailingBodyOnModule: + Description: 'Module body goes below module statement.' + Enabled: true + VersionAdded: '0.53' + +Style/TrailingCommaInArguments: + Description: 'Checks for trailing comma in argument lists.' + StyleGuide: '#no-trailing-params-comma' + Enabled: true + VersionAdded: '0.36' + # If `comma`, the cop requires a comma after the last argument, but only for + # parenthesized method calls where each argument is on its own line. + # If `consistent_comma`, the cop requires a comma after the last argument, + # for all parenthesized method calls with arguments. EnforcedStyleForMultiline: no_comma - SupportedStyles: + SupportedStylesForMultiline: + - comma + - consistent_comma + - no_comma + +Style/TrailingCommaInArrayLiteral: + Description: 'Checks for trailing comma in array literals.' + StyleGuide: '#no-trailing-array-commas' + Enabled: true + VersionAdded: '0.53' + # If `comma`, the cop requires a comma after the last item in an array, but only when each item is + # on its own line. + # If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline + # array literals. + # If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline array + # literals, but only when that last item immediately precedes a newline. + EnforcedStyleForMultiline: no_comma + SupportedStylesForMultiline: - comma - consistent_comma + - diff_comma - no_comma -# TrivialAccessors requires exact name matches and doesn't allow +Style/TrailingCommaInBlockArgs: + Description: 'Checks for useless trailing commas in block arguments.' + Enabled: false + Safe: false + VersionAdded: '0.81' + +Style/TrailingCommaInHashLiteral: + Description: 'Checks for trailing comma in hash literals.' + Enabled: true + # If `comma`, the cop requires a comma after the last item in a hash, but only when each item is + # on its own line. + # If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline + # hash literals. + # If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline hash + # literals, but only when that last item immediately precedes a newline. + EnforcedStyleForMultiline: no_comma + SupportedStylesForMultiline: + - comma + - consistent_comma + - diff_comma + - no_comma + VersionAdded: '0.53' + +Style/TrailingMethodEndStatement: + Description: 'Checks for trailing end statement on line of method body.' + Enabled: true + VersionAdded: '0.52' + +Style/TrailingUnderscoreVariable: + Description: >- + Checks for the usage of unneeded trailing underscores at the + end of parallel variable assignment. + AllowNamedUnderscoreVariables: true + Enabled: true + VersionAdded: '0.31' + VersionChanged: '0.35' + +# `TrivialAccessors` requires exact name matches and doesn't allow # predicated methods by default. Style/TrivialAccessors: - # When set to false the cop will suggest the use of accessor methods + Description: 'Prefer attr_* methods to trivial readers/writers.' + StyleGuide: '#attr_family' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '1.15' + # When set to `false` the cop will suggest the use of accessor methods # in situations like: # # def name @@ -727,7 +5922,7 @@ Style/TrivialAccessors: # # This way you can uncover "hidden" attributes in your code. ExactNameMatch: true - AllowPredicates: false + AllowPredicates: true # Allows trivial writers that don't end in an equal sign. e.g. # # def on_exception(action) @@ -736,9 +5931,9 @@ Style/TrivialAccessors: # on_exception :restart # # Commonly used in DSLs - AllowDSLWriters: false + AllowDSLWriters: true IgnoreClassMethods: false - Whitelist: + AllowedMethods: - to_ary - to_a - to_c @@ -757,152 +5952,120 @@ Style/TrivialAccessors: - to_s - to_sym -Style/VariableName: - EnforcedStyle: snake_case - SupportedStyles: - - snake_case - - camelCase - -Style/WhileUntilModifier: - MaxLineLength: 80 - -Style/WordArray: - MinSize: 0 - # The regular expression WordRegex decides what is considered a word. - WordRegex: !ruby/regexp '/\A[\p{Word}]+\z/' - -##################### Metrics ################################## - -Metrics/AbcSize: - # The ABC size is a calculated magnitude, so this number can be a Fixnum or - # a Float. - Max: 15 - -Metrics/BlockNesting: - Max: 3 - -Metrics/ClassLength: - CountComments: false # count full line comments? - Max: 100 - -Metrics/ModuleLength: - CountComments: false # count full line comments? - Max: 100 - -# Avoid complex methods. -Metrics/CyclomaticComplexity: - Max: 6 - -Metrics/LineLength: - Max: 80 - # To make it possible to copy or click on URIs in the code, we allow lines - # contaning a URI to be longer than Max. - AllowURI: true - URISchemes: - - http - - https +Style/UnlessElse: + Description: >- + Do not use unless with else. Rewrite these with the positive + case first. + StyleGuide: '#no-else-with-unless' + Enabled: true + VersionAdded: '0.9' -Metrics/MethodLength: - CountComments: false # count full line comments? - Max: 10 +Style/UnlessLogicalOperators: + Description: >- + Checks for use of logical operators in an unless condition. + Enabled: false + VersionAdded: '1.11' + EnforcedStyle: forbid_mixed_logical_operators + SupportedStyles: + - forbid_mixed_logical_operators + - forbid_logical_operators -Metrics/ParameterLists: - Max: 5 - CountKeywordArgs: true +Style/UnpackFirst: + Description: >- + Checks for accessing the first element of `String#unpack` + instead of using `unpack1`. + Enabled: true + VersionAdded: '0.54' -Metrics/PerceivedComplexity: - Max: 7 +Style/VariableInterpolation: + Description: >- + Don't interpolate global, instance and class variables + directly in strings. + StyleGuide: '#curlies-interpolate' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.20' -##################### Lint ################################## +Style/WhenThen: + Description: 'Use when x then ... for one-line cases.' + StyleGuide: '#no-when-semicolons' + Enabled: true + VersionAdded: '0.9' -# Allow safe assignment in conditions. -Lint/AssignmentInCondition: - AllowSafeAssignment: true +Style/WhileUntilDo: + Description: 'Checks for redundant do after while or until.' + StyleGuide: '#no-multiline-while-do' + Enabled: true + VersionAdded: '0.9' -# Align ends correctly. -Lint/EndAlignment: - # The value `keyword` means that `end` should be aligned with the matching - # keyword (if, while, etc.). - # The value `variable` means that in assignments, `end` should be aligned - # with the start of the variable on the left hand side of `=`. In all other - # situations, `end` should still be aligned with the keyword. - AlignWith: keyword - SupportedStyles: - - keyword - - variable - AutoCorrect: false +Style/WhileUntilModifier: + Description: >- + Favor modifier while/until usage when you have a + single-line body. + StyleGuide: '#while-as-a-modifier' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '0.30' -Lint/DefEndAlignment: - # The value `def` means that `end` should be aligned with the def keyword. - # The value `start_of_line` means that `end` should be aligned with method - # calls like `private`, `public`, etc, if present in front of the `def` - # keyword on the same line. - AlignWith: start_of_line +Style/WordArray: + Description: 'Use %w or %W for arrays of words.' + StyleGuide: '#percent-w' + Enabled: true + VersionAdded: '0.9' + VersionChanged: '1.19' + EnforcedStyle: percent SupportedStyles: - - start_of_line - - def - AutoCorrect: false - -##################### Rails ################################## + # percent style: %w(word1 word2) + - percent + # bracket style: ['word1', 'word2'] + - brackets + # The `MinSize` option causes the `WordArray` rule to be ignored for arrays + # smaller than a certain size. The rule is only applied to arrays + # whose element count is greater than or equal to `MinSize`. + MinSize: 2 + # The regular expression `WordRegex` decides what is considered a word. + WordRegex: !ruby/regexp '/\A(?:\p{Word}|\p{Word}-\p{Word}|\n|\t)+\z/' -Rails/ActionFilter: - EnforcedStyle: action - SupportedStyles: - - action - - filter - Include: - - app/controllers/**/*.rb +Style/YAMLFileRead: + Description: 'Checks for the use of `YAML.load`, `YAML.safe_load`, and `YAML.parse` with `File.read` argument.' + Enabled: pending + VersionAdded: '1.53' -Rails/Date: - # The value `strict` disallows usage of `Date.today`, `Date.current`, - # `Date#to_time` etc. - # The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc - # (but not `Date.today`) which are overriden by ActiveSupport to handle current - # time zone. - EnforcedStyle: flexible +Style/YodaCondition: + Description: 'Forbid or enforce yoda conditions.' + References: + - 'https://en.wikipedia.org/wiki/Yoda_conditions' + Enabled: true + EnforcedStyle: forbid_for_all_comparison_operators SupportedStyles: - - strict - - flexible - -Rails/DefaultScope: - Include: - - app/models/**/*.rb - -Rails/FindBy: - Include: - - app/models/**/*.rb - -Rails/FindEach: - Include: - - app/models/**/*.rb - -Rails/HasAndBelongsToMany: - Include: - - app/models/**/*.rb - -Rails/Output: - Include: - - app/**/*.rb - - config/**/*.rb - - db/**/*.rb - - lib/**/*.rb - -Rails/ReadWriteAttribute: - Include: - - app/models/**/*.rb - -Rails/ScopeArgs: - Include: - - app/models/**/*.rb + # check all comparison operators + - forbid_for_all_comparison_operators + # check only equality operators: `!=` and `==` + - forbid_for_equality_operators_only + # enforce yoda for all comparison operators + - require_for_all_comparison_operators + # enforce yoda only for equality operators: `!=` and `==` + - require_for_equality_operators_only + Safe: false + VersionAdded: '0.49' + VersionChanged: '0.75' -Rails/TimeZone: - # The value `strict` means that `Time` should be used with `zone`. - # The value `flexible` allows usage of `in_time_zone` instead of `zone`. - EnforcedStyle: flexible - SupportedStyles: - - strict - - flexible +Style/YodaExpression: + Description: 'Forbid the use of yoda expressions.' + Enabled: false + Safe: false + VersionAdded: '1.42' + VersionChanged: '1.43' + SupportedOperators: + - '*' + - '+' + - '&' + - '|' + - '^' -Rails/Validation: - Include: - - app/models/**/*.rb +Style/ZeroLengthPredicate: + Description: 'Use #empty? when testing for objects of length 0.' + Enabled: true + Safe: false + VersionAdded: '0.37' + VersionChanged: '0.39' diff --git a/config/disabled.yml b/config/disabled.yml deleted file mode 100644 index 3a27bff2e56a..000000000000 --- a/config/disabled.yml +++ /dev/null @@ -1,67 +0,0 @@ -# These are all the cops that are disabled in the default configuration. - -Style/AutoResourceCleanup: - Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).' - Enabled: false - -Style/CollectionMethods: - Description: 'Preferred collection methods.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size' - Enabled: false - -Style/Copyright: - Description: 'Include a copyright notice in each file before any code.' - Enabled: false - -Style/Encoding: - Description: 'Use UTF-8 as the source file encoding.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#utf-8' - Enabled: false - -Style/InlineComment: - Description: 'Avoid inline comments.' - Enabled: false - -Style/MethodCalledOnDoEndBlock: - Description: 'Avoid chaining a method call on a do...end block.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks' - Enabled: false - -Style/MissingElse: - Description: >- - Require if/case expressions to have an else branches. - If enabled, it is recommended that - Style/UnlessElse and Style/EmptyElse be enabled. - This will conflict with Style/EmptyElse if - Style/EmptyElse is configured to style "both" - Enabled: false - EnforcedStyle: both - SupportedStyles: - # if - warn when an if expression is missing an else branch - # case - warn when a case expression is missing an else branch - # both - warn when an if or case expression is missing an else branch - - if - - case - - both - -Style/MutableConstant: - Description: 'Do not assign mutable objects to constants.' - Enabled: false - -Style/OptionHash: - Description: "Don't use option hashes when you can use keyword arguments." - Enabled: false - -Style/Send: - Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#prefer-public-send' - Enabled: false - -Style/SymbolArray: - Description: 'Use %i or %I for arrays of symbols.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-i' - Enabled: false - -Lint/LiteralInInterpolation: - Description: 'Avoid interpolating literals in strings' - AutoCorrect: false diff --git a/config/enabled.yml b/config/enabled.yml deleted file mode 100644 index 175e8a5e5f62..000000000000 --- a/config/enabled.yml +++ /dev/null @@ -1,1177 +0,0 @@ -# These are all the cops that are enabled in the default configuration. - -Style/AccessModifierIndentation: - Description: Check indentation of private/protected visibility modifiers. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-public-private-protected' - Enabled: true - -Style/AccessorMethodName: - Description: Check the naming of accessor methods for get_/set_. - Enabled: true - -Style/Alias: - Description: 'Use alias_method instead of alias.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method' - Enabled: true - -Style/AlignArray: - Description: >- - Align the elements of an array literal if they span more than - one line. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#align-multiline-arrays' - Enabled: true - -Style/AlignHash: - Description: >- - Align the elements of a hash literal if they span more than - one line. - Enabled: true - -Style/AlignParameters: - Description: >- - Align the parameters of a method call if they span more - than one line. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent' - Enabled: true - -Style/AndOr: - Description: 'Use &&/|| instead of and/or.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-and-or-or' - Enabled: true - -Style/ArrayJoin: - Description: 'Use Array#join instead of Array#*.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#array-join' - Enabled: true - -Style/AsciiComments: - Description: 'Use only ascii symbols in comments.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments' - Enabled: true - -Style/AsciiIdentifiers: - Description: 'Use only ascii symbols in identifiers.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers' - Enabled: true - -Style/Attr: - Description: 'Checks for uses of Module#attr.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr' - Enabled: true - -Style/BeginBlock: - Description: 'Avoid the use of BEGIN blocks.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-BEGIN-blocks' - Enabled: true - -Style/BarePercentLiterals: - Description: 'Checks if usage of %() or %Q() matches configuration.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-q-shorthand' - Enabled: true - -Style/BlockComments: - Description: 'Do not use block comments.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-block-comments' - Enabled: true - -Style/BlockEndNewline: - Description: 'Put end statement of multiline block on its own line.' - Enabled: true - -Style/BlockDelimiters: - Description: >- - Avoid using {...} for multi-line blocks (multiline chaining is - always ugly). - Prefer {...} over do...end for single-line blocks. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks' - Enabled: true - -Style/BracesAroundHashParameters: - Description: 'Enforce braces style around hash parameters.' - Enabled: true - -Style/CaseEquality: - Description: 'Avoid explicit use of the case equality operator(===).' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality' - Enabled: true - -Style/CaseIndentation: - Description: 'Indentation of when in a case/when/[else/]end.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-when-to-case' - Enabled: true - -Style/CharacterLiteral: - Description: 'Checks for uses of character literals.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals' - Enabled: true - -Style/ClassAndModuleCamelCase: - Description: 'Use CamelCase for classes and modules.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#camelcase-classes' - Enabled: true - -Style/ClassAndModuleChildren: - Description: 'Checks style of children classes and modules.' - Enabled: true - -Style/ClassCheck: - Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.' - Enabled: true - -Style/ClassMethods: - Description: 'Use self when defining module/class methods.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#def-self-class-methods' - Enabled: true - -Style/ClassVars: - Description: 'Avoid the use of class variables.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars' - Enabled: true - -Style/ClosingParenthesisIndentation: - Description: 'Checks the indentation of hanging closing parentheses.' - Enabled: true - -Style/ColonMethodCall: - Description: 'Do not use :: for method call.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#double-colons' - Enabled: true - -Style/CommandLiteral: - Description: 'Use `` or %x around command literals.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-x' - Enabled: true - -Style/CommentAnnotation: - Description: >- - Checks formatting of special comments - (TODO, FIXME, OPTIMIZE, HACK, REVIEW). - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#annotate-keywords' - Enabled: true - -Style/CommentIndentation: - Description: 'Indentation of comments.' - Enabled: true - -Style/ConstantName: - Description: 'Constants should use SCREAMING_SNAKE_CASE.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#screaming-snake-case' - Enabled: true - -Style/DefWithParentheses: - Description: 'Use def with parentheses when there are arguments.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens' - Enabled: true - -Style/DeprecatedHashMethods: - Description: 'Checks for use of deprecated Hash methods.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-key' - Enabled: true - -Style/Documentation: - Description: 'Document classes and non-namespace modules.' - Enabled: true - -Style/DotPosition: - Description: 'Checks the position of the dot in multi-line method calls.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains' - Enabled: true - -Style/DoubleNegation: - Description: 'Checks for uses of double negation (!!).' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang' - Enabled: true - -Style/EachWithObject: - Description: 'Prefer `each_with_object` over `inject` or `reduce`.' - Enabled: true - -Style/ElseAlignment: - Description: 'Align elses and elsifs correctly.' - Enabled: true - -Style/EmptyElse: - Description: 'Avoid empty else-clauses.' - Enabled: true - -Style/EmptyLineBetweenDefs: - Description: 'Use empty lines between defs.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#empty-lines-between-methods' - Enabled: true - -Style/EmptyLines: - Description: "Don't use several empty lines in a row." - Enabled: true - -Style/EmptyLinesAroundAccessModifier: - Description: "Keep blank lines around access modifiers." - Enabled: true - -Style/EmptyLinesAroundBlockBody: - Description: "Keeps track of empty lines around block bodies." - Enabled: true - -Style/EmptyLinesAroundClassBody: - Description: "Keeps track of empty lines around class bodies." - Enabled: true - -Style/EmptyLinesAroundModuleBody: - Description: "Keeps track of empty lines around module bodies." - Enabled: true - -Style/EmptyLinesAroundMethodBody: - Description: "Keeps track of empty lines around method bodies." - Enabled: true - -Style/EmptyLiteral: - Description: 'Prefer literals to Array.new/Hash.new/String.new.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash' - Enabled: true - -Style/EndBlock: - Description: 'Avoid the use of END blocks.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-END-blocks' - Enabled: true - -Style/EndOfLine: - Description: 'Use Unix-style line endings.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#crlf' - Enabled: true - -Style/EvenOdd: - Description: 'Favor the use of Fixnum#even? && Fixnum#odd?' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods' - Enabled: true - -Style/ExtraSpacing: - Description: 'Do not use unnecessary spacing.' - Enabled: true - -Style/FileName: - Description: 'Use snake_case for source file names.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files' - Enabled: true - -Style/InitialIndentation: - Description: >- - Checks the indentation of the first non-blank non-comment line in a file. - Enabled: true - -Style/FirstParameterIndentation: - Description: 'Checks the indentation of the first parameter in a method call.' - Enabled: true - -Style/FlipFlop: - Description: 'Checks for flip flops' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops' - Enabled: true - -Style/For: - Description: 'Checks use of for or each in multiline loops.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-for-loops' - Enabled: true - -Style/FormatString: - Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf' - Enabled: true - -Style/GlobalVars: - Description: 'Do not introduce global variables.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars' - Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html' - Enabled: true - -Style/GuardClause: - Description: 'Check for conditionals that can be replaced with guard clauses' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals' - Enabled: true - -Style/HashSyntax: - Description: >- - Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax - { :a => 1, :b => 2 }. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-literals' - Enabled: true - -Style/IfUnlessModifier: - Description: >- - Favor modifier if/unless usage when you have a - single-line body. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier' - Enabled: true - -Style/IfWithSemicolon: - Description: 'Do not use if x; .... Use the ternary operator instead.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs' - Enabled: true - -Style/IndentationConsistency: - Description: 'Keep indentation straight.' - Enabled: true - -Style/IndentationWidth: - Description: 'Use 2 spaces for indentation.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation' - Enabled: true - -Style/IndentArray: - Description: >- - Checks the indentation of the first element in an array - literal. - Enabled: true - -Style/IndentHash: - Description: 'Checks the indentation of the first key in a hash literal.' - Enabled: true - -Style/InfiniteLoop: - Description: 'Use Kernel#loop for infinite loops.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#infinite-loop' - Enabled: true - -Style/Lambda: - Description: 'Use the new lambda literal syntax for single-line blocks.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line' - Enabled: true - -Style/LambdaCall: - Description: 'Use lambda.call(...) instead of lambda.(...).' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call' - Enabled: true - -Style/LeadingCommentSpace: - Description: 'Comments should start with a space.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-space' - Enabled: true - -Style/LineEndConcatenation: - Description: >- - Use \ instead of + or << to concatenate two string literals at - line end. - Enabled: true - -Style/MethodCallParentheses: - Description: 'Do not use parentheses for method calls with no arguments.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens' - Enabled: true - -Style/MethodDefParentheses: - Description: >- - Checks if the method definitions have or don't have - parentheses. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens' - Enabled: true - -Style/MethodName: - Description: 'Use the configured style when naming methods.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars' - Enabled: true - -Style/ModuleFunction: - Description: 'Checks for usage of `extend self` in modules.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function' - Enabled: true - -Style/MultilineBlockChain: - Description: 'Avoid multi-line chains of blocks.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks' - Enabled: true - -Style/MultilineBlockLayout: - Description: 'Ensures newlines after multiline block do statements.' - Enabled: true - -Style/MultilineIfThen: - Description: 'Do not use then for multi-line if/unless.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-then' - Enabled: true - -Style/MultilineOperationIndentation: - Description: >- - Checks indentation of binary operations that span more than - one line. - Enabled: true - -Style/MultilineTernaryOperator: - Description: >- - Avoid multi-line ?: (the ternary operator); - use if/unless instead. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-multiline-ternary' - Enabled: true - -Style/NegatedIf: - Description: >- - Favor unless over if for negative conditions - (or control flow or). - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives' - Enabled: true - -Style/NegatedWhile: - Description: 'Favor until over while for negative conditions.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives' - Enabled: true - -Style/NestedTernaryOperator: - Description: 'Use one expression per branch in a ternary operator.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-ternary' - Enabled: true - -Style/Next: - Description: 'Use `next` to skip iteration instead of a condition at the end.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals' - Enabled: true - -Style/NilComparison: - Description: 'Prefer x.nil? to x == nil.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods' - Enabled: true - -Style/NonNilCheck: - Description: 'Checks for redundant nil checks.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-non-nil-checks' - Enabled: true - -Style/Not: - Description: 'Use ! instead of not.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not' - Enabled: true - -Style/NumericLiterals: - Description: >- - Add underscores to large numeric literals to improve their - readability. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics' - Enabled: true - -Style/OneLineConditional: - Description: >- - Favor the ternary operator(?:) over - if/then/else/end constructs. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator' - Enabled: true - -Style/OpMethod: - Description: 'When defining binary operators, name the argument other.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg' - Enabled: true - -Style/OptionalArguments: - Description: >- - Checks for optional arguments that do not appear at the end - of the argument list - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#optional-arguments' - Enabled: true - -Style/ParallelAssignment: - Description: >- - Check for simple usages of parallel assignment. - It will only warn when the number of variables - matches on both sides of the assignment. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parallel-assignment' - Enabled: true - -Style/ParenthesesAroundCondition: - Description: >- - Don't use parentheses around the condition of an - if/unless/while. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-parens-if' - Enabled: true - -Style/PercentLiteralDelimiters: - Description: 'Use `%`-literal delimiters consistently' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces' - Enabled: true - -Style/PercentQLiterals: - Description: 'Checks if uses of %Q/%q match the configured preference.' - Enabled: true - -Style/PerlBackrefs: - Description: 'Avoid Perl-style regex back references.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers' - Enabled: true - -Style/PredicateName: - Description: 'Check the names of predicate methods.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark' - Enabled: true - -Style/Proc: - Description: 'Use proc instead of Proc.new.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc' - Enabled: true - -Style/RaiseArgs: - Description: 'Checks the arguments passed to raise/fail.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages' - Enabled: true - -Style/RedundantBegin: - Description: "Don't use begin blocks when they are not needed." - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#begin-implicit' - Enabled: true - -Style/RedundantException: - Description: "Checks for an obsolete RuntimeException argument in raise/fail." - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-explicit-runtimeerror' - Enabled: true - -Style/RedundantFreeze: - Description: "Checks usages of Object#freeze on immutable objects." - Enabled: true - -Style/RedundantReturn: - Description: "Don't use return where it's not required." - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-explicit-return' - Enabled: true - -Style/RedundantSelf: - Description: "Don't use self where it's not needed." - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-self-unless-required' - Enabled: true - -Style/RegexpLiteral: - Description: 'Use / or %r around regular expressions.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r' - Enabled: true - -Style/RescueEnsureAlignment: - Description: 'Align rescues and ensures correctly.' - Enabled: true - -Style/RescueModifier: - Description: 'Avoid using rescue in its modifier form.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-rescue-modifiers' - Enabled: true - -Style/SelfAssignment: - Description: >- - Checks for places where self-assignment shorthand should have - been used. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment' - Enabled: true - -Style/Semicolon: - Description: "Don't use semicolons to terminate expressions." - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon' - Enabled: true - -Style/SignalException: - Description: 'Checks for proper usage of fail and raise.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method' - Enabled: true - -Style/SingleLineBlockParams: - Description: 'Enforces the names of some block params.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks' - Enabled: true - -Style/SingleLineMethods: - Description: 'Avoid single-line methods.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods' - Enabled: true - -Style/SingleSpaceBeforeFirstArg: - Description: >- - Checks that exactly one space is used between a method name - and the first argument for method calls without parentheses. - Enabled: true - -Style/SpaceAfterColon: - Description: 'Use spaces after colons.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' - Enabled: true - -Style/SpaceAfterComma: - Description: 'Use spaces after commas.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' - Enabled: true - -Style/SpaceAfterControlKeyword: - Description: 'Use spaces after if/elsif/unless/while/until/case/when.' - Enabled: true - -Style/SpaceAfterMethodName: - Description: >- - Do not put a space between a method name and the opening - parenthesis in a method definition. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces' - Enabled: true - -Style/SpaceAfterNot: - Description: Tracks redundant space after the ! operator. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-space-bang' - Enabled: true - -Style/SpaceAfterSemicolon: - Description: 'Use spaces after semicolons.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' - Enabled: true - -Style/SpaceBeforeBlockBraces: - Description: >- - Checks that the left block brace has or doesn't have space - before it. - Enabled: true - -Style/SpaceBeforeComma: - Description: 'No spaces before commas.' - Enabled: true - -Style/SpaceBeforeComment: - Description: >- - Checks for missing space between code and a comment on the - same line. - Enabled: true - -Style/SpaceBeforeSemicolon: - Description: 'No spaces before semicolons.' - Enabled: true - -Style/SpaceInsideBlockBraces: - Description: >- - Checks that block braces have or don't have surrounding space. - For blocks taking parameters, checks that the left brace has - or doesn't have trailing space. - Enabled: true - -Style/SpaceAroundBlockParameters: - Description: 'Checks the spacing inside and after block parameters pipes.' - Enabled: true - -Style/SpaceAroundEqualsInParameterDefault: - Description: >- - Checks that the equals signs in parameter default assignments - have or don't have surrounding space depending on - configuration. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-around-equals' - Enabled: true - -Style/SpaceAroundOperators: - Description: 'Use a single space around operators.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' - Enabled: true - -Style/SpaceBeforeModifierKeyword: - Description: 'Put a space before the modifier keyword.' - Enabled: true - -Style/SpaceInsideBrackets: - Description: 'No spaces after [ or before ].' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-spaces-braces' - Enabled: true - -Style/SpaceInsideHashLiteralBraces: - Description: "Use spaces inside hash literal braces - or don't." - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' - Enabled: true - -Style/SpaceInsideParens: - Description: 'No spaces after ( or before ).' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-spaces-braces' - Enabled: true - -Style/SpaceInsideRangeLiteral: - Description: 'No spaces inside range literals.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-space-inside-range-literals' - Enabled: true - -Style/SpaceInsideStringInterpolation: - Description: 'Checks for padding/surrounding spaces inside string interpolation.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#string-interpolation' - Enabled: true - -Style/SpecialGlobalVars: - Description: 'Avoid Perl-style global variables.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms' - Enabled: true - -Style/StringLiterals: - Description: 'Checks if uses of quotes match the configured preference.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals' - Enabled: true - -Style/StringLiteralsInInterpolation: - Description: >- - Checks if uses of quotes inside expressions in interpolated - strings match the configured preference. - Enabled: true - -Style/StringMethods: - Description: 'Checks if configured preferred methods are used over non-preferred.' - Enabled: true - -Style/StructInheritance: - Description: 'Checks for inheritance from Struct.new.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-extend-struct-new' - Enabled: true - -Style/SymbolLiteral: - Description: 'Use plain symbols instead of string symbols when possible.' - Enabled: true - -Style/SymbolProc: - Description: 'Use symbols as procs instead of blocks when possible.' - Enabled: true - -Style/Tab: - Description: 'No hard tabs.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation' - Enabled: true - -Style/TrailingBlankLines: - Description: 'Checks trailing blank lines and final newline.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#newline-eof' - Enabled: true - -Style/TrailingComma: - Description: 'Checks for trailing comma in parameter lists and literals.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas' - Enabled: true - -Style/TrailingWhitespace: - Description: 'Avoid trailing whitespace.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-whitespace' - Enabled: true - -Style/TrivialAccessors: - Description: 'Prefer attr_* methods to trivial readers/writers.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family' - Enabled: true - -Style/UnlessElse: - Description: >- - Do not use unless with else. Rewrite these with the positive - case first. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-else-with-unless' - Enabled: true - -Style/UnneededCapitalW: - Description: 'Checks for %W when interpolation is not needed.' - Enabled: true - -Style/UnneededPercentQ: - Description: 'Checks for %q/%Q when single quotes or double quotes would do.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-q' - Enabled: true - -Style/TrailingUnderscoreVariable: - Description: >- - Checks for the usage of unneeded trailing underscores at the - end of parallel variable assignment. - Enabled: true - -Style/VariableInterpolation: - Description: >- - Don't interpolate global, instance and class variables - directly in strings. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate' - Enabled: true - -Style/VariableName: - Description: 'Use the configured style when naming variables.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars' - Enabled: true - -Style/WhenThen: - Description: 'Use when x then ... for one-line cases.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases' - Enabled: true - -Style/WhileUntilDo: - Description: 'Checks for redundant do after while or until.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-multiline-while-do' - Enabled: true - -Style/WhileUntilModifier: - Description: >- - Favor modifier while/until usage when you have a - single-line body. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier' - Enabled: true - -Style/WordArray: - Description: 'Use %w or %W for arrays of words.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w' - Enabled: true - -#################### Metrics ################################ - -Metrics/AbcSize: - Description: >- - A calculated magnitude based on number of assignments, - branches, and conditions. - Reference: 'http://c2.com/cgi/wiki?AbcMetric' - Enabled: true - -Metrics/BlockNesting: - Description: 'Avoid excessive block nesting' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count' - Enabled: true - -Metrics/ClassLength: - Description: 'Avoid classes longer than 100 lines of code.' - Enabled: true - -Metrics/ModuleLength: - Description: 'Avoid modules longer than 100 lines of code.' - Enabled: true - -Metrics/CyclomaticComplexity: - Description: >- - A complexity metric that is strongly correlated to the number - of test cases needed to validate a method. - Enabled: true - -Metrics/LineLength: - Description: 'Limit lines to 80 characters.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits' - Enabled: true - -Metrics/MethodLength: - Description: 'Avoid methods longer than 10 lines of code.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods' - Enabled: true - -Metrics/ParameterLists: - Description: 'Avoid parameter lists longer than three or four parameters.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params' - Enabled: true - -Metrics/PerceivedComplexity: - Description: >- - A complexity metric geared towards measuring complexity for a - human reader. - Enabled: true - -#################### Lint ################################ -### Warnings - -Lint/AmbiguousOperator: - Description: >- - Checks for ambiguous operators in the first argument of a - method invocation without parentheses. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args' - Enabled: true - -Lint/AmbiguousRegexpLiteral: - Description: >- - Checks for ambiguous regexp literals in the first argument of - a method invocation without parenthesis. - Enabled: true - -Lint/AssignmentInCondition: - Description: "Don't use assignment in conditions." - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition' - Enabled: true - -Lint/BlockAlignment: - Description: 'Align block ends correctly.' - Enabled: true - -Lint/CircularArgumentReference: - Description: "Don't refer to the keyword argument in the default value." - Enabled: true - -Lint/ConditionPosition: - Description: >- - Checks for condition placed in a confusing position relative to - the keyword. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition' - Enabled: true - -Lint/Debugger: - Description: 'Check for debugger calls.' - Enabled: true - -Lint/DefEndAlignment: - Description: 'Align ends corresponding to defs correctly.' - Enabled: true - -Lint/DeprecatedClassMethods: - Description: 'Check for deprecated class method calls.' - Enabled: true - -Lint/DuplicateMethods: - Description: 'Check for duplicate methods calls.' - Enabled: true - -Lint/DuplicatedKey: - Description: 'Check for duplicate keys in hash literals.' - Enabled: true - -Lint/EachWithObjectArgument: - Description: 'Check for immutable argument given to each_with_object.' - Enabled: true - -Lint/ElseLayout: - Description: 'Check for odd code arrangement in an else block.' - Enabled: true - -Lint/EmptyEnsure: - Description: 'Checks for empty ensure block.' - Enabled: true - -Lint/EmptyInterpolation: - Description: 'Checks for empty string interpolation.' - Enabled: true - -Lint/EndAlignment: - Description: 'Align ends correctly.' - Enabled: true - -Lint/EndInMethod: - Description: 'END blocks should not be placed inside method definitions.' - Enabled: true - -Lint/EnsureReturn: - Description: 'Do not use return in an ensure block.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-return-ensure' - Enabled: true - -Lint/Eval: - Description: 'The use of eval represents a serious security risk.' - Enabled: true - -Lint/FormatParameterMismatch: - Description: 'The number of parameters to format/sprint must match the fields.' - Enabled: true - -Lint/HandleExceptions: - Description: "Don't suppress exception." - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions' - Enabled: true - -Lint/InvalidCharacterLiteral: - Description: >- - Checks for invalid character literals with a non-escaped - whitespace character. - Enabled: true - -Lint/LiteralInCondition: - Description: 'Checks of literals used in conditions.' - Enabled: true - -Lint/LiteralInInterpolation: - Description: 'Checks for literals used in interpolation.' - Enabled: true - -Lint/Loop: - Description: >- - Use Kernel#loop with break rather than begin/end/until or - begin/end/while for post-loop tests. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break' - Enabled: true - -Lint/NestedMethodDefinition: - Description: 'Do not use nested method definitions.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods' - Enabled: true - -Lint/NonLocalExitFromIterator: - Description: 'Do not use return in iterator to cause non-local exit.' - Enabled: true - -Lint/ParenthesesAsGroupedExpression: - Description: >- - Checks for method calls with a space before the opening - parenthesis. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces' - Enabled: true - -Lint/RequireParentheses: - Description: >- - Use parentheses in the method call to avoid confusion - about precedence. - Enabled: true - -Lint/RescueException: - Description: 'Avoid rescuing the Exception class.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-blind-rescues' - Enabled: true - -Lint/ShadowingOuterLocalVariable: - Description: >- - Do not use the same name as outer local variable - for block arguments or block local variables. - Enabled: true - -Lint/SpaceBeforeFirstArg: - Description: >- - Put a space between a method name and the first argument - in a method call without parentheses. - Enabled: true - -Lint/StringConversionInInterpolation: - Description: 'Checks for Object#to_s usage in string interpolation.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-to-s' - Enabled: true - -Lint/UnderscorePrefixedVariableName: - Description: 'Do not use prefix `_` for a variable that is used.' - Enabled: true - -Lint/UnneededDisable: - Description: >- - Checks for rubocop:disable comments that can be removed. - Note: this cop is not disabled when disabling all cops. - It must be explicitly disabled. - Enabled: true - -Lint/UnusedBlockArgument: - Description: 'Checks for unused block arguments.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars' - Enabled: true - -Lint/UnusedMethodArgument: - Description: 'Checks for unused method arguments.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars' - Enabled: true - -Lint/UnreachableCode: - Description: 'Unreachable code.' - Enabled: true - -Lint/UselessAccessModifier: - Description: 'Checks for useless access modifiers.' - Enabled: true - -Lint/UselessAssignment: - Description: 'Checks for useless assignment to a local variable.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars' - Enabled: true - -Lint/UselessComparison: - Description: 'Checks for comparison of something with itself.' - Enabled: true - -Lint/UselessElseWithoutRescue: - Description: 'Checks for useless `else` in `begin..end` without `rescue`.' - Enabled: true - -Lint/UselessSetterCall: - Description: 'Checks for useless setter call to a local variable.' - Enabled: true - -Lint/Void: - Description: 'Possible use of operator/literal/variable in void context.' - Enabled: true - -##################### Performance ############################# - -Performance/CaseWhenSplat: - Description: >- - Place `when` conditions that use splat at the end - of the list of `when` branches. - Enabled: true - -Performance/Count: - Description: >- - Use `count` instead of `select...size`, `reject...size`, - `select...count`, `reject...count`, `select...length`, - and `reject...length`. - Enabled: true - -Performance/Detect: - Description: >- - Use `detect` instead of `select.first`, `find_all.first`, - `select.last`, and `find_all.last`. - Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code' - Enabled: true - -Performance/FlatMap: - Description: >- - Use `Enumerable#flat_map` - instead of `Enumerable#map...Array#flatten(1)` - or `Enumberable#collect..Array#flatten(1)` - Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code' - Enabled: true - EnabledForFlattenWithoutParams: false - # If enabled, this cop will warn about usages of - # `flatten` being called without any parameters. - # This can be dangerous since `flat_map` will only flatten 1 level, and - # `flatten` without any parameters can flatten multiple levels. - -Performance/ReverseEach: - Description: 'Use `reverse_each` instead of `reverse.each`.' - Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code' - Enabled: true - -Performance/Sample: - Description: >- - Use `sample` instead of `shuffle.first`, - `shuffle.last`, and `shuffle[Fixnum]`. - Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code' - Enabled: true - -Performance/Size: - Description: >- - Use `size` instead of `count` for counting - the number of elements in `Array` and `Hash`. - Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code' - Enabled: true - -Performance/StringReplacement: - Description: >- - Use `tr` instead of `gsub` when you are replacing the same - number of characters. Use `delete` instead of `gsub` when - you are deleting characters. - Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code' - Enabled: true - -##################### Rails ################################## - -Rails/ActionFilter: - Description: 'Enforces consistent use of action filter methods.' - Enabled: true - -Rails/Date: - Description: >- - Checks the correct usage of date aware methods, - such as Date.today, Date.current etc. - Enabled: true - -Rails/DefaultScope: - Description: 'Checks if the argument passed to default_scope is a block.' - Enabled: true - -Rails/Delegate: - Description: 'Prefer delegate method for delegations.' - Enabled: true - -Rails/FindBy: - Description: 'Prefer find_by over where.first.' - Enabled: true - -Rails/FindEach: - Description: 'Prefer all.find_each over all.find.' - Enabled: true - -Rails/HasAndBelongsToMany: - Description: 'Prefer has_many :through to has_and_belongs_to_many.' - Enabled: true - -Rails/Output: - Description: 'Checks for calls to puts, print, etc.' - Enabled: true - -Rails/ReadWriteAttribute: - Description: >- - Checks for read_attribute(:attr) and - write_attribute(:attr, val). - Enabled: true - -Rails/ScopeArgs: - Description: 'Checks the arguments of ActiveRecord scopes.' - Enabled: true - -Rails/TimeZone: - Description: 'Checks the correct usage of time zone aware methods.' - StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time' - Reference: 'http://danilenko.org/2012/7/6/rails_timezones' - Enabled: true - -Rails/Validation: - Description: 'Use validates :attribute, hash of validations.' - Enabled: true diff --git a/config/internal_affairs.yml b/config/internal_affairs.yml new file mode 100644 index 000000000000..cfff30cf0966 --- /dev/null +++ b/config/internal_affairs.yml @@ -0,0 +1,31 @@ +# Configuration for InternalAffairs cops. This file will be +# automatically loaded when `rubocop/cop/internal_affairs` is required. +# Only do this when developing custom cops or a RuboCop extension. + +InternalAffairs/CopDescription: + Include: + - 'lib/rubocop/cop/**/*.rb' + +InternalAffairs/ExampleHeredocDelimiter: + Include: + - 'spec/rubocop/cop/**/*.rb' + +InternalAffairs/ExampleDescription: + Include: + - 'spec/rubocop/cop/**/*.rb' + +InternalAffairs/NodeTypeGroup: + Include: + - 'lib/rubocop/cop/**/*.rb' + +InternalAffairs/OnSendWithoutOnCSend: + Include: + - 'lib/rubocop/cop/**/*.rb' + +InternalAffairs/UndefinedConfig: + Include: + - 'lib/rubocop/cop/**/*.rb' + +InternalAffairs/UselessMessageAssertion: + Include: + - '**/*_spec.rb' diff --git a/config/obsoletion.yml b/config/obsoletion.yml new file mode 100644 index 000000000000..a86e213daf7b --- /dev/null +++ b/config/obsoletion.yml @@ -0,0 +1,243 @@ +# Configuration of obsolete/deprecated cops used by `ConfigObsoletion` + +# Cops that were renamed +renamed: + Layout/AlignArguments: Layout/ArgumentAlignment + Layout/AlignArray: Layout/ArrayAlignment + Layout/AlignHash: Layout/HashAlignment + Layout/AlignParameters: Layout/ParameterAlignment + Layout/IndentArray: Layout/FirstArrayElementIndentation + Layout/IndentAssignment: Layout/AssignmentIndentation + Layout/IndentFirstArgument: Layout/FirstArgumentIndentation + Layout/IndentFirstArrayElement: Layout/FirstArrayElementIndentation + Layout/IndentFirstHashElement: Layout/FirstHashElementIndentation + Layout/IndentFirstParameter: Layout/FirstParameterIndentation + Layout/IndentHash: Layout/FirstHashElementIndentation + Layout/IndentHeredoc: Layout/HeredocIndentation + Layout/LeadingBlankLines: Layout/LeadingEmptyLines + Layout/Tab: Layout/IndentationStyle + Layout/TrailingBlankLines: Layout/TrailingEmptyLines + Lint/BlockAlignment: Layout/BlockAlignment + Lint/DefEndAlignment: Layout/DefEndAlignment + Lint/DuplicatedKey: Lint/DuplicateHashKey + Lint/EndAlignment: Layout/EndAlignment + Lint/EndInMethod: Style/EndBlock + Lint/Eval: Security/Eval + Lint/HandleExceptions: Lint/SuppressedException + Lint/MultipleCompare: Lint/MultipleComparison + Lint/StringConversionInInterpolation: Lint/RedundantStringCoercion + Lint/UnneededCopDisableDirective: Lint/RedundantCopDisableDirective + Lint/UnneededCopEnableDirective: Lint/RedundantCopEnableDirective + Lint/UnneededRequireStatement: Lint/RedundantRequireStatement + Lint/UnneededSplatExpansion: Lint/RedundantSplatExpansion + Metrics/LineLength: Layout/LineLength + Naming/PredicateName: + new_name: Naming/PredicatePrefix + severity: warning + Naming/UncommunicativeBlockParamName: Naming/BlockParameterName + Naming/UncommunicativeMethodParamName: Naming/MethodParameterName + Style/AccessorMethodName: Naming/AccessorMethodName + Style/AsciiIdentifiers: Naming/AsciiIdentifiers + Style/ClassAndModuleCamelCase: Naming/ClassAndModuleCamelCase + Style/ConstantName: Naming/ConstantName + Style/DeprecatedHashMethods: Style/PreferredHashMethods + Style/FileName: Naming/FileName + Style/FlipFlop: Lint/FlipFlop + Style/MethodCallParentheses: Style/MethodCallWithoutArgsParentheses + Style/MethodName: Naming/MethodName + Style/OpMethod: Naming/BinaryOperatorParameterName + Style/PredicateName: + new_name: Naming/PredicatePrefix + severity: warning + Style/SingleSpaceBeforeFirstArg: Layout/SpaceBeforeFirstArg + Style/UnneededCapitalW: Style/RedundantCapitalW + Style/UnneededCondition: Style/RedundantCondition + Style/UnneededInterpolation: Style/RedundantInterpolation + Style/UnneededPercentQ: Style/RedundantPercentQ + Style/UnneededSort: Style/RedundantSort + Style/VariableName: Naming/VariableName + Style/VariableNumber: Naming/VariableNumber + +# Cops that were removed +removed: + Gemspec/DateAssignment: + alternatives: Gemspec/DeprecatedAttributeAssignment + Layout/SpaceAfterControlKeyword: + alternatives: Layout/SpaceAroundKeyword + Layout/SpaceBeforeModifierKeyword: + alternatives: Layout/SpaceAroundKeyword + Lint/InvalidCharacterLiteral: + reason: it was never being actually triggered + Lint/RescueWithoutErrorClass: + alternatives: Style/RescueStandardError + Lint/SpaceBeforeFirstArg: + reason: > + it was a duplicate of `Layout/SpaceBeforeFirstArg`. Please use + `Layout/SpaceBeforeFirstArg` instead + Lint/UselessComparison: + reason: > + it has been superseded by + `Lint/BinaryOperatorWithIdenticalOperands`. Please use + `Lint/BinaryOperatorWithIdenticalOperands` instead + Style/BracesAroundHashParameters: true + Style/MethodMissingSuper: + reason: > + it has been superseded by `Lint/MissingSuper`. Please use + `Lint/MissingSuper` instead + Style/SpaceAfterControlKeyword: + alternatives: Layout/SpaceAroundKeyword + Style/SpaceBeforeModifierKeyword: + alternatives: Layout/SpaceAroundKeyword + Style/TrailingComma: + alternatives: + - Style/TrailingCommaInArguments + - Style/TrailingCommaInArrayLiteral + - Style/TrailingCommaInHashLiteral + Style/TrailingCommaInLiteral: + alternatives: + - Style/TrailingCommaInArrayLiteral + - Style/TrailingCommaInHashLiteral + +# Cops split into multiple other cops +split: + Style/MethodMissing: + alternatives: + - Style/MethodMissingSuper + - Style/MissingRespondToMissing + +# Cops that were extracted into a different gem +extracted: + Performance/*: rubocop-performance + Rails/*: rubocop-rails + +# Cop parameters that have been changed +# Can be treated as a warning instead of a failure with `severity: warning` +changed_parameters: + - cops: + - Layout/SpaceAroundOperators + - Style/SpaceAroundOperators + parameters: MultiSpaceAllowedForOperators + reason: > + If your intention was to allow extra spaces for alignment, please + use `AllowForAlignment: true` instead. + - cops: Style/Encoding + parameters: + - EnforcedStyle + - SupportedStyles + - AutoCorrectEncodingComment + reason: '`Style/Encoding` no longer supports styles. The "never" behavior is always assumed.' + - cops: Style/IfUnlessModifier + parameters: MaxLineLength + reason: > + `Style/IfUnlessModifier: MaxLineLength` has been removed. + Use `Layout/LineLength: Max` instead + - cops: Style/WhileUntilModifier + parameters: MaxLineLength + reason: > + `Style/WhileUntilModifier: MaxLineLength` has been removed. + Use `Layout/LineLength: Max` instead + - cops: AllCops + parameters: RunRailsCops + reason: |- + Use the following configuration instead: + Rails: + Enabled: true + - cops: Layout/CaseIndentation + parameters: IndentWhenRelativeTo + alternative: EnforcedStyle + - cops: + - Lint/BlockAlignment + - Layout/BlockAlignment + - Lint/EndAlignment + - Layout/EndAlignment + - Lint/DefEndAlignment + - Layout/DefEndAlignment + parameters: AlignWith + alternative: EnforcedStyleAlignWith + - cops: Rails/UniqBeforePluck + parameters: EnforcedMode + alternative: EnforcedStyle + - cops: Style/MethodCallWithArgsParentheses + parameters: IgnoredMethodPatterns + alternative: AllowedPatterns + - cops: + - Performance/Count + - Performance/Detect + parameters: SafeMode + reason: "`SafeMode` has been removed. Use `SafeAutoCorrect` instead." + - cops: Bundler/GemComment + parameters: Whitelist + alternative: IgnoredGems + - cops: + - Lint/SafeNavigationChain + - Lint/SafeNavigationConsistency + - Style/NestedParenthesizedCalls + - Style/SafeNavigation + - Style/TrivialAccessors + parameters: Whitelist + alternative: AllowedMethods + - cops: Style/IpAddresses + parameters: Whitelist + alternative: AllowedAddresses + - cops: Naming/HeredocDelimiterNaming + parameters: Blacklist + alternative: ForbiddenDelimiters + - cops: Naming/PredicatePrefix + parameters: NamePrefixBlacklist + alternative: ForbiddenPrefixes + - cops: Naming/PredicatePrefix + parameters: NameWhitelist + alternative: AllowedMethods + - cops: + - Metrics/BlockLength + - Metrics/MethodLength + parameters: ExcludedMethods + alternatives: + - AllowedMethods + - AllowedPatterns + severity: warning + - cops: Lint/Debugger + parameters: DebuggerReceivers + reason: "`DebuggerReceivers` is no longer necessary, method receivers should be specified in `DebuggerMethods` instead." + severity: warning + - cops: + - Layout/IndentationWidth + - Layout/LineLength + - Lint/UnreachableLoop + - Naming/MethodName + - Style/MethodCallWithArgsParentheses + parameters: IgnoredPatterns + alternative: AllowedPatterns + severity: warning + - cops: + - Lint/AmbiguousBlockAssociation + - Lint/NumberConversion + - Metrics/AbcSize + - Metrics/BlockLength + - Metrics/CyclomaticComplexity + - Metrics/MethodLength + - Metrics/PerceivedComplexity + - Style/BlockDelimiters + - Style/ClassEqualityComparison + - Style/FormatStringToken + - Style/MethodCallWithArgsParentheses + - Style/MethodCallWithoutArgsParentheses + - Style/NumericPredicate + - Style/SymbolLiteral + parameters: IgnoredMethods + alternatives: + - AllowedMethods + - AllowedPatterns + severity: warning + - cops: Style/ArgumentsForwarding + parameters: AllowOnlyRestArgument + reason: "`AllowOnlyRestArgument` has no effect with TargetRubyVersion >= 3.2." + severity: warning + minimum_ruby_version: 3.2 + +# Enforced styles that have been removed or replaced +changed_enforced_styles: + - cops: Layout/IndentationConsistency + parameters: EnforcedStyle + value: rails + alternative: indented_internal_methods diff --git a/docs/antora.yml b/docs/antora.yml new file mode 100644 index 000000000000..9c897ea03d1d --- /dev/null +++ b/docs/antora.yml @@ -0,0 +1,7 @@ +name: rubocop +title: RuboCop +# We always provide version without patch here (e.g. 1.1), +# as patch versions should not appear in the docs. +version: ~ +nav: + - modules/ROOT/nav.adoc diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc new file mode 100644 index 000000000000..ded0f1be8be2 --- /dev/null +++ b/docs/modules/ROOT/nav.adoc @@ -0,0 +1,39 @@ +* xref:index.adoc[Home] +* xref:installation.adoc[Installation] +* xref:compatibility.adoc[Compatibility] +* Usage +** xref:usage/basic_usage.adoc[Basic Usage] +** xref:usage/autocorrect.adoc[Autocorrect] +** xref:usage/caching.adoc[Caching] +** xref:usage/lsp.adoc[LSP] +** xref:usage/server.adoc[Server] +** xref:usage/profiling.adoc[Profiling] +* xref:configuration.adoc[Configuration] +* xref:cops.adoc[Cops] +* xref:formatters.adoc[Formatters] +* Cop Documentation +** xref:cops_bundler.adoc[Bundler] +** xref:cops_gemspec.adoc[Gemspec] +** xref:cops_layout.adoc[Layout] +** xref:cops_lint.adoc[Lint] +** xref:cops_metrics.adoc[Metrics] +** xref:cops_migration.adoc[Migration] +** xref:cops_naming.adoc[Naming] +** xref:cops_security.adoc[Security] +** xref:cops_style.adoc[Style] +** xref:v1_upgrade_notes.adoc[Upgrade Notes] +* Plugins +** xref:extensions.adoc[Plugin Configuration] +** xref:plugin_migration_guide.adoc[Plugin Migration Guide] +* xref:integration_with_other_tools.adoc[Integration with Other Tools] +* xref:automated_code_review.adoc[Automated Code Review] +* xref:development.adoc[Development] +* xref:contributing.adoc[Contributing] +* xref:support.adoc[Support] +* xref:versioning.adoc[Versioning] +* About +** xref:about/history.adoc[History] +** xref:about/team.adoc[Team] +** xref:about/changelog.adoc[Changelog] +** xref:about/logo.adoc[Logo] +** xref:about/license.adoc[License] diff --git a/docs/modules/ROOT/pages/about/changelog.adoc b/docs/modules/ROOT/pages/about/changelog.adoc new file mode 100644 index 000000000000..d8a45c87c91f --- /dev/null +++ b/docs/modules/ROOT/pages/about/changelog.adoc @@ -0,0 +1,38 @@ += Changelog + +An extensive changelog is available https://github.com/rubocop/rubocop/tree/master/relnotes[here]. + +NOTE: Only user-visible changes are documented there. + +== Changelog Generation + +The changelog is automatically generated from the files in https://github.com/rubocop/rubocop/blob/master/changelog/[the changelog folder] +at release time. Direct editing of the changelog file is discouraged as it often creates merge conflicts (pretty much every PR would modify +this file and this used to be quite the annoyance in the past). One can create new changelog entries like this: + + $ bundle exec rake changelog:new + $ bundle exec rake changelog:fix + $ bundle exec rake changelog:change + +Those commands correspond to "new feature", "bug-fix" and "changed" entries in the changelog. To update the changelog file you can +run: + + $ bundle exec rake changelog:merge + +NOTE: Typically only the RuboCop maintainers would need to do this. + +=== Background + +Our `CHANGELOG.md` file was previously updated manually by each +contributor that felt their change warranted an entry. When two merge +requests added their own entries at the same spot in the list, it +created a merge conflict in one as soon as the other was merged. When +we had dozens of merge requests fighting for the same changelog entry +location, this quickly became a major source of merge conflicts and +delays in development. + +Eventually we adopted GitLab's solution to this common problem, that they discussed https://docs.gitlab.com/ee/development/changelog.html#history-and-reasoning[here]. + +== Release Notes + +You can also peruse the release notes for individual release over at https://github.com/rubocop/rubocop/releases[GitHub]. diff --git a/docs/modules/ROOT/pages/about/history.adoc b/docs/modules/ROOT/pages/about/history.adoc new file mode 100644 index 000000000000..5e0536bff04a --- /dev/null +++ b/docs/modules/ROOT/pages/about/history.adoc @@ -0,0 +1,25 @@ += History + +[quote] +You don't know where you're going until you know where you've been. + +RuboCop was created by Bozhidar Batsov in the spring of 2012, as an attempt +to make it easy to apply consistently the guidelines from the community Ruby Style Guide.footnote:[This is the https://github.com/rubocop/ruby-style-guide/issues/54[GitHub issue] that started it all.] + + +== Notable Milestones + +* 12 Sep 2011 - Creation of the community Ruby Style Guide. +* 21 Apr 2012 - Initial commit by Bozhidar Batsov. +* 03 May 2012 - RuboCop 0.0.0 is released. +* 28 May 2013 - RuboCop 0.8 is released. It's the first version fully powered by the powerful `parser` gem. +* 01 Jul 2013 - RuboCop 0.9 introduces autocorrection and output formatters. +* 31 May 2018 - At RubyKaigi 2018 Bozhidar announces the transition of the project to a RuboCop GitHub organization. He also outlines the plans for a 1.0 release that guide the next couple of years of development. +* 21 Oct 2020 - RuboCop 1.0 is released (exactly 7.5 years after the first commit). +* 06 Mar 2024 - RuboCop 1.62 adds support for Prism. + +== Additional Resources + +* https://www.youtube.com/watch?v=nrHjVCuVsGA[All About RuboCop (RubyKaigi 2018)] +* https://metaredux.com/posts/2020/10/21/rubocop-1-0.html[RuboCop 1.0] +* https://metaredux.com/posts/2022/04/21/rubocop-turns-10.html[RuboCop Turns 10] diff --git a/docs/modules/ROOT/pages/about/license.adoc b/docs/modules/ROOT/pages/about/license.adoc new file mode 100644 index 000000000000..064033d31909 --- /dev/null +++ b/docs/modules/ROOT/pages/about/license.adoc @@ -0,0 +1,16 @@ += License & Copyright + +== Code License + +Use of RuboCop is granted under the terms of the MIT license. Check +out the `LICENSE.txt` file in RuboCop's code repository for more details. + +== Documentation License + +All the original text is available under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0). + +All the original Ruby code is available under the terms of the MIT license. + +== Copyright + +Copyright (c) 2012-2025 Bozhidar Batsov and RuboCop contributors. diff --git a/docs/modules/ROOT/pages/about/logo.adoc b/docs/modules/ROOT/pages/about/logo.adoc new file mode 100644 index 000000000000..de8d265e12ea --- /dev/null +++ b/docs/modules/ROOT/pages/about/logo.adoc @@ -0,0 +1,7 @@ += Logo + +RuboCop's logo was created by https://www.chadomoto.com/[Dimiter Petrov]. You can find the logo in various +formats https://github.com/rubocop/rubocop/tree/master/logo[here]. + +The logo is licensed under a +http://creativecommons.org/licenses/by-nc/4.0/deed.en_GB[Creative Commons Attribution-NonCommercial 4.0 International License]. diff --git a/docs/modules/ROOT/pages/about/team.adoc b/docs/modules/ROOT/pages/about/team.adoc new file mode 100644 index 000000000000..1592858db186 --- /dev/null +++ b/docs/modules/ROOT/pages/about/team.adoc @@ -0,0 +1,37 @@ += Team + +== The Core Team + +The direction of the project and its official extensions is being +stewarded by the RuboCop core team. This group of long-term +contributors manages releases, evaluates pull-requests, and does a lot +of the groundwork on major new features. Here are the current members +of the RuboCop core team, listed in the order of joining it: + +* https://github.com/bbatsov[Bozhidar Batsov] (author & head maintainer) +* https://github.com/jonas054[Jonas Arvidsson] +* https://github.com/drenmi[Ted Johansson] +* https://github.com/koic[Koichi Ito] (also head maintainer of RuboCop Rails, RuboCop Performance and RuboCop Minitest) +* https://github.com/darhazer[Maxim Krizhanovski] +* https://github.com/bquorning[Benjamin Quorning] (also head maintainer of RuboCop RSpec) +* https://github.com/marcandre[Marc-André Lafortune] (also head maintainer of RuboCop AST) +* https://github.com/dvandersluis[Daniel Vandersluis] + +== RuboCop Alumni + +In addition, we'd like to extend a special thanks the following retired RuboCop +core team members. Lovingly known as The Alumni: + +* https://github.com/yujinakayama[Yuji Nakayama] (also author of `guard-rubocop`) +* https://github.com/edzhelyov[Evgeni Dzhelyov] +* https://github.com/pocke[Masataka Kuwabara] + +== Joining the Core Team + +We're always looking for more people to join our Core Team, as there's plenty of work to go around. +There's no formal procedure for applying to the team, but it's fairly straightforward to get an invitation +to join it: + +* contribute consistently over an extended period of time (e.g. 6-12 months) +* demonstrate a passion for what we're doing +* eventually an invitation will be extended to you to become part of RuboCop's team diff --git a/docs/modules/ROOT/pages/automated_code_review.adoc b/docs/modules/ROOT/pages/automated_code_review.adoc new file mode 100644 index 000000000000..3030709f30b7 --- /dev/null +++ b/docs/modules/ROOT/pages/automated_code_review.adoc @@ -0,0 +1,39 @@ += Automated Code Review + +The section describes SaaS solutions that provide automated code reviews for Ruby based on RuboCop. + +NOTE: The services are listed in alphabetical order. + +== Awesome Code + +https://awesomecode.io[Awesome Code] improves your code readability by git push or sending pull requests, with one click or even fully automated. It's an online `rubocop -a` service. + +== Codacy + +https://www.codacy.com/[Codacy] checks your code from style to security, duplication, complexity, and also integrates with coverage. +Codacy is free for open source, and it provides RuboCop analysis out-of-the-box. + +== Code Climate + +https://codeclimate.com/[Code Climate] provides automated code review for test coverage, complexity, duplication, security, style, and more, and merge with confidence. + +== CodeFactor + +https://www.codefactor.io[CodeFactor] reports various code metrics like duplication, churn, and problems for code style, performance, complexity, and many others. CodeFactor is free for open source. It supports analysis and autocorrection for RuboCop. + +== Codety + +https://www.codety.io[Codety] detects code issues for 30+ programming languages and IaC frameworks, Codety Scanner is open source and it embeds 6,000+ code analysis rules(including RuboCop rules). + +== Hound + +https://houndci.com/[Hound] comments on style violations in GitHub pull requests, allowing you and your team to better review and maintain a clean codebase. +It is open source software. + +== Pronto + +https://github.com/prontolabs/pronto[Pronto] does quick automated code review of your changes. Created to be used on GitHub pull requests, but also works locally and integrates with GitLab and Bitbucket. + +== ReviewDog + +https://github.com/reviewdog/reviewdog[ReviewDog] is similar to Pronto but with better support for GitHub Actions. diff --git a/docs/modules/ROOT/pages/compatibility.adoc b/docs/modules/ROOT/pages/compatibility.adoc new file mode 100644 index 000000000000..9474a5aeb156 --- /dev/null +++ b/docs/modules/ROOT/pages/compatibility.adoc @@ -0,0 +1,52 @@ += Compatibility + +RuboCop targets Ruby 2.0+ code analysis.footnote:[As defined by its reference implementation MRI.] + +RuboCop officially runtime supports MRI (a.k.a. CRuby) and JRuby. + +- MRI 2.7+ +- JRuby 9.4+ + +The oldest supported JRuby version is derived from the oldest compatible MRI version. + +NOTE: RuboCop might be working with other Ruby implementations as well, but it's tested only on MRI and JRuby. + +== Support Matrix + +RuboCop generally aims to follow MRI's own support policy - meaning RuboCop would support all officially supported MRI releases.footnote:[Typically the last 3 releases.] To give people extra time for a smooth transition, we've customarily provided support for about one year after EOL of MRI version. footnote:[At the core team's discretion this policy might be waived aside for MRI releases causing significant maintenance overhead.] + +NOTE: There are major version incompatibilities between Ruby 2.7 and Ruby 3.0, and the latest stable version of Ruby on Rails, 7.1, still supports Ruby 2.7. Therefore, it might be early for RuboCop to drop support for Ruby 2.7 at this stage. As long as Rails 7.1 is in the "Bug Fix" phase of the https://guides.rubyonrails.org/maintenance_policy.html[Maintenance Policy for Ruby on Rails], RuboCop will continue supporting Ruby 2.7. + +The following table is the runtime support matrix. + +|=== +| Supported runtime Ruby version | Last supported RuboCop version + +| 1.9 | 0.41 +| 2.0 | 0.50 +| 2.1 | 0.57 +| 2.2 | 0.68 +| 2.3 | 0.81 +| 2.4 | 1.12 +| 2.5 | 1.28 +| 2.6 | 1.50 +| 2.7 | - +| 3.0 | - +| 3.1 | - +| 3.2 | - +| 3.3 | - +| 3.4 | - +| 3.5 (experimental) | - +|=== + +RuboCop targets Ruby 2.0+ code analysis with Parser gem as a parser since RuboCop 1.30. It restored code analysis support that had been removed earlier by mistake, together with dropping runtime support for unsupported Ruby versions. + +Starting from RuboCop 1.62, support for Prism's translation layer will allow analysis of Ruby 3.3+ with the `prism` gem. + +Starting from RuboCop 1.75, the `prism` translation layer is used by default when analyzing Ruby 3.4+. + +NOTE: The compatibility xref:configuration.adoc#setting-the-target-ruby-version[setting `TargetRubyVersion`] is about code analysis (what RuboCop can analyze), not runtime (is RuboCop capable of running on some Ruby or not). + +== Forward Compatibility + +Features may be provided for development version of Ruby. These are all considered experimental, and may change before the stable version of Ruby will be released. diff --git a/docs/modules/ROOT/pages/configuration.adoc b/docs/modules/ROOT/pages/configuration.adoc new file mode 100644 index 000000000000..727fbf8638f9 --- /dev/null +++ b/docs/modules/ROOT/pages/configuration.adoc @@ -0,0 +1,1028 @@ += Configuration + +The behavior of RuboCop can be controlled via the +https://github.com/rubocop/rubocop/blob/master/.rubocop.yml[.rubocop.yml] +configuration file. It makes it possible to enable/disable certain cops +(checks) and to alter their behavior if they accept any parameters. The file +can be placed in your home directory, XDG config directory, or in some project +directory. + +The file has the following format: + +[source,yaml] +---- +inherit_from: ../.rubocop.yml + +Style/Encoding: + Enabled: false + +Layout/LineLength: + Max: 99 +---- + +NOTE: Qualifying cop name with its type, e.g., `Style`, is recommended, +but not necessary as long as the cop name is unique across all types. + +== Config file locations + +RuboCop will start looking for the configuration file in the directory +where the inspected file is and continue its way up to the root directory. + +If it cannot be found until reaching the project's root directory, then it will +be searched for in the https://dot-config.github.io[.config directory of the project root] +and the user's global config locations. The user's global config locations consist of a +dotfile or a config file inside the https://specifications.freedesktop.org/basedir-spec/latest/index.html[XDG Base Directory +specification]. + +* `.config/.rubocop.yml` or `.config/rubocop/config.yml` at the project root +* `~/.rubocop.yml` +* `$XDG_CONFIG_HOME/rubocop/config.yml` (expands to `~/.config/rubocop/config.yml` +if `$XDG_CONFIG_HOME` is not set) + +If both files exist, the dotfile will be selected. + +As an example, if RuboCop is invoked from inside `/path/to/project/lib/utils`, +then RuboCop will use the config as specified inside the first of the following +files: + +* `/path/to/project/lib/utils/.rubocop.yml` +* `/path/to/project/lib/.rubocop.yml` +* `/path/to/project/.rubocop.yml` +* `/path/to/project/.config/.rubocop.yml` +* `/path/to/project/.config/rubocop/config.yml` +* `~/.rubocop.yml` +* `~/.config/rubocop/config.yml` +* https://github.com/rubocop/rubocop/blob/master/config/default.yml[RuboCop's default configuration] + +NOTE: All the previous logic does not apply if a specific configuration file is passed +on the command line through the `--config` flag. In that case, the resolved +configuration file will be the one passed to the CLI. + +== Inheritance + +All configuration inherits from https://github.com/rubocop/rubocop/blob/master/config/default.yml[RuboCop's default configuration] (See +"Defaults"). + +RuboCop also supports inheritance in user's configuration files. The most common +example would be the `.rubocop_todo.yml` file (See "Automatically Generated +Configuration" below). + +Settings in the child file (that which inherits) override those in the parent +(that which is inherited), with the following caveats. + +=== Inheritance of hashes vs. other types + +Configuration parameters that are hashes, for example `PreferredMethods` in +`Style/CollectionMethods`, are merged with the same parameter in the parent +configuration. This means that any key-value pairs given in child configuration +override the same keys in parent configuration. Giving `~`, YAML's +representation of `nil`, as a value cancels the setting of the corresponding +key in the parent configuration. For example: + +[source,yaml] +---- +Style/CollectionMethods: + Enabled: true + PreferredMethods: + # No preference for collect, keep all others from default config. + collect: ~ +---- + +Other types, such as `AllCops` / `Include` (an array), are overridden by the +child setting. + +Arrays override because if they were merged, there would be no way to +remove elements in child files. + +However, advanced users can still merge arrays using the `inherit_mode` setting. +See "Merging arrays using inherit_mode" below. + +=== Inheriting from another configuration file in the project + +The optional `inherit_from` directive is used to include configuration +from one or more files. This makes it possible to have the common +project settings in the `.rubocop.yml` file at the project root, and +then only the deviations from those rules in the subdirectories. The +files can be given with absolute paths or paths relative to the file +where they are referenced. The settings after an `inherit_from` +directive override any settings in the file(s) inherited from. When +multiple files are included, the first file in the list has the lowest +precedence and the last one has the highest. The format for multiple +inheritance is: + +[source,yaml] +---- +inherit_from: + - ../.rubocop.yml + - ../conf/.rubocop.yml +---- + +`inherit_from` also accepts a glob, for example: + +[source,yaml] +---- +inherit_from: + - packages/*/.rubocop_todo.yml +---- + +The example above is one potential use-case: allowing components within your repo to organize their own `.rubocop_todo.yml` files. + +== Inheriting configuration from a remote URL + +The optional `inherit_from` directive can contain a full url to a remote +file. This makes it possible to have common project settings stored on a http +server and shared between many projects. + +The remote config file is cached locally and is only updated if: + +* The file does not exist. +* The file has not been updated in the last 24 hours. +* The remote copy has a newer modification time than the local copy. + +You can inherit from both remote and local files in the same config and the +same inheritance rules apply to remote URLs and inheriting from local +files where the first file in the list has the lowest precedence and the +last one has the highest. The format for multiple inheritance using URLs is: + +[source,yaml] +---- +inherit_from: + - http://www.example.com/rubocop.yml + - ../.rubocop.yml +---- + +You can inherit from a repo with basic auth that is authorized to access the repo as follows: + +[source,yaml] +---- +inherit_from: + - http://:@raw.github.com/example/rubocop.yml +---- + +A link:https://docs.github.com/en/developers/apps/about-apps#personal-access-token[GitHub personal access token] +can also be configured as follows: + +[source,yaml] +---- +inherit_from: + - http://@raw.github.com/example/rubocop.yml +---- + +=== Inheriting configuration from a dependency gem + +The optional `inherit_gem` directive is used to include configuration from +one or more gems external to the current project. This makes it possible to +inherit a shared dependency's RuboCop configuration that can be used from +multiple disparate projects. + +Configurations inherited in this way will be essentially _prepended_ to the +`inherit_from` directive, such that the `inherit_gem` configurations will be +loaded first, then the `inherit_from` relative file paths will be loaded +(overriding the configurations from the gems), and finally the remaining +directives in the configuration file will supersede any of the inherited +configurations. This means the configurations inherited from one or more gems +have the lowest precedence of inheritance. + +The directive should be formatted as a YAML Hash using the gem name as the +key and the relative path within the gem as the value: + +[source,yaml] +---- +inherit_gem: + my-shared-gem: .rubocop.yml + cucumber: conf/rubocop.yml +---- + +An array can also be used as the value to include multiple configuration files +from a single gem: + +[source,yaml] +---- +inherit_gem: + my-shared-gem: + - default.yml + - strict.yml +---- + +NOTE: If the shared dependency is declared using a https://bundler.io/[Bundler] +Gemfile and the gem was installed using `bundle install`, it would be +necessary to also invoke RuboCop using Bundler in order to find the +dependency's installation path at runtime: + +[source,sh] +---- +$ bundle exec rubocop +---- + +=== Merging arrays using inherit_mode + +The optional directive `inherit_mode` specifies which configuration keys that +have array values should be merged together instead of overriding the inherited +value. + +This applies to explicit inheritance using `inherit_from` as well as implicit +inheritance from https://github.com/rubocop/rubocop/blob/master/config/default.yml[the default configuration]. + +Given the following config: + +[source,yaml] +---- +# .rubocop.yml +inherit_from: + - shared.yml + +inherit_mode: + merge: + - Exclude + +AllCops: + Exclude: + - 'generated/**/*.rb' + +Style/For: + Exclude: + - bar.rb +---- + +[source,yaml] +---- +# .shared.yml +Style/For: + Exclude: + - foo.rb +---- + +The list of ``Exclude``s for the `Style/For` cop in this example will be +`['foo.rb', 'bar.rb']`. Similarly, the `AllCops:Exclude` list will contain all +the default patterns plus the `+generated/**/*.rb+` entry that was added locally. + +The directive can also be used on individual cop configurations to override +the global setting. + +[source,yaml] +---- +inherit_from: + - shared.yml + +inherit_mode: + merge: + - Exclude + +Style/For: + inherit_mode: + override: + - Exclude + Exclude: + - bar.rb +---- + +In this example the `Exclude` would only include `bar.rb`. + +== Pre-processing + +Configuration files are pre-processed using the ERB templating mechanism. This +makes it possible to add dynamic content that will be evaluated when the +configuration file is read. For example, you could let RuboCop ignore all files +ignored by Git. + +[source,yaml] +---- +AllCops: + Exclude: + <% `git status --ignored --porcelain`.lines.grep(/^!! /).each do |path| %> + - <%= path.sub(/^!! /, '').sub(/\/$/, '/**/*') %> + <% end %> +---- + +== Defaults + +The file https://github.com/rubocop/rubocop/blob/master/config/default.yml[config/default.yml] under the RuboCop home directory contains the +default settings that all configurations inherit from. Project and personal +`.rubocop.yml` files need only make settings that are different from the +default ones. If there is no `.rubocop.yml` file in the project, home or XDG +directories, `config/default.yml` will be used. + +== Including/Excluding files + +RuboCop does a recursive file search starting from the directory it is +run in, or directories given as command line arguments. Files that +match any pattern listed under `AllCops`/`Include` and extensionless +files with a hash-bang (`#!`) declaration containing one of the known +ruby interpreters listed under `AllCops`/`RubyInterpreters` are +inspected, unless the file also matches a pattern in +`AllCops`/`Exclude`. Hidden directories (i.e., directories whose names +start with a dot) are not searched by default. + +Here is an example that might be used for a Rails project: + +[source,yaml] +---- +AllCops: + Exclude: + - 'db/**/*' + - 'config/**/*' + - 'script/**/*' + - 'bin/{rails,rake}' + - !ruby/regexp /old_and_unused\.rb$/ + +# other configuration +# ... +---- + +NOTE: When inspecting a certain directory(or file) +given as RuboCop's command line arguments, +patterns listed under `AllCops` / `Exclude` are also inspected. +If you want to apply `AllCops` / `Exclude` rules in this circumstance, +add `--force-exclusion` to the command line argument. + +Here is an example: + +[source,yaml] +---- +# .rubocop.yml +AllCops: + Exclude: + - foo.rb +---- + +If `foo.rb` is specified as a RuboCop's command line argument, the result is: + +[source,sh] +---- +# RuboCop inspects foo.rb. +$ bundle exec rubocop foo.rb + +# RuboCop does not inspect foo.rb. +$ bundle exec rubocop --force-exclusion foo.rb +---- + +=== Path relativity + +In `.rubocop.yml` and any other configuration file beginning with `.rubocop`, +files, and directories are specified relative to the directory where the +configuration file is. In configuration files that don't begin with `.rubocop`, +e.g. `our_company_defaults.yml`, paths are relative to the directory where +`rubocop` is run. + +This affects cops that have customisable paths: if the default is `db/migrate/\*.rb`, +and the cop is enabled in `db/migrate/.rubocop.yml`, the path will need to be +explicitly set as `*.rb`, as the default will look for `db/migrate/db/migrate/*.rb`. +This is unlikely to be what you wanted. + +=== Unusual files, that would not be included by default + +RuboCop comes with a comprehensive list of common ruby file names and +extensions. But, if you'd like RuboCop to check files that are not included by +default, you'll need to pass them in on the command line, or add entries for +them under `AllCops`/`Include`. Remember that your configuration files override +https://github.com/rubocop/rubocop/blob/master/config/default.yml[RuboCops's defaults]. In the following example, we want to include +`foo.unusual_extension`, but we also must copy any other patterns we need from +the overridden `default.yml`. + +[source,yaml] +---- +AllCops: + Include: + - foo.unusual_extension + - '**/*.rb' + - '**/*.gemfile' + - '**/*.gemspec' + - '**/*.rake' + - '**/*.ru' + - '**/Gemfile' + - '**/Rakefile' +---- + +This behavior of `Include` (overriding `default.yml`) was introduced in +https://github.com/rubocop/rubocop/releases/tag/v0.56.0[0.56.0] +via https://github.com/rubocop/rubocop/pull/5882[#5882]. This change allows +people to include/exclude precisely what they need to, without the defaults +getting in the way. + +==== Another example, using `inherit_mode` + +[source,yaml] +---- +inherit_mode: + merge: + - Include + +AllCops: + Include: + - foo.unusual_extension +---- + +See "Merging arrays using inherit_mode" above. + +=== Deprecated patterns + +Patterns that are just a file name, e.g. `Rakefile`, will match +that file name in any directory, but this pattern style is deprecated. The +correct way to match the file in any directory, including the current, is +`+**/Rakefile+`. + +The pattern `+config/**+` will match any file recursively under +`config`, but this pattern style is deprecated and should be replaced by +`+config/**/*+`. + +==== `Include` and `Exclude` are relative to their directory + +The `Include` and `Exclude` parameters are special. They are +valid for the directory tree starting where they are defined. They are not +shadowed by the setting of `Include` and `Exclude` in other `.rubocop.yml` +files in subdirectories. This is different from all other parameters, who +follow RuboCop's general principle that configuration for an inspected file +is taken from the nearest `.rubocop.yml`, searching upwards. + +NOTE: This behavior +will be overridden if you specify the `--ignore-parent-exclusion` command line +argument. + +=== Cop-specific `Include` and `Exclude` + +Cops can be run only on specific sets of files when that's needed (for +instance you might want to run some Rails model checks only on files whose +paths match `app/models/*.rb`). All cops support the +`Include` param. + +[source,yaml] +---- +Rails/HasAndBelongsToMany: + Include: + - app/models/*.rb +---- + +Cops can also exclude only specific sets of files when that's needed (for +instance you might want to run some cop only on a specific file). All cops support the +`Exclude` param. + +[source,yaml] +---- +Rails/HasAndBelongsToMany: + Exclude: + - app/models/problematic.rb +---- + +== Generic configuration parameters + +In addition to `Include` and `Exclude`, the following parameters are available +for every cop. + +=== Enabled + +Specific cops can be disabled by setting `Enabled` to `false` for that specific cop. + +[source,yaml] +---- +Layout/LineLength: + Enabled: false +---- + +Most cops are enabled by default. Cops, introduced or significantly updated +between major versions, are in a special pending status (read more in +xref:versioning.adoc["Versioning"]). Some cops, configured the above `Enabled: false` +in https://github.com/rubocop/rubocop/blob/master/config/default.yml[config/default.yml], +are disabled by default. + +The cop enabling process can be altered by setting `DisabledByDefault` or +`EnabledByDefault` (but not both) to `true`. These settings override the default for *all* +cops to disabled or enabled, except `Lint/Syntax` which is always enabled, +regardless of the cops' default values (whether enabled, disabled or pending). + +[source,yaml] +---- +AllCops: + DisabledByDefault: true +---- + +All cops except `Lint/Syntax` are then disabled by default. Only cops appearing in user +configuration files with `Enabled: true` will be enabled; every other cop will +be disabled without having to explicitly disable them in configuration. It is +also possible to enable entire departments by adding for example + +[source,yaml] +---- +Style: + Enabled: true +---- + +All cops in the `Style` department are then enabled. In this case, only the cops +in the `Style` department that are enabled by default will be enabled. +The cops in the `Style` department that are disabled by default will remain disabled. + +If a department is disabled, cops in that department can still be individually +enabled, and that setting overrides the setting for its department in the same +configuration file and in any inherited file. + +[source,yaml] +---- +inherit_from: config_that_disables_the_metrics_department.yml + +Metrics/MethodLength: + Enabled: true + +Style: + Enabled: false + +Style/Alias: + Enabled: true +---- + +=== Severity + +Each cop has a default severity level based on which department it belongs +to. The level is normally `warning` for `Lint` and `convention` for all the +others, but this can be changed in user configuration. Cops can customize their +severity level. Allowed values are `info`, `refactor`, `convention`, `warning`, `error` +and `fatal`. + +Cops with severity `info` will be reported but will not cause `rubocop` to return +a non-zero value. + +There is one exception from the general rule above and that is `Lint/Syntax`, a +special cop that checks for syntax errors before the other cops are invoked. It +cannot be disabled and its severity (`fatal`) cannot be changed in +configuration. + +[source,yaml] +---- +Lint: + Severity: error + +Metrics/CyclomaticComplexity: + Severity: warning +---- + +=== Details + +Individual cops can be embellished with extra details in offense messages: + +[source,yaml] +---- +Layout/LineLength: + Details: >- + If lines are too short, text becomes hard to read because you must + constantly jump from one line to the next while reading. If lines are too + long, the line jumping becomes too hard because you "lose the line" while + going back to the start of the next line. 80 characters is a good + compromise. +---- + +These details will only be seen when RuboCop is run with the `--extra-details` flag or if `ExtraDetails` is set to true in your global RuboCop configuration. + +=== AutoCorrect + +Cops that support the `--autocorrect` option offer flexible settings for autocorrection. +These settings can be specified in the configuration file as follows: + +- `always` +- `contextual` +- `disabled` + +==== `always (Default)` + +This setting enables autocorrection always by default. For backward compatibility, `true` is treated the same as `always`. + +[source,yaml] +---- +Style/PerlBackrefs: + AutoCorrect: always # or true +---- + +==== `contextual` + +This setting enables autocorrection when launched from the `rubocop` command, but it is not available through LSP. +e.g., `rubocop --lsp`, `rubocop --editor-mode`, or a program where `RuboCop::LSP.enable` has been applied. + +Inspections via the command line are treated as code that has been finalized. + +[source,yaml] +---- +Style/PerlBackrefs: + AutoCorrect: contextual +---- + +This setting prevents autocorrection during editing in the editor. e.g, with `textDocument/formatting` LSP method. +However `workspace/executeCommand` LSP method, which is triggered by intentional user actions, respects the user's intention for autocorrection. + +Additionally, for cases like `Metrics` cops where the highlight range extends over the entire body of classes, modules, methods, or blocks +offending range will be confined to only name. This approach helps to avoid redundant and noisy offenses in editor display. + +==== `disabled` + +This setting disables autocorrection. For backward compatibility, `false` is treated the same as `disabled`. + +[source,yaml] +---- +Style/PerlBackrefs: + AutoCorrect: disabled # or false +---- + +== Common configuration parameters +There are some configuration parameters that are shared by many cops, with the same behavior. + +=== IgnoredMethods + +Cops that evaluate methods can often be configured to ignore certain methods. Both strings and +regular expressions can be used. For example: + +[source,yaml] +---- +Metrics/BlockLength: + IgnoredMethods: + - refine + - !ruby/regexp /\b(class|instance)_methods\b/ +---- + +== Setting the target Ruby version + +Some checks are dependent on the version of the Ruby interpreter which the +inspected code must run on. For example, enforcing using Ruby 2.6+ endless +ranges `foo[n..]` rather than `foo[n..-1]` can help make your code shorter and +more consistent... _unless_ it must run on e.g. Ruby 2.5. + +Users may let RuboCop know the oldest version of Ruby which your project +supports with: + +[source,yaml] +---- +AllCops: + TargetRubyVersion: 2.5 +---- + +If a `TargetRubyVersion` is not specified in your config, then RuboCop will +check your project for a series of other files where the Ruby version may be +specified already. The files that will be checked are (in this order): +`*.gemspec`, `.ruby-version`, `.tool-versions`, and `Gemfile.lock`. + +The target ruby version may also be specified by setting the +`RUBOCOP_TARGET_RUBY_VERSION` environment variable to the desired version: for +example, running `RUBOCOP_TARGET_RUBY_VERSION=3.3 rubocop` will +run rubocop with a target ruby version of 3.3. Using this environment variable +will override all other sources of version information, including +`.rubocop.yml`. + +If a target Ruby version cannot be found via any of the above sources, then a +default target Ruby version will be used. + +=== Finding target Ruby in a `*.gemspec` file + +In order for RuboCop to parse a `*.gemspec` file's `required_ruby_version`, the +Ruby version must be specified using one of these syntaxes: + +1. a string range, e.g. `'~> 3.2.0'` or `'>= 3.2.2'` +2. an array of strings, e.g. `['>= 3.0.0', '< 3.4.0']` +3. a `Gem::Requirement`, e.g. `Gem::Requirement.new('>= 3.1.2')` + +If a `*.gemspec` file specifies a range of supported Ruby versions via any of +these means, then the greater of the following Ruby versions will be used: + +- the lowest Ruby version that is compatible with your specified range +- the lowest version of Ruby that is still supported by your version of RuboCop + +If a `*.gemspec` file defines its `required_ruby_version` dynamically (e.g. by +reading from a `.ruby-version` file, via an environment variable, referencing a +constant or local variable, etc), then RuboCop will _not_ detect that Ruby +version, and will instead try to find a target Ruby version elsewhere. + +== Setting the parser engine + +NOTE: The parser engine configuration was introduced in RuboCop 1.62. Since RuboCop 1.75, RuboCop chooses the parser engine automatically, so you don't need to configure it yourself. + +RuboCop allows switching the backend parser by specifying either +`parser_whitequark` or `parser_prism` as the value for the `ParserEngine`. + +Here are the parsers used as backends for each value: + +- `ParserEngine: default` +- `ParserEngine: parser_whitequark` ... https://github.com/whitequark/parser +- `ParserEngine: parser_prism` ... https://github.com/ruby/prism (`Prism::Translation::Parser`) + +`parser_whitequark` can analyze source code from Ruby 2.0 until Ruby 3.4: + +[source,yaml] +---- +AllCops: + ParserEngine: parser_whitequark +---- + +`parser_prism` can analyze source code from Ruby 3.3 and above: + +[source,yaml] +---- +AllCops: + ParserEngine: parser_prism + TargetRubyVersion: 3.3 +---- + +`parser_prism` tends to perform analysis faster than `parser_whitequark`. + +== Automatically Generated Configuration + +If you have a code base with an overwhelming amount of offenses, it can +be a good idea to use `rubocop --auto-gen-config`, which creates +`.rubocop_todo.yml` and adds `inherit_from: .rubocop_todo.yml` in your +`.rubocop.yml`. The generated file `.rubocop_todo.yml` contains +configuration to disable cops that currently detect an offense in the +code by changing the configuration for the cop, excluding the offending +files, or disabling the cop altogether once a file count limit has been +reached. + +By adding the option `--exclude-limit COUNT`, e.g., `rubocop +--auto-gen-config --exclude-limit 5`, you can change how many files are +excluded before the cop is entirely disabled. The default COUNT is 15. +If you don't want the cop to be entirely disabled regardless of the +number of files, use the `--no-exclude-limit` option, e.g., +`rubocop --auto-gen-config --no-exclude-limit`. + +The next step is to cut and paste configuration from `.rubocop_todo.yml` +into `.rubocop.yml` for everything that you think is in line with your +(organization's) code style and not a good fit for a todo list. Pay +attention to the comments above each entry. They can reveal configuration +parameters such as `EnforcedStyle`, which can be used to modify the +behavior of a cop instead of disabling it completely. + +Then you can start removing the entries in the generated +`.rubocop_todo.yml` file one by one as you work through all the offenses +in the code. You can also regenerate your `.rubocop_todo.yml` using +the same options by running `rubocop --regenerate-todo`. + +Another way of silencing offense reports, aside from configuration, is +through source code comments. These can be added manually or +automatically. See "Disabling Cops within Source Code" below. + +The cops in the `Metrics` department will by default get `Max` parameters +generated in `.rubocop_todo.yml`. The value of these will be just high enough +so that no offenses are reported the next time you run `rubocop`. If you +prefer to exclude files, like for other cops, add `--auto-gen-only-exclude` +when running with `--auto-gen-config`. It will still change the maximum if the +number of excluded files is higher than the exclude limit. + +Some cops have a configurable option named `EnforcedStyle`. +By default, when generating the `.rubocop_todo.yml`, if one style is used +for all files, these cops will add the settings for the style being used. +If you want to exclude on a file-by-file basis, +add the `--no-auto-gen-enforced-style` option along with `--auto-gen-config`. + +== Updating the configuration file + +When you update RuboCop version, sometimes you need to change `.rubocop.yml`. +If you use https://github.com/pocke/mry[mry], you can update `.rubocop.yml` +to latest version automatically. + +[source,sh] +---- +$ gem install mry +# Update to latest version +$ mry .rubocop.yml +# Update to specified version +$ mry --target=0.48.0 .rubocop.yml +---- + +See https://github.com/pocke/mry for more information. + +== Disabling Cops within Source Code + +One or more individual cops can be disabled locally in a section of a +file by adding a comment such as + +[source,ruby] +---- +# rubocop:disable Layout/LineLength, Style/StringLiterals +[...] +# rubocop:enable Layout/LineLength, Style/StringLiterals +---- + +You can also disable entire departments by giving a department name in the comment. + +[source,ruby] +---- +# rubocop:disable Metrics, Layout/LineLength +[...] +# rubocop:enable Metrics, Layout/LineLength +---- + +You can also disable _all_ cops with + +[source,ruby] +---- +# rubocop:disable all +[...] +# rubocop:enable all +---- + +In cases where you want to differentiate intentionally-disabled cops vs. cops +you'd like to revisit later, you can use `rubocop:todo` as an alias of +`rubocop:disable`. + +[source,ruby] +---- +# rubocop:todo Layout/LineLength, Style/StringLiterals +[...] +# rubocop:enable Layout/LineLength, Style/StringLiterals +---- + +One or more cops can be disabled on a single line with an end-of-line +comment. + +[source,ruby] +---- +for x in (0..19) # rubocop:disable Style/For +---- + +If you want to disable a cop that inspects comments, you can do so by +adding an "inner comment" on the comment line. + +[source,ruby] +---- +# coding: utf-8 # rubocop:disable Style/Encoding +---- + +Running `rubocop --autocorrect --disable-uncorrectable` will +create comments to disable all offenses that can't be automatically +corrected. + +You can add a comment to the disabling/enabling directive by prefixing it with `--`. For example: + +[source,ruby] +---- +# rubocop:disable Layout/LineLength -- A comment explaining why the cop is disabled +---- + +The syntax of directives can be checked using the cop `Lint/CopDirectiveSyntax`. + +== Temporarily enabling cops in source code + +In a similar way to disabling cops within source code, you can also temporarily enable specific +cops if you want to enforce specific rules for part of the totality of a file. + +Let's use the cop `Style/AsciiComments`, which is by default `Enabled: false`. If you want a +specific file to have ASCII-only comments to be compatible with some specific post-processing. + +[source,ruby] +---- +# rubocop:enable Style/AsciiComments +# If applicable, leave a comment to others explaining the rationale: +# We need the comments to remain ASCII only for compatibility with lib/post_processor.rb + +class Restaurant + # This comment has to be ASCII-only because of the rubocop:enable directive + def menu + return dishes.map(&:humanize) + end +end +---- + +You can also enforce the same for part of a file by disabling the cop afterwards + +[source,ruby] +---- +class Dish + def humanize + return [ + "Delicious #{self.name}" + *ingredients + ].join("\n") + end +end + +# rubocop:enable Style/AsciiComments +# If applicable, leave a comment to others explaining the rationale: +# We need the comments to remain ASCII only for compatibility with lib/post_processor.rb + +class Restaurant + # This comment has to be ASCII-only because of the rubocop:enable directive + def menu + return dishes.map(&:humanize) + end +end + +# rubocop:disable Style/AsciiComments + +class Ingredient + # Notice how the comment below is non-ASCII + # Gets rid of odd characters like 😀, ͸ + def sanitize + self.name.gsub(/[^a-z]/, '') + end +end +---- + +== Setting the style guide URL + +You can specify the base URL of the style guide using `StyleGuideBaseURL`. +If specified under `AllCops`, all cops are targeted. + +[source,yaml] +---- +AllCops: + StyleGuideBaseURL: https://rubystyle.guide +---- + +`StyleGuideBaseURL` is combined with `StyleGuide` specified to the cop. + +[source,yaml] +---- +Lint/UselessAssignment: + StyleGuide: '#underscore-unused-vars' +---- + +The style guide URL is https://rubystyle.guide#underscore-unused-vars. + +If specified under a specific department, it takes precedence over `AllCops`. +The following is an example of specifying `Rails` department. + +[source,yaml] +---- +Rails: + StyleGuideBaseURL: https://rails.rubystyle.guide +---- + +[source,yaml] +---- +Rails/TimeZone: + StyleGuide: '#time' +---- + +The style guide URL is https://rails.rubystyle.guide#time. + +== Setting the documentation URL + +You can specify the base URL of the documentation using `DocumentationBaseURL`. +If specified under `AllCops`, all cops are targeted. + +[source,yaml] +---- +AllCops: + DocumentationBaseURL: https://docs.rubocop.org/rubocop +---- + +If specified under a specific department, it takes precedence over `AllCops`. +The following is an example of specifying `Rails` department. + +[source,yaml] +---- +Rails: + DocumentationBaseURL: https://docs.rubocop.org/rubocop-rails +---- + +By default, documentation is expected to be served as HTML but if you prefer +to use something else like markdown you can set `DocumentationExtension`. + +With markdown as the documentation format you are able to host it directly through +GitHub without having to own a domain or using GitHub Pages. The `rubocop-sorbet` +extension is an example of this, its docs are available +https://github.com/Shopify/rubocop-sorbet/blob/main/manual[here]. + +[source,yaml] +---- +Sorbet: + DocumentationBaseURL: https://github.com/Shopify/rubocop-sorbet/blob/main/manual + DocumentationExtension: .md +---- + +== Setting the version tracking metadata for cops + +This configuration is particularly useful when custom cops are distributed as a gem. + +Each cop can have the following additional metadata: + +* `VersionAdded` - the RuboCop version in which it was added +* `VersionChanged` (optional) - the latest RuboCop version in which it was changed in a user-impacting way (new config, updated defaults, etc) + +[source,yaml] +---- +Style/HashSyntax: + VersionAdded: '0.9' + VersionChanged: '1.67' +---- + +NOTE: These values do not include patch versions. + +Those will be pretty useful for the documentation (so the manual generation has to be enhanced to include them) and keeping track of changes. + +== Enable checking Active Support extensions + +Some cops for checking specified methods (e.g. `Style/HashExcept`) support Active Support extensions. +This is off by default, but can be enabled by the `ActiveSupportExtensionsEnabled` option. + +[source,yaml] +---- +AllCops: + ActiveSupportExtensionsEnabled: true +---- + +== Opting into globally frozen string literals + +Ruby continues to move into the direction of having all string literals frozen by default. +Ruby 3.4 for example will show a warning if a non-frozen string literal from a file without +the frozen string literal magic comment gets modified. By starting ruby with the environment +variable `RUBYOPT` set to `--enable=frozen-string-literal` you can opt into that behaviour today. +For RuboCop to provide accurate analysis you must also configure the `StringLiteralsFrozenByDefault` +option. + +[source,yaml] +---- +AllCops: + StringLiteralsFrozenByDefault: true +---- diff --git a/docs/modules/ROOT/pages/contributing.adoc b/docs/modules/ROOT/pages/contributing.adoc new file mode 100644 index 000000000000..deb67b3a00dd --- /dev/null +++ b/docs/modules/ROOT/pages/contributing.adoc @@ -0,0 +1,103 @@ += Contributing + +== Issues + +Report issues and suggest features and improvements on the +https://github.com/rubocop/rubocop/issues[GitHub issue tracker]. + +If you want to file an issue (bug report or feature request), please provide all +the necessary info listed in our issue reporting template (it's loaded +automatically when you create a new GitHub issue). + +NOTE: Please, don't ask support-like questions on the issue tracker (e.g. "How +can I configure RuboCop to do X?" - use the xref:support.adoc[support channels] +instead. + +== Patches + +Patches in any form are always welcome! GitHub pull requests are even better! :-) + +Before submitting a patch or a pull request make sure all tests are +passing and that your patch is in line with the https://github.com/rubocop/rubocop/blob/master/CONTRIBUTING.md[contribution +guidelines]. + +A handy way to test only the files that you have modified in the last commit +(with `rspec` and `rubocop`) is to use `rake check_commit`. + +Also see the xref:development.adoc[Development section]. + +== Documentation + +Good documentation is just as important as good code. +Please, help us improve RuboCop's documentation. + +You should also check out the +xref:development.adoc#documentation[cop documentation section] of the docs and consider +adding or improving Cop descriptions. + +=== Working on the Docs + +The manual is generated from the AsciiDoc files in the https://github.com/rubocop/rubocop/tree/master/docs[docs] folder of RuboCop's GitHub repo and is published to https://docs.rubocop.org. +https://antora.org[Antora] is used to convert the manual into HTML. +The filesystem layout is described at https://docs.antora.org/antora/2.0/component-structure/. + +To make changes to the manual you simply have to change the files under `doc`. +The manual will be regenerated manually periodically. + +==== Installing Antora + +NOTE: The instructions here assume you already have (the right version of) node.js installed. + +Installing the Antora is super simple: + +[source] +---- +$ npm i -g @antora/cli@2.0 @antora/site-generator-default@2.0 +---- + +Check out https://docs.antora.org/antora/2.0/install/install-antora/[the detailed installation instructions] +if you run into any problems. + +==== Building the Site + +You can build the documentation locally from the https://github.com/rubocop/docs.rubocop.org[docs.rubocop.org] repo. + +[source] +---- +$ cd docs.rubocop.org +$ antora --pull antora-playbook.yml +---- + +After you're done with the initial setup you can use the `deploy` script to push changes to the site: + +[source] +---- +./deploy +---- + +NOTE: You'll need commit access to the repository for this to work. + +To check the generated site you can simply open `docs/index.html` in your favourite browser. + +If you want to make changes to the manual's page structure you'll have to edit +https://github.com/rubocop/rubocop/blob/master/docs/modules/ROOT/nav.adoc[nav.adoc]. + +== Funding + +While RuboCop is free software and will always be, the project would benefit immensely from some funding. +Raising a monthly budget of a couple of thousand dollars would make it possible to pay people to work on +certain complex features, fund other development related stuff (e.g. hardware, conference trips) and so on. +Raising a monthly budget of over $5000 would open the possibility of someone working full-time on the project +which would speed up the pace of development significantly. + +We welcome both individual and corporate sponsors! We also offer a wide array of funding channels to account +for your preferences (although currently https://opencollective.com/rubocop[Open Collective] is our preferred funding platform). + +If you're working in a company that's making significant use of RuboCop we'd appreciate it if you suggest to your company +to become a RuboCop sponsor. + +You can support the development of RuboCop via +https://github.com/sponsors/bbatsov[GitHub Sponsors], +https://www.patreon.com/bbatsov[Patreon], +https://paypal.me/bbatsov[PayPal], +and https://opencollective.com/rubocop[Open Collective]. diff --git a/docs/modules/ROOT/pages/cops.adoc b/docs/modules/ROOT/pages/cops.adoc new file mode 100644 index 000000000000..1ffab0eb9839 --- /dev/null +++ b/docs/modules/ROOT/pages/cops.adoc @@ -0,0 +1,691 @@ += Cops + +In RuboCop lingo the various checks performed on the code are called cops. +Each cop is responsible for detecting one particular offense. There are several +cop departments, grouping the cops by class of offense. A short description of +the different departments is provided below. + +Many of the Style and Layout cops have configuration options, allowing them to +enforce different coding conventions. + +You can also load xref:extensions.adoc#custom-cops[custom cops]. + +Cop-related failures are silenced by default but can be turned on using the +`--raise-cop-errors` option. + +== Style + +Style cops check for stylistic consistency of your code. Many of them are +based on the https://rubystyle.guide[Ruby Style Guide]. + +== Layout + +Layout cops inspect your code for consistent use of indentation, alignment, +and white space. + +== Lint + +Lint cops check for ambiguities and possible errors in your code. + +RuboCop implements, in a portable way, all built-in MRI lint checks +(`ruby -wc`) and adds a lot of extra lint checks of its own. + +You can run only the Lint cops like this: + +[source,sh] +---- +$ rubocop -l +---- + +The `-l`/`--lint` option can be used together with `--only` to run all the +enabled Lint cops plus a selection of other cops. + +Disabling Lint cops is generally a bad idea. + +== Metrics + +Metrics cops deal with properties of the source code that can be measured, +such as class length, method length, etc. Generally speaking, they have a +configuration parameter called `Max` and when running +`rubocop --auto-gen-config`, this parameter will be set to the highest value +found for the inspected code. + +== Naming + +Naming cops check for naming issues in your code, such as method name, constant +name, file name, etc. + +== Security + +Security cops check for method calls and constructs which are known to be +associated with potential security issues. + +== Bundler + +Bundler cops check for style and bad practices in Bundler files, e.g. `Gemfile`. + +== Gemspec + +Gemspec cops check for style and bad practices in gemspec files, e.g. `rubocop.gemspec`. + +== Available cops + +In the following section you find all available cops: + +// START_COP_LIST + +=== Department xref:cops_bundler.adoc[Bundler] + +* xref:cops_bundler.adoc#bundlerduplicatedgem[Bundler/DuplicatedGem] +* xref:cops_bundler.adoc#bundlerduplicatedgroup[Bundler/DuplicatedGroup] +* xref:cops_bundler.adoc#bundlergemcomment[Bundler/GemComment] +* xref:cops_bundler.adoc#bundlergemfilename[Bundler/GemFilename] +* xref:cops_bundler.adoc#bundlergemversion[Bundler/GemVersion] +* xref:cops_bundler.adoc#bundlerinsecureprotocolsource[Bundler/InsecureProtocolSource] +* xref:cops_bundler.adoc#bundlerorderedgems[Bundler/OrderedGems] + +=== Department xref:cops_gemspec.adoc[Gemspec] + +* xref:cops_gemspec.adoc#gemspecaddruntimedependency[Gemspec/AddRuntimeDependency] +* xref:cops_gemspec.adoc#gemspecattributeassignment[Gemspec/AttributeAssignment] +* xref:cops_gemspec.adoc#gemspecdependencyversion[Gemspec/DependencyVersion] +* xref:cops_gemspec.adoc#gemspecdeprecatedattributeassignment[Gemspec/DeprecatedAttributeAssignment] +* xref:cops_gemspec.adoc#gemspecdevelopmentdependencies[Gemspec/DevelopmentDependencies] +* xref:cops_gemspec.adoc#gemspecduplicatedassignment[Gemspec/DuplicatedAssignment] +* xref:cops_gemspec.adoc#gemspecordereddependencies[Gemspec/OrderedDependencies] +* xref:cops_gemspec.adoc#gemspecrequiremfa[Gemspec/RequireMFA] +* xref:cops_gemspec.adoc#gemspecrequiredrubyversion[Gemspec/RequiredRubyVersion] +* xref:cops_gemspec.adoc#gemspecrubyversionglobalsusage[Gemspec/RubyVersionGlobalsUsage] + +=== Department xref:cops_layout.adoc[Layout] + +* xref:cops_layout.adoc#layoutaccessmodifierindentation[Layout/AccessModifierIndentation] +* xref:cops_layout.adoc#layoutargumentalignment[Layout/ArgumentAlignment] +* xref:cops_layout.adoc#layoutarrayalignment[Layout/ArrayAlignment] +* xref:cops_layout.adoc#layoutassignmentindentation[Layout/AssignmentIndentation] +* xref:cops_layout.adoc#layoutbeginendalignment[Layout/BeginEndAlignment] +* xref:cops_layout.adoc#layoutblockalignment[Layout/BlockAlignment] +* xref:cops_layout.adoc#layoutblockendnewline[Layout/BlockEndNewline] +* xref:cops_layout.adoc#layoutcaseindentation[Layout/CaseIndentation] +* xref:cops_layout.adoc#layoutclassstructure[Layout/ClassStructure] +* xref:cops_layout.adoc#layoutclosingheredocindentation[Layout/ClosingHeredocIndentation] +* xref:cops_layout.adoc#layoutclosingparenthesisindentation[Layout/ClosingParenthesisIndentation] +* xref:cops_layout.adoc#layoutcommentindentation[Layout/CommentIndentation] +* xref:cops_layout.adoc#layoutconditionposition[Layout/ConditionPosition] +* xref:cops_layout.adoc#layoutdefendalignment[Layout/DefEndAlignment] +* xref:cops_layout.adoc#layoutdotposition[Layout/DotPosition] +* xref:cops_layout.adoc#layoutelsealignment[Layout/ElseAlignment] +* xref:cops_layout.adoc#layoutemptycomment[Layout/EmptyComment] +* xref:cops_layout.adoc#layoutemptylineafterguardclause[Layout/EmptyLineAfterGuardClause] +* xref:cops_layout.adoc#layoutemptylineaftermagiccomment[Layout/EmptyLineAfterMagicComment] +* xref:cops_layout.adoc#layoutemptylineaftermultilinecondition[Layout/EmptyLineAfterMultilineCondition] +* xref:cops_layout.adoc#layoutemptylinebetweendefs[Layout/EmptyLineBetweenDefs] +* xref:cops_layout.adoc#layoutemptylines[Layout/EmptyLines] +* xref:cops_layout.adoc#layoutemptylinesaftermoduleinclusion[Layout/EmptyLinesAfterModuleInclusion] +* xref:cops_layout.adoc#layoutemptylinesaroundaccessmodifier[Layout/EmptyLinesAroundAccessModifier] +* xref:cops_layout.adoc#layoutemptylinesaroundarguments[Layout/EmptyLinesAroundArguments] +* xref:cops_layout.adoc#layoutemptylinesaroundattributeaccessor[Layout/EmptyLinesAroundAttributeAccessor] +* xref:cops_layout.adoc#layoutemptylinesaroundbeginbody[Layout/EmptyLinesAroundBeginBody] +* xref:cops_layout.adoc#layoutemptylinesaroundblockbody[Layout/EmptyLinesAroundBlockBody] +* xref:cops_layout.adoc#layoutemptylinesaroundclassbody[Layout/EmptyLinesAroundClassBody] +* xref:cops_layout.adoc#layoutemptylinesaroundexceptionhandlingkeywords[Layout/EmptyLinesAroundExceptionHandlingKeywords] +* xref:cops_layout.adoc#layoutemptylinesaroundmethodbody[Layout/EmptyLinesAroundMethodBody] +* xref:cops_layout.adoc#layoutemptylinesaroundmodulebody[Layout/EmptyLinesAroundModuleBody] +* xref:cops_layout.adoc#layoutendalignment[Layout/EndAlignment] +* xref:cops_layout.adoc#layoutendofline[Layout/EndOfLine] +* xref:cops_layout.adoc#layoutextraspacing[Layout/ExtraSpacing] +* xref:cops_layout.adoc#layoutfirstargumentindentation[Layout/FirstArgumentIndentation] +* xref:cops_layout.adoc#layoutfirstarrayelementindentation[Layout/FirstArrayElementIndentation] +* xref:cops_layout.adoc#layoutfirstarrayelementlinebreak[Layout/FirstArrayElementLineBreak] +* xref:cops_layout.adoc#layoutfirsthashelementindentation[Layout/FirstHashElementIndentation] +* xref:cops_layout.adoc#layoutfirsthashelementlinebreak[Layout/FirstHashElementLineBreak] +* xref:cops_layout.adoc#layoutfirstmethodargumentlinebreak[Layout/FirstMethodArgumentLineBreak] +* xref:cops_layout.adoc#layoutfirstmethodparameterlinebreak[Layout/FirstMethodParameterLineBreak] +* xref:cops_layout.adoc#layoutfirstparameterindentation[Layout/FirstParameterIndentation] +* xref:cops_layout.adoc#layouthashalignment[Layout/HashAlignment] +* xref:cops_layout.adoc#layoutheredocargumentclosingparenthesis[Layout/HeredocArgumentClosingParenthesis] +* xref:cops_layout.adoc#layoutheredocindentation[Layout/HeredocIndentation] +* xref:cops_layout.adoc#layoutindentationconsistency[Layout/IndentationConsistency] +* xref:cops_layout.adoc#layoutindentationstyle[Layout/IndentationStyle] +* xref:cops_layout.adoc#layoutindentationwidth[Layout/IndentationWidth] +* xref:cops_layout.adoc#layoutinitialindentation[Layout/InitialIndentation] +* xref:cops_layout.adoc#layoutleadingcommentspace[Layout/LeadingCommentSpace] +* xref:cops_layout.adoc#layoutleadingemptylines[Layout/LeadingEmptyLines] +* xref:cops_layout.adoc#layoutlinecontinuationleadingspace[Layout/LineContinuationLeadingSpace] +* xref:cops_layout.adoc#layoutlinecontinuationspacing[Layout/LineContinuationSpacing] +* xref:cops_layout.adoc#layoutlineendstringconcatenationindentation[Layout/LineEndStringConcatenationIndentation] +* xref:cops_layout.adoc#layoutlinelength[Layout/LineLength] +* xref:cops_layout.adoc#layoutmultilinearraybracelayout[Layout/MultilineArrayBraceLayout] +* xref:cops_layout.adoc#layoutmultilinearraylinebreaks[Layout/MultilineArrayLineBreaks] +* xref:cops_layout.adoc#layoutmultilineassignmentlayout[Layout/MultilineAssignmentLayout] +* xref:cops_layout.adoc#layoutmultilineblocklayout[Layout/MultilineBlockLayout] +* xref:cops_layout.adoc#layoutmultilinehashbracelayout[Layout/MultilineHashBraceLayout] +* xref:cops_layout.adoc#layoutmultilinehashkeylinebreaks[Layout/MultilineHashKeyLineBreaks] +* xref:cops_layout.adoc#layoutmultilinemethodargumentlinebreaks[Layout/MultilineMethodArgumentLineBreaks] +* xref:cops_layout.adoc#layoutmultilinemethodcallbracelayout[Layout/MultilineMethodCallBraceLayout] +* xref:cops_layout.adoc#layoutmultilinemethodcallindentation[Layout/MultilineMethodCallIndentation] +* xref:cops_layout.adoc#layoutmultilinemethoddefinitionbracelayout[Layout/MultilineMethodDefinitionBraceLayout] +* xref:cops_layout.adoc#layoutmultilinemethodparameterlinebreaks[Layout/MultilineMethodParameterLineBreaks] +* xref:cops_layout.adoc#layoutmultilineoperationindentation[Layout/MultilineOperationIndentation] +* xref:cops_layout.adoc#layoutparameteralignment[Layout/ParameterAlignment] +* xref:cops_layout.adoc#layoutredundantlinebreak[Layout/RedundantLineBreak] +* xref:cops_layout.adoc#layoutrescueensurealignment[Layout/RescueEnsureAlignment] +* xref:cops_layout.adoc#layoutsinglelineblockchain[Layout/SingleLineBlockChain] +* xref:cops_layout.adoc#layoutspaceaftercolon[Layout/SpaceAfterColon] +* xref:cops_layout.adoc#layoutspaceaftercomma[Layout/SpaceAfterComma] +* xref:cops_layout.adoc#layoutspaceaftermethodname[Layout/SpaceAfterMethodName] +* xref:cops_layout.adoc#layoutspaceafternot[Layout/SpaceAfterNot] +* xref:cops_layout.adoc#layoutspaceaftersemicolon[Layout/SpaceAfterSemicolon] +* xref:cops_layout.adoc#layoutspacearoundblockparameters[Layout/SpaceAroundBlockParameters] +* xref:cops_layout.adoc#layoutspacearoundequalsinparameterdefault[Layout/SpaceAroundEqualsInParameterDefault] +* xref:cops_layout.adoc#layoutspacearoundkeyword[Layout/SpaceAroundKeyword] +* xref:cops_layout.adoc#layoutspacearoundmethodcalloperator[Layout/SpaceAroundMethodCallOperator] +* xref:cops_layout.adoc#layoutspacearoundoperators[Layout/SpaceAroundOperators] +* xref:cops_layout.adoc#layoutspacebeforeblockbraces[Layout/SpaceBeforeBlockBraces] +* xref:cops_layout.adoc#layoutspacebeforebrackets[Layout/SpaceBeforeBrackets] +* xref:cops_layout.adoc#layoutspacebeforecomma[Layout/SpaceBeforeComma] +* xref:cops_layout.adoc#layoutspacebeforecomment[Layout/SpaceBeforeComment] +* xref:cops_layout.adoc#layoutspacebeforefirstarg[Layout/SpaceBeforeFirstArg] +* xref:cops_layout.adoc#layoutspacebeforesemicolon[Layout/SpaceBeforeSemicolon] +* xref:cops_layout.adoc#layoutspaceinlambdaliteral[Layout/SpaceInLambdaLiteral] +* xref:cops_layout.adoc#layoutspaceinsidearrayliteralbrackets[Layout/SpaceInsideArrayLiteralBrackets] +* xref:cops_layout.adoc#layoutspaceinsidearraypercentliteral[Layout/SpaceInsideArrayPercentLiteral] +* xref:cops_layout.adoc#layoutspaceinsideblockbraces[Layout/SpaceInsideBlockBraces] +* xref:cops_layout.adoc#layoutspaceinsidehashliteralbraces[Layout/SpaceInsideHashLiteralBraces] +* xref:cops_layout.adoc#layoutspaceinsideparens[Layout/SpaceInsideParens] +* xref:cops_layout.adoc#layoutspaceinsidepercentliteraldelimiters[Layout/SpaceInsidePercentLiteralDelimiters] +* xref:cops_layout.adoc#layoutspaceinsiderangeliteral[Layout/SpaceInsideRangeLiteral] +* xref:cops_layout.adoc#layoutspaceinsidereferencebrackets[Layout/SpaceInsideReferenceBrackets] +* xref:cops_layout.adoc#layoutspaceinsidestringinterpolation[Layout/SpaceInsideStringInterpolation] +* xref:cops_layout.adoc#layouttrailingemptylines[Layout/TrailingEmptyLines] +* xref:cops_layout.adoc#layouttrailingwhitespace[Layout/TrailingWhitespace] + +=== Department xref:cops_lint.adoc[Lint] + +* xref:cops_lint.adoc#lintambiguousassignment[Lint/AmbiguousAssignment] +* xref:cops_lint.adoc#lintambiguousblockassociation[Lint/AmbiguousBlockAssociation] +* xref:cops_lint.adoc#lintambiguousoperator[Lint/AmbiguousOperator] +* xref:cops_lint.adoc#lintambiguousoperatorprecedence[Lint/AmbiguousOperatorPrecedence] +* xref:cops_lint.adoc#lintambiguousrange[Lint/AmbiguousRange] +* xref:cops_lint.adoc#lintambiguousregexpliteral[Lint/AmbiguousRegexpLiteral] +* xref:cops_lint.adoc#lintarrayliteralinregexp[Lint/ArrayLiteralInRegexp] +* xref:cops_lint.adoc#lintassignmentincondition[Lint/AssignmentInCondition] +* xref:cops_lint.adoc#lintbigdecimalnew[Lint/BigDecimalNew] +* xref:cops_lint.adoc#lintbinaryoperatorwithidenticaloperands[Lint/BinaryOperatorWithIdenticalOperands] +* xref:cops_lint.adoc#lintbooleansymbol[Lint/BooleanSymbol] +* xref:cops_lint.adoc#lintcircularargumentreference[Lint/CircularArgumentReference] +* xref:cops_lint.adoc#lintconstantdefinitioninblock[Lint/ConstantDefinitionInBlock] +* xref:cops_lint.adoc#lintconstantoverwritteninrescue[Lint/ConstantOverwrittenInRescue] +* xref:cops_lint.adoc#lintconstantreassignment[Lint/ConstantReassignment] +* xref:cops_lint.adoc#lintconstantresolution[Lint/ConstantResolution] +* xref:cops_lint.adoc#lintcopdirectivesyntax[Lint/CopDirectiveSyntax] +* xref:cops_lint.adoc#lintdebugger[Lint/Debugger] +* xref:cops_lint.adoc#lintdeprecatedclassmethods[Lint/DeprecatedClassMethods] +* xref:cops_lint.adoc#lintdeprecatedconstants[Lint/DeprecatedConstants] +* xref:cops_lint.adoc#lintdeprecatedopensslconstant[Lint/DeprecatedOpenSSLConstant] +* xref:cops_lint.adoc#lintdisjunctiveassignmentinconstructor[Lint/DisjunctiveAssignmentInConstructor] +* xref:cops_lint.adoc#lintduplicatebranch[Lint/DuplicateBranch] +* xref:cops_lint.adoc#lintduplicatecasecondition[Lint/DuplicateCaseCondition] +* xref:cops_lint.adoc#lintduplicateelsifcondition[Lint/DuplicateElsifCondition] +* xref:cops_lint.adoc#lintduplicatehashkey[Lint/DuplicateHashKey] +* xref:cops_lint.adoc#lintduplicatemagiccomment[Lint/DuplicateMagicComment] +* xref:cops_lint.adoc#lintduplicatematchpattern[Lint/DuplicateMatchPattern] +* xref:cops_lint.adoc#lintduplicatemethods[Lint/DuplicateMethods] +* xref:cops_lint.adoc#lintduplicateregexpcharacterclasselement[Lint/DuplicateRegexpCharacterClassElement] +* xref:cops_lint.adoc#lintduplicaterequire[Lint/DuplicateRequire] +* xref:cops_lint.adoc#lintduplicaterescueexception[Lint/DuplicateRescueException] +* xref:cops_lint.adoc#lintduplicatesetelement[Lint/DuplicateSetElement] +* xref:cops_lint.adoc#linteachwithobjectargument[Lint/EachWithObjectArgument] +* xref:cops_lint.adoc#lintelselayout[Lint/ElseLayout] +* xref:cops_lint.adoc#lintemptyblock[Lint/EmptyBlock] +* xref:cops_lint.adoc#lintemptyclass[Lint/EmptyClass] +* xref:cops_lint.adoc#lintemptyconditionalbody[Lint/EmptyConditionalBody] +* xref:cops_lint.adoc#lintemptyensure[Lint/EmptyEnsure] +* xref:cops_lint.adoc#lintemptyexpression[Lint/EmptyExpression] +* xref:cops_lint.adoc#lintemptyfile[Lint/EmptyFile] +* xref:cops_lint.adoc#lintemptyinpattern[Lint/EmptyInPattern] +* xref:cops_lint.adoc#lintemptyinterpolation[Lint/EmptyInterpolation] +* xref:cops_lint.adoc#lintemptywhen[Lint/EmptyWhen] +* xref:cops_lint.adoc#lintensurereturn[Lint/EnsureReturn] +* xref:cops_lint.adoc#linterbnewarguments[Lint/ErbNewArguments] +* xref:cops_lint.adoc#lintflipflop[Lint/FlipFlop] +* xref:cops_lint.adoc#lintfloatcomparison[Lint/FloatComparison] +* xref:cops_lint.adoc#lintfloatoutofrange[Lint/FloatOutOfRange] +* xref:cops_lint.adoc#lintformatparametermismatch[Lint/FormatParameterMismatch] +* xref:cops_lint.adoc#linthashcomparebyidentity[Lint/HashCompareByIdentity] +* xref:cops_lint.adoc#linthashnewwithkeywordargumentsasdefault[Lint/HashNewWithKeywordArgumentsAsDefault] +* xref:cops_lint.adoc#lintheredocmethodcallposition[Lint/HeredocMethodCallPosition] +* xref:cops_lint.adoc#lintidentitycomparison[Lint/IdentityComparison] +* xref:cops_lint.adoc#lintimplicitstringconcatenation[Lint/ImplicitStringConcatenation] +* xref:cops_lint.adoc#lintincompatibleioselectwithfiberscheduler[Lint/IncompatibleIoSelectWithFiberScheduler] +* xref:cops_lint.adoc#lintineffectiveaccessmodifier[Lint/IneffectiveAccessModifier] +* xref:cops_lint.adoc#lintinheritexception[Lint/InheritException] +* xref:cops_lint.adoc#lintinterpolationcheck[Lint/InterpolationCheck] +* xref:cops_lint.adoc#lintitwithoutargumentsinblock[Lint/ItWithoutArgumentsInBlock] +* xref:cops_lint.adoc#lintlambdawithoutliteralblock[Lint/LambdaWithoutLiteralBlock] +* xref:cops_lint.adoc#lintliteralascondition[Lint/LiteralAsCondition] +* xref:cops_lint.adoc#lintliteralassignmentincondition[Lint/LiteralAssignmentInCondition] +* xref:cops_lint.adoc#lintliteralininterpolation[Lint/LiteralInInterpolation] +* xref:cops_lint.adoc#lintloop[Lint/Loop] +* xref:cops_lint.adoc#lintmissingcopenabledirective[Lint/MissingCopEnableDirective] +* xref:cops_lint.adoc#lintmissingsuper[Lint/MissingSuper] +* xref:cops_lint.adoc#lintmixedcaserange[Lint/MixedCaseRange] +* xref:cops_lint.adoc#lintmixedregexpcapturetypes[Lint/MixedRegexpCaptureTypes] +* xref:cops_lint.adoc#lintmultiplecomparison[Lint/MultipleComparison] +* xref:cops_lint.adoc#lintnestedmethoddefinition[Lint/NestedMethodDefinition] +* xref:cops_lint.adoc#lintnestedpercentliteral[Lint/NestedPercentLiteral] +* xref:cops_lint.adoc#lintnextwithoutaccumulator[Lint/NextWithoutAccumulator] +* xref:cops_lint.adoc#lintnoreturninbeginendblocks[Lint/NoReturnInBeginEndBlocks] +* xref:cops_lint.adoc#lintnonatomicfileoperation[Lint/NonAtomicFileOperation] +* xref:cops_lint.adoc#lintnondeterministicrequireorder[Lint/NonDeterministicRequireOrder] +* xref:cops_lint.adoc#lintnonlocalexitfromiterator[Lint/NonLocalExitFromIterator] +* xref:cops_lint.adoc#lintnumberconversion[Lint/NumberConversion] +* xref:cops_lint.adoc#lintnumberedparameterassignment[Lint/NumberedParameterAssignment] +* xref:cops_lint.adoc#lintnumericoperationwithconstantresult[Lint/NumericOperationWithConstantResult] +* xref:cops_lint.adoc#lintorassignmenttoconstant[Lint/OrAssignmentToConstant] +* xref:cops_lint.adoc#lintorderedmagiccomments[Lint/OrderedMagicComments] +* xref:cops_lint.adoc#lintoutofrangeregexpref[Lint/OutOfRangeRegexpRef] +* xref:cops_lint.adoc#lintparenthesesasgroupedexpression[Lint/ParenthesesAsGroupedExpression] +* xref:cops_lint.adoc#lintpercentstringarray[Lint/PercentStringArray] +* xref:cops_lint.adoc#lintpercentsymbolarray[Lint/PercentSymbolArray] +* xref:cops_lint.adoc#lintraiseexception[Lint/RaiseException] +* xref:cops_lint.adoc#lintrandone[Lint/RandOne] +* xref:cops_lint.adoc#lintredundantcopdisabledirective[Lint/RedundantCopDisableDirective] +* xref:cops_lint.adoc#lintredundantcopenabledirective[Lint/RedundantCopEnableDirective] +* xref:cops_lint.adoc#lintredundantdirglobsort[Lint/RedundantDirGlobSort] +* xref:cops_lint.adoc#lintredundantregexpquantifiers[Lint/RedundantRegexpQuantifiers] +* xref:cops_lint.adoc#lintredundantrequirestatement[Lint/RedundantRequireStatement] +* xref:cops_lint.adoc#lintredundantsafenavigation[Lint/RedundantSafeNavigation] +* xref:cops_lint.adoc#lintredundantsplatexpansion[Lint/RedundantSplatExpansion] +* xref:cops_lint.adoc#lintredundantstringcoercion[Lint/RedundantStringCoercion] +* xref:cops_lint.adoc#lintredundanttypeconversion[Lint/RedundantTypeConversion] +* xref:cops_lint.adoc#lintredundantwithindex[Lint/RedundantWithIndex] +* xref:cops_lint.adoc#lintredundantwithobject[Lint/RedundantWithObject] +* xref:cops_lint.adoc#lintrefinementimportmethods[Lint/RefinementImportMethods] +* xref:cops_lint.adoc#lintregexpascondition[Lint/RegexpAsCondition] +* xref:cops_lint.adoc#lintrequireparentheses[Lint/RequireParentheses] +* xref:cops_lint.adoc#lintrequirerangeparentheses[Lint/RequireRangeParentheses] +* xref:cops_lint.adoc#lintrequirerelativeselfpath[Lint/RequireRelativeSelfPath] +* xref:cops_lint.adoc#lintrescueexception[Lint/RescueException] +* xref:cops_lint.adoc#lintrescuetype[Lint/RescueType] +* xref:cops_lint.adoc#lintreturninvoidcontext[Lint/ReturnInVoidContext] +* xref:cops_lint.adoc#lintsafenavigationchain[Lint/SafeNavigationChain] +* xref:cops_lint.adoc#lintsafenavigationconsistency[Lint/SafeNavigationConsistency] +* xref:cops_lint.adoc#lintsafenavigationwithempty[Lint/SafeNavigationWithEmpty] +* xref:cops_lint.adoc#lintscriptpermission[Lint/ScriptPermission] +* xref:cops_lint.adoc#lintselfassignment[Lint/SelfAssignment] +* xref:cops_lint.adoc#lintsendwithmixinargument[Lint/SendWithMixinArgument] +* xref:cops_lint.adoc#lintshadowedargument[Lint/ShadowedArgument] +* xref:cops_lint.adoc#lintshadowedexception[Lint/ShadowedException] +* xref:cops_lint.adoc#lintshadowingouterlocalvariable[Lint/ShadowingOuterLocalVariable] +* xref:cops_lint.adoc#lintsharedmutabledefault[Lint/SharedMutableDefault] +* xref:cops_lint.adoc#lintstructnewoverride[Lint/StructNewOverride] +* xref:cops_lint.adoc#lintsuppressedexception[Lint/SuppressedException] +* xref:cops_lint.adoc#lintsuppressedexceptioninnumberconversion[Lint/SuppressedExceptionInNumberConversion] +* xref:cops_lint.adoc#lintsymbolconversion[Lint/SymbolConversion] +* xref:cops_lint.adoc#lintsyntax[Lint/Syntax] +* xref:cops_lint.adoc#linttoenumarguments[Lint/ToEnumArguments] +* xref:cops_lint.adoc#linttojson[Lint/ToJSON] +* xref:cops_lint.adoc#linttoplevelreturnwithargument[Lint/TopLevelReturnWithArgument] +* xref:cops_lint.adoc#linttrailingcommainattributedeclaration[Lint/TrailingCommaInAttributeDeclaration] +* xref:cops_lint.adoc#linttriplequotes[Lint/TripleQuotes] +* xref:cops_lint.adoc#lintunderscoreprefixedvariablename[Lint/UnderscorePrefixedVariableName] +* xref:cops_lint.adoc#lintunescapedbracketinregexp[Lint/UnescapedBracketInRegexp] +* xref:cops_lint.adoc#lintunexpectedblockarity[Lint/UnexpectedBlockArity] +* xref:cops_lint.adoc#lintunifiedinteger[Lint/UnifiedInteger] +* xref:cops_lint.adoc#lintunmodifiedreduceaccumulator[Lint/UnmodifiedReduceAccumulator] +* xref:cops_lint.adoc#lintunreachablecode[Lint/UnreachableCode] +* xref:cops_lint.adoc#lintunreachableloop[Lint/UnreachableLoop] +* xref:cops_lint.adoc#lintunusedblockargument[Lint/UnusedBlockArgument] +* xref:cops_lint.adoc#lintunusedmethodargument[Lint/UnusedMethodArgument] +* xref:cops_lint.adoc#linturiescapeunescape[Lint/UriEscapeUnescape] +* xref:cops_lint.adoc#linturiregexp[Lint/UriRegexp] +* xref:cops_lint.adoc#lintuselessaccessmodifier[Lint/UselessAccessModifier] +* xref:cops_lint.adoc#lintuselessassignment[Lint/UselessAssignment] +* xref:cops_lint.adoc#lintuselessconstantscoping[Lint/UselessConstantScoping] +* xref:cops_lint.adoc#lintuselessdefaultvalueargument[Lint/UselessDefaultValueArgument] +* xref:cops_lint.adoc#lintuselessdefined[Lint/UselessDefined] +* xref:cops_lint.adoc#lintuselesselsewithoutrescue[Lint/UselessElseWithoutRescue] +* xref:cops_lint.adoc#lintuselessmethoddefinition[Lint/UselessMethodDefinition] +* xref:cops_lint.adoc#lintuselessnumericoperation[Lint/UselessNumericOperation] +* xref:cops_lint.adoc#lintuselessor[Lint/UselessOr] +* xref:cops_lint.adoc#lintuselessrescue[Lint/UselessRescue] +* xref:cops_lint.adoc#lintuselessruby2keywords[Lint/UselessRuby2Keywords] +* xref:cops_lint.adoc#lintuselesssettercall[Lint/UselessSetterCall] +* xref:cops_lint.adoc#lintuselesstimes[Lint/UselessTimes] +* xref:cops_lint.adoc#lintvoid[Lint/Void] + +=== Department xref:cops_metrics.adoc[Metrics] + +* xref:cops_metrics.adoc#metricsabcsize[Metrics/AbcSize] +* xref:cops_metrics.adoc#metricsblocklength[Metrics/BlockLength] +* xref:cops_metrics.adoc#metricsblocknesting[Metrics/BlockNesting] +* xref:cops_metrics.adoc#metricsclasslength[Metrics/ClassLength] +* xref:cops_metrics.adoc#metricscollectionliterallength[Metrics/CollectionLiteralLength] +* xref:cops_metrics.adoc#metricscyclomaticcomplexity[Metrics/CyclomaticComplexity] +* xref:cops_metrics.adoc#metricsmethodlength[Metrics/MethodLength] +* xref:cops_metrics.adoc#metricsmodulelength[Metrics/ModuleLength] +* xref:cops_metrics.adoc#metricsparameterlists[Metrics/ParameterLists] +* xref:cops_metrics.adoc#metricsperceivedcomplexity[Metrics/PerceivedComplexity] + +=== Department xref:cops_migration.adoc[Migration] + +* xref:cops_migration.adoc#migrationdepartmentname[Migration/DepartmentName] + +=== Department xref:cops_naming.adoc[Naming] + +* xref:cops_naming.adoc#namingaccessormethodname[Naming/AccessorMethodName] +* xref:cops_naming.adoc#namingasciiidentifiers[Naming/AsciiIdentifiers] +* xref:cops_naming.adoc#namingbinaryoperatorparametername[Naming/BinaryOperatorParameterName] +* xref:cops_naming.adoc#namingblockforwarding[Naming/BlockForwarding] +* xref:cops_naming.adoc#namingblockparametername[Naming/BlockParameterName] +* xref:cops_naming.adoc#namingclassandmodulecamelcase[Naming/ClassAndModuleCamelCase] +* xref:cops_naming.adoc#namingconstantname[Naming/ConstantName] +* xref:cops_naming.adoc#namingfilename[Naming/FileName] +* xref:cops_naming.adoc#namingheredocdelimitercase[Naming/HeredocDelimiterCase] +* xref:cops_naming.adoc#namingheredocdelimiternaming[Naming/HeredocDelimiterNaming] +* xref:cops_naming.adoc#naminginclusivelanguage[Naming/InclusiveLanguage] +* xref:cops_naming.adoc#namingmemoizedinstancevariablename[Naming/MemoizedInstanceVariableName] +* xref:cops_naming.adoc#namingmethodname[Naming/MethodName] +* xref:cops_naming.adoc#namingmethodparametername[Naming/MethodParameterName] +* xref:cops_naming.adoc#namingpredicatemethod[Naming/PredicateMethod] +* xref:cops_naming.adoc#namingpredicateprefix[Naming/PredicatePrefix] +* xref:cops_naming.adoc#namingrescuedexceptionsvariablename[Naming/RescuedExceptionsVariableName] +* xref:cops_naming.adoc#namingvariablename[Naming/VariableName] +* xref:cops_naming.adoc#namingvariablenumber[Naming/VariableNumber] + +=== Department xref:cops_security.adoc[Security] + +* xref:cops_security.adoc#securitycompoundhash[Security/CompoundHash] +* xref:cops_security.adoc#securityeval[Security/Eval] +* xref:cops_security.adoc#securityiomethods[Security/IoMethods] +* xref:cops_security.adoc#securityjsonload[Security/JSONLoad] +* xref:cops_security.adoc#securitymarshalload[Security/MarshalLoad] +* xref:cops_security.adoc#securityopen[Security/Open] +* xref:cops_security.adoc#securityyamlload[Security/YAMLLoad] + +=== Department xref:cops_style.adoc[Style] + +* xref:cops_style.adoc#styleaccessmodifierdeclarations[Style/AccessModifierDeclarations] +* xref:cops_style.adoc#styleaccessorgrouping[Style/AccessorGrouping] +* xref:cops_style.adoc#stylealias[Style/Alias] +* xref:cops_style.adoc#styleambiguousendlessmethoddefinition[Style/AmbiguousEndlessMethodDefinition] +* xref:cops_style.adoc#styleandor[Style/AndOr] +* xref:cops_style.adoc#styleargumentsforwarding[Style/ArgumentsForwarding] +* xref:cops_style.adoc#stylearraycoercion[Style/ArrayCoercion] +* xref:cops_style.adoc#stylearrayfirstlast[Style/ArrayFirstLast] +* xref:cops_style.adoc#stylearrayintersect[Style/ArrayIntersect] +* xref:cops_style.adoc#stylearrayjoin[Style/ArrayJoin] +* xref:cops_style.adoc#styleasciicomments[Style/AsciiComments] +* xref:cops_style.adoc#styleattr[Style/Attr] +* xref:cops_style.adoc#styleautoresourcecleanup[Style/AutoResourceCleanup] +* xref:cops_style.adoc#stylebarepercentliterals[Style/BarePercentLiterals] +* xref:cops_style.adoc#stylebeginblock[Style/BeginBlock] +* xref:cops_style.adoc#stylebisectedattraccessor[Style/BisectedAttrAccessor] +* xref:cops_style.adoc#stylebitwisepredicate[Style/BitwisePredicate] +* xref:cops_style.adoc#styleblockcomments[Style/BlockComments] +* xref:cops_style.adoc#styleblockdelimiters[Style/BlockDelimiters] +* xref:cops_style.adoc#stylecaseequality[Style/CaseEquality] +* xref:cops_style.adoc#stylecaselikeif[Style/CaseLikeIf] +* xref:cops_style.adoc#stylecharacterliteral[Style/CharacterLiteral] +* xref:cops_style.adoc#styleclassandmodulechildren[Style/ClassAndModuleChildren] +* xref:cops_style.adoc#styleclasscheck[Style/ClassCheck] +* xref:cops_style.adoc#styleclassequalitycomparison[Style/ClassEqualityComparison] +* xref:cops_style.adoc#styleclassmethods[Style/ClassMethods] +* xref:cops_style.adoc#styleclassmethodsdefinitions[Style/ClassMethodsDefinitions] +* xref:cops_style.adoc#styleclassvars[Style/ClassVars] +* xref:cops_style.adoc#stylecollectioncompact[Style/CollectionCompact] +* xref:cops_style.adoc#stylecollectionmethods[Style/CollectionMethods] +* xref:cops_style.adoc#stylecollectionquerying[Style/CollectionQuerying] +* xref:cops_style.adoc#stylecolonmethodcall[Style/ColonMethodCall] +* xref:cops_style.adoc#stylecolonmethoddefinition[Style/ColonMethodDefinition] +* xref:cops_style.adoc#stylecombinabledefined[Style/CombinableDefined] +* xref:cops_style.adoc#stylecombinableloops[Style/CombinableLoops] +* xref:cops_style.adoc#stylecommandliteral[Style/CommandLiteral] +* xref:cops_style.adoc#stylecommentannotation[Style/CommentAnnotation] +* xref:cops_style.adoc#stylecommentedkeyword[Style/CommentedKeyword] +* xref:cops_style.adoc#stylecomparablebetween[Style/ComparableBetween] +* xref:cops_style.adoc#stylecomparableclamp[Style/ComparableClamp] +* xref:cops_style.adoc#styleconcatarrayliterals[Style/ConcatArrayLiterals] +* xref:cops_style.adoc#styleconditionalassignment[Style/ConditionalAssignment] +* xref:cops_style.adoc#styleconstantvisibility[Style/ConstantVisibility] +* xref:cops_style.adoc#stylecopyright[Style/Copyright] +* xref:cops_style.adoc#styledatainheritance[Style/DataInheritance] +* xref:cops_style.adoc#styledatetime[Style/DateTime] +* xref:cops_style.adoc#styledefwithparentheses[Style/DefWithParentheses] +* xref:cops_style.adoc#styledigchain[Style/DigChain] +* xref:cops_style.adoc#styledir[Style/Dir] +* xref:cops_style.adoc#styledirempty[Style/DirEmpty] +* xref:cops_style.adoc#styledisablecopswithinsourcecodedirective[Style/DisableCopsWithinSourceCodeDirective] +* xref:cops_style.adoc#styledocumentdynamicevaldefinition[Style/DocumentDynamicEvalDefinition] +* xref:cops_style.adoc#styledocumentation[Style/Documentation] +* xref:cops_style.adoc#styledocumentationmethod[Style/DocumentationMethod] +* xref:cops_style.adoc#styledoublecopdisabledirective[Style/DoubleCopDisableDirective] +* xref:cops_style.adoc#styledoublenegation[Style/DoubleNegation] +* xref:cops_style.adoc#styleeachforsimpleloop[Style/EachForSimpleLoop] +* xref:cops_style.adoc#styleeachwithobject[Style/EachWithObject] +* xref:cops_style.adoc#styleemptyblockparameter[Style/EmptyBlockParameter] +* xref:cops_style.adoc#styleemptycasecondition[Style/EmptyCaseCondition] +* xref:cops_style.adoc#styleemptyelse[Style/EmptyElse] +* xref:cops_style.adoc#styleemptyheredoc[Style/EmptyHeredoc] +* xref:cops_style.adoc#styleemptylambdaparameter[Style/EmptyLambdaParameter] +* xref:cops_style.adoc#styleemptyliteral[Style/EmptyLiteral] +* xref:cops_style.adoc#styleemptymethod[Style/EmptyMethod] +* xref:cops_style.adoc#styleemptystringinsideinterpolation[Style/EmptyStringInsideInterpolation] +* xref:cops_style.adoc#styleencoding[Style/Encoding] +* xref:cops_style.adoc#styleendblock[Style/EndBlock] +* xref:cops_style.adoc#styleendlessmethod[Style/EndlessMethod] +* xref:cops_style.adoc#styleenvhome[Style/EnvHome] +* xref:cops_style.adoc#styleevalwithlocation[Style/EvalWithLocation] +* xref:cops_style.adoc#styleevenodd[Style/EvenOdd] +* xref:cops_style.adoc#styleexactregexpmatch[Style/ExactRegexpMatch] +* xref:cops_style.adoc#styleexpandpatharguments[Style/ExpandPathArguments] +* xref:cops_style.adoc#styleexplicitblockargument[Style/ExplicitBlockArgument] +* xref:cops_style.adoc#styleexponentialnotation[Style/ExponentialNotation] +* xref:cops_style.adoc#stylefetchenvvar[Style/FetchEnvVar] +* xref:cops_style.adoc#stylefileempty[Style/FileEmpty] +* xref:cops_style.adoc#stylefilenull[Style/FileNull] +* xref:cops_style.adoc#stylefileread[Style/FileRead] +* xref:cops_style.adoc#stylefiletouch[Style/FileTouch] +* xref:cops_style.adoc#stylefilewrite[Style/FileWrite] +* xref:cops_style.adoc#stylefloatdivision[Style/FloatDivision] +* xref:cops_style.adoc#stylefor[Style/For] +* xref:cops_style.adoc#styleformatstring[Style/FormatString] +* xref:cops_style.adoc#styleformatstringtoken[Style/FormatStringToken] +* xref:cops_style.adoc#stylefrozenstringliteralcomment[Style/FrozenStringLiteralComment] +* xref:cops_style.adoc#styleglobalstdstream[Style/GlobalStdStream] +* xref:cops_style.adoc#styleglobalvars[Style/GlobalVars] +* xref:cops_style.adoc#styleguardclause[Style/GuardClause] +* xref:cops_style.adoc#stylehashaslastarrayitem[Style/HashAsLastArrayItem] +* xref:cops_style.adoc#stylehashconversion[Style/HashConversion] +* xref:cops_style.adoc#stylehasheachmethods[Style/HashEachMethods] +* xref:cops_style.adoc#stylehashexcept[Style/HashExcept] +* xref:cops_style.adoc#stylehashfetchchain[Style/HashFetchChain] +* xref:cops_style.adoc#stylehashlikecase[Style/HashLikeCase] +* xref:cops_style.adoc#stylehashslice[Style/HashSlice] +* xref:cops_style.adoc#stylehashsyntax[Style/HashSyntax] +* xref:cops_style.adoc#stylehashtransformkeys[Style/HashTransformKeys] +* xref:cops_style.adoc#stylehashtransformvalues[Style/HashTransformValues] +* xref:cops_style.adoc#styleidenticalconditionalbranches[Style/IdenticalConditionalBranches] +* xref:cops_style.adoc#styleifinsideelse[Style/IfInsideElse] +* xref:cops_style.adoc#styleifunlessmodifier[Style/IfUnlessModifier] +* xref:cops_style.adoc#styleifunlessmodifierofifunless[Style/IfUnlessModifierOfIfUnless] +* xref:cops_style.adoc#styleifwithbooleanliteralbranches[Style/IfWithBooleanLiteralBranches] +* xref:cops_style.adoc#styleifwithsemicolon[Style/IfWithSemicolon] +* xref:cops_style.adoc#styleimplicitruntimeerror[Style/ImplicitRuntimeError] +* xref:cops_style.adoc#styleinpatternthen[Style/InPatternThen] +* xref:cops_style.adoc#styleinfiniteloop[Style/InfiniteLoop] +* xref:cops_style.adoc#styleinlinecomment[Style/InlineComment] +* xref:cops_style.adoc#styleinversemethods[Style/InverseMethods] +* xref:cops_style.adoc#styleinvertibleunlesscondition[Style/InvertibleUnlessCondition] +* xref:cops_style.adoc#styleipaddresses[Style/IpAddresses] +* xref:cops_style.adoc#styleitassignment[Style/ItAssignment] +* xref:cops_style.adoc#styleitblockparameter[Style/ItBlockParameter] +* xref:cops_style.adoc#stylekeywordargumentsmerging[Style/KeywordArgumentsMerging] +* xref:cops_style.adoc#stylekeywordparametersorder[Style/KeywordParametersOrder] +* xref:cops_style.adoc#stylelambda[Style/Lambda] +* xref:cops_style.adoc#stylelambdacall[Style/LambdaCall] +* xref:cops_style.adoc#stylelineendconcatenation[Style/LineEndConcatenation] +* xref:cops_style.adoc#stylemagiccommentformat[Style/MagicCommentFormat] +* xref:cops_style.adoc#stylemapcompactwithconditionalblock[Style/MapCompactWithConditionalBlock] +* xref:cops_style.adoc#stylemapintoarray[Style/MapIntoArray] +* xref:cops_style.adoc#stylemaptohash[Style/MapToHash] +* xref:cops_style.adoc#stylemaptoset[Style/MapToSet] +* xref:cops_style.adoc#stylemethodcallwithargsparentheses[Style/MethodCallWithArgsParentheses] +* xref:cops_style.adoc#stylemethodcallwithoutargsparentheses[Style/MethodCallWithoutArgsParentheses] +* xref:cops_style.adoc#stylemethodcalledondoendblock[Style/MethodCalledOnDoEndBlock] +* xref:cops_style.adoc#stylemethoddefparentheses[Style/MethodDefParentheses] +* xref:cops_style.adoc#styleminmax[Style/MinMax] +* xref:cops_style.adoc#styleminmaxcomparison[Style/MinMaxComparison] +* xref:cops_style.adoc#stylemissingelse[Style/MissingElse] +* xref:cops_style.adoc#stylemissingrespondtomissing[Style/MissingRespondToMissing] +* xref:cops_style.adoc#stylemixingrouping[Style/MixinGrouping] +* xref:cops_style.adoc#stylemixinusage[Style/MixinUsage] +* xref:cops_style.adoc#stylemodulefunction[Style/ModuleFunction] +* xref:cops_style.adoc#stylemultilineblockchain[Style/MultilineBlockChain] +* xref:cops_style.adoc#stylemultilineifmodifier[Style/MultilineIfModifier] +* xref:cops_style.adoc#stylemultilineifthen[Style/MultilineIfThen] +* xref:cops_style.adoc#stylemultilineinpatternthen[Style/MultilineInPatternThen] +* xref:cops_style.adoc#stylemultilinememoization[Style/MultilineMemoization] +* xref:cops_style.adoc#stylemultilinemethodsignature[Style/MultilineMethodSignature] +* xref:cops_style.adoc#stylemultilineternaryoperator[Style/MultilineTernaryOperator] +* xref:cops_style.adoc#stylemultilinewhenthen[Style/MultilineWhenThen] +* xref:cops_style.adoc#stylemultiplecomparison[Style/MultipleComparison] +* xref:cops_style.adoc#stylemutableconstant[Style/MutableConstant] +* xref:cops_style.adoc#stylenegatedif[Style/NegatedIf] +* xref:cops_style.adoc#stylenegatedifelsecondition[Style/NegatedIfElseCondition] +* xref:cops_style.adoc#stylenegatedunless[Style/NegatedUnless] +* xref:cops_style.adoc#stylenegatedwhile[Style/NegatedWhile] +* xref:cops_style.adoc#stylenestedfiledirname[Style/NestedFileDirname] +* xref:cops_style.adoc#stylenestedmodifier[Style/NestedModifier] +* xref:cops_style.adoc#stylenestedparenthesizedcalls[Style/NestedParenthesizedCalls] +* xref:cops_style.adoc#stylenestedternaryoperator[Style/NestedTernaryOperator] +* xref:cops_style.adoc#stylenext[Style/Next] +* xref:cops_style.adoc#stylenilcomparison[Style/NilComparison] +* xref:cops_style.adoc#stylenillambda[Style/NilLambda] +* xref:cops_style.adoc#stylenonnilcheck[Style/NonNilCheck] +* xref:cops_style.adoc#stylenot[Style/Not] +* xref:cops_style.adoc#stylenumberedparameters[Style/NumberedParameters] +* xref:cops_style.adoc#stylenumberedparameterslimit[Style/NumberedParametersLimit] +* xref:cops_style.adoc#stylenumericliteralprefix[Style/NumericLiteralPrefix] +* xref:cops_style.adoc#stylenumericliterals[Style/NumericLiterals] +* xref:cops_style.adoc#stylenumericpredicate[Style/NumericPredicate] +* xref:cops_style.adoc#styleobjectthen[Style/ObjectThen] +* xref:cops_style.adoc#styleonelineconditional[Style/OneLineConditional] +* xref:cops_style.adoc#styleopenstructuse[Style/OpenStructUse] +* xref:cops_style.adoc#styleoperatormethodcall[Style/OperatorMethodCall] +* xref:cops_style.adoc#styleoptionhash[Style/OptionHash] +* xref:cops_style.adoc#styleoptionalarguments[Style/OptionalArguments] +* xref:cops_style.adoc#styleoptionalbooleanparameter[Style/OptionalBooleanParameter] +* xref:cops_style.adoc#styleorassignment[Style/OrAssignment] +* xref:cops_style.adoc#styleparallelassignment[Style/ParallelAssignment] +* xref:cops_style.adoc#styleparenthesesaroundcondition[Style/ParenthesesAroundCondition] +* xref:cops_style.adoc#stylepercentliteraldelimiters[Style/PercentLiteralDelimiters] +* xref:cops_style.adoc#stylepercentqliterals[Style/PercentQLiterals] +* xref:cops_style.adoc#styleperlbackrefs[Style/PerlBackrefs] +* xref:cops_style.adoc#stylepreferredhashmethods[Style/PreferredHashMethods] +* xref:cops_style.adoc#styleproc[Style/Proc] +* xref:cops_style.adoc#stylequotedsymbols[Style/QuotedSymbols] +* xref:cops_style.adoc#styleraiseargs[Style/RaiseArgs] +* xref:cops_style.adoc#stylerandomwithoffset[Style/RandomWithOffset] +* xref:cops_style.adoc#styleredundantargument[Style/RedundantArgument] +* xref:cops_style.adoc#styleredundantarrayconstructor[Style/RedundantArrayConstructor] +* xref:cops_style.adoc#styleredundantarrayflatten[Style/RedundantArrayFlatten] +* xref:cops_style.adoc#styleredundantassignment[Style/RedundantAssignment] +* xref:cops_style.adoc#styleredundantbegin[Style/RedundantBegin] +* xref:cops_style.adoc#styleredundantcapitalw[Style/RedundantCapitalW] +* xref:cops_style.adoc#styleredundantcondition[Style/RedundantCondition] +* xref:cops_style.adoc#styleredundantconditional[Style/RedundantConditional] +* xref:cops_style.adoc#styleredundantconstantbase[Style/RedundantConstantBase] +* xref:cops_style.adoc#styleredundantcurrentdirectoryinpath[Style/RedundantCurrentDirectoryInPath] +* xref:cops_style.adoc#styleredundantdoublesplathashbraces[Style/RedundantDoubleSplatHashBraces] +* xref:cops_style.adoc#styleredundanteach[Style/RedundantEach] +* xref:cops_style.adoc#styleredundantexception[Style/RedundantException] +* xref:cops_style.adoc#styleredundantfetchblock[Style/RedundantFetchBlock] +* xref:cops_style.adoc#styleredundantfileextensioninrequire[Style/RedundantFileExtensionInRequire] +* xref:cops_style.adoc#styleredundantfilterchain[Style/RedundantFilterChain] +* xref:cops_style.adoc#styleredundantformat[Style/RedundantFormat] +* xref:cops_style.adoc#styleredundantfreeze[Style/RedundantFreeze] +* xref:cops_style.adoc#styleredundantheredocdelimiterquotes[Style/RedundantHeredocDelimiterQuotes] +* xref:cops_style.adoc#styleredundantinitialize[Style/RedundantInitialize] +* xref:cops_style.adoc#styleredundantinterpolation[Style/RedundantInterpolation] +* xref:cops_style.adoc#styleredundantinterpolationunfreeze[Style/RedundantInterpolationUnfreeze] +* xref:cops_style.adoc#styleredundantlinecontinuation[Style/RedundantLineContinuation] +* xref:cops_style.adoc#styleredundantparentheses[Style/RedundantParentheses] +* xref:cops_style.adoc#styleredundantpercentq[Style/RedundantPercentQ] +* xref:cops_style.adoc#styleredundantregexpargument[Style/RedundantRegexpArgument] +* xref:cops_style.adoc#styleredundantregexpcharacterclass[Style/RedundantRegexpCharacterClass] +* xref:cops_style.adoc#styleredundantregexpconstructor[Style/RedundantRegexpConstructor] +* xref:cops_style.adoc#styleredundantregexpescape[Style/RedundantRegexpEscape] +* xref:cops_style.adoc#styleredundantreturn[Style/RedundantReturn] +* xref:cops_style.adoc#styleredundantself[Style/RedundantSelf] +* xref:cops_style.adoc#styleredundantselfassignment[Style/RedundantSelfAssignment] +* xref:cops_style.adoc#styleredundantselfassignmentbranch[Style/RedundantSelfAssignmentBranch] +* xref:cops_style.adoc#styleredundantsort[Style/RedundantSort] +* xref:cops_style.adoc#styleredundantsortby[Style/RedundantSortBy] +* xref:cops_style.adoc#styleredundantstringescape[Style/RedundantStringEscape] +* xref:cops_style.adoc#styleregexpliteral[Style/RegexpLiteral] +* xref:cops_style.adoc#stylerequireorder[Style/RequireOrder] +* xref:cops_style.adoc#stylerescuemodifier[Style/RescueModifier] +* xref:cops_style.adoc#stylerescuestandarderror[Style/RescueStandardError] +* xref:cops_style.adoc#stylereturnnil[Style/ReturnNil] +* xref:cops_style.adoc#stylereturnnilinpredicatemethoddefinition[Style/ReturnNilInPredicateMethodDefinition] +* xref:cops_style.adoc#stylesafenavigation[Style/SafeNavigation] +* xref:cops_style.adoc#stylesafenavigationchainlength[Style/SafeNavigationChainLength] +* xref:cops_style.adoc#stylesample[Style/Sample] +* xref:cops_style.adoc#styleselectbyregexp[Style/SelectByRegexp] +* xref:cops_style.adoc#styleselfassignment[Style/SelfAssignment] +* xref:cops_style.adoc#stylesemicolon[Style/Semicolon] +* xref:cops_style.adoc#stylesend[Style/Send] +* xref:cops_style.adoc#stylesendwithliteralmethodname[Style/SendWithLiteralMethodName] +* xref:cops_style.adoc#stylesignalexception[Style/SignalException] +* xref:cops_style.adoc#stylesingleargumentdig[Style/SingleArgumentDig] +* xref:cops_style.adoc#stylesinglelineblockparams[Style/SingleLineBlockParams] +* xref:cops_style.adoc#stylesinglelinedoendblock[Style/SingleLineDoEndBlock] +* xref:cops_style.adoc#stylesinglelinemethods[Style/SingleLineMethods] +* xref:cops_style.adoc#styleslicingwithrange[Style/SlicingWithRange] +* xref:cops_style.adoc#stylesolenestedconditional[Style/SoleNestedConditional] +* xref:cops_style.adoc#stylespecialglobalvars[Style/SpecialGlobalVars] +* xref:cops_style.adoc#stylestabbylambdaparentheses[Style/StabbyLambdaParentheses] +* xref:cops_style.adoc#stylestaticclass[Style/StaticClass] +* xref:cops_style.adoc#stylestderrputs[Style/StderrPuts] +* xref:cops_style.adoc#stylestringchars[Style/StringChars] +* xref:cops_style.adoc#stylestringconcatenation[Style/StringConcatenation] +* xref:cops_style.adoc#stylestringhashkeys[Style/StringHashKeys] +* xref:cops_style.adoc#stylestringliterals[Style/StringLiterals] +* xref:cops_style.adoc#stylestringliteralsininterpolation[Style/StringLiteralsInInterpolation] +* xref:cops_style.adoc#stylestringmethods[Style/StringMethods] +* xref:cops_style.adoc#stylestrip[Style/Strip] +* xref:cops_style.adoc#stylestructinheritance[Style/StructInheritance] +* xref:cops_style.adoc#stylesuperarguments[Style/SuperArguments] +* xref:cops_style.adoc#stylesuperwithargsparentheses[Style/SuperWithArgsParentheses] +* xref:cops_style.adoc#styleswapvalues[Style/SwapValues] +* xref:cops_style.adoc#stylesymbolarray[Style/SymbolArray] +* xref:cops_style.adoc#stylesymbolliteral[Style/SymbolLiteral] +* xref:cops_style.adoc#stylesymbolproc[Style/SymbolProc] +* xref:cops_style.adoc#styleternaryparentheses[Style/TernaryParentheses] +* xref:cops_style.adoc#styletoplevelmethoddefinition[Style/TopLevelMethodDefinition] +* xref:cops_style.adoc#styletrailingbodyonclass[Style/TrailingBodyOnClass] +* xref:cops_style.adoc#styletrailingbodyonmethoddefinition[Style/TrailingBodyOnMethodDefinition] +* xref:cops_style.adoc#styletrailingbodyonmodule[Style/TrailingBodyOnModule] +* xref:cops_style.adoc#styletrailingcommainarguments[Style/TrailingCommaInArguments] +* xref:cops_style.adoc#styletrailingcommainarrayliteral[Style/TrailingCommaInArrayLiteral] +* xref:cops_style.adoc#styletrailingcommainblockargs[Style/TrailingCommaInBlockArgs] +* xref:cops_style.adoc#styletrailingcommainhashliteral[Style/TrailingCommaInHashLiteral] +* xref:cops_style.adoc#styletrailingmethodendstatement[Style/TrailingMethodEndStatement] +* xref:cops_style.adoc#styletrailingunderscorevariable[Style/TrailingUnderscoreVariable] +* xref:cops_style.adoc#styletrivialaccessors[Style/TrivialAccessors] +* xref:cops_style.adoc#styleunlesselse[Style/UnlessElse] +* xref:cops_style.adoc#styleunlesslogicaloperators[Style/UnlessLogicalOperators] +* xref:cops_style.adoc#styleunpackfirst[Style/UnpackFirst] +* xref:cops_style.adoc#stylevariableinterpolation[Style/VariableInterpolation] +* xref:cops_style.adoc#stylewhenthen[Style/WhenThen] +* xref:cops_style.adoc#stylewhileuntildo[Style/WhileUntilDo] +* xref:cops_style.adoc#stylewhileuntilmodifier[Style/WhileUntilModifier] +* xref:cops_style.adoc#stylewordarray[Style/WordArray] +* xref:cops_style.adoc#styleyamlfileread[Style/YAMLFileRead] +* xref:cops_style.adoc#styleyodacondition[Style/YodaCondition] +* xref:cops_style.adoc#styleyodaexpression[Style/YodaExpression] +* xref:cops_style.adoc#stylezerolengthpredicate[Style/ZeroLengthPredicate] + +// END_COP_LIST diff --git a/docs/modules/ROOT/pages/cops_bundler.adoc b/docs/modules/ROOT/pages/cops_bundler.adoc new file mode 100644 index 000000000000..e9c0bdccee0c --- /dev/null +++ b/docs/modules/ROOT/pages/cops_bundler.adoc @@ -0,0 +1,603 @@ +//// + Do NOT edit this file by hand directly, as it is automatically generated. + + Please make any necessary changes to the cop documentation within the source files themselves. +//// + += Bundler + +[#bundlerduplicatedgem] +== Bundler/DuplicatedGem + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.46 +| 1.40 +|=== + +A Gem's requirements should be listed only once in a Gemfile. + +[#examples-bundlerduplicatedgem] +=== Examples + +[source,ruby] +---- +# bad +gem 'rubocop' +gem 'rubocop' + +# bad +group :development do + gem 'rubocop' +end + +group :test do + gem 'rubocop' +end + +# good +group :development, :test do + gem 'rubocop' +end + +# good +gem 'rubocop', groups: [:development, :test] + +# good - conditional declaration +if Dir.exist?(local) + gem 'rubocop', path: local +elsif ENV['RUBOCOP_VERSION'] == 'master' + gem 'rubocop', git: 'https://github.com/rubocop/rubocop.git' +else + gem 'rubocop', '~> 0.90.0' +end +---- + +[#configurable-attributes-bundlerduplicatedgem] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Severity +| `warning` +| String + +| Include +| `+**/*.gemfile+`, `+**/Gemfile+`, `+**/gems.rb+` +| Array +|=== + +[#bundlerduplicatedgroup] +== Bundler/DuplicatedGroup + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 1.56 +| - +|=== + +A Gem group, or a set of groups, should be listed only once in a Gemfile. + +For example, if the values of `source`, `git`, `platforms`, or `path` +surrounding `group` are different, no offense will be registered: + +[source,ruby] +----- +platforms :ruby do + group :default do + gem 'openssl' + end +end + +platforms :jruby do + group :default do + gem 'jruby-openssl' + end +end +----- + +[#examples-bundlerduplicatedgroup] +=== Examples + +[source,ruby] +---- +# bad +group :development do + gem 'rubocop' +end + +group :development do + gem 'rubocop-rails' +end + +# bad (same set of groups declared twice) +group :development, :test do + gem 'rubocop' +end + +group :test, :development do + gem 'rspec' +end + +# good +group :development do + gem 'rubocop' +end + +group :development, :test do + gem 'rspec' +end + +# good +gem 'rubocop', groups: [:development, :test] +gem 'rspec', groups: [:development, :test] +---- + +[#configurable-attributes-bundlerduplicatedgroup] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Severity +| `warning` +| String + +| Include +| `+**/*.gemfile+`, `+**/Gemfile+`, `+**/gems.rb+` +| Array +|=== + +[#bundlergemcomment] +== Bundler/GemComment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| No +| 0.59 +| 0.85 +|=== + +Each gem in the Gemfile should have a comment explaining +its purpose in the project, or the reason for its version +or source. + +The optional "OnlyFor" configuration array +can be used to only register offenses when the gems +use certain options or have version specifiers. + +When "version_specifiers" is included, a comment +will be enforced if the gem has any version specifier. + +When "restrictive_version_specifiers" is included, a comment +will be enforced if the gem has a version specifier that +holds back the version of the gem. + +For any other value in the array, a comment will be enforced for +a gem if an option by the same name is present. +A useful use case is to enforce a comment when using +options that change the source of a gem: + +- `bitbucket` +- `gist` +- `git` +- `github` +- `source` + +For a full list of options supported by bundler, +see https://bundler.io/man/gemfile.5.html +. + +[#examples-bundlergemcomment] +=== Examples + +[#onlyfor_-__-_default_-bundlergemcomment] +==== OnlyFor: [] (default) + +[source,ruby] +---- +# bad + +gem 'foo' + +# good + +# Helpers for the foo things. +gem 'foo' +---- + +[#onlyfor_-__version_specifiers__-bundlergemcomment] +==== OnlyFor: ['version_specifiers'] + +[source,ruby] +---- +# bad + +gem 'foo', '< 2.1' + +# good + +# Version 2.1 introduces breaking change baz +gem 'foo', '< 2.1' +---- + +[#onlyfor_-__restrictive_version_specifiers__-bundlergemcomment] +==== OnlyFor: ['restrictive_version_specifiers'] + +[source,ruby] +---- +# bad + +gem 'foo', '< 2.1' + +# good + +gem 'foo', '>= 1.0' + +# Version 2.1 introduces breaking change baz +gem 'foo', '< 2.1' +---- + +[#onlyfor_-__version_specifiers__-_github__-bundlergemcomment] +==== OnlyFor: ['version_specifiers', 'github'] + +[source,ruby] +---- +# bad + +gem 'foo', github: 'some_account/some_fork_of_foo' + +gem 'bar', '< 2.1' + +# good + +# Using this fork because baz +gem 'foo', github: 'some_account/some_fork_of_foo' + +# Version 2.1 introduces breaking change baz +gem 'bar', '< 2.1' +---- + +[#configurable-attributes-bundlergemcomment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Include +| `+**/*.gemfile+`, `+**/Gemfile+`, `+**/gems.rb+` +| Array + +| IgnoredGems +| `[]` +| Array + +| OnlyFor +| `[]` +| Array +|=== + +[#bundlergemfilename] +== Bundler/GemFilename + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 1.20 +| - +|=== + +Verifies that a project contains Gemfile or gems.rb file and correct +associated lock file based on the configuration. + +[#examples-bundlergemfilename] +=== Examples + +[#enforcedstyle_-gemfile-_default_-bundlergemfilename] +==== EnforcedStyle: Gemfile (default) + +[source,ruby] +---- +# bad +Project contains gems.rb and gems.locked files + +# bad +Project contains Gemfile and gems.locked file + +# good +Project contains Gemfile and Gemfile.lock +---- + +[#enforcedstyle_-gems_rb-bundlergemfilename] +==== EnforcedStyle: gems.rb + +[source,ruby] +---- +# bad +Project contains Gemfile and Gemfile.lock files + +# bad +Project contains gems.rb and Gemfile.lock file + +# good +Project contains gems.rb and gems.locked files +---- + +[#configurable-attributes-bundlergemfilename] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `Gemfile` +| `Gemfile`, `gems.rb` + +| Include +| `+**/Gemfile+`, `+**/gems.rb+`, `+**/Gemfile.lock+`, `+**/gems.locked+` +| Array +|=== + +[#bundlergemversion] +== Bundler/GemVersion + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| No +| 1.14 +| - +|=== + +Enforce that Gem version specifications or a commit reference (branch, +ref, or tag) are either required or forbidden. + +[#examples-bundlergemversion] +=== Examples + +[#enforcedstyle_-required-_default_-bundlergemversion] +==== EnforcedStyle: required (default) + +[source,ruby] +---- +# bad +gem 'rubocop' + +# good +gem 'rubocop', '~> 1.12' + +# good +gem 'rubocop', '>= 1.10.0' + +# good +gem 'rubocop', '>= 1.5.0', '< 1.10.0' + +# good +gem 'rubocop', branch: 'feature-branch' + +# good +gem 'rubocop', ref: '74b5bfbb2c4b6fd6cdbbc7254bd7084b36e0c85b' + +# good +gem 'rubocop', tag: 'v1.17.0' +---- + +[#enforcedstyle_-forbidden-bundlergemversion] +==== EnforcedStyle: forbidden + +[source,ruby] +---- +# good +gem 'rubocop' + +# bad +gem 'rubocop', '~> 1.12' + +# bad +gem 'rubocop', '>= 1.10.0' + +# bad +gem 'rubocop', '>= 1.5.0', '< 1.10.0' + +# bad +gem 'rubocop', branch: 'feature-branch' + +# bad +gem 'rubocop', ref: '74b5bfbb2c4b6fd6cdbbc7254bd7084b36e0c85b' + +# bad +gem 'rubocop', tag: 'v1.17.0' +---- + +[#configurable-attributes-bundlergemversion] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `required` +| `required`, `forbidden` + +| Include +| `+**/*.gemfile+`, `+**/Gemfile+`, `+**/gems.rb+` +| Array + +| AllowedGems +| `[]` +| Array +|=== + +[#bundlerinsecureprotocolsource] +== Bundler/InsecureProtocolSource + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.50 +| 1.40 +|=== + +Passing symbol arguments to `source` (e.g. `source :rubygems`) is +deprecated because they default to using HTTP requests. Instead, specify +`'https://rubygems.org'` if possible, or `'http://rubygems.org'` if not. + +When autocorrecting, this cop will replace symbol arguments with +`'https://rubygems.org'`. + +This cop will not replace existing sources that use `http://`. This may +be necessary where HTTPS is not available. For example, where using an +internal gem server via an intranet, or where HTTPS is prohibited. +However, you should strongly prefer `https://` where possible, as it is +more secure. + +If you don't allow `http://`, please set `false` to `AllowHttpProtocol`. +This option is `true` by default for safe autocorrection. + +[#examples-bundlerinsecureprotocolsource] +=== Examples + +[source,ruby] +---- +# bad +source :gemcutter +source :rubygems +source :rubyforge + +# good +source 'https://rubygems.org' # strongly recommended +---- + +[#allowhttpprotocol_-true-_default_-bundlerinsecureprotocolsource] +==== AllowHttpProtocol: true (default) + +[source,ruby] +---- +# good +source 'http://rubygems.org' # use only if HTTPS is unavailable +---- + +[#allowhttpprotocol_-false-bundlerinsecureprotocolsource] +==== AllowHttpProtocol: false + +[source,ruby] +---- +# bad +source 'http://rubygems.org' +---- + +[#configurable-attributes-bundlerinsecureprotocolsource] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Severity +| `warning` +| String + +| AllowHttpProtocol +| `true` +| Boolean + +| Include +| `+**/*.gemfile+`, `+**/Gemfile+`, `+**/gems.rb+` +| Array +|=== + +[#bundlerorderedgems] +== Bundler/OrderedGems + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.46 +| 0.47 +|=== + +Gems should be alphabetically sorted within groups. + +[#examples-bundlerorderedgems] +=== Examples + +[source,ruby] +---- +# bad +gem 'rubocop' +gem 'rspec' + +# good +gem 'rspec' +gem 'rubocop' + +# good +gem 'rubocop' + +gem 'rspec' +---- + +[#treatcommentsasgroupseparators_-true-_default_-bundlerorderedgems] +==== TreatCommentsAsGroupSeparators: true (default) + +[source,ruby] +---- +# good +# For code quality +gem 'rubocop' +# For tests +gem 'rspec' +---- + +[#treatcommentsasgroupseparators_-false-bundlerorderedgems] +==== TreatCommentsAsGroupSeparators: false + +[source,ruby] +---- +# bad +# For code quality +gem 'rubocop' +# For tests +gem 'rspec' +---- + +[#configurable-attributes-bundlerorderedgems] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| TreatCommentsAsGroupSeparators +| `true` +| Boolean + +| ConsiderPunctuation +| `false` +| Boolean + +| Include +| `+**/*.gemfile+`, `+**/Gemfile+`, `+**/gems.rb+` +| Array +|=== diff --git a/docs/modules/ROOT/pages/cops_gemspec.adoc b/docs/modules/ROOT/pages/cops_gemspec.adoc new file mode 100644 index 000000000000..fd1abe2c6a3d --- /dev/null +++ b/docs/modules/ROOT/pages/cops_gemspec.adoc @@ -0,0 +1,810 @@ +//// + Do NOT edit this file by hand directly, as it is automatically generated. + + Please make any necessary changes to the cop documentation within the source files themselves. +//// + += Gemspec + +[#gemspecaddruntimedependency] +== Gemspec/AddRuntimeDependency + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.65 +| - +|=== + +Prefer `add_dependency` over `add_runtime_dependency` as the latter is +considered soft-deprecated. + +[#examples-gemspecaddruntimedependency] +=== Examples + +[source,ruby] +---- +# bad +Gem::Specification.new do |spec| + spec.add_runtime_dependency('rubocop') +end + +# good +Gem::Specification.new do |spec| + spec.add_dependency('rubocop') +end +---- + +[#configurable-attributes-gemspecaddruntimedependency] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Include +| `+**/*.gemspec+` +| Array +|=== + +[#references-gemspecaddruntimedependency] +=== References + +* https://rubystyle.guide#add_dependency_vs_add_runtime_dependency +* https://github.com/rubygems/rubygems/issues/7799#issuecomment-2192720316 + +[#gemspecattributeassignment] +== Gemspec/AttributeAssignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.77 +| - +|=== + +Use consistent style for Gemspec attributes assignment. + +[#examples-gemspecattributeassignment] +=== Examples + +[source,ruby] +---- +# bad +# This example uses two styles for assignment of metadata attribute. +Gem::Specification.new do |spec| + spec.metadata = { 'key' => 'value' } + spec.metadata['another-key'] = 'another-value' +end + +# good +Gem::Specification.new do |spec| + spec.metadata['key'] = 'value' + spec.metadata['another-key'] = 'another-value' +end + +# good +Gem::Specification.new do |spec| + spec.metadata = { 'key' => 'value', 'another-key' => 'another-value' } +end + +# bad +# This example uses two styles for assignment of authors attribute. +Gem::Specification.new do |spec| + spec.authors = %w[author-0 author-1] + spec.authors[2] = 'author-2' +end + +# good +Gem::Specification.new do |spec| + spec.authors = %w[author-0 author-1 author-2] +end + +# good +Gem::Specification.new do |spec| + spec.authors[0] = 'author-0' + spec.authors[1] = 'author-1' + spec.authors[2] = 'author-2' +end + +# good +# This example uses consistent assignment per attribute, +# even though two different styles are used overall. +Gem::Specification.new do |spec| + spec.metadata = { 'key' => 'value' } + spec.authors[0] = 'author-0' + spec.authors[1] = 'author-1' + spec.authors[2] = 'author-2' +end +---- + +[#configurable-attributes-gemspecattributeassignment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Include +| `+**/*.gemspec+` +| Array +|=== + +[#gemspecdependencyversion] +== Gemspec/DependencyVersion + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| No +| 1.29 +| - +|=== + +Enforce that gem dependency version specifications or a commit reference (branch, +ref, or tag) are either required or forbidden. + +[#examples-gemspecdependencyversion] +=== Examples + +[#enforcedstyle_-required-_default_-gemspecdependencyversion] +==== EnforcedStyle: required (default) + +[source,ruby] +---- +# bad +Gem::Specification.new do |spec| + spec.add_dependency 'parser' +end + +# bad +Gem::Specification.new do |spec| + spec.add_development_dependency 'parser' +end + +# good +Gem::Specification.new do |spec| + spec.add_dependency 'parser', '>= 2.3.3.1', '< 3.0' +end + +# good +Gem::Specification.new do |spec| + spec.add_development_dependency 'parser', '>= 2.3.3.1', '< 3.0' +end +---- + +[#enforcedstyle_-forbidden-gemspecdependencyversion] +==== EnforcedStyle: forbidden + +[source,ruby] +---- +# bad +Gem::Specification.new do |spec| + spec.add_dependency 'parser', '>= 2.3.3.1', '< 3.0' +end + +# bad +Gem::Specification.new do |spec| + spec.add_development_dependency 'parser', '>= 2.3.3.1', '< 3.0' +end + +# good +Gem::Specification.new do |spec| + spec.add_dependency 'parser' +end + +# good +Gem::Specification.new do |spec| + spec.add_development_dependency 'parser' +end +---- + +[#configurable-attributes-gemspecdependencyversion] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `required` +| `required`, `forbidden` + +| Include +| `+**/*.gemspec+` +| Array + +| AllowedGems +| `[]` +| Array +|=== + +[#gemspecdeprecatedattributeassignment] +== Gemspec/DeprecatedAttributeAssignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.30 +| 1.40 +|=== + +Checks that deprecated attributes are not set in a gemspec file. +Removing deprecated attributes allows the user to receive smaller packed gems. + +[#examples-gemspecdeprecatedattributeassignment] +=== Examples + +[source,ruby] +---- +# bad +Gem::Specification.new do |spec| + spec.name = 'your_cool_gem_name' + spec.test_files = Dir.glob('test/**/*') +end + +# bad +Gem::Specification.new do |spec| + spec.name = 'your_cool_gem_name' + spec.test_files += Dir.glob('test/**/*') +end + +# good +Gem::Specification.new do |spec| + spec.name = 'your_cool_gem_name' +end +---- + +[#configurable-attributes-gemspecdeprecatedattributeassignment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Severity +| `warning` +| String + +| Include +| `+**/*.gemspec+` +| Array +|=== + +[#gemspecdevelopmentdependencies] +== Gemspec/DevelopmentDependencies + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.44 +| - +|=== + +Enforce that development dependencies for a gem are specified in +`Gemfile`, rather than in the `gemspec` using +`add_development_dependency`. Alternatively, using `EnforcedStyle: +gemspec`, enforce that all dependencies are specified in `gemspec`, +rather than in `Gemfile`. + +[#examples-gemspecdevelopmentdependencies] +=== Examples + +[#enforcedstyle_-gemfile-_default_-gemspecdevelopmentdependencies] +==== EnforcedStyle: Gemfile (default) + +[source,ruby] +---- +# Specify runtime dependencies in your gemspec, +# but all other dependencies in your Gemfile. + +# bad +# example.gemspec +s.add_development_dependency "foo" + +# good +# Gemfile +gem "foo" + +# good +# gems.rb +gem "foo" + +# good (with AllowedGems: ["bar"]) +# example.gemspec +s.add_development_dependency "bar" +---- + +[#enforcedstyle_-gems_rb-gemspecdevelopmentdependencies] +==== EnforcedStyle: gems.rb + +[source,ruby] +---- +# Specify runtime dependencies in your gemspec, +# but all other dependencies in your Gemfile. +# +# Identical to `EnforcedStyle: Gemfile`, but with a different error message. +# Rely on Bundler/GemFilename to enforce the use of `Gemfile` vs `gems.rb`. + +# bad +# example.gemspec +s.add_development_dependency "foo" + +# good +# Gemfile +gem "foo" + +# good +# gems.rb +gem "foo" + +# good (with AllowedGems: ["bar"]) +# example.gemspec +s.add_development_dependency "bar" +---- + +[#enforcedstyle_-gemspec-gemspecdevelopmentdependencies] +==== EnforcedStyle: gemspec + +[source,ruby] +---- +# Specify all dependencies in your gemspec. + +# bad +# Gemfile +gem "foo" + +# good +# example.gemspec +s.add_development_dependency "foo" + +# good (with AllowedGems: ["bar"]) +# Gemfile +gem "bar" +---- + +[#configurable-attributes-gemspecdevelopmentdependencies] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `Gemfile` +| `Gemfile`, `gems.rb`, `gemspec` + +| AllowedGems +| `[]` +| Array + +| Include +| `+**/*.gemspec+`, `+**/Gemfile+`, `+**/gems.rb+` +| Array +|=== + +[#gemspecduplicatedassignment] +== Gemspec/DuplicatedAssignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.52 +| 1.40 +|=== + +An attribute assignment method calls should be listed only once +in a gemspec. + +Assigning to an attribute with the same name using `spec.foo =` or +`spec.attribute#[]=` will be an unintended usage. On the other hand, +duplication of methods such # as `spec.requirements`, +`spec.add_runtime_dependency`, and others are permitted because it is +the intended use of appending values. + +[#examples-gemspecduplicatedassignment] +=== Examples + +[source,ruby] +---- +# bad +Gem::Specification.new do |spec| + spec.name = 'rubocop' + spec.name = 'rubocop2' +end + +# good +Gem::Specification.new do |spec| + spec.name = 'rubocop' +end + +# good +Gem::Specification.new do |spec| + spec.requirements << 'libmagick, v6.0' + spec.requirements << 'A good graphics card' +end + +# good +Gem::Specification.new do |spec| + spec.add_dependency('parallel', '~> 1.10') + spec.add_dependency('parser', '>= 2.3.3.1', '< 3.0') +end + +# bad +Gem::Specification.new do |spec| + spec.metadata["key"] = "value" + spec.metadata["key"] = "value" +end + +# good +Gem::Specification.new do |spec| + spec.metadata["key"] = "value" +end +---- + +[#configurable-attributes-gemspecduplicatedassignment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Severity +| `warning` +| String + +| Include +| `+**/*.gemspec+` +| Array +|=== + +[#gemspecordereddependencies] +== Gemspec/OrderedDependencies + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.51 +| - +|=== + +Dependencies in the gemspec should be alphabetically sorted. + +[#examples-gemspecordereddependencies] +=== Examples + +[source,ruby] +---- +# bad +spec.add_dependency 'rubocop' +spec.add_dependency 'rspec' + +# good +spec.add_dependency 'rspec' +spec.add_dependency 'rubocop' + +# good +spec.add_dependency 'rubocop' + +spec.add_dependency 'rspec' + +# bad +spec.add_development_dependency 'rubocop' +spec.add_development_dependency 'rspec' + +# good +spec.add_development_dependency 'rspec' +spec.add_development_dependency 'rubocop' + +# good +spec.add_development_dependency 'rubocop' + +spec.add_development_dependency 'rspec' + +# bad +spec.add_runtime_dependency 'rubocop' +spec.add_runtime_dependency 'rspec' + +# good +spec.add_runtime_dependency 'rspec' +spec.add_runtime_dependency 'rubocop' + +# good +spec.add_runtime_dependency 'rubocop' + +spec.add_runtime_dependency 'rspec' +---- + +[#treatcommentsasgroupseparators_-true-_default_-gemspecordereddependencies] +==== TreatCommentsAsGroupSeparators: true (default) + +[source,ruby] +---- +# good +# For code quality +spec.add_dependency 'rubocop' +# For tests +spec.add_dependency 'rspec' +---- + +[#treatcommentsasgroupseparators_-false-gemspecordereddependencies] +==== TreatCommentsAsGroupSeparators: false + +[source,ruby] +---- +# bad +# For code quality +spec.add_dependency 'rubocop' +# For tests +spec.add_dependency 'rspec' +---- + +[#configurable-attributes-gemspecordereddependencies] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| TreatCommentsAsGroupSeparators +| `true` +| Boolean + +| ConsiderPunctuation +| `false` +| Boolean + +| Include +| `+**/*.gemspec+` +| Array +|=== + +[#gemspecrequiremfa] +== Gemspec/RequireMFA + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.23 +| 1.40 +|=== + +Requires a gemspec to have `rubygems_mfa_required` metadata set. + +This setting tells RubyGems that MFA (Multi-Factor Authentication) is +required for accounts to be able perform privileged operations, such as +(see RubyGems' documentation for the full list of privileged +operations): + +* `gem push` +* `gem yank` +* `gem owner --add/remove` +* adding or removing owners using gem ownership page + +This helps make your gem more secure, as users can be more +confident that gem updates were pushed by maintainers. + +[#examples-gemspecrequiremfa] +=== Examples + +[source,ruby] +---- +# bad +Gem::Specification.new do |spec| + # no `rubygems_mfa_required` metadata specified +end + +# good +Gem::Specification.new do |spec| + spec.metadata = { + 'rubygems_mfa_required' => 'true' + } +end + +# good +Gem::Specification.new do |spec| + spec.metadata['rubygems_mfa_required'] = 'true' +end + +# bad +Gem::Specification.new do |spec| + spec.metadata = { + 'rubygems_mfa_required' => 'false' + } +end + +# good +Gem::Specification.new do |spec| + spec.metadata = { + 'rubygems_mfa_required' => 'true' + } +end + +# bad +Gem::Specification.new do |spec| + spec.metadata['rubygems_mfa_required'] = 'false' +end + +# good +Gem::Specification.new do |spec| + spec.metadata['rubygems_mfa_required'] = 'true' +end +---- + +[#configurable-attributes-gemspecrequiremfa] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Severity +| `warning` +| String + +| Include +| `+**/*.gemspec+` +| Array +|=== + +[#references-gemspecrequiremfa] +=== References + +* https://guides.rubygems.org/mfa-requirement-opt-in/ + +[#gemspecrequiredrubyversion] +== Gemspec/RequiredRubyVersion + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.52 +| 1.40 +|=== + +Checks that `required_ruby_version` in a gemspec file is set to a valid +value (non-blank) and matches `TargetRubyVersion` as set in RuboCop's +configuration for the gem. + +This ensures that RuboCop is using the same Ruby version as the gem. + +[#examples-gemspecrequiredrubyversion] +=== Examples + +[source,ruby] +---- +# When `TargetRubyVersion` of .rubocop.yml is `2.5`. + +# bad +Gem::Specification.new do |spec| + # no `required_ruby_version` specified +end + +# bad +Gem::Specification.new do |spec| + spec.required_ruby_version = '>= 2.4.0' +end + +# bad +Gem::Specification.new do |spec| + spec.required_ruby_version = '>= 2.6.0' +end + +# bad +Gem::Specification.new do |spec| + spec.required_ruby_version = '' +end + +# good +Gem::Specification.new do |spec| + spec.required_ruby_version = '>= 2.5.0' +end + +# good +Gem::Specification.new do |spec| + spec.required_ruby_version = '>= 2.5' +end + +# accepted but not recommended +Gem::Specification.new do |spec| + spec.required_ruby_version = ['>= 2.5.0', '< 2.7.0'] +end + +# accepted but not recommended, since +# Ruby does not really follow semantic versioning +Gem::Specification.new do |spec| + spec.required_ruby_version = '~> 2.5' +end +---- + +[#configurable-attributes-gemspecrequiredrubyversion] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Severity +| `warning` +| String + +| Include +| `+**/*.gemspec+` +| Array +|=== + +[#gemspecrubyversionglobalsusage] +== Gemspec/RubyVersionGlobalsUsage + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.72 +| 1.40 +|=== + +Checks that `RUBY_VERSION` constant is not used in gemspec. +Using `RUBY_VERSION` is dangerous because value of the +constant is determined by `rake release`. +It's possible to have dependency based on ruby version used +to execute `rake release` and not user's ruby version. + +[#examples-gemspecrubyversionglobalsusage] +=== Examples + +[source,ruby] +---- +# bad +Gem::Specification.new do |spec| + if RUBY_VERSION >= '3.0' + spec.add_dependency 'gem_a' + else + spec.add_dependency 'gem_b' + end +end + +# good +Gem::Specification.new do |spec| + spec.add_dependency 'gem_a' +end +---- + +[#configurable-attributes-gemspecrubyversionglobalsusage] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Severity +| `warning` +| String + +| Include +| `+**/*.gemspec+` +| Array +|=== + +[#references-gemspecrubyversionglobalsusage] +=== References + +* https://rubystyle.guide#no-ruby-version-in-the-gemspec diff --git a/docs/modules/ROOT/pages/cops_layout.adoc b/docs/modules/ROOT/pages/cops_layout.adoc new file mode 100644 index 000000000000..2ec69019094a --- /dev/null +++ b/docs/modules/ROOT/pages/cops_layout.adoc @@ -0,0 +1,8228 @@ +//// + Do NOT edit this file by hand directly, as it is automatically generated. + + Please make any necessary changes to the cop documentation within the source files themselves. +//// + += Layout + +[#layoutaccessmodifierindentation] +== Layout/AccessModifierIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +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. + +[#examples-layoutaccessmodifierindentation] +=== Examples + +[#enforcedstyle_-indent-_default_-layoutaccessmodifierindentation] +==== EnforcedStyle: indent (default) + +[source,ruby] +---- +# bad +class Plumbus +private + def smooth; end +end + +# good +class Plumbus + private + def smooth; end +end +---- + +[#enforcedstyle_-outdent-layoutaccessmodifierindentation] +==== EnforcedStyle: outdent + +[source,ruby] +---- +# bad +class Plumbus + private + def smooth; end +end + +# good +class Plumbus +private + def smooth; end +end +---- + +[#configurable-attributes-layoutaccessmodifierindentation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `indent` +| `outdent`, `indent` + +| IndentationWidth +| `` +| Integer +|=== + +[#references-layoutaccessmodifierindentation] +=== References + +* https://rubystyle.guide#indent-public-private-protected + +[#layoutargumentalignment] +== Layout/ArgumentAlignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.68 +| 0.77 +|=== + +Check that the arguments on a multi-line method call are aligned. + +[#examples-layoutargumentalignment] +=== Examples + +[#enforcedstyle_-with_first_argument-_default_-layoutargumentalignment] +==== EnforcedStyle: with_first_argument (default) + +[source,ruby] +---- +# good + +foo :bar, + :baz, + key: value + +foo( + :bar, + :baz, + key: value +) + +# bad + +foo :bar, + :baz, + key: value + +foo( + :bar, + :baz, + key: value +) +---- + +[#enforcedstyle_-with_fixed_indentation-layoutargumentalignment] +==== EnforcedStyle: with_fixed_indentation + +[source,ruby] +---- +# good + +foo :bar, + :baz, + key: value + +# bad + +foo :bar, + :baz, + key: value +---- + +[#configurable-attributes-layoutargumentalignment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `with_first_argument` +| `with_first_argument`, `with_fixed_indentation` + +| IndentationWidth +| `` +| Integer +|=== + +[#references-layoutargumentalignment] +=== References + +* https://rubystyle.guide#no-double-indent + +[#layoutarrayalignment] +== Layout/ArrayAlignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 0.77 +|=== + +Check that the elements of a multi-line array literal are +aligned. + +[#examples-layoutarrayalignment] +=== Examples + +[#enforcedstyle_-with_first_element-_default_-layoutarrayalignment] +==== EnforcedStyle: with_first_element (default) + +[source,ruby] +---- +# good + +array = [1, 2, 3, + 4, 5, 6] +array = ['run', + 'forrest', + 'run'] + +# bad + +array = [1, 2, 3, + 4, 5, 6] +array = ['run', + 'forrest', + 'run'] +---- + +[#enforcedstyle_-with_fixed_indentation-layoutarrayalignment] +==== EnforcedStyle: with_fixed_indentation + +[source,ruby] +---- +# good + +array = [1, 2, 3, + 4, 5, 6] + +# bad + +array = [1, 2, 3, + 4, 5, 6] +---- + +[#configurable-attributes-layoutarrayalignment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `with_first_element` +| `with_first_element`, `with_fixed_indentation` + +| IndentationWidth +| `` +| Integer +|=== + +[#references-layoutarrayalignment] +=== References + +* https://rubystyle.guide#no-double-indent + +[#layoutassignmentindentation] +== Layout/AssignmentIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 1.45 +|=== + +Checks the indentation of the first line of the +right-hand-side of a multi-line assignment. + +The indentation of the remaining lines can be corrected with +other cops such as `Layout/IndentationConsistency` and `Layout/EndAlignment`. + +[#examples-layoutassignmentindentation] +=== Examples + +[source,ruby] +---- +# bad +value = +if foo + 'bar' +end + +# good +value = + if foo + 'bar' + end +---- + +[#configurable-attributes-layoutassignmentindentation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| IndentationWidth +| `` +| Integer +|=== + +[#layoutbeginendalignment] +== Layout/BeginEndAlignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.91 +| - +|=== + +Checks whether the end keyword of `begin` is aligned properly. + +Two modes are supported through the `EnforcedStyleAlignWith` configuration +parameter. If it's set to `start_of_line` (which is the default), the +`end` shall be aligned with the start of the line where the `begin` +keyword is. If it's set to `begin`, the `end` shall be aligned with the +`begin` keyword. + +`Layout/EndAlignment` cop aligns with keywords (e.g. `if`, `while`, `case`) +by default. On the other hand, `||= begin` that this cop targets tends to +align with the start of the line, it defaults to `EnforcedStyleAlignWith: start_of_line`. +These style can be configured by each cop. + +[#examples-layoutbeginendalignment] +=== Examples + +[#enforcedstylealignwith_-start_of_line-_default_-layoutbeginendalignment] +==== EnforcedStyleAlignWith: start_of_line (default) + +[source,ruby] +---- +# bad +foo ||= begin + do_something + end + +# good +foo ||= begin + do_something +end +---- + +[#enforcedstylealignwith_-begin-layoutbeginendalignment] +==== EnforcedStyleAlignWith: begin + +[source,ruby] +---- +# bad +foo ||= begin + do_something +end + +# good +foo ||= begin + do_something + end +---- + +[#configurable-attributes-layoutbeginendalignment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyleAlignWith +| `start_of_line` +| `start_of_line`, `begin` + +| Severity +| `warning` +| String +|=== + +[#layoutblockalignment] +== Layout/BlockAlignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.53 +| - +|=== + +Checks whether the end keywords are aligned properly for do +end blocks. + +Three modes are supported through the `EnforcedStyleAlignWith` +configuration parameter: + +`start_of_block` : the `end` shall be aligned with the +start of the line where the `do` appeared. + +`start_of_line` : the `end` shall be aligned with the +start of the line where the expression started. + +`either` (which is the default) : the `end` is allowed to be in either +location. The autocorrect will default to `start_of_line`. + +[#examples-layoutblockalignment] +=== Examples + +[#enforcedstylealignwith_-either-_default_-layoutblockalignment] +==== EnforcedStyleAlignWith: either (default) + +[source,ruby] +---- +# bad + +foo.bar + .each do + baz + end + +# good + +foo.bar + .each do + baz +end +---- + +[#enforcedstylealignwith_-start_of_block-layoutblockalignment] +==== EnforcedStyleAlignWith: start_of_block + +[source,ruby] +---- +# bad + +foo.bar + .each do + baz + end + +# good + +foo.bar + .each do + baz + end +---- + +[#enforcedstylealignwith_-start_of_line-layoutblockalignment] +==== EnforcedStyleAlignWith: start_of_line + +[source,ruby] +---- +# bad + +foo.bar + .each do + baz + end + +# good + +foo.bar + .each do + baz +end +---- + +[#configurable-attributes-layoutblockalignment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyleAlignWith +| `either` +| `either`, `start_of_block`, `start_of_line` +|=== + +[#layoutblockendnewline] +== Layout/BlockEndNewline + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks whether the end statement of a do..end block +is on its own line. + +[#examples-layoutblockendnewline] +=== Examples + +[source,ruby] +---- +# bad +blah do |i| + foo(i) end + +# good +blah do |i| + foo(i) +end + +# bad +blah { |i| + foo(i) } + +# good +blah { |i| + foo(i) +} +---- + +[#layoutcaseindentation] +== Layout/CaseIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 1.16 +|=== + +Checks how the `when` and ``in``s of a `case` expression +are indented in relation to its `case` or `end` keyword. + +It will register a separate offense for each misaligned `when` and `in`. + +[#examples-layoutcaseindentation] +=== Examples + +[source,ruby] +---- +# If Layout/EndAlignment is set to keyword style (default) +# *case* and *end* should always be aligned to same depth, +# and therefore *when* should always be aligned to both - +# regardless of configuration. + +# bad for all styles +case n + when 0 + x * 2 + else + y / 3 +end + +case n + in pattern + x * 2 + else + y / 3 +end + +# good for all styles +case n +when 0 + x * 2 +else + y / 3 +end + +case n +in pattern + x * 2 +else + y / 3 +end +---- + +[#enforcedstyle_-case-_default_-layoutcaseindentation] +==== EnforcedStyle: case (default) + +[source,ruby] +---- +# if EndAlignment is set to other style such as +# start_of_line (as shown below), then *when* alignment +# configuration does have an effect. + +# bad +a = case n +when 0 + x * 2 +else + y / 3 +end + +a = case n +in pattern + x * 2 +else + y / 3 +end + +# good +a = case n + when 0 + x * 2 + else + y / 3 +end + +a = case n + in pattern + x * 2 + else + y / 3 +end +---- + +[#enforcedstyle_-end-layoutcaseindentation] +==== EnforcedStyle: end + +[source,ruby] +---- +# bad +a = case n + when 0 + x * 2 + else + y / 3 +end + +a = case n + in pattern + x * 2 + else + y / 3 +end + +# good +a = case n +when 0 + x * 2 +else + y / 3 +end + +a = case n +in pattern + x * 2 +else + y / 3 +end +---- + +[#configurable-attributes-layoutcaseindentation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `case` +| `case`, `end` + +| IndentOneStep +| `false` +| Boolean + +| IndentationWidth +| `` +| Integer +|=== + +[#references-layoutcaseindentation] +=== References + +* https://rubystyle.guide#indent-when-to-case + +[#layoutclassstructure] +== Layout/ClassStructure + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always (Unsafe) +| 0.52 +| 1.53 +|=== + +Checks if the code style follows the `ExpectedOrder` configuration: + +`Categories` allows us to map macro names into a category. + +Consider an example of code style that covers the following order: + +* Module inclusion (`include`, `prepend`, `extend`) +* Constants +* Associations (`has_one`, `has_many`) +* Public attribute macros (`attr_accessor`, `attr_writer`, `attr_reader`) +* Other macros (`validates`, `validate`) +* Public class methods +* Initializer +* Public instance methods +* Protected attribute macros (`attr_accessor`, `attr_writer`, `attr_reader`) +* Protected instance methods +* Private attribute macros (`attr_accessor`, `attr_writer`, `attr_reader`) +* Private instance methods + +NOTE: Simply enabling the cop with `Enabled: true` will not use +the example order shown below. +To enforce the order of macros like `attr_reader`, +you must define both `ExpectedOrder` *and* `Categories`. + +You can configure the following order: + +[source,yaml] +---- + Layout/ClassStructure: + ExpectedOrder: + - module_inclusion + - constants + - association + - public_attribute_macros + - public_delegate + - macros + - public_class_methods + - initializer + - public_methods + - protected_attribute_macros + - protected_methods + - private_attribute_macros + - private_delegate + - private_methods +---- + +Instead of putting all literals in the expected order, is also +possible to group categories of macros. Visibility levels are handled +automatically. + +[source,yaml] +---- + Layout/ClassStructure: + Categories: + association: + - has_many + - has_one + attribute_macros: + - attr_accessor + - attr_reader + - attr_writer + macros: + - validates + - validate + module_inclusion: + - include + - prepend + - extend +---- + +If you only set `ExpectedOrder` +without defining `Categories`, +macros such as `attr_reader` or `has_many` +will not be recognized as part of a category, and their order will not be validated. +For example, the following will NOT raise any offenses, even if the order is incorrect: + +[source,yaml] +---- +Layout/ClassStructure: + Enabled: true + ExpectedOrder: + - public_attribute_macros + - initializer +---- + +To make it work as expected, you must also specify `Categories` like this: + +[source,yaml] +---- +Layout/ClassStructure: + ExpectedOrder: + - public_attribute_macros + - initializer + Categories: + attribute_macros: + - attr_reader + - attr_writer + - attr_accessor +---- + +[#safety-layoutclassstructure] +=== Safety + +Autocorrection is unsafe because class methods and module inclusion +can behave differently, based on which methods or constants have +already been defined. + +Constants will only be moved when they are assigned with literals. + +[#examples-layoutclassstructure] +=== Examples + +[source,ruby] +---- +# bad +# Expect extend be before constant +class Person < ApplicationRecord + has_many :orders + ANSWER = 42 + + extend SomeModule + include AnotherModule +end + +# good +class Person + # extend and include go first + extend SomeModule + include AnotherModule + + # inner classes + CustomError = Class.new(StandardError) + + # constants are next + SOME_CONSTANT = 20 + + # afterwards we have public attribute macros + attr_reader :name + + # followed by other macros (if any) + validates :name + + # then we have public delegate macros + delegate :to_s, to: :name + + # public class methods are next in line + def self.some_method + end + + # initialization goes between class methods and instance methods + def initialize + end + + # followed by other public instance methods + def some_method + end + + # protected attribute macros and methods go next + protected + + attr_reader :protected_name + + def some_protected_method + end + + # private attribute macros, delegate macros and methods + # are grouped near the end + private + + attr_reader :private_name + + delegate :some_private_delegate, to: :name + + def some_private_method + end +end +---- + +[#configurable-attributes-layoutclassstructure] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Categories +| `{"module_inclusion" => ["include", "prepend", "extend"]}` +| + +| ExpectedOrder +| `module_inclusion`, `constants`, `public_class_methods`, `initializer`, `public_methods`, `protected_methods`, `private_methods` +| Array +|=== + +[#references-layoutclassstructure] +=== References + +* https://rubystyle.guide#consistent-classes + +[#layoutclosingheredocindentation] +== Layout/ClosingHeredocIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.57 +| - +|=== + +Checks the indentation of here document closings. + +[#examples-layoutclosingheredocindentation] +=== Examples + +[source,ruby] +---- +# bad +class Foo + def bar + <<~SQL + 'Hi' + SQL + end +end + +# good +class Foo + def bar + <<~SQL + 'Hi' + SQL + end +end + +# bad + +# heredoc contents is before closing heredoc. +foo arg, + <<~EOS + Hi + EOS + +# good +foo arg, + <<~EOS + Hi +EOS + +# good +foo arg, + <<~EOS + Hi + EOS +---- + +[#layoutclosingparenthesisindentation] +== Layout/ClosingParenthesisIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks the indentation of hanging closing parentheses in +method calls, method definitions, and grouped expressions. A hanging +closing parenthesis means `)` preceded by a line break. + +[#examples-layoutclosingparenthesisindentation] +=== Examples + +[source,ruby] +---- +# bad +some_method( + a, + b + ) + +some_method( + a, b + ) + +some_method(a, b, c + ) + +some_method(a, + b, + c + ) + +some_method(a, + x: 1, + y: 2 + ) + +# Scenario 1: When First Parameter Is On Its Own Line + +# good: when first param is on a new line, right paren is *always* +# outdented by IndentationWidth +some_method( + a, + b +) + +# good +some_method( + a, b +) + +# Scenario 2: When First Parameter Is On The Same Line + +# good: when all other params are also on the same line, outdent +# right paren by IndentationWidth +some_method(a, b, c + ) + +# good: when all other params are on multiple lines, but are lined +# up, align right paren with left paren +some_method(a, + b, + c + ) + +# good: when other params are not lined up on multiple lines, outdent +# right paren by IndentationWidth +some_method(a, + x: 1, + y: 2 +) +---- + +[#layoutcommentindentation] +== Layout/CommentIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 1.24 +|=== + +Checks the indentation of comments. + +[#examples-layoutcommentindentation] +=== Examples + +[source,ruby] +---- +# bad + # comment here +def method_name +end + + # comment here +a = 'hello' + +# yet another comment + if true + true + end + +# good +# comment here +def method_name +end + +# comment here +a = 'hello' + +# yet another comment +if true + true +end +---- + +[#allowforalignment_-false-_default_-layoutcommentindentation] +==== AllowForAlignment: false (default) + +[source,ruby] +---- +# bad +a = 1 # A really long comment + # spanning two lines. + +# good +# A really long comment spanning one line. +a = 1 +---- + +[#allowforalignment_-true-layoutcommentindentation] +==== AllowForAlignment: true + +[source,ruby] +---- +# good +a = 1 # A really long comment + # spanning two lines. +---- + +[#configurable-attributes-layoutcommentindentation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowForAlignment +| `false` +| Boolean +|=== + +[#layoutconditionposition] +== Layout/ConditionPosition + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.53 +| 0.83 +|=== + +Checks for conditions that are not on the same line as +if/while/until. + +[#examples-layoutconditionposition] +=== Examples + +[source,ruby] +---- +# bad +if + some_condition + do_something +end + +# good +if some_condition + do_something +end +---- + +[#references-layoutconditionposition] +=== References + +* https://rubystyle.guide#same-line-condition + +[#layoutdefendalignment] +== Layout/DefEndAlignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.53 +| - +|=== + +Checks whether the end keywords of method definitions are +aligned properly. + +Two modes are supported through the EnforcedStyleAlignWith configuration +parameter. If it's set to `start_of_line` (which is the default), the +`end` shall be aligned with the start of the line where the `def` +keyword is. If it's set to `def`, the `end` shall be aligned with the +`def` keyword. + +[#examples-layoutdefendalignment] +=== Examples + +[#enforcedstylealignwith_-start_of_line-_default_-layoutdefendalignment] +==== EnforcedStyleAlignWith: start_of_line (default) + +[source,ruby] +---- +# bad + +private def foo + end + +# good + +private def foo +end +---- + +[#enforcedstylealignwith_-def-layoutdefendalignment] +==== EnforcedStyleAlignWith: def + +[source,ruby] +---- +# bad + +private def foo + end + +# good + +private def foo + end +---- + +[#configurable-attributes-layoutdefendalignment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyleAlignWith +| `start_of_line` +| `start_of_line`, `def` + +| Severity +| `warning` +| String +|=== + +[#layoutdotposition] +== Layout/DotPosition + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks the . position in multi-line method calls. + +[#examples-layoutdotposition] +=== Examples + +[#enforcedstyle_-leading-_default_-layoutdotposition] +==== EnforcedStyle: leading (default) + +[source,ruby] +---- +# bad +something. + method + +# good +something + .method +---- + +[#enforcedstyle_-trailing-layoutdotposition] +==== EnforcedStyle: trailing + +[source,ruby] +---- +# bad +something + .method + +# good +something. + method +---- + +[#configurable-attributes-layoutdotposition] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `leading` +| `leading`, `trailing` +|=== + +[#references-layoutdotposition] +=== References + +* https://rubystyle.guide#consistent-multi-line-chains + +[#layoutelsealignment] +== Layout/ElseAlignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks the alignment of else keywords. Normally they should +be aligned with an if/unless/while/until/begin/def/rescue keyword, but there +are special cases when they should follow the same rules as the +alignment of end. + +[#examples-layoutelsealignment] +=== Examples + +[source,ruby] +---- +# bad +if something + code + else + code +end + +# bad +if something + code + elsif something + code +end + +# good +if something + code +else + code +end +---- + +[#layoutemptycomment] +== Layout/EmptyComment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Command-line only +| 0.53 +| 1.61 +|=== + +Checks empty comment. + +[#examples-layoutemptycomment] +=== Examples + +[source,ruby] +---- +# bad + +# +class Foo +end + +# good + +# +# Description of `Foo` class. +# +class Foo +end +---- + +[#allowbordercomment_-true-_default_-layoutemptycomment] +==== AllowBorderComment: true (default) + +[source,ruby] +---- +# good + +def foo +end + +################# + +def bar +end +---- + +[#allowbordercomment_-false-layoutemptycomment] +==== AllowBorderComment: false + +[source,ruby] +---- +# bad + +def foo +end + +################# + +def bar +end +---- + +[#allowmargincomment_-true-_default_-layoutemptycomment] +==== AllowMarginComment: true (default) + +[source,ruby] +---- +# good + +# +# Description of `Foo` class. +# +class Foo +end +---- + +[#allowmargincomment_-false-layoutemptycomment] +==== AllowMarginComment: false + +[source,ruby] +---- +# bad + +# +# Description of `Foo` class. +# +class Foo +end +---- + +[#configurable-attributes-layoutemptycomment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowBorderComment +| `true` +| Boolean + +| AllowMarginComment +| `true` +| Boolean +|=== + +[#layoutemptylineafterguardclause] +== Layout/EmptyLineAfterGuardClause + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.56 +| 0.59 +|=== + +Enforces empty line after guard clause. + +This cop allows `# :nocov:` directive after guard clause because +SimpleCov excludes code from the coverage report by wrapping it in `# :nocov:`: + +[source,ruby] +---- +def foo + # :nocov: + return if condition + # :nocov: + bar +end +---- + +Refer to SimpleCov's documentation for more details: +https://github.com/simplecov-ruby/simplecov#ignoringskipping-code + +[#examples-layoutemptylineafterguardclause] +=== Examples + +[source,ruby] +---- +# bad +def foo + return if need_return? + bar +end + +# good +def foo + return if need_return? + + bar +end + +# good +def foo + return if something? + return if something_different? + + bar +end + +# also good +def foo + if something? + do_something + return if need_return? + end +end +---- + +[#layoutemptylineaftermagiccomment] +== Layout/EmptyLineAfterMagicComment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for a newline after the final magic comment. + +[#examples-layoutemptylineaftermagiccomment] +=== Examples + +[source,ruby] +---- +# good +# frozen_string_literal: true + +# Some documentation for Person +class Person + # Some code +end + +# bad +# frozen_string_literal: true +# Some documentation for Person +class Person + # Some code +end +---- + +[#references-layoutemptylineaftermagiccomment] +=== References + +* https://rubystyle.guide#separate-magic-comments-from-code + +[#layoutemptylineaftermultilinecondition] +== Layout/EmptyLineAfterMultilineCondition + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 0.90 +| - +|=== + +Enforces empty line after multiline condition. + +[#examples-layoutemptylineaftermultilinecondition] +=== Examples + +[source,ruby] +---- +# bad +if multiline && + condition + do_something +end + +# good +if multiline && + condition + + do_something +end + +# bad +case x +when foo, + bar + do_something +end + +# good +case x +when foo, + bar + + do_something +end + +# bad +begin + do_something +rescue FooError, + BarError + handle_error +end + +# good +begin + do_something +rescue FooError, + BarError + + handle_error +end +---- + +[#references-layoutemptylineaftermultilinecondition] +=== References + +* https://github.com/airbnb/ruby#multiline-if-newline + +[#layoutemptylinebetweendefs] +== Layout/EmptyLineBetweenDefs + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 1.23 +|=== + +Checks whether class/module/method definitions are +separated by one or more empty lines. + +`NumberOfEmptyLines` can be an integer (default is 1) or +an array (e.g. [1, 2]) to specify a minimum and maximum +number of empty lines permitted. + +`AllowAdjacentOneLineDefs` configures whether adjacent +one-line definitions are considered an offense. + +[#examples-layoutemptylinebetweendefs] +=== Examples + +[#emptylinebetweenmethoddefs_-true-_default_-layoutemptylinebetweendefs] +==== EmptyLineBetweenMethodDefs: true (default) + +[source,ruby] +---- +# checks for empty lines between method definitions. + +# bad +def a +end +def b +end + +# good +def a +end + +def b +end +---- + +[#emptylinebetweenclassdefs_-true-_default_-layoutemptylinebetweendefs] +==== EmptyLineBetweenClassDefs: true (default) + +[source,ruby] +---- +# checks for empty lines between class definitions. + +# bad +class A +end +class B +end +def b +end + +# good +class A +end + +class B +end + +def b +end +---- + +[#emptylinebetweenmoduledefs_-true-_default_-layoutemptylinebetweendefs] +==== EmptyLineBetweenModuleDefs: true (default) + +[source,ruby] +---- +# checks for empty lines between module definitions. + +# bad +module A +end +module B +end +def b +end + +# good +module A +end + +module B +end + +def b +end +---- + +[#allowadjacentonelinedefs_-true-_default_-layoutemptylinebetweendefs] +==== AllowAdjacentOneLineDefs: true (default) + +[source,ruby] +---- +# good +class ErrorA < BaseError; end +class ErrorB < BaseError; end +class ErrorC < BaseError; end + +# good +class ErrorA < BaseError; end + +class ErrorB < BaseError; end + +class ErrorC < BaseError; end +---- + +[#allowadjacentonelinedefs_-false-layoutemptylinebetweendefs] +==== AllowAdjacentOneLineDefs: false + +[source,ruby] +---- +# bad +class ErrorA < BaseError; end +class ErrorB < BaseError; end +class ErrorC < BaseError; end + +# good +class ErrorA < BaseError; end + +class ErrorB < BaseError; end + +class ErrorC < BaseError; end +---- + +[#configurable-attributes-layoutemptylinebetweendefs] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EmptyLineBetweenMethodDefs +| `true` +| Boolean + +| EmptyLineBetweenClassDefs +| `true` +| Boolean + +| EmptyLineBetweenModuleDefs +| `true` +| Boolean + +| DefLikeMacros +| `[]` +| Array + +| AllowAdjacentOneLineDefs +| `true` +| Boolean + +| NumberOfEmptyLines +| `1` +| Integer +|=== + +[#references-layoutemptylinebetweendefs] +=== References + +* https://rubystyle.guide#empty-lines-between-methods + +[#layoutemptylines] +== Layout/EmptyLines + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for two or more consecutive blank lines. + +[#examples-layoutemptylines] +=== Examples + +[source,ruby] +---- +# bad - It has two empty lines. +some_method +# one empty line +# two empty lines +some_method + +# good +some_method +# one empty line +some_method +---- + +[#references-layoutemptylines] +=== References + +* https://rubystyle.guide#two-or-more-empty-lines + +[#layoutemptylinesaftermoduleinclusion] +== Layout/EmptyLinesAfterModuleInclusion + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.79 +| - +|=== + +Checks for an empty line after a module inclusion method (`extend`, +`include` and `prepend`), or a group of them. + +[#examples-layoutemptylinesaftermoduleinclusion] +=== Examples + +[source,ruby] +---- +# bad +class Foo + include Bar + attr_reader :baz +end + +# good +class Foo + include Bar + + attr_reader :baz +end + +# also good - multiple module inclusions grouped together +class Foo + extend Bar + include Baz + prepend Qux +end +---- + +[#references-layoutemptylinesaftermoduleinclusion] +=== References + +* https://rubystyle.guide#empty-lines-after-module-inclusion + +[#layoutemptylinesaroundaccessmodifier] +== Layout/EmptyLinesAroundAccessModifier + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Access modifiers should be surrounded by blank lines. + +[#examples-layoutemptylinesaroundaccessmodifier] +=== Examples + +[#enforcedstyle_-around-_default_-layoutemptylinesaroundaccessmodifier] +==== EnforcedStyle: around (default) + +[source,ruby] +---- +# bad +class Foo + def bar; end + private + def baz; end +end + +# good +class Foo + def bar; end + + private + + def baz; end +end +---- + +[#enforcedstyle_-only_before-layoutemptylinesaroundaccessmodifier] +==== EnforcedStyle: only_before + +[source,ruby] +---- +# bad +class Foo + def bar; end + private + def baz; end +end + +# good +class Foo + def bar; end + + private + def baz; end +end +---- + +[#configurable-attributes-layoutemptylinesaroundaccessmodifier] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `around` +| `around`, `only_before` +|=== + +[#references-layoutemptylinesaroundaccessmodifier] +=== References + +* https://rubystyle.guide#empty-lines-around-access-modifier +* https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions + +[#layoutemptylinesaroundarguments] +== Layout/EmptyLinesAroundArguments + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.52 +| - +|=== + +Checks if empty lines exist around the arguments +of a method invocation. + +[#examples-layoutemptylinesaroundarguments] +=== Examples + +[source,ruby] +---- +# bad +do_something( + foo + +) + +process(bar, + + baz: qux, + thud: fred) + +some_method( + + [1,2,3], + x: y +) + +# good +do_something( + foo +) + +process(bar, + baz: qux, + thud: fred) + +some_method( + [1,2,3], + x: y +) +---- + +[#layoutemptylinesaroundattributeaccessor] +== Layout/EmptyLinesAroundAttributeAccessor + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.83 +| 0.84 +|=== + +Checks for a newline after an attribute accessor or a group of them. +`alias` syntax and `alias_method`, `public`, `protected`, and `private` methods are allowed +by default. These are customizable with `AllowAliasSyntax` and `AllowedMethods` options. + +[#examples-layoutemptylinesaroundattributeaccessor] +=== Examples + +[source,ruby] +---- +# bad +attr_accessor :foo +def do_something +end + +# good +attr_accessor :foo + +def do_something +end + +# good +attr_accessor :foo +attr_reader :bar +attr_writer :baz +attr :qux + +def do_something +end +---- + +[#allowaliassyntax_-true-_default_-layoutemptylinesaroundattributeaccessor] +==== AllowAliasSyntax: true (default) + +[source,ruby] +---- +# good +attr_accessor :foo +alias :foo? :foo + +def do_something +end +---- + +[#allowaliassyntax_-false-layoutemptylinesaroundattributeaccessor] +==== AllowAliasSyntax: false + +[source,ruby] +---- +# bad +attr_accessor :foo +alias :foo? :foo + +def do_something +end + +# good +attr_accessor :foo + +alias :foo? :foo + +def do_something +end +---- + +[#allowedmethods_-__private__-layoutemptylinesaroundattributeaccessor] +==== AllowedMethods: ['private'] + +[source,ruby] +---- +# good +attr_accessor :foo +private :foo + +def do_something +end +---- + +[#configurable-attributes-layoutemptylinesaroundattributeaccessor] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowAliasSyntax +| `true` +| Boolean + +| AllowedMethods +| `alias_method`, `public`, `protected`, `private` +| Array +|=== + +[#references-layoutemptylinesaroundattributeaccessor] +=== References + +* https://rubystyle.guide#empty-lines-around-attribute-accessor + +[#layoutemptylinesaroundbeginbody] +== Layout/EmptyLinesAroundBeginBody + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks if empty lines exist around the bodies of begin-end +blocks. + +[#examples-layoutemptylinesaroundbeginbody] +=== Examples + +[source,ruby] +---- +# bad +begin + + # ... + +end + +# good +begin + # ... +end +---- + +[#references-layoutemptylinesaroundbeginbody] +=== References + +* https://rubystyle.guide#empty-lines-around-bodies + +[#layoutemptylinesaroundblockbody] +== Layout/EmptyLinesAroundBlockBody + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks if empty lines around the bodies of blocks match +the configuration. + +[#examples-layoutemptylinesaroundblockbody] +=== Examples + +[#enforcedstyle_-no_empty_lines-_default_-layoutemptylinesaroundblockbody] +==== EnforcedStyle: no_empty_lines (default) + +[source,ruby] +---- +# good + +foo do |bar| + # ... +end +---- + +[#enforcedstyle_-empty_lines-layoutemptylinesaroundblockbody] +==== EnforcedStyle: empty_lines + +[source,ruby] +---- +# good + +foo do |bar| + + # ... + +end +---- + +[#configurable-attributes-layoutemptylinesaroundblockbody] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `no_empty_lines` +| `empty_lines`, `no_empty_lines` +|=== + +[#references-layoutemptylinesaroundblockbody] +=== References + +* https://rubystyle.guide#empty-lines-around-bodies + +[#layoutemptylinesaroundclassbody] +== Layout/EmptyLinesAroundClassBody + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 0.53 +|=== + +Checks if empty lines around the bodies of classes match +the configuration. + +[#examples-layoutemptylinesaroundclassbody] +=== Examples + +[#enforcedstyle_-no_empty_lines-_default_-layoutemptylinesaroundclassbody] +==== EnforcedStyle: no_empty_lines (default) + +[source,ruby] +---- +# good + +class Foo + def bar + # ... + end +end +---- + +[#enforcedstyle_-empty_lines-layoutemptylinesaroundclassbody] +==== EnforcedStyle: empty_lines + +[source,ruby] +---- +# good + +class Foo + + def bar + # ... + end + +end +---- + +[#enforcedstyle_-empty_lines_except_namespace-layoutemptylinesaroundclassbody] +==== EnforcedStyle: empty_lines_except_namespace + +[source,ruby] +---- +# good + +class Foo + class Bar + + # ... + + end +end +---- + +[#enforcedstyle_-empty_lines_special-layoutemptylinesaroundclassbody] +==== EnforcedStyle: empty_lines_special + +[source,ruby] +---- +# good +class Foo + + def bar; end + +end +---- + +[#enforcedstyle_-beginning_only-layoutemptylinesaroundclassbody] +==== EnforcedStyle: beginning_only + +[source,ruby] +---- +# good + +class Foo + + def bar + # ... + end +end +---- + +[#enforcedstyle_-ending_only-layoutemptylinesaroundclassbody] +==== EnforcedStyle: ending_only + +[source,ruby] +---- +# good + +class Foo + def bar + # ... + end + +end +---- + +[#configurable-attributes-layoutemptylinesaroundclassbody] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `no_empty_lines` +| `empty_lines`, `empty_lines_except_namespace`, `empty_lines_special`, `no_empty_lines`, `beginning_only`, `ending_only` +|=== + +[#references-layoutemptylinesaroundclassbody] +=== References + +* https://rubystyle.guide#empty-lines-around-bodies + +[#layoutemptylinesaroundexceptionhandlingkeywords] +== Layout/EmptyLinesAroundExceptionHandlingKeywords + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks if empty lines exist around the bodies of `begin` +sections. This cop doesn't check empty lines at `begin` body +beginning/end and around method definition body. +`Layout/EmptyLinesAroundBeginBody` or `Layout/EmptyLinesAroundMethodBody` +can be used for this purpose. + +[#examples-layoutemptylinesaroundexceptionhandlingkeywords] +=== Examples + +[source,ruby] +---- +# good + +begin + do_something +rescue + do_something2 +else + do_something3 +ensure + do_something4 +end + +# good + +def foo + do_something +rescue + do_something2 +end + +# bad + +begin + do_something + +rescue + + do_something2 + +else + + do_something3 + +ensure + + do_something4 +end + +# bad + +def foo + do_something + +rescue + + do_something2 +end +---- + +[#references-layoutemptylinesaroundexceptionhandlingkeywords] +=== References + +* https://rubystyle.guide#empty-lines-around-bodies + +[#layoutemptylinesaroundmethodbody] +== Layout/EmptyLinesAroundMethodBody + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks if empty lines exist around the bodies of methods. + +[#examples-layoutemptylinesaroundmethodbody] +=== Examples + +[source,ruby] +---- +# good + +def foo + # ... +end + +# bad + +def bar + + # ... + +end +---- + +[#references-layoutemptylinesaroundmethodbody] +=== References + +* https://rubystyle.guide#empty-lines-around-bodies + +[#layoutemptylinesaroundmodulebody] +== Layout/EmptyLinesAroundModuleBody + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks if empty lines around the bodies of modules match +the configuration. + +[#examples-layoutemptylinesaroundmodulebody] +=== Examples + +[#enforcedstyle_-no_empty_lines-_default_-layoutemptylinesaroundmodulebody] +==== EnforcedStyle: no_empty_lines (default) + +[source,ruby] +---- +# good + +module Foo + def bar + # ... + end +end +---- + +[#enforcedstyle_-empty_lines-layoutemptylinesaroundmodulebody] +==== EnforcedStyle: empty_lines + +[source,ruby] +---- +# good + +module Foo + + def bar + # ... + end + +end +---- + +[#enforcedstyle_-empty_lines_except_namespace-layoutemptylinesaroundmodulebody] +==== EnforcedStyle: empty_lines_except_namespace + +[source,ruby] +---- +# good + +module Foo + module Bar + + # ... + + end +end +---- + +[#enforcedstyle_-empty_lines_special-layoutemptylinesaroundmodulebody] +==== EnforcedStyle: empty_lines_special + +[source,ruby] +---- +# good +module Foo + + def bar; end + +end +---- + +[#configurable-attributes-layoutemptylinesaroundmodulebody] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `no_empty_lines` +| `empty_lines`, `empty_lines_except_namespace`, `empty_lines_special`, `no_empty_lines` +|=== + +[#references-layoutemptylinesaroundmodulebody] +=== References + +* https://rubystyle.guide#empty-lines-around-bodies + +[#layoutendalignment] +== Layout/EndAlignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.53 +| - +|=== + +Checks whether the end keywords are aligned properly. + +Three modes are supported through the `EnforcedStyleAlignWith` +configuration parameter: + +If it's set to `keyword` (which is the default), the `end` +shall be aligned with the start of the keyword (if, class, etc.). + +If it's set to `variable` the `end` shall be aligned with the +left-hand-side of the variable assignment, if there is one. + +If it's set to `start_of_line`, the `end` shall be aligned with the +start of the line where the matching keyword appears. + +This `Layout/EndAlignment` cop aligns with keywords (e.g. `if`, `while`, `case`) +by default. On the other hand, `Layout/BeginEndAlignment` cop aligns with +`EnforcedStyleAlignWith: start_of_line` by default due to `||= begin` tends +to align with the start of the line. `Layout/DefEndAlignment` cop also aligns with +`EnforcedStyleAlignWith: start_of_line` by default. +These style can be configured by each cop. + +[#examples-layoutendalignment] +=== Examples + +[#enforcedstylealignwith_-keyword-_default_-layoutendalignment] +==== EnforcedStyleAlignWith: keyword (default) + +[source,ruby] +---- +# bad + +variable = if true + end + +# good + +variable = if true + end + +variable = + if true + end +---- + +[#enforcedstylealignwith_-variable-layoutendalignment] +==== EnforcedStyleAlignWith: variable + +[source,ruby] +---- +# bad + +variable = if true + end + +# good + +variable = if true +end + +variable = + if true + end +---- + +[#enforcedstylealignwith_-start_of_line-layoutendalignment] +==== EnforcedStyleAlignWith: start_of_line + +[source,ruby] +---- +# bad + +variable = if true + end + +puts(if true + end) + +# good + +variable = if true +end + +puts(if true +end) + +variable = + if true + end +---- + +[#configurable-attributes-layoutendalignment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyleAlignWith +| `keyword` +| `keyword`, `variable`, `start_of_line` + +| Severity +| `warning` +| String +|=== + +[#layoutendofline] +== Layout/EndOfLine + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.49 +| - +|=== + +Checks for Windows-style line endings in the source code. + +[#examples-layoutendofline] +=== Examples + +[#enforcedstyle_-native-_default_-layoutendofline] +==== EnforcedStyle: native (default) + +[source,ruby] +---- +# The `native` style means that CR+LF (Carriage Return + Line Feed) is +# enforced on Windows, and LF is enforced on other platforms. + +# bad +puts 'Hello' # Return character is LF on Windows. +puts 'Hello' # Return character is CR+LF on other than Windows. + +# good +puts 'Hello' # Return character is CR+LF on Windows. +puts 'Hello' # Return character is LF on other than Windows. +---- + +[#enforcedstyle_-lf-layoutendofline] +==== EnforcedStyle: lf + +[source,ruby] +---- +# The `lf` style means that LF (Line Feed) is enforced on +# all platforms. + +# bad +puts 'Hello' # Return character is CR+LF on all platforms. + +# good +puts 'Hello' # Return character is LF on all platforms. +---- + +[#enforcedstyle_-crlf-layoutendofline] +==== EnforcedStyle: crlf + +[source,ruby] +---- +# The `crlf` style means that CR+LF (Carriage Return + Line Feed) is +# enforced on all platforms. + +# bad +puts 'Hello' # Return character is LF on all platforms. + +# good +puts 'Hello' # Return character is CR+LF on all platforms. +---- + +[#configurable-attributes-layoutendofline] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `native` +| `native`, `lf`, `crlf` +|=== + +[#references-layoutendofline] +=== References + +* https://rubystyle.guide#crlf + +[#layoutextraspacing] +== Layout/ExtraSpacing + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for extra/unnecessary whitespace. + +[#examples-layoutextraspacing] +=== Examples + +[source,ruby] +---- +# good if AllowForAlignment is true +name = "RuboCop" +# Some comment and an empty line + +website += "/rubocop/rubocop" unless cond +puts "rubocop" if debug + +# bad for any configuration +set_app("RuboCop") +website = "https://github.com/rubocop/rubocop" + +# good only if AllowBeforeTrailingComments is true +object.method(arg) # this is a comment + +# good even if AllowBeforeTrailingComments is false or not set +object.method(arg) # this is a comment + +# good with either AllowBeforeTrailingComments or AllowForAlignment +object.method(arg) # this is a comment +another_object.method(arg) # this is another comment +some_object.method(arg) # this is some comment +---- + +[#configurable-attributes-layoutextraspacing] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowForAlignment +| `true` +| Boolean + +| AllowBeforeTrailingComments +| `false` +| Boolean + +| ForceEqualSignAlignment +| `false` +| Boolean +|=== + +[#layoutfirstargumentindentation] +== Layout/FirstArgumentIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.68 +| 0.77 +|=== + +Checks the indentation of the first argument in a method call. +Arguments after the first one are checked by `Layout/ArgumentAlignment`, +not by this cop. + +For indenting the first parameter of method _definitions_, check out +`Layout/FirstParameterIndentation`. + +This cop will respect `Layout/ArgumentAlignment` and will not work when +`EnforcedStyle: with_fixed_indentation` is specified for `Layout/ArgumentAlignment`. + +[#examples-layoutfirstargumentindentation] +=== Examples + +[source,ruby] +---- +# bad +some_method( +first_param, +second_param) + +foo = some_method( +first_param, +second_param) + +foo = some_method(nested_call( +nested_first_param), +second_param) + +foo = some_method( +nested_call( +nested_first_param), +second_param) + +some_method nested_call( +nested_first_param), +second_param +---- + +[#enforcedstyle_-special_for_inner_method_call_in_parentheses-_default_-layoutfirstargumentindentation] +==== EnforcedStyle: special_for_inner_method_call_in_parentheses (default) + +[source,ruby] +---- +# Same as `special_for_inner_method_call` except that the special rule +# only applies if the outer method call encloses its arguments in +# parentheses. + +# good +some_method( + first_param, +second_param) + +foo = some_method( + first_param, +second_param) + +foo = some_method(nested_call( + nested_first_param), +second_param) + +foo = some_method( + nested_call( + nested_first_param), +second_param) + +some_method nested_call( + nested_first_param), +second_param +---- + +[#enforcedstyle_-consistent-layoutfirstargumentindentation] +==== EnforcedStyle: consistent + +[source,ruby] +---- +# The first argument should always be indented one step more than the +# preceding line. + +# good +some_method( + first_param, +second_param) + +foo = some_method( + first_param, +second_param) + +foo = some_method(nested_call( + nested_first_param), +second_param) + +foo = some_method( + nested_call( + nested_first_param), +second_param) + +some_method nested_call( + nested_first_param), +second_param +---- + +[#enforcedstyle_-consistent_relative_to_receiver-layoutfirstargumentindentation] +==== EnforcedStyle: consistent_relative_to_receiver + +[source,ruby] +---- +# The first argument should always be indented one level relative to +# the parent that is receiving the argument + +# good +some_method( + first_param, +second_param) + +foo = some_method( + first_param, +second_param) + +foo = some_method(nested_call( + nested_first_param), +second_param) + +foo = some_method( + nested_call( + nested_first_param), +second_param) + +some_method nested_call( + nested_first_param), +second_params +---- + +[#enforcedstyle_-special_for_inner_method_call-layoutfirstargumentindentation] +==== EnforcedStyle: special_for_inner_method_call + +[source,ruby] +---- +# The first argument should normally be indented one step more than +# the preceding line, but if it's an argument for a method call that +# is itself an argument in a method call, then the inner argument +# should be indented relative to the inner method. + +# good +some_method( + first_param, +second_param) + +foo = some_method( + first_param, +second_param) + +foo = some_method(nested_call( + nested_first_param), +second_param) + +foo = some_method( + nested_call( + nested_first_param), +second_param) + +some_method nested_call( + nested_first_param), +second_param +---- + +[#configurable-attributes-layoutfirstargumentindentation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `special_for_inner_method_call_in_parentheses` +| `consistent`, `consistent_relative_to_receiver`, `special_for_inner_method_call`, `special_for_inner_method_call_in_parentheses` + +| IndentationWidth +| `` +| Integer +|=== + +[#layoutfirstarrayelementindentation] +== Layout/FirstArrayElementIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.68 +| 0.77 +|=== + +Checks the indentation of the first element in an array literal +where the opening bracket and the first element are on separate lines. +The other elements' indentations are handled by `Layout/ArrayAlignment` cop. + +This cop will respect `Layout/ArrayAlignment` and will not work when +`EnforcedStyle: with_fixed_indentation` is specified for `Layout/ArrayAlignment`. + +By default, array literals that are arguments in a method call with +parentheses, and where the opening square bracket of the array is on the +same line as the opening parenthesis of the method call, shall have +their first element indented one step (two spaces) more than the +position inside the opening parenthesis. + +Other array literals shall have their first element indented one step +more than the start of the line where the opening square bracket is. + +This default style is called 'special_inside_parentheses'. Alternative +styles are 'consistent' and 'align_brackets'. Here are examples: + +[#examples-layoutfirstarrayelementindentation] +=== Examples + +[#enforcedstyle_-special_inside_parentheses-_default_-layoutfirstarrayelementindentation] +==== EnforcedStyle: special_inside_parentheses (default) + +[source,ruby] +---- +# The `special_inside_parentheses` style enforces that the first +# element in an array literal where the opening bracket and first +# element are on separate lines is indented one step (two spaces) more +# than the position inside the opening parenthesis. + +# bad +array = [ + :value +] +and_in_a_method_call([ + :no_difference + ]) + +# good +array = [ + :value +] +but_in_a_method_call([ + :its_like_this + ]) +---- + +[#enforcedstyle_-consistent-layoutfirstarrayelementindentation] +==== EnforcedStyle: consistent + +[source,ruby] +---- +# The `consistent` style enforces that the first element in an array +# literal where the opening bracket and the first element are on +# separate lines is indented the same as an array literal which is not +# defined inside a method call. + +# bad +array = [ + :value +] +but_in_a_method_call([ + :its_like_this +]) + +# good +array = [ + :value +] +and_in_a_method_call([ + :no_difference +]) +---- + +[#enforcedstyle_-align_brackets-layoutfirstarrayelementindentation] +==== EnforcedStyle: align_brackets + +[source,ruby] +---- +# The `align_brackets` style enforces that the opening and closing +# brackets are indented to the same position. + +# bad +and_now_for_something = [ + :completely_different +] + +# good +and_now_for_something = [ + :completely_different + ] +---- + +[#configurable-attributes-layoutfirstarrayelementindentation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `special_inside_parentheses` +| `special_inside_parentheses`, `consistent`, `align_brackets` + +| IndentationWidth +| `` +| Integer +|=== + +[#layoutfirstarrayelementlinebreak] +== Layout/FirstArrayElementLineBreak + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for a line break before the first element in a +multi-line array. + +[#examples-layoutfirstarrayelementlinebreak] +=== Examples + +[source,ruby] +---- +# bad +[ :a, + :b] + +# good +[ + :a, + :b] + +# good +[:a, :b] +---- + +[#allowmultilinefinalelement_-false-_default_-layoutfirstarrayelementlinebreak] +==== AllowMultilineFinalElement: false (default) + +[source,ruby] +---- +# bad +[ :a, { + :b => :c +}] + +# good +[ + :a, { + :b => :c +}] +---- + +[#allowmultilinefinalelement_-true-layoutfirstarrayelementlinebreak] +==== AllowMultilineFinalElement: true + +[source,ruby] +---- +# good +[:a, { + :b => :c +}] +---- + +[#configurable-attributes-layoutfirstarrayelementlinebreak] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| xref:cops_layout.adoc#allowmultilinefinalelement[AllowMultilineFinalElement] +| `false` +| Boolean +|=== + +[#layoutfirsthashelementindentation] +== Layout/FirstHashElementIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.68 +| 0.77 +|=== + +Checks the indentation of the first key in a hash literal +where the opening brace and the first key are on separate lines. The +other keys' indentations are handled by the HashAlignment cop. + +By default, `Hash` literals that are arguments in a method call with +parentheses, and where the opening curly brace of the hash is on the +same line as the opening parenthesis of the method call, shall have +their first key indented one step (two spaces) more than the position +inside the opening parenthesis. + +Other hash literals shall have their first key indented one step more +than the start of the line where the opening curly brace is. + +This default style is called 'special_inside_parentheses'. Alternative +styles are 'consistent' and 'align_braces'. Here are examples: + +[#examples-layoutfirsthashelementindentation] +=== Examples + +[#enforcedstyle_-special_inside_parentheses-_default_-layoutfirsthashelementindentation] +==== EnforcedStyle: special_inside_parentheses (default) + +[source,ruby] +---- +# The `special_inside_parentheses` style enforces that the first key +# in a hash literal where the opening brace and the first key are on +# separate lines is indented one step (two spaces) more than the +# position inside the opening parentheses. + +# bad +hash = { + key: :value +} +and_in_a_method_call({ + no: :difference + }) +takes_multi_pairs_hash(x: { + a: 1, + b: 2 +}, + y: { + c: 1, + d: 2 + }) + +# good +special_inside_parentheses +hash = { + key: :value +} +but_in_a_method_call({ + its_like: :this + }) +takes_multi_pairs_hash(x: { + a: 1, + b: 2 + }, + y: { + c: 1, + d: 2 + }) +---- + +[#enforcedstyle_-consistent-layoutfirsthashelementindentation] +==== EnforcedStyle: consistent + +[source,ruby] +---- +# The `consistent` style enforces that the first key in a hash +# literal where the opening brace and the first key are on +# separate lines is indented the same as a hash literal which is not +# defined inside a method call. + +# bad +hash = { + key: :value +} +but_in_a_method_call({ + its_like: :this + }) + +# good +hash = { + key: :value +} +and_in_a_method_call({ + no: :difference +}) +---- + +[#enforcedstyle_-align_braces-layoutfirsthashelementindentation] +==== EnforcedStyle: align_braces + +[source,ruby] +---- +# The `align_brackets` style enforces that the opening and closing +# braces are indented to the same position. + +# bad +and_now_for_something = { + completely: :different +} +takes_multi_pairs_hash(x: { + a: 1, + b: 2 +}, + y: { + c: 1, + d: 2 + }) + +# good +and_now_for_something = { + completely: :different + } +takes_multi_pairs_hash(x: { + a: 1, + b: 2 + }, + y: { + c: 1, + d: 2 + }) +---- + +[#configurable-attributes-layoutfirsthashelementindentation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `special_inside_parentheses` +| `special_inside_parentheses`, `consistent`, `align_braces` + +| IndentationWidth +| `` +| Integer +|=== + +[#layoutfirsthashelementlinebreak] +== Layout/FirstHashElementLineBreak + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for a line break before the first element in a +multi-line hash. + +[#examples-layoutfirsthashelementlinebreak] +=== Examples + +[source,ruby] +---- +# bad +{ a: 1, + b: 2} + +# good +{ + a: 1, + b: 2 } + +# good +{ + a: 1, b: { + c: 3 +}} +---- + +[#allowmultilinefinalelement_-false-_default_-layoutfirsthashelementlinebreak] +==== AllowMultilineFinalElement: false (default) + +[source,ruby] +---- +# bad +{ a: 1, b: { + c: 3 +}} +---- + +[#allowmultilinefinalelement_-true-layoutfirsthashelementlinebreak] +==== AllowMultilineFinalElement: true + +[source,ruby] +---- +# bad +{ a: 1, + b: { + c: 3 +}} + +# good +{ a: 1, b: { + c: 3 +}} +---- + +[#configurable-attributes-layoutfirsthashelementlinebreak] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| xref:cops_layout.adoc#allowmultilinefinalelement[AllowMultilineFinalElement] +| `false` +| Boolean +|=== + +[#layoutfirstmethodargumentlinebreak] +== Layout/FirstMethodArgumentLineBreak + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for a line break before the first argument in a +multi-line method call. + +[#examples-layoutfirstmethodargumentlinebreak] +=== Examples + +[source,ruby] +---- +# bad +method(foo, bar, + baz) + +# good +method( + foo, bar, + baz) + + # ignored + method foo, bar, + baz +---- + +[#allowmultilinefinalelement_-false-_default_-layoutfirstmethodargumentlinebreak] +==== AllowMultilineFinalElement: false (default) + +[source,ruby] +---- +# bad +method(foo, bar, { + baz: "a", + qux: "b", +}) + +# good +method( + foo, bar, { + baz: "a", + qux: "b", +}) +---- + +[#allowmultilinefinalelement_-true-layoutfirstmethodargumentlinebreak] +==== AllowMultilineFinalElement: true + +[source,ruby] +---- +# bad +method(foo, + bar, + { + baz: "a", + qux: "b", + } +) + +# good +method(foo, bar, { + baz: "a", + qux: "b", +}) + +# good +method( + foo, + bar, + { + baz: "a", + qux: "b", + } +) +---- + +[#allowedmethods_-__some_method__-layoutfirstmethodargumentlinebreak] +==== AllowedMethods: ['some_method'] + +[source,ruby] +---- +# good +some_method(foo, bar, + baz) +---- + +[#configurable-attributes-layoutfirstmethodargumentlinebreak] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| xref:cops_layout.adoc#allowmultilinefinalelement[AllowMultilineFinalElement] +| `false` +| Boolean + +| AllowedMethods +| `[]` +| Array +|=== + +[#layoutfirstmethodparameterlinebreak] +== Layout/FirstMethodParameterLineBreak + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for a line break before the first parameter in a +multi-line method parameter definition. + +[#examples-layoutfirstmethodparameterlinebreak] +=== Examples + +[source,ruby] +---- +# bad +def method(foo, bar, + baz) + do_something +end + +# good +def method( + foo, bar, + baz) + do_something +end + +# ignored +def method foo, + bar + do_something +end +---- + +[#allowmultilinefinalelement_-false-_default_-layoutfirstmethodparameterlinebreak] +==== AllowMultilineFinalElement: false (default) + +[source,ruby] +---- +# bad +def method(foo, bar, baz = { + :a => "b", +}) + do_something +end + +# good +def method( + foo, bar, baz = { + :a => "b", +}) + do_something +end +---- + +[#allowmultilinefinalelement_-true-layoutfirstmethodparameterlinebreak] +==== AllowMultilineFinalElement: true + +[source,ruby] +---- +# good +def method(foo, bar, baz = { + :a => "b", +}) + do_something +end +---- + +[#configurable-attributes-layoutfirstmethodparameterlinebreak] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| xref:cops_layout.adoc#allowmultilinefinalelement[AllowMultilineFinalElement] +| `false` +| Boolean +|=== + +[#layoutfirstparameterindentation] +== Layout/FirstParameterIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 0.77 +|=== + +Checks the indentation of the first parameter in a method +definition. Parameters after the first one are checked by +`Layout/ParameterAlignment`, not by this cop. + +For indenting the first argument of method _calls_, check out +`Layout/FirstArgumentIndentation`, which supports options related to +nesting that are irrelevant for method _definitions_. + +[#examples-layoutfirstparameterindentation] +=== Examples + +[source,ruby] +---- +# bad +def some_method( +first_param, +second_param) + 123 +end +---- + +[#enforcedstyle_-consistent-_default_-layoutfirstparameterindentation] +==== EnforcedStyle: consistent (default) + +[source,ruby] +---- +# The first parameter should always be indented one step more than the +# preceding line. + +# good +def some_method( + first_param, +second_param) + 123 +end +---- + +[#enforcedstyle_-align_parentheses-layoutfirstparameterindentation] +==== EnforcedStyle: align_parentheses + +[source,ruby] +---- +# The first parameter should always be indented one step more than the +# opening parenthesis. + +# good +def some_method( + first_param, +second_param) + 123 +end +---- + +[#configurable-attributes-layoutfirstparameterindentation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `consistent` +| `consistent`, `align_parentheses` + +| IndentationWidth +| `` +| Integer +|=== + +[#layouthashalignment] +== Layout/HashAlignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 1.16 +|=== + +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, one space before hash rockets and values) +* separator (align hash rockets and colons, right align keys) +* table (left align keys, hash rockets, and values) + +The treatment of hashes passed as the last argument to a method call +can also be configured. The options are: + +* always_inspect +* always_ignore +* ignore_implicit (without curly braces) + +Alternatively you can specify multiple allowed styles. That's done by +passing a list of styles to EnforcedHashRocketStyle and EnforcedColonStyle. + +[#examples-layouthashalignment] +=== Examples + +[#enforcedhashrocketstyle_-key-_default_-layouthashalignment] +==== EnforcedHashRocketStyle: key (default) + +[source,ruby] +---- +# bad +{ + :foo => bar, + :ba => baz +} +{ + :foo => bar, + :ba => baz +} + +# good +{ + :foo => bar, + :ba => baz +} +---- + +[#enforcedhashrocketstyle_-separator-layouthashalignment] +==== EnforcedHashRocketStyle: separator + +[source,ruby] +---- +# bad +{ + :foo => bar, + :ba => baz +} +{ + :foo => bar, + :ba => baz +} + +# good +{ + :foo => bar, + :ba => baz +} +---- + +[#enforcedhashrocketstyle_-table-layouthashalignment] +==== EnforcedHashRocketStyle: table + +[source,ruby] +---- +# bad +{ + :foo => bar, + :ba => baz +} + +# good +{ + :foo => bar, + :ba => baz +} +---- + +[#enforcedcolonstyle_-key-_default_-layouthashalignment] +==== EnforcedColonStyle: key (default) + +[source,ruby] +---- +# bad +{ + foo: bar, + ba: baz +} +{ + foo: bar, + ba: baz +} + +# good +{ + foo: bar, + ba: baz +} +---- + +[#enforcedcolonstyle_-separator-layouthashalignment] +==== EnforcedColonStyle: separator + +[source,ruby] +---- +# bad +{ + foo: bar, + ba: baz +} + +# good +{ + foo: bar, + ba: baz +} +---- + +[#enforcedcolonstyle_-table-layouthashalignment] +==== EnforcedColonStyle: table + +[source,ruby] +---- +# bad +{ + foo: bar, + ba: baz +} + +# good +{ + foo: bar, + ba: baz +} +---- + +[#enforcedlastargumenthashstyle_-always_inspect-_default_-layouthashalignment] +==== EnforcedLastArgumentHashStyle: always_inspect (default) + +[source,ruby] +---- +# 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 +}) +---- + +[#enforcedlastargumenthashstyle_-always_ignore-layouthashalignment] +==== EnforcedLastArgumentHashStyle: always_ignore + +[source,ruby] +---- +# Ignore both implicit and explicit hashes. + +# good +do_something(foo: 1, + bar: 2) + +# good +do_something({foo: 1, + bar: 2}) +---- + +[#enforcedlastargumenthashstyle_-ignore_implicit-layouthashalignment] +==== EnforcedLastArgumentHashStyle: ignore_implicit + +[source,ruby] +---- +# Ignore only implicit hashes. + +# bad +do_something({foo: 1, + bar: 2}) + +# good +do_something(foo: 1, + bar: 2) +---- + +[#enforcedlastargumenthashstyle_-ignore_explicit-layouthashalignment] +==== EnforcedLastArgumentHashStyle: ignore_explicit + +[source,ruby] +---- +# Ignore only explicit hashes. + +# bad +do_something(foo: 1, + bar: 2) + +# good +do_something({foo: 1, + bar: 2}) +---- + +[#configurable-attributes-layouthashalignment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedHashRocketStyle +| `key` +| `key`, `separator`, `table` + +| EnforcedColonStyle +| `key` +| `key`, `separator`, `table` + +| EnforcedLastArgumentHashStyle +| `always_inspect` +| `always_inspect`, `always_ignore`, `ignore_implicit`, `ignore_explicit` +|=== + +[#layoutheredocargumentclosingparenthesis] +== Layout/HeredocArgumentClosingParenthesis + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 0.68 +| - +|=== + +Checks for the placement of the closing parenthesis +in a method call that passes a HEREDOC string as an argument. +It should be placed at the end of the line containing the +opening HEREDOC tag. + +[#examples-layoutheredocargumentclosingparenthesis] +=== Examples + +[source,ruby] +---- +# bad + + foo(<<-SQL + bar + SQL + ) + + foo(<<-SQL, 123, <<-NOSQL, + bar + SQL + baz + NOSQL + ) + + foo( + bar(<<-SQL + baz + SQL + ), + 123, + ) + +# good + + foo(<<-SQL) + bar + SQL + + foo(<<-SQL, 123, <<-NOSQL) + bar + SQL + baz + NOSQL + + foo( + bar(<<-SQL), + baz + SQL + 123, + ) +---- + +[#references-layoutheredocargumentclosingparenthesis] +=== References + +* https://rubystyle.guide#heredoc-argument-closing-parentheses + +[#layoutheredocindentation] +== Layout/HeredocIndentation + +NOTE: Requires Ruby version 2.3 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 0.85 +|=== + +Checks the indentation of the here document bodies. The bodies +are indented one step. + +NOTE: When ``Layout/LineLength``'s `AllowHeredoc` is false (not default), + this cop does not add any offenses for long here documents to + avoid ``Layout/LineLength``'s offenses. + +[#examples-layoutheredocindentation] +=== Examples + +[source,ruby] +---- +# bad +<<-RUBY +something +RUBY + +# good +<<~RUBY + something +RUBY +---- + +[#references-layoutheredocindentation] +=== References + +* https://rubystyle.guide#squiggly-heredocs + +[#layoutindentationconsistency] +== Layout/IndentationConsistency + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for inconsistent indentation. + +The difference between `indented_internal_methods` and `normal` is +that the `indented_internal_methods` style prescribes that in +classes and modules the `protected` and `private` modifier keywords +shall be indented the same as public methods and that protected and +private members shall be indented one step more than the modifiers. +Other than that, both styles mean that entities on the same logical +depth shall have the same indentation. + +[#examples-layoutindentationconsistency] +=== Examples + +[#enforcedstyle_-normal-_default_-layoutindentationconsistency] +==== EnforcedStyle: normal (default) + +[source,ruby] +---- +# bad +class A + def test + puts 'hello' + puts 'world' + end +end + +# bad +class A + def test + puts 'hello' + puts 'world' + end + + protected + + def foo + end + + private + + def bar + end +end + +# good +class A + def test + puts 'hello' + puts 'world' + end +end + +# good +class A + def test + puts 'hello' + puts 'world' + end + + protected + + def foo + end + + private + + def bar + end +end +---- + +[#enforcedstyle_-indented_internal_methods-layoutindentationconsistency] +==== EnforcedStyle: indented_internal_methods + +[source,ruby] +---- +# bad +class A + def test + puts 'hello' + puts 'world' + end +end + +# bad +class A + def test + puts 'hello' + puts 'world' + end + + protected + + def foo + end + + private + + def bar + end +end + +# good +class A + def test + puts 'hello' + puts 'world' + end +end + +# good +class A + def test + puts 'hello' + puts 'world' + end + + protected + + def foo + end + + private + + def bar + end +end +---- + +[#configurable-attributes-layoutindentationconsistency] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `normal` +| `normal`, `indented_internal_methods` +|=== + +[#references-layoutindentationconsistency] +=== References + +* https://rubystyle.guide#spaces-indentation +* https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions + +[#layoutindentationstyle] +== Layout/IndentationStyle + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 0.82 +|=== + +Checks that the indentation method is consistent. +Either tabs only or spaces only are used for indentation. + +[#examples-layoutindentationstyle] +=== Examples + +[#enforcedstyle_-spaces-_default_-layoutindentationstyle] +==== EnforcedStyle: spaces (default) + +[source,ruby] +---- +# 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 +---- + +[#enforcedstyle_-tabs-layoutindentationstyle] +==== EnforcedStyle: tabs + +[source,ruby] +---- +# 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 +---- + +[#configurable-attributes-layoutindentationstyle] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| IndentationWidth +| `` +| Integer + +| EnforcedStyle +| `spaces` +| `spaces`, `tabs` +|=== + +[#references-layoutindentationstyle] +=== References + +* https://rubystyle.guide#spaces-indentation + +[#layoutindentationwidth] +== Layout/IndentationWidth + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for indentation that doesn't use the specified number of spaces. +The indentation width can be configured using the `Width` setting. The default width is 2. + +See also the `Layout/IndentationConsistency` cop which is the companion to this one. + +[#examples-layoutindentationwidth] +=== Examples + +[#width_-2-_default_-layoutindentationwidth] +==== Width: 2 (default) + +[source,ruby] +---- +# bad +class A + def test + puts 'hello' + end +end + +# good +class A + def test + puts 'hello' + end +end +---- + +[#allowedpatterns_-____s_module__-layoutindentationwidth] +==== AllowedPatterns: ['^\s*module'] + +[source,ruby] +---- +# bad +module A +class B + def test + puts 'hello' + end +end +end + +# good +module A +class B + def test + puts 'hello' + end +end +end +---- + +[#configurable-attributes-layoutindentationwidth] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Width +| `2` +| Integer + +| AllowedPatterns +| `[]` +| Array +|=== + +[#references-layoutindentationwidth] +=== References + +* https://rubystyle.guide#spaces-indentation + +[#layoutinitialindentation] +== Layout/InitialIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for indentation of the first non-blank non-comment +line in a file. + +[#examples-layoutinitialindentation] +=== Examples + +[source,ruby] +---- +# bad + class A + def foo; end + end + +# good +class A + def foo; end +end +---- + +[#layoutleadingcommentspace] +== Layout/LeadingCommentSpace + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 0.73 +|=== + +Checks whether comments have a leading space after the +`#` denoting the start of the comment. The leading space is not +required for some RDoc special syntax, like `#++`, `#--`, +`#:nodoc`, `=begin`- and `=end` comments, "shebang" directives, +or rackup options. + +[#examples-layoutleadingcommentspace] +=== Examples + +[source,ruby] +---- +# bad +#Some comment + +# good +# Some comment +---- + +[#allowdoxygencommentstyle_-false-_default_-layoutleadingcommentspace] +==== AllowDoxygenCommentStyle: false (default) + +[source,ruby] +---- +# bad + +#** +# Some comment +# Another line of comment +#* +---- + +[#allowdoxygencommentstyle_-true-layoutleadingcommentspace] +==== AllowDoxygenCommentStyle: true + +[source,ruby] +---- +# good + +#** +# Some comment +# Another line of comment +#* +---- + +[#allowgemfilerubycomment_-false-_default_-layoutleadingcommentspace] +==== AllowGemfileRubyComment: false (default) + +[source,ruby] +---- +# bad + +#ruby=2.7.0 +#ruby-gemset=myproject +---- + +[#allowgemfilerubycomment_-true-layoutleadingcommentspace] +==== AllowGemfileRubyComment: true + +[source,ruby] +---- +# good + +#ruby=2.7.0 +#ruby-gemset=myproject +---- + +[#allowrbsinlineannotation_-false-_default_-layoutleadingcommentspace] +==== AllowRBSInlineAnnotation: false (default) + +[source,ruby] +---- +# bad + +include Enumerable #[Integer] + +attr_reader :name #: String +attr_reader :age #: Integer? + +#: ( +#| Integer, +#| String +#| ) -> void +def foo; end +---- + +[#allowrbsinlineannotation_-true-layoutleadingcommentspace] +==== AllowRBSInlineAnnotation: true + +[source,ruby] +---- +# good + +include Enumerable #[Integer] + +attr_reader :name #: String +attr_reader :age #: Integer? + +#: ( +#| Integer, +#| String +#| ) -> void +def foo; end +---- + +[#allowsteepannotation_-false-_default_-layoutleadingcommentspace] +==== AllowSteepAnnotation: false (default) + +[source,ruby] +---- +# bad +[1, 2, 3].each_with_object([]) do |n, list| #$ Array[Integer] + list << n +end + +name = 'John' #: String +---- + +[#allowsteepannotation_-true-layoutleadingcommentspace] +==== AllowSteepAnnotation: true + +[source,ruby] +---- +# good + +[1, 2, 3].each_with_object([]) do |n, list| #$ Array[Integer] + list << n +end + +name = 'John' #: String +---- + +[#configurable-attributes-layoutleadingcommentspace] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowDoxygenCommentStyle +| `false` +| Boolean + +| AllowGemfileRubyComment +| `false` +| Boolean + +| AllowRBSInlineAnnotation +| `false` +| Boolean + +| AllowSteepAnnotation +| `false` +| Boolean +|=== + +[#references-layoutleadingcommentspace] +=== References + +* https://rubystyle.guide#hash-space + +[#layoutleadingemptylines] +== Layout/LeadingEmptyLines + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.57 +| 0.77 +|=== + +Checks for unnecessary leading blank lines at the beginning +of a file. + +[#examples-layoutleadingemptylines] +=== Examples + +[source,ruby] +---- +# bad +# (start of file) + +class Foo +end + +# bad +# (start of file) + +# a comment + +# good +# (start of file) +class Foo +end + +# good +# (start of file) +# a comment +---- + +[#layoutlinecontinuationleadingspace] +== Layout/LineContinuationLeadingSpace + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.31 +| 1.45 +|=== + +Checks that strings broken over multiple lines (by a backslash) contain +trailing spaces instead of leading spaces (default) or leading spaces +instead of trailing spaces. + +[#examples-layoutlinecontinuationleadingspace] +=== Examples + +[#enforcedstyle_-trailing-_default_-layoutlinecontinuationleadingspace] +==== EnforcedStyle: trailing (default) + +[source,ruby] +---- +# bad +'this text contains a lot of' \ +' spaces' + +# good +'this text contains a lot of ' \ +'spaces' + +# bad +'this text is too' \ +' long' + +# good +'this text is too ' \ +'long' +---- + +[#enforcedstyle_-leading-layoutlinecontinuationleadingspace] +==== EnforcedStyle: leading + +[source,ruby] +---- +# bad +'this text contains a lot of ' \ +'spaces' + +# good +'this text contains a lot of' \ +' spaces' + +# bad +'this text is too ' \ +'long' + +# good +'this text is too' \ +' long' +---- + +[#configurable-attributes-layoutlinecontinuationleadingspace] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `trailing` +| `leading`, `trailing` +|=== + +[#layoutlinecontinuationspacing] +== Layout/LineContinuationSpacing + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.31 +| - +|=== + +Checks that the backslash of a line continuation is separated from +preceding text by exactly one space (default) or zero spaces. + +[#examples-layoutlinecontinuationspacing] +=== Examples + +[#enforcedstyle_-space-_default_-layoutlinecontinuationspacing] +==== EnforcedStyle: space (default) + +[source,ruby] +---- +# bad +'a'\ +'b' \ +'c' + +# good +'a' \ +'b' \ +'c' +---- + +[#enforcedstyle_-no_space-layoutlinecontinuationspacing] +==== EnforcedStyle: no_space + +[source,ruby] +---- +# bad +'a' \ +'b' \ +'c' + +# good +'a'\ +'b'\ +'c' +---- + +[#configurable-attributes-layoutlinecontinuationspacing] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `space` +| `space`, `no_space` +|=== + +[#layoutlineendstringconcatenationindentation] +== Layout/LineEndStringConcatenationIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.18 +| - +|=== + +Checks the indentation of the next line after a line that ends with a string +literal and a backslash. + +If `EnforcedStyle: aligned` is set, the concatenated string parts shall be aligned with the +first part. There are some exceptions, such as implicit return values, where the +concatenated string parts shall be indented regardless of `EnforcedStyle` configuration. + +If `EnforcedStyle: indented` is set, it's the second line that shall be indented one step +more than the first line. Lines 3 and forward shall be aligned with line 2. + +[#examples-layoutlineendstringconcatenationindentation] +=== Examples + +[source,ruby] +---- +# bad +def some_method + 'x' \ + 'y' \ + 'z' +end + +my_hash = { + first: 'a message' \ + 'in two parts' +} + +# good +def some_method + 'x' \ + 'y' \ + 'z' +end +---- + +[#enforcedstyle_-aligned-_default_-layoutlineendstringconcatenationindentation] +==== EnforcedStyle: aligned (default) + +[source,ruby] +---- +# bad +puts 'x' \ + 'y' + +my_hash = { + first: 'a message' \ + 'in two parts' +} + +# good +puts 'x' \ + 'y' + +my_hash = { + first: 'a message' \ + 'in two parts' +} +---- + +[#enforcedstyle_-indented-layoutlineendstringconcatenationindentation] +==== EnforcedStyle: indented + +[source,ruby] +---- +# bad +result = 'x' \ + 'y' + +my_hash = { + first: 'a message' \ + 'in two parts' +} + +# good +result = 'x' \ + 'y' + +my_hash = { + first: 'a message' \ + 'in two parts' +} +---- + +[#configurable-attributes-layoutlineendstringconcatenationindentation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `aligned` +| `aligned`, `indented` + +| IndentationWidth +| `` +| Integer +|=== + +[#layoutlinelength] +== Layout/LineLength + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.25 +| 1.69 +|=== + +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/IndentationStyle` cop. +It also ignores a shebang line by default. + +This cop has some autocorrection capabilities. +It can programmatically shorten certain long lines by +inserting line breaks into expressions that can be safely +split across lines. These include arrays, hashes, and +method calls with argument lists. + +If autocorrection is enabled, the following cops +are recommended to further format the broken lines. +(Many of these are enabled by default.) + +* `Layout/ArgumentAlignment` +* `Layout/ArrayAlignment` +* `Layout/BlockAlignment` +* `Layout/BlockEndNewline` +* `Layout/ClosingParenthesisIndentation` +* `Layout/FirstArgumentIndentation` +* `Layout/FirstArrayElementIndentation` +* `Layout/FirstHashElementIndentation` +* `Layout/FirstParameterIndentation` +* `Layout/HashAlignment` +* `Layout/IndentationWidth` +* `Layout/MultilineArrayLineBreaks` +* `Layout/MultilineBlockLayout` +* `Layout/MultilineHashBraceLayout` +* `Layout/MultilineHashKeyLineBreaks` +* `Layout/MultilineMethodArgumentLineBreaks` +* `Layout/MultilineMethodParameterLineBreaks` +* `Layout/ParameterAlignment` +* `Style/BlockDelimiters` + +Together, these cops will pretty print hashes, arrays, +method calls, etc. For example, let's say the max columns +is 25: + +[#examples-layoutlinelength] +=== Examples + +[source,ruby] +---- +# bad +{foo: "0000000000", bar: "0000000000", baz: "0000000000"} + +# good +{foo: "0000000000", +bar: "0000000000", baz: "0000000000"} + +# good (with recommended cops enabled) +{ + foo: "0000000000", + bar: "0000000000", + baz: "0000000000", +} +---- + +[#configurable-attributes-layoutlinelength] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Max +| `120` +| Integer + +| AllowHeredoc +| `true` +| Boolean + +| AllowURI +| `true` +| Boolean + +| AllowQualifiedName +| `true` +| Boolean + +| URISchemes +| `http`, `https` +| Array + +| IgnoreCopDirectives +| `true` +| Boolean + +| AllowedPatterns +| `[]` +| Array + +| SplitStrings +| `false` +| Boolean +|=== + +[#references-layoutlinelength] +=== References + +* https://rubystyle.guide#max-line-length + +[#layoutmultilinearraybracelayout] +== Layout/MultilineArrayBraceLayout + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks that the closing brace in an array literal is either +on the same line as the last array element or on a new line. + +When using the `symmetrical` (default) style: + +If an array's opening brace is on the same line as the first element +of the array, then the closing brace should be on the same line as +the last element of the array. + +If an array's opening brace is on the line above the first element +of the array, then the closing brace should be on the line below +the last element of the array. + +When using the `new_line` style: + +The closing brace of a multi-line array literal must be on the line +after the last element of the array. + +When using the `same_line` style: + +The closing brace of a multi-line array literal must be on the same +line as the last element of the array. + +[#examples-layoutmultilinearraybracelayout] +=== Examples + +[#enforcedstyle_-symmetrical-_default_-layoutmultilinearraybracelayout] +==== EnforcedStyle: symmetrical (default) + +[source,ruby] +---- +# bad +[ :a, + :b +] + +# bad +[ + :a, + :b ] + +# good +[ :a, + :b ] + +# good +[ + :a, + :b +] +---- + +[#enforcedstyle_-new_line-layoutmultilinearraybracelayout] +==== EnforcedStyle: new_line + +[source,ruby] +---- +# bad +[ + :a, + :b ] + +# bad +[ :a, + :b ] + +# good +[ :a, + :b +] + +# good +[ + :a, + :b +] +---- + +[#enforcedstyle_-same_line-layoutmultilinearraybracelayout] +==== EnforcedStyle: same_line + +[source,ruby] +---- +# bad +[ :a, + :b +] + +# bad +[ + :a, + :b +] + +# good +[ + :a, + :b ] + +# good +[ :a, + :b ] +---- + +[#configurable-attributes-layoutmultilinearraybracelayout] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `symmetrical` +| `symmetrical`, `new_line`, `same_line` +|=== + +[#layoutmultilinearraylinebreaks] +== Layout/MultilineArrayLineBreaks + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 0.67 +| - +|=== + +Ensures that each item in a multi-line array +starts on a separate line. + +[#examples-layoutmultilinearraylinebreaks] +=== Examples + +[source,ruby] +---- +# bad +[ + a, b, + c +] + +# good +[ + a, + b, + c +] + +# good +[ + a, + b, + foo( + bar + ) +] +---- + +[#allowmultilinefinalelement_-false-_default_-layoutmultilinearraylinebreaks] +==== AllowMultilineFinalElement: false (default) + +[source,ruby] +---- +# bad +[a, b, foo( + bar +)] +---- + +[#allowmultilinefinalelement_-true-layoutmultilinearraylinebreaks] +==== AllowMultilineFinalElement: true + +[source,ruby] +---- +# good +[a, b, foo( + bar +)] +---- + +[#configurable-attributes-layoutmultilinearraylinebreaks] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| xref:cops_layout.adoc#allowmultilinefinalelement[AllowMultilineFinalElement] +| `false` +| Boolean +|=== + +[#layoutmultilineassignmentlayout] +== Layout/MultilineAssignmentLayout + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks whether the multiline assignments have a newline +after the assignment operator. + +[#examples-layoutmultilineassignmentlayout] +=== Examples + +[#enforcedstyle_-new_line-_default_-layoutmultilineassignmentlayout] +==== EnforcedStyle: new_line (default) + +[source,ruby] +---- +# bad +foo = if expression + 'bar' +end + +# good +foo = + if expression + 'bar' + end + +# good +foo = + begin + compute + rescue => e + nil + end +---- + +[#enforcedstyle_-same_line-layoutmultilineassignmentlayout] +==== EnforcedStyle: same_line + +[source,ruby] +---- +# good +foo = if expression + 'bar' +end +---- + +[#supportedtypes_-__block__-_case__-_class__-_if__-_kwbegin__-_module__-_default_-layoutmultilineassignmentlayout] +==== SupportedTypes: ['block', 'case', 'class', 'if', 'kwbegin', 'module'] (default) + +[source,ruby] +---- +# good +foo = + if expression + 'bar' + end + +# good +foo = + [1].map do |i| + i + 1 + end +---- + +[#supportedtypes_-__block__-layoutmultilineassignmentlayout] +==== SupportedTypes: ['block'] + +[source,ruby] +---- +# good +foo = if expression + 'bar' +end + +# good +foo = + [1].map do |i| + 'bar' * i + end +---- + +[#configurable-attributes-layoutmultilineassignmentlayout] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `new_line` +| `same_line`, `new_line` +|=== + +[#references-layoutmultilineassignmentlayout] +=== References + +* https://rubystyle.guide#indent-conditional-assignment + +[#layoutmultilineblocklayout] +== Layout/MultilineBlockLayout + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks whether the multiline do end blocks have a newline +after the start of the block. Additionally, it checks whether the block +arguments, if any, are on the same line as the start of the +block. Putting block arguments on separate lines, because the whole +line would otherwise be too long, is accepted. + +[#examples-layoutmultilineblocklayout] +=== Examples + +[source,ruby] +---- +# bad +blah do |i| foo(i) + bar(i) +end + +# bad +blah do + |i| foo(i) + bar(i) +end + +# good +blah do |i| + foo(i) + bar(i) +end + +# bad +blah { |i| foo(i) + bar(i) +} + +# good +blah { |i| + foo(i) + bar(i) +} + +# good +blah { | + long_list, + of_parameters, + that_would_not, + fit_on_one_line +| + foo(i) + bar(i) +} +---- + +[#layoutmultilinehashbracelayout] +== Layout/MultilineHashBraceLayout + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks that the closing brace in a hash literal is either +on the same line as the last hash element, or a new line. + +When using the `symmetrical` (default) style: + +If a hash's opening brace is on the same line as the first element +of the hash, then the closing brace should be on the same line as +the last element of the hash. + +If a hash's opening brace is on the line above the first element +of the hash, then the closing brace should be on the line below +the last element of the hash. + +When using the `new_line` style: + +The closing brace of a multi-line hash literal must be on the line +after the last element of the hash. + +When using the `same_line` style: + +The closing brace of a multi-line hash literal must be on the same +line as the last element of the hash. + +[#examples-layoutmultilinehashbracelayout] +=== Examples + +[#enforcedstyle_-symmetrical-_default_-layoutmultilinehashbracelayout] +==== EnforcedStyle: symmetrical (default) + +[source,ruby] +---- +# bad +{ a: 1, + b: 2 +} +# bad +{ + a: 1, + b: 2 } + +# good +{ a: 1, + b: 2 } + +# good +{ + a: 1, + b: 2 +} +---- + +[#enforcedstyle_-new_line-layoutmultilinehashbracelayout] +==== EnforcedStyle: new_line + +[source,ruby] +---- +# bad +{ + a: 1, + b: 2 } + +# bad +{ a: 1, + b: 2 } + +# good +{ a: 1, + b: 2 +} + +# good +{ + a: 1, + b: 2 +} +---- + +[#enforcedstyle_-same_line-layoutmultilinehashbracelayout] +==== EnforcedStyle: same_line + +[source,ruby] +---- +# bad +{ a: 1, + b: 2 +} + +# bad +{ + a: 1, + b: 2 +} + +# good +{ + a: 1, + b: 2 } + +# good +{ a: 1, + b: 2 } +---- + +[#configurable-attributes-layoutmultilinehashbracelayout] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `symmetrical` +| `symmetrical`, `new_line`, `same_line` +|=== + +[#layoutmultilinehashkeylinebreaks] +== Layout/MultilineHashKeyLineBreaks + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 0.67 +| - +|=== + +Ensures that each key in a multi-line hash +starts on a separate line. + +[#examples-layoutmultilinehashkeylinebreaks] +=== Examples + +[source,ruby] +---- +# bad +{ + a: 1, b: 2, + c: 3 +} + +# good +{ + a: 1, + b: 2, + c: 3 +} + +# good +{ + a: 1, + b: { + c: 3, + } +} +---- + +[#allowmultilinefinalelement_-false-_default_-layoutmultilinehashkeylinebreaks] +==== AllowMultilineFinalElement: false (default) + +[source,ruby] +---- +# bad +{ a: 1, b: { + c: 3, +}} +---- + +[#allowmultilinefinalelement_-true-layoutmultilinehashkeylinebreaks] +==== AllowMultilineFinalElement: true + +[source,ruby] +---- +# good +{ a: 1, b: { + c: 3, +}} +---- + +[#configurable-attributes-layoutmultilinehashkeylinebreaks] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| xref:cops_layout.adoc#allowmultilinefinalelement[AllowMultilineFinalElement] +| `false` +| Boolean +|=== + +[#layoutmultilinemethodargumentlinebreaks] +== Layout/MultilineMethodArgumentLineBreaks + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 0.67 +| - +|=== + +Ensures that each argument in a multi-line method call +starts on a separate line. + +NOTE: This cop does not move the first argument, if you want that to +be on a separate line, see `Layout/FirstMethodArgumentLineBreak`. + +[#examples-layoutmultilinemethodargumentlinebreaks] +=== Examples + +[source,ruby] +---- +# bad +foo(a, b, + c +) + +# bad +foo(a, b, { + foo: "bar", +}) + +# good +foo( + a, + b, + c +) + +# good +foo(a, b, c) +---- + +[#allowmultilinefinalelement_-false-_default_-layoutmultilinemethodargumentlinebreaks] +==== AllowMultilineFinalElement: false (default) + +[source,ruby] +---- +# bad +foo(a, b, + c +) + +# bad +foo( + a, b, { + foo: "bar", + } +) + +# good +foo( + a, + b, + { + foo: "bar", + } +) +---- + +[#allowmultilinefinalelement_-true-layoutmultilinemethodargumentlinebreaks] +==== AllowMultilineFinalElement: true + +[source,ruby] +---- +# bad +foo(a, b, + c +) + +# good +foo( + a, b, { + foo: "bar", + } +) + +# good +foo( + a, + b, + { + foo: "bar", + } +) +---- + +[#configurable-attributes-layoutmultilinemethodargumentlinebreaks] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| xref:cops_layout.adoc#allowmultilinefinalelement[AllowMultilineFinalElement] +| `false` +| Boolean +|=== + +[#layoutmultilinemethodcallbracelayout] +== Layout/MultilineMethodCallBraceLayout + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks that the closing brace in a method call is either +on the same line as the last method argument, or a new line. + +When using the `symmetrical` (default) style: + +If a method call's opening brace is on the same line as the first +argument of the call, then the closing brace should be on the same +line as the last argument of the call. + +If a method call's opening brace is on the line above the first +argument of the call, then the closing brace should be on the line +below the last argument of the call. + +When using the `new_line` style: + +The closing brace of a multi-line method call must be on the line +after the last argument of the call. + +When using the `same_line` style: + +The closing brace of a multi-line method call must be on the same +line as the last argument of the call. + +[#examples-layoutmultilinemethodcallbracelayout] +=== Examples + +[#enforcedstyle_-symmetrical-_default_-layoutmultilinemethodcallbracelayout] +==== EnforcedStyle: symmetrical (default) + +[source,ruby] +---- +# bad +foo(a, + b +) + +# bad +foo( + a, + b) + +# good +foo(a, + b) + +# good +foo( + a, + b +) +---- + +[#enforcedstyle_-new_line-layoutmultilinemethodcallbracelayout] +==== EnforcedStyle: new_line + +[source,ruby] +---- +# bad +foo( + a, + b) + +# bad +foo(a, + b) + +# good +foo(a, + b +) + +# good +foo( + a, + b +) +---- + +[#enforcedstyle_-same_line-layoutmultilinemethodcallbracelayout] +==== EnforcedStyle: same_line + +[source,ruby] +---- +# bad +foo(a, + b +) + +# bad +foo( + a, + b +) + +# good +foo( + a, + b) + +# good +foo(a, + b) +---- + +[#configurable-attributes-layoutmultilinemethodcallbracelayout] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `symmetrical` +| `symmetrical`, `new_line`, `same_line` +|=== + +[#layoutmultilinemethodcallindentation] +== Layout/MultilineMethodCallIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks the indentation of the method name part in method calls +that span more than one line. + +[#examples-layoutmultilinemethodcallindentation] +=== Examples + +[#enforcedstyle_-aligned-_default_-layoutmultilinemethodcallindentation] +==== EnforcedStyle: aligned (default) + +[source,ruby] +---- +# bad +while myvariable +.b + # do something +end + +# good +while myvariable + .b + # do something +end + +# good +Thing.a + .b + .c +---- + +[#enforcedstyle_-indented-layoutmultilinemethodcallindentation] +==== EnforcedStyle: indented + +[source,ruby] +---- +# good +while myvariable + .b + + # do something +end +---- + +[#enforcedstyle_-indented_relative_to_receiver-layoutmultilinemethodcallindentation] +==== EnforcedStyle: indented_relative_to_receiver + +[source,ruby] +---- +# good +while myvariable + .a + .b + + # do something +end + +# good +myvariable = Thing + .a + .b + .c +---- + +[#configurable-attributes-layoutmultilinemethodcallindentation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `aligned` +| `aligned`, `indented`, `indented_relative_to_receiver` + +| IndentationWidth +| `` +| Integer +|=== + +[#layoutmultilinemethoddefinitionbracelayout] +== Layout/MultilineMethodDefinitionBraceLayout + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks that the closing brace in a method definition is either +on the same line as the last method parameter, or a new line. + +When using the `symmetrical` (default) style: + +If a method definition's opening brace is on the same line as the +first parameter of the definition, then the closing brace should be +on the same line as the last parameter of the definition. + +If a method definition's opening brace is on the line above the first +parameter of the definition, then the closing brace should be on the +line below the last parameter of the definition. + +When using the `new_line` style: + +The closing brace of a multi-line method definition must be on the line +after the last parameter of the definition. + +When using the `same_line` style: + +The closing brace of a multi-line method definition must be on the same +line as the last parameter of the definition. + +[#examples-layoutmultilinemethoddefinitionbracelayout] +=== Examples + +[#enforcedstyle_-symmetrical-_default_-layoutmultilinemethoddefinitionbracelayout] +==== EnforcedStyle: symmetrical (default) + +[source,ruby] +---- +# bad +def foo(a, + b +) +end + +# bad +def foo( + a, + b) +end + +# good +def foo(a, + b) +end + +# good +def foo( + a, + b +) +end +---- + +[#enforcedstyle_-new_line-layoutmultilinemethoddefinitionbracelayout] +==== EnforcedStyle: new_line + +[source,ruby] +---- +# bad +def foo( + a, + b) +end + +# bad +def foo(a, + b) +end + +# good +def foo(a, + b +) +end + +# good +def foo( + a, + b +) +end +---- + +[#enforcedstyle_-same_line-layoutmultilinemethoddefinitionbracelayout] +==== EnforcedStyle: same_line + +[source,ruby] +---- +# bad +def foo(a, + b +) +end + +# bad +def foo( + a, + b +) +end + +# good +def foo( + a, + b) +end + +# good +def foo(a, + b) +end +---- + +[#configurable-attributes-layoutmultilinemethoddefinitionbracelayout] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `symmetrical` +| `symmetrical`, `new_line`, `same_line` +|=== + +[#layoutmultilinemethodparameterlinebreaks] +== Layout/MultilineMethodParameterLineBreaks + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 1.32 +| - +|=== + +Ensures that each parameter in a multi-line method definition +starts on a separate line. + +NOTE: This cop does not move the first argument, if you want that to +be on a separate line, see `Layout/FirstMethodParameterLineBreak`. + +[#examples-layoutmultilinemethodparameterlinebreaks] +=== Examples + +[source,ruby] +---- +# bad +def foo(a, b, + c +) +end + +# good +def foo( + a, + b, + c +) +end + +# good +def foo( + a, + b = { + foo: "bar", + } +) +end + +# good +def foo(a, b, c) +end +---- + +[#allowmultilinefinalelement_-false-_default_-layoutmultilinemethodparameterlinebreaks] +==== AllowMultilineFinalElement: false (default) + +[source,ruby] +---- +# bad +def foo(a, b = { + foo: "bar", +}) +end +---- + +[#allowmultilinefinalelement_-true-layoutmultilinemethodparameterlinebreaks] +==== AllowMultilineFinalElement: true + +[source,ruby] +---- +# good +def foo(a, b = { + foo: "bar", +}) +end +---- + +[#configurable-attributes-layoutmultilinemethodparameterlinebreaks] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| xref:cops_layout.adoc#allowmultilinefinalelement[AllowMultilineFinalElement] +| `false` +| Boolean +|=== + +[#layoutmultilineoperationindentation] +== Layout/MultilineOperationIndentation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks the indentation of the right hand side operand in binary operations that +span more than one line. + +The `aligned` style checks that operators are aligned if they are part of an `if` or `while` +condition, an explicit `return` statement, etc. In other contexts, the second operand should +be indented regardless of enforced style. + +[#examples-layoutmultilineoperationindentation] +=== Examples + +[#enforcedstyle_-aligned-_default_-layoutmultilineoperationindentation] +==== EnforcedStyle: aligned (default) + +[source,ruby] +---- +# bad +if a + + b + something && + something_else +end + +# good +if a + + b + something && + something_else +end +---- + +[#enforcedstyle_-indented-layoutmultilineoperationindentation] +==== EnforcedStyle: indented + +[source,ruby] +---- +# bad +if a + + b + something && + something_else +end + +# good +if a + + b + something && + something_else +end +---- + +[#configurable-attributes-layoutmultilineoperationindentation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `aligned` +| `aligned`, `indented` + +| IndentationWidth +| `` +| Integer +|=== + +[#layoutparameteralignment] +== Layout/ParameterAlignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 0.77 +|=== + +Check that the parameters on a multi-line method call or definition are aligned. + +To set the alignment of the first argument, use the +`Layout/FirstParameterIndentation` cop. + +[#examples-layoutparameteralignment] +=== Examples + +[#enforcedstyle_-with_first_parameter-_default_-layoutparameteralignment] +==== EnforcedStyle: with_first_parameter (default) + +[source,ruby] +---- +# good + +def foo(bar, + baz) + 123 +end + +def foo( + bar, + baz +) + 123 +end + +# bad + +def foo(bar, + baz) + 123 +end + +# bad + +def foo( + bar, + baz) + 123 +end +---- + +[#enforcedstyle_-with_fixed_indentation-layoutparameteralignment] +==== EnforcedStyle: with_fixed_indentation + +[source,ruby] +---- +# good + +def foo(bar, + baz) + 123 +end + +def foo( + bar, + baz +) + 123 +end + +# bad + +def foo(bar, + baz) + 123 +end + +# bad + +def foo( + bar, + baz) + 123 +end +---- + +[#configurable-attributes-layoutparameteralignment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `with_first_parameter` +| `with_first_parameter`, `with_fixed_indentation` + +| IndentationWidth +| `` +| Integer +|=== + +[#references-layoutparameteralignment] +=== References + +* https://rubystyle.guide#no-double-indent + +[#layoutredundantlinebreak] +== Layout/RedundantLineBreak + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 1.13 +| - +|=== + +Checks whether certain expressions, e.g. method calls, that could fit +completely on a single line, are broken up into multiple lines unnecessarily. + +[#examples-layoutredundantlinebreak] +=== Examples + +[source,ruby] +---- +# bad +foo( + a, + b +) + +# good +foo(a, b) + +# bad +puts 'string that fits on ' \ + 'a single line' + +# good +puts 'string that fits on a single line' + +# bad +things + .select { |thing| thing.cond? } + .join('-') + +# good +things.select { |thing| thing.cond? }.join('-') +---- + +[#inspectblocks_-false-_default_-layoutredundantlinebreak] +==== InspectBlocks: false (default) + +[source,ruby] +---- +# good +foo(a) do |x| + puts x +end +---- + +[#inspectblocks_-true-layoutredundantlinebreak] +==== InspectBlocks: true + +[source,ruby] +---- +# bad +foo(a) do |x| + puts x +end + +# good +foo(a) { |x| puts x } +---- + +[#configurable-attributes-layoutredundantlinebreak] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| InspectBlocks +| `false` +| Boolean +|=== + +[#layoutrescueensurealignment] +== Layout/RescueEnsureAlignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks whether the rescue and ensure keywords are aligned +properly. + +[#examples-layoutrescueensurealignment] +=== Examples + +[source,ruby] +---- +# bad +begin + something + rescue + puts 'error' +end + +# good +begin + something +rescue + puts 'error' +end +---- + +[#layoutsinglelineblockchain] +== Layout/SingleLineBlockChain + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 1.14 +| - +|=== + +Checks if method calls are chained onto single line blocks. It considers that a +line break before the dot improves the readability of the code. + +[#examples-layoutsinglelineblockchain] +=== Examples + +[source,ruby] +---- +# bad +example.select { |item| item.cond? }.join('-') + +# good +example.select { |item| item.cond? } + .join('-') + +# good (not a concern for this cop) +example.select do |item| + item.cond? +end.join('-') +---- + +[#layoutspaceaftercolon] +== Layout/SpaceAfterColon + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for colon (`:`) not followed by some kind of space. +N.B. this cop does not handle spaces after a ternary operator, which are +instead handled by `Layout/SpaceAroundOperators`. + +[#examples-layoutspaceaftercolon] +=== Examples + +[source,ruby] +---- +# bad +def f(a:, b:2); {a:3}; end + +# good +def f(a:, b: 2); {a: 3}; end +---- + +[#references-layoutspaceaftercolon] +=== References + +* https://rubystyle.guide#spaces-operators + +[#layoutspaceaftercomma] +== Layout/SpaceAfterComma + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for comma (`,`) not followed by some kind of space. + +[#examples-layoutspaceaftercomma] +=== Examples + +[source,ruby] +---- +# bad +[1,2] +{ foo:bar,} + +# good +[1, 2] +{ foo:bar, } +---- + +[#references-layoutspaceaftercomma] +=== References + +* https://rubystyle.guide#spaces-operators + +[#layoutspaceaftermethodname] +== Layout/SpaceAfterMethodName + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for space between a method name and a left parenthesis in defs. + +[#examples-layoutspaceaftermethodname] +=== Examples + +[source,ruby] +---- +# bad +def func (x) end +def method= (y) end + +# good +def func(x) end +def method=(y) end +---- + +[#references-layoutspaceaftermethodname] +=== References + +* https://rubystyle.guide#parens-no-spaces + +[#layoutspaceafternot] +== Layout/SpaceAfterNot + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for space after `!`. + +[#examples-layoutspaceafternot] +=== Examples + +[source,ruby] +---- +# bad +! something + +# good +!something +---- + +[#references-layoutspaceafternot] +=== References + +* https://rubystyle.guide#no-space-bang + +[#layoutspaceaftersemicolon] +== Layout/SpaceAfterSemicolon + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for semicolon (`;`) not followed by some kind of space. + +[#examples-layoutspaceaftersemicolon] +=== Examples + +[source,ruby] +---- +# bad +x = 1;y = 2 + +# good +x = 1; y = 2 +---- + +[#references-layoutspaceaftersemicolon] +=== References + +* https://rubystyle.guide#spaces-operators + +[#layoutspacearoundblockparameters] +== Layout/SpaceAroundBlockParameters + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks the spacing inside and after block parameters pipes. Line breaks +inside parameter pipes are checked by `Layout/MultilineBlockLayout` and +not by this cop. + +[#examples-layoutspacearoundblockparameters] +=== Examples + +[#enforcedstyleinsidepipes_-no_space-_default_-layoutspacearoundblockparameters] +==== EnforcedStyleInsidePipes: no_space (default) + +[source,ruby] +---- +# bad +{}.each { | x, y |puts x } +->( x, y ) { puts x } + +# good +{}.each { |x, y| puts x } +->(x, y) { puts x } +---- + +[#enforcedstyleinsidepipes_-space-layoutspacearoundblockparameters] +==== EnforcedStyleInsidePipes: space + +[source,ruby] +---- +# bad +{}.each { |x, y| puts x } +->(x, y) { puts x } + +# good +{}.each { | x, y | puts x } +->( x, y ) { puts x } +---- + +[#configurable-attributes-layoutspacearoundblockparameters] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyleInsidePipes +| `no_space` +| `space`, `no_space` +|=== + +[#layoutspacearoundequalsinparameterdefault] +== Layout/SpaceAroundEqualsInParameterDefault + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks that the equals signs in parameter default assignments +have or don't have surrounding space depending on configuration. + +[#examples-layoutspacearoundequalsinparameterdefault] +=== Examples + +[#enforcedstyle_-space-_default_-layoutspacearoundequalsinparameterdefault] +==== EnforcedStyle: space (default) + +[source,ruby] +---- +# bad +def some_method(arg1=:default, arg2=nil, arg3=[]) + # do something... +end + +# good +def some_method(arg1 = :default, arg2 = nil, arg3 = []) + # do something... +end +---- + +[#enforcedstyle_-no_space-layoutspacearoundequalsinparameterdefault] +==== EnforcedStyle: no_space + +[source,ruby] +---- +# bad +def some_method(arg1 = :default, arg2 = nil, arg3 = []) + # do something... +end + +# good +def some_method(arg1=:default, arg2=nil, arg3=[]) + # do something... +end +---- + +[#configurable-attributes-layoutspacearoundequalsinparameterdefault] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `space` +| `space`, `no_space` +|=== + +[#references-layoutspacearoundequalsinparameterdefault] +=== References + +* https://rubystyle.guide#spaces-around-equals + +[#layoutspacearoundkeyword] +== Layout/SpaceAroundKeyword + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks the spacing around the keywords. + +[#examples-layoutspacearoundkeyword] +=== Examples + +[source,ruby] +---- +# bad +something 'test'do|x| +end + +while(something) +end + +something = 123if test + +return(foo + bar) + +# good +something 'test' do |x| +end + +while (something) +end + +something = 123 if test + +return (foo + bar) +---- + +[#layoutspacearoundmethodcalloperator] +== Layout/SpaceAroundMethodCallOperator + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.82 +| - +|=== + +Checks method call operators to not have spaces around them. + +[#examples-layoutspacearoundmethodcalloperator] +=== Examples + +[source,ruby] +---- +# 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:: Base +:: RuboCop::Cop + +# good +foo.bar +foo.bar.buzz +foo + .bar + .buzz +foo&.bar +foo&.bar&.buzz +RuboCop::Cop +RuboCop::Cop::Base +::RuboCop::Cop +---- + +[#layoutspacearoundoperators] +== Layout/SpaceAroundOperators + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks that operators have space around them, except for ** which +should or shouldn't have surrounding space depending on configuration. +It allows vertical alignment consisting of one or more whitespace +around operators. + +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. + +[#examples-layoutspacearoundoperators] +=== Examples + +[source,ruby] +---- +# bad +total = 3*4 +"apple"+"juice" +my_number = 38/4 + +# good +total = 3 * 4 +"apple" + "juice" +my_number = 38 / 4 +---- + +[#allowforalignment_-true-_default_-layoutspacearoundoperators] +==== AllowForAlignment: true (default) + +[source,ruby] +---- +# good +{ + 1 => 2, + 11 => 3 +} +---- + +[#allowforalignment_-false-layoutspacearoundoperators] +==== AllowForAlignment: false + +[source,ruby] +---- +# bad +{ + 1 => 2, + 11 => 3 +} +---- + +[#enforcedstyleforexponentoperator_-no_space-_default_-layoutspacearoundoperators] +==== EnforcedStyleForExponentOperator: no_space (default) + +[source,ruby] +---- +# bad +a ** b + +# good +a**b +---- + +[#enforcedstyleforexponentoperator_-space-layoutspacearoundoperators] +==== EnforcedStyleForExponentOperator: space + +[source,ruby] +---- +# bad +a**b + +# good +a ** b +---- + +[#enforcedstyleforrationalliterals_-no_space-_default_-layoutspacearoundoperators] +==== EnforcedStyleForRationalLiterals: no_space (default) + +[source,ruby] +---- +# bad +1 / 48r + +# good +1/48r +---- + +[#enforcedstyleforrationalliterals_-space-layoutspacearoundoperators] +==== EnforcedStyleForRationalLiterals: space + +[source,ruby] +---- +# bad +1/48r + +# good +1 / 48r +---- + +[#configurable-attributes-layoutspacearoundoperators] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowForAlignment +| `true` +| Boolean + +| EnforcedStyleForExponentOperator +| `no_space` +| `space`, `no_space` + +| EnforcedStyleForRationalLiterals +| `no_space` +| `space`, `no_space` +|=== + +[#references-layoutspacearoundoperators] +=== References + +* https://rubystyle.guide#spaces-operators + +[#layoutspacebeforeblockbraces] +== Layout/SpaceBeforeBlockBraces + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 0.52 +|=== + +Checks that block braces have or don't have a space before the opening +brace depending on configuration. + +[#examples-layoutspacebeforeblockbraces] +=== Examples + +[#enforcedstyle_-space-_default_-layoutspacebeforeblockbraces] +==== EnforcedStyle: space (default) + +[source,ruby] +---- +# bad +foo.map{ |a| + a.bar.to_s +} + +# good +foo.map { |a| + a.bar.to_s +} +---- + +[#enforcedstyle_-no_space-layoutspacebeforeblockbraces] +==== EnforcedStyle: no_space + +[source,ruby] +---- +# bad +foo.map { |a| + a.bar.to_s +} + +# good +foo.map{ |a| + a.bar.to_s +} +---- + +[#enforcedstyleforemptybraces_-space-_default_-layoutspacebeforeblockbraces] +==== EnforcedStyleForEmptyBraces: space (default) + +[source,ruby] +---- +# bad +7.times{} + +# good +7.times {} +---- + +[#enforcedstyleforemptybraces_-no_space-layoutspacebeforeblockbraces] +==== EnforcedStyleForEmptyBraces: no_space + +[source,ruby] +---- +# bad +7.times {} + +# good +7.times{} +---- + +[#configurable-attributes-layoutspacebeforeblockbraces] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `space` +| `space`, `no_space` + +| EnforcedStyleForEmptyBraces +| `space` +| `space`, `no_space` +|=== + +[#layoutspacebeforebrackets] +== Layout/SpaceBeforeBrackets + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.7 +| - +|=== + +Checks for space between the name of a receiver and a left +brackets. + +[#examples-layoutspacebeforebrackets] +=== Examples + +[source,ruby] +---- +# bad +collection [index_or_key] + +# good +collection[index_or_key] +---- + +[#references-layoutspacebeforebrackets] +=== References + +* https://rubystyle.guide#space-in-brackets-access + +[#layoutspacebeforecomma] +== Layout/SpaceBeforeComma + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for comma (`,`) preceded by space. + +[#examples-layoutspacebeforecomma] +=== Examples + +[source,ruby] +---- +# bad +[1 , 2 , 3] +a(1 , 2) +each { |a , b| } + +# good +[1, 2, 3] +a(1, 2) +each { |a, b| } +---- + +[#layoutspacebeforecomment] +== Layout/SpaceBeforeComment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for missing space between a token and a comment on the +same line. + +[#examples-layoutspacebeforecomment] +=== Examples + +[source,ruby] +---- +# bad +1 + 1# this operation does ... + +# good +1 + 1 # this operation does ... +---- + +[#layoutspacebeforefirstarg] +== Layout/SpaceBeforeFirstArg + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks that exactly one space is used between a method name and the +first argument for method calls without parentheses. + +Alternatively, extra spaces can be added to align the argument with +something on a preceding or following line, if the AllowForAlignment +config parameter is true. + +[#examples-layoutspacebeforefirstarg] +=== Examples + +[source,ruby] +---- +# bad +something x +something y, z +something'hello' + +# good +something x +something y, z +something 'hello' +---- + +[#configurable-attributes-layoutspacebeforefirstarg] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowForAlignment +| `true` +| Boolean +|=== + +[#layoutspacebeforesemicolon] +== Layout/SpaceBeforeSemicolon + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for semicolon (`;`) preceded by space. + +[#examples-layoutspacebeforesemicolon] +=== Examples + +[source,ruby] +---- +# bad +x = 1 ; y = 2 + +# good +x = 1; y = 2 +---- + +[#layoutspaceinlambdaliteral] +== Layout/SpaceInLambdaLiteral + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for spaces between `->` and opening parameter +parenthesis (`(`) in lambda literals. + +[#examples-layoutspaceinlambdaliteral] +=== Examples + +[#enforcedstyle_-require_no_space-_default_-layoutspaceinlambdaliteral] +==== EnforcedStyle: require_no_space (default) + +[source,ruby] +---- +# bad +a = -> (x, y) { x + y } + +# good +a = ->(x, y) { x + y } +---- + +[#enforcedstyle_-require_space-layoutspaceinlambdaliteral] +==== EnforcedStyle: require_space + +[source,ruby] +---- +# bad +a = ->(x, y) { x + y } + +# good +a = -> (x, y) { x + y } +---- + +[#configurable-attributes-layoutspaceinlambdaliteral] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `require_no_space` +| `require_no_space`, `require_space` +|=== + +[#layoutspaceinsidearrayliteralbrackets] +== Layout/SpaceInsideArrayLiteralBrackets + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.52 +| - +|=== + +Checks that brackets used for array literals have or don't have +surrounding space depending on configuration. + +Array pattern matching is handled in the same way. + +[#examples-layoutspaceinsidearrayliteralbrackets] +=== Examples + +[#enforcedstyle_-no_space-_default_-layoutspaceinsidearrayliteralbrackets] +==== EnforcedStyle: no_space (default) + +[source,ruby] +---- +# The `no_space` style enforces that array literals have +# no surrounding space. + +# bad +array = [ a, b, c, d ] +array = [ a, [ b, c ]] + +# good +array = [a, b, c, d] +array = [a, [b, c]] +---- + +[#enforcedstyle_-space-layoutspaceinsidearrayliteralbrackets] +==== EnforcedStyle: space + +[source,ruby] +---- +# The `space` style enforces that array literals have +# surrounding space. + +# bad +array = [a, b, c, d] +array = [ a, [ b, c ]] + +# good +array = [ a, b, c, d ] +array = [ a, [ b, c ] ] +---- + +[#enforcedstyle_-compact-layoutspaceinsidearrayliteralbrackets] +==== EnforcedStyle: compact + +[source,ruby] +---- +# The `compact` style normally requires a space inside +# array brackets, with the exception that successive left +# or right brackets are collapsed together in nested arrays. + +# bad +array = [a, b, c, d] +array = [ a, [ b, c ] ] +array = [ + [ a ], + [ b, c ] +] + +# good +array = [ a, b, c, d ] +array = [ a, [ b, c ]] +array = [[ a ], + [ b, c ]] +---- + +[#enforcedstyleforemptybrackets_-no_space-_default_-layoutspaceinsidearrayliteralbrackets] +==== EnforcedStyleForEmptyBrackets: no_space (default) + +[source,ruby] +---- +# The `no_space` EnforcedStyleForEmptyBrackets style enforces that +# empty array brackets do not contain spaces. + +# bad +foo = [ ] +bar = [ ] + +# good +foo = [] +bar = [] +---- + +[#enforcedstyleforemptybrackets_-space-layoutspaceinsidearrayliteralbrackets] +==== EnforcedStyleForEmptyBrackets: space + +[source,ruby] +---- +# The `space` EnforcedStyleForEmptyBrackets style enforces that +# empty array brackets contain exactly one space. + +# bad +foo = [] +bar = [ ] + +# good +foo = [ ] +bar = [ ] +---- + +[#configurable-attributes-layoutspaceinsidearrayliteralbrackets] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `no_space` +| `space`, `no_space`, `compact` + +| EnforcedStyleForEmptyBrackets +| `no_space` +| `space`, `no_space` +|=== + +[#layoutspaceinsidearraypercentliteral] +== Layout/SpaceInsideArrayPercentLiteral + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for unnecessary additional spaces inside array percent literals +(i.e. %i/%w). + +Note that blank percent literals (e.g. `%i( )`) are checked by +`Layout/SpaceInsidePercentLiteralDelimiters`. + +[#examples-layoutspaceinsidearraypercentliteral] +=== Examples + +[source,ruby] +---- +# bad +%w(foo bar baz) +# good +%i(foo bar baz) +---- + +[#layoutspaceinsideblockbraces] +== Layout/SpaceInsideBlockBraces + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks that block braces have or don't have surrounding space inside +them on configuration. For blocks taking parameters, it checks that the +left brace has or doesn't have trailing space depending on +configuration. + +[#examples-layoutspaceinsideblockbraces] +=== Examples + +[#enforcedstyle_-space-_default_-layoutspaceinsideblockbraces] +==== EnforcedStyle: space (default) + +[source,ruby] +---- +# The `space` style enforces that block braces have +# surrounding space. + +# bad +some_array.each {puts e} + +# good +some_array.each { puts e } +---- + +[#enforcedstyle_-no_space-layoutspaceinsideblockbraces] +==== EnforcedStyle: no_space + +[source,ruby] +---- +# The `no_space` style enforces that block braces don't +# have surrounding space. + +# bad +some_array.each { puts e } + +# good +some_array.each {puts e} +---- + +[#enforcedstyleforemptybraces_-no_space-_default_-layoutspaceinsideblockbraces] +==== EnforcedStyleForEmptyBraces: no_space (default) + +[source,ruby] +---- +# The `no_space` EnforcedStyleForEmptyBraces style enforces that +# block braces don't have a space in between when empty. + +# bad +some_array.each { } +some_array.each { } +some_array.each { } + +# good +some_array.each {} +---- + +[#enforcedstyleforemptybraces_-space-layoutspaceinsideblockbraces] +==== EnforcedStyleForEmptyBraces: space + +[source,ruby] +---- +# The `space` EnforcedStyleForEmptyBraces style enforces that +# block braces have at least a space in between when empty. + +# bad +some_array.each {} + +# good +some_array.each { } +some_array.each { } +some_array.each { } +---- + +[#spacebeforeblockparameters_-true-_default_-layoutspaceinsideblockbraces] +==== SpaceBeforeBlockParameters: true (default) + +[source,ruby] +---- +# The SpaceBeforeBlockParameters style set to `true` enforces that +# there is a space between `{` and `|`. Overrides `EnforcedStyle` +# if there is a conflict. + +# bad +[1, 2, 3].each {|n| n * 2 } + +# good +[1, 2, 3].each { |n| n * 2 } +---- + +[#spacebeforeblockparameters_-false-layoutspaceinsideblockbraces] +==== SpaceBeforeBlockParameters: false + +[source,ruby] +---- +# The SpaceBeforeBlockParameters style set to `false` enforces that +# there is no space between `{` and `|`. Overrides `EnforcedStyle` +# if there is a conflict. + +# bad +[1, 2, 3].each { |n| n * 2 } + +# good +[1, 2, 3].each {|n| n * 2 } +---- + +[#configurable-attributes-layoutspaceinsideblockbraces] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `space` +| `space`, `no_space` + +| EnforcedStyleForEmptyBraces +| `no_space` +| `space`, `no_space` + +| SpaceBeforeBlockParameters +| `true` +| Boolean +|=== + +[#layoutspaceinsidehashliteralbraces] +== Layout/SpaceInsideHashLiteralBraces + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks that braces used for hash literals have or don't have +surrounding space depending on configuration. + +Hash pattern matching is handled in the same way. + +[#examples-layoutspaceinsidehashliteralbraces] +=== Examples + +[#enforcedstyle_-space-_default_-layoutspaceinsidehashliteralbraces] +==== EnforcedStyle: space (default) + +[source,ruby] +---- +# The `space` style enforces that hash literals have +# surrounding space. + +# bad +h = {a: 1, b: 2} +foo = {{ a: 1 } => { b: { c: 2 }}} + +# good +h = { a: 1, b: 2 } +foo = { { a: 1 } => { b: { c: 2 } } } +---- + +[#enforcedstyle_-no_space-layoutspaceinsidehashliteralbraces] +==== EnforcedStyle: no_space + +[source,ruby] +---- +# The `no_space` style enforces that hash literals have +# no surrounding space. + +# bad +h = { a: 1, b: 2 } +foo = {{ a: 1 } => { b: { c: 2 }}} + +# good +h = {a: 1, b: 2} +foo = {{a: 1} => {b: {c: 2}}} +---- + +[#enforcedstyle_-compact-layoutspaceinsidehashliteralbraces] +==== EnforcedStyle: compact + +[source,ruby] +---- +# The `compact` style normally requires a space inside +# hash braces, with the exception that successive left +# braces or right braces are collapsed together in nested hashes. + +# bad +h = { a: { b: 2 } } +foo = { { a: 1 } => { b: { c: 2 } } } + +# good +h = { a: { b: 2 }} +foo = {{ a: 1 } => { b: { c: 2 }}} +---- + +[#enforcedstyleforemptybraces_-no_space-_default_-layoutspaceinsidehashliteralbraces] +==== EnforcedStyleForEmptyBraces: no_space (default) + +[source,ruby] +---- +# The `no_space` EnforcedStyleForEmptyBraces style enforces that +# empty hash braces do not contain spaces. + +# bad +foo = { } +bar = { } +baz = { +} + +# good +foo = {} +bar = {} +baz = {} +---- + +[#enforcedstyleforemptybraces_-space-layoutspaceinsidehashliteralbraces] +==== EnforcedStyleForEmptyBraces: space + +[source,ruby] +---- +# The `space` EnforcedStyleForEmptyBraces style enforces that +# empty hash braces contain space. + +# bad +foo = {} + +# good +foo = { } +foo = { } +foo = { +} +---- + +[#configurable-attributes-layoutspaceinsidehashliteralbraces] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `space` +| `space`, `no_space`, `compact` + +| EnforcedStyleForEmptyBraces +| `no_space` +| `space`, `no_space` +|=== + +[#references-layoutspaceinsidehashliteralbraces] +=== References + +* https://rubystyle.guide#spaces-braces + +[#layoutspaceinsideparens] +== Layout/SpaceInsideParens + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 1.22 +|=== + +Checks for spaces inside ordinary round parentheses. + +[#examples-layoutspaceinsideparens] +=== Examples + +[#enforcedstyle_-no_space-_default_-layoutspaceinsideparens] +==== EnforcedStyle: no_space (default) + +[source,ruby] +---- +# The `no_space` style enforces that parentheses do not have spaces. + +# bad +f( 3) +g = (a + 3 ) +f( ) + +# good +f(3) +g = (a + 3) +f() +---- + +[#enforcedstyle_-space-layoutspaceinsideparens] +==== EnforcedStyle: space + +[source,ruby] +---- +# The `space` style enforces that parentheses have a space at the +# beginning and end. +# Note: Empty parentheses should not have spaces. + +# bad +f(3) +g = (a + 3) +y( ) + +# good +f( 3 ) +g = ( a + 3 ) +y() +---- + +[#enforcedstyle_-compact-layoutspaceinsideparens] +==== EnforcedStyle: compact + +[source,ruby] +---- +# The `compact` style enforces that parentheses have a space at the +# beginning with the exception that successive parentheses are allowed. +# Note: Empty parentheses should not have spaces. + +# bad +f(3) +g = (a + 3) +y( ) +g( f( x ) ) +g( f( x( 3 ) ), 5 ) +g( ( ( 3 + 5 ) * f) ** x, 5 ) + +# good +f( 3 ) +g = ( a + 3 ) +y() +g( f( x )) +g( f( x( 3 )), 5 ) +g((( 3 + 5 ) * f ) ** x, 5 ) +---- + +[#configurable-attributes-layoutspaceinsideparens] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `no_space` +| `space`, `compact`, `no_space` +|=== + +[#references-layoutspaceinsideparens] +=== References + +* https://rubystyle.guide#spaces-braces + +[#layoutspaceinsidepercentliteraldelimiters] +== Layout/SpaceInsidePercentLiteralDelimiters + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for unnecessary additional spaces inside the delimiters of +%i/%w/%x literals. + +[#examples-layoutspaceinsidepercentliteraldelimiters] +=== Examples + +[source,ruby] +---- +# bad +%i( foo bar baz ) + +# good +%i(foo bar baz) + +# bad +%w( foo bar baz ) + +# good +%w(foo bar baz) + +# bad +%x( ls -l ) + +# good +%x(ls -l) + +# bad +%w( ) +%w( +) + +# good +%w() +---- + +[#layoutspaceinsiderangeliteral] +== Layout/SpaceInsideRangeLiteral + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for spaces inside range literals. + +[#examples-layoutspaceinsiderangeliteral] +=== Examples + +[source,ruby] +---- +# bad +1 .. 3 + +# good +1..3 + +# bad +'a' .. 'z' + +# good +'a'..'z' +---- + +[#references-layoutspaceinsiderangeliteral] +=== References + +* https://rubystyle.guide#no-space-inside-range-literals + +[#layoutspaceinsidereferencebrackets] +== Layout/SpaceInsideReferenceBrackets + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.52 +| 0.53 +|=== + +Checks that reference brackets have or don't have +surrounding space depending on configuration. + +[#examples-layoutspaceinsidereferencebrackets] +=== Examples + +[#enforcedstyle_-no_space-_default_-layoutspaceinsidereferencebrackets] +==== EnforcedStyle: no_space (default) + +[source,ruby] +---- +# The `no_space` style enforces that reference brackets have +# no surrounding space. + +# bad +hash[ :key ] +array[ index ] + +# good +hash[:key] +array[index] +---- + +[#enforcedstyle_-space-layoutspaceinsidereferencebrackets] +==== EnforcedStyle: space + +[source,ruby] +---- +# The `space` style enforces that reference brackets have +# surrounding space. + +# bad +hash[:key] +array[index] + +# good +hash[ :key ] +array[ index ] +---- + +[#enforcedstyleforemptybrackets_-no_space-_default_-layoutspaceinsidereferencebrackets] +==== EnforcedStyleForEmptyBrackets: no_space (default) + +[source,ruby] +---- +# The `no_space` EnforcedStyleForEmptyBrackets style enforces that +# empty reference brackets do not contain spaces. + +# bad +foo[ ] +foo[ ] +foo[ +] + +# good +foo[] +---- + +[#enforcedstyleforemptybrackets_-space-layoutspaceinsidereferencebrackets] +==== EnforcedStyleForEmptyBrackets: space + +[source,ruby] +---- +# The `space` EnforcedStyleForEmptyBrackets style enforces that +# empty reference brackets contain exactly one space. + +# bad +foo[] +foo[ ] +foo[ +] + +# good +foo[ ] +---- + +[#configurable-attributes-layoutspaceinsidereferencebrackets] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `no_space` +| `space`, `no_space` + +| EnforcedStyleForEmptyBrackets +| `no_space` +| `space`, `no_space` +|=== + +[#layoutspaceinsidestringinterpolation] +== Layout/SpaceInsideStringInterpolation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for whitespace within string interpolations. + +[#examples-layoutspaceinsidestringinterpolation] +=== Examples + +[#enforcedstyle_-no_space-_default_-layoutspaceinsidestringinterpolation] +==== EnforcedStyle: no_space (default) + +[source,ruby] +---- +# bad + var = "This is the #{ space } example" + +# good + var = "This is the #{no_space} example" +---- + +[#enforcedstyle_-space-layoutspaceinsidestringinterpolation] +==== EnforcedStyle: space + +[source,ruby] +---- +# bad + var = "This is the #{no_space} example" + +# good + var = "This is the #{ space } example" +---- + +[#configurable-attributes-layoutspaceinsidestringinterpolation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `no_space` +| `space`, `no_space` +|=== + +[#references-layoutspaceinsidestringinterpolation] +=== References + +* https://rubystyle.guide#string-interpolation + +[#layouttrailingemptylines] +== Layout/TrailingEmptyLines + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 0.77 +|=== + +Looks for trailing blank lines and a final newline in the +source code. + +[#examples-layouttrailingemptylines] +=== Examples + +[#enforcedstyle_-final_newline-_default_-layouttrailingemptylines] +==== EnforcedStyle: final_newline (default) + +[source,ruby] +---- +# `final_newline` looks for one newline at the end of files. + +# bad +class Foo; end + +# EOF + +# bad +class Foo; end # EOF + +# good +class Foo; end +# EOF +---- + +[#enforcedstyle_-final_blank_line-layouttrailingemptylines] +==== EnforcedStyle: final_blank_line + +[source,ruby] +---- +# `final_blank_line` looks for one blank line followed by a new line +# at the end of files. + +# bad +class Foo; end +# EOF + +# bad +class Foo; end # EOF + +# good +class Foo; end + +# EOF +---- + +[#configurable-attributes-layouttrailingemptylines] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `final_newline` +| `final_newline`, `final_blank_line` +|=== + +[#references-layouttrailingemptylines] +=== References + +* https://rubystyle.guide#newline-eof + +[#layouttrailingwhitespace] +== Layout/TrailingWhitespace + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 1.0 +|=== + +Looks for trailing whitespace in the source code. + +[#examples-layouttrailingwhitespace] +=== Examples + +[source,ruby] +---- +# The line in this example contains spaces after the 0. +# bad +x = 0 + +# The line in this example ends directly after the 0. +# good +x = 0 +---- + +[#allowinheredoc_-false-_default_-layouttrailingwhitespace] +==== AllowInHeredoc: false (default) + +[source,ruby] +---- +# The line in this example contains spaces after the 0. +# bad +code = <<~RUBY + x = 0 +RUBY + +# ok +code = <<~RUBY + x = 0 #{} +RUBY + +# good +trailing_whitespace = ' ' +code = <<~RUBY + x = 0#{trailing_whitespace} +RUBY +---- + +[#allowinheredoc_-true-layouttrailingwhitespace] +==== AllowInHeredoc: true + +[source,ruby] +---- +# The line in this example contains spaces after the 0. +# good +code = <<~RUBY + x = 0 +RUBY +---- + +[#configurable-attributes-layouttrailingwhitespace] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowInHeredoc +| `false` +| Boolean +|=== + +[#references-layouttrailingwhitespace] +=== References + +* https://rubystyle.guide#no-trailing-whitespace + +include::../partials/cops_layout_footer.adoc[] diff --git a/docs/modules/ROOT/pages/cops_lint.adoc b/docs/modules/ROOT/pages/cops_lint.adoc new file mode 100644 index 000000000000..8916b7463832 --- /dev/null +++ b/docs/modules/ROOT/pages/cops_lint.adoc @@ -0,0 +1,9017 @@ +//// + Do NOT edit this file by hand directly, as it is automatically generated. + + Please make any necessary changes to the cop documentation within the source files themselves. +//// + += Lint + +[#lintambiguousassignment] +== Lint/AmbiguousAssignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.7 +| - +|=== + +Checks for mistyped shorthand assignments. + +[#examples-lintambiguousassignment] +=== Examples + +[source,ruby] +---- +# bad +x =- y +x =+ y +x =* y +x =! y + +# good +x -= y # or x = -y +x += y # or x = +y +x *= y # or x = *y +x != y # or x = !y +---- + +[#lintambiguousblockassociation] +== Lint/AmbiguousBlockAssociation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.48 +| 1.13 +|=== + +Checks for ambiguous block association with method +when param passed without parentheses. + +This cop can customize allowed methods with `AllowedMethods`. +By default, there are no methods to allowed. + +[#examples-lintambiguousblockassociation] +=== Examples + +[source,ruby] +---- +# bad +some_method a { |val| puts val } + +# good +# With parentheses, there's no ambiguity. +some_method(a { |val| puts val }) +# or (different meaning) +some_method(a) { |val| puts val } + +# good +# Operator methods require no disambiguation +foo == bar { |b| b.baz } + +# good +# Lambda arguments require no disambiguation +foo = ->(bar) { bar.baz } +---- + +[#allowedmethods_-__-_default_-lintambiguousblockassociation] +==== AllowedMethods: [] (default) + +[source,ruby] +---- +# bad +expect { do_something }.to change { object.attribute } +---- + +[#allowedmethods_-_change_-lintambiguousblockassociation] +==== AllowedMethods: [change] + +[source,ruby] +---- +# good +expect { do_something }.to change { object.attribute } +---- + +[#allowedpatterns_-__-_default_-lintambiguousblockassociation] +==== AllowedPatterns: [] (default) + +[source,ruby] +---- +# bad +expect { do_something }.to change { object.attribute } +---- + +[#allowedpatterns_-__change__-lintambiguousblockassociation] +==== AllowedPatterns: ['change'] + +[source,ruby] +---- +# good +expect { do_something }.to change { object.attribute } +expect { do_something }.to not_change { object.attribute } +---- + +[#configurable-attributes-lintambiguousblockassociation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedMethods +| `[]` +| Array + +| AllowedPatterns +| `[]` +| Array +|=== + +[#lintambiguousoperator] +== Lint/AmbiguousOperator + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.17 +| 0.83 +|=== + +Checks for ambiguous operators in the first argument of a +method invocation without parentheses. + +[#examples-lintambiguousoperator] +=== Examples + +[source,ruby] +---- +# bad + +# The `*` is interpreted as a splat operator but it could possibly be +# a `*` method invocation (i.e. `do_something.*(some_array)`). +do_something *some_array + +# good + +# With parentheses, there's no ambiguity. +do_something(*some_array) +---- + +[#references-lintambiguousoperator] +=== References + +* https://rubystyle.guide#method-invocation-parens + +[#lintambiguousoperatorprecedence] +== Lint/AmbiguousOperatorPrecedence + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.21 +| - +|=== + +Looks for expressions containing multiple binary operators +where precedence is ambiguous due to lack of parentheses. For example, +in `1 + 2 * 3`, the multiplication will happen before the addition, but +lexically it appears that the addition will happen first. + +The cop does not consider unary operators (ie. `!a` or `-b`) or comparison +operators (ie. `a =~ b`) because those are not ambiguous. + +NOTE: Ranges are handled by `Lint/AmbiguousRange`. + +[#examples-lintambiguousoperatorprecedence] +=== Examples + +[source,ruby] +---- +# bad +a + b * c +a || b && c +a ** b + c + +# good (different precedence) +a + (b * c) +a || (b && c) +(a ** b) + c + +# good (same precedence) +a + b + c +a * b / c % d +---- + +[#lintambiguousrange] +== Lint/AmbiguousRange + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always (Unsafe) +| 1.19 +| - +|=== + +Checks for ambiguous ranges. + +Ranges have quite low precedence, which leads to unexpected behavior when +using a range with other operators. This cop avoids that by making ranges +explicit by requiring parenthesis around complex range boundaries (anything +that is not a literal: numerics, strings, symbols, etc.). + +This cop can be configured with `RequireParenthesesForMethodChains` in order to +specify whether method chains (including `self.foo`) should be wrapped in parens +by this cop. + +NOTE: Regardless of this configuration, if a method receiver is a basic literal +value, it will be wrapped in order to prevent the ambiguity of `1..2.to_a`. + +[#safety-lintambiguousrange] +=== Safety + +The cop autocorrects by wrapping the entire boundary in parentheses, which +makes the outcome more explicit but is possible to not be the intention of the +programmer. For this reason, this cop's autocorrect is unsafe (it will not +change the behavior of the code, but will not necessarily match the +intent of the program). + +[#examples-lintambiguousrange] +=== Examples + +[source,ruby] +---- +# bad +x || 1..2 +x - 1..2 +(x || 1..2) +x || 1..y || 2 +1..2.to_a + +# good, unambiguous +1..2 +'a'..'z' +:bar..:baz +MyClass::MIN..MyClass::MAX +@min..@max +a..b +-a..b + +# good, ambiguity removed +x || (1..2) +(x - 1)..2 +(x || 1)..2 +(x || 1)..(y || 2) +(1..2).to_a +---- + +[#requireparenthesesformethodchains_-false-_default_-lintambiguousrange] +==== RequireParenthesesForMethodChains: false (default) + +[source,ruby] +---- +# good +a.foo..b.bar +(a.foo)..(b.bar) +---- + +[#requireparenthesesformethodchains_-true-lintambiguousrange] +==== RequireParenthesesForMethodChains: true + +[source,ruby] +---- +# bad +a.foo..b.bar + +# good +(a.foo)..(b.bar) +---- + +[#configurable-attributes-lintambiguousrange] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| RequireParenthesesForMethodChains +| `false` +| Boolean +|=== + +[#lintambiguousregexpliteral] +== Lint/AmbiguousRegexpLiteral + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.17 +| 0.83 +|=== + +Checks for ambiguous regexp literals in the first argument of +a method invocation without parentheses. + +[#examples-lintambiguousregexpliteral] +=== Examples + +[source,ruby] +---- +# bad + +# This is interpreted as a method invocation with a regexp literal, +# but it could possibly be `/` method invocations. +# (i.e. `do_something./(pattern)./(i)`) +do_something /pattern/i + +# good + +# With parentheses, there's no ambiguity. +do_something(/pattern/i) +---- + +[#lintarrayliteralinregexp] +== Lint/ArrayLiteralInRegexp + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always (Unsafe) +| 1.71 +| - +|=== + +Checks for an array literal interpolated inside a regexp. + +When interpolating an array literal, it is converted to a string. This means +that when inside a regexp, it acts as a character class but with additional +quotes, spaces and commas that are likely not intended. For example, +`/#{%w[a b c]}/` parses as `/["a", "b", "c"]/` (or `/["a, bc]/` without +repeated characters). + +The cop can autocorrect to a character class (if all items in the array are a +single character) or alternation (if the array contains longer items). + +NOTE: This only considers interpolated arrays that contain only strings, symbols, +integers, and floats. Any other type is not easily convertible to a character class +or regexp alternation. + +[#safety-lintarrayliteralinregexp] +=== Safety + +Autocorrection is unsafe because it will change the regexp pattern, by +removing the additional quotes, spaces and commas from the character class. + +[#examples-lintarrayliteralinregexp] +=== Examples + +[source,ruby] +---- +# bad +/#{%w[a b c]}/ + +# good +/[abc]/ + +# bad +/#{%w[foo bar baz]}/ + +# good +/(?:foo|bar|baz)/ + +# bad - construct a regexp rather than interpolate an array of identifiers +/#{[foo, bar]}/ +---- + +[#lintassignmentincondition] +== Lint/AssignmentInCondition + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always (Unsafe) +| 0.9 +| 1.45 +|=== + +Checks for assignments in the conditions of +if/while/until. + +`AllowSafeAssignment` option for safe assignment. +By safe assignment we mean putting parentheses around +an assignment to indicate "I know I'm using an assignment +as a condition. It's not a mistake." + +[#safety-lintassignmentincondition] +=== Safety + +This cop's autocorrection is unsafe because it assumes that +the author meant to use an assignment result as a condition. + +[#examples-lintassignmentincondition] +=== Examples + +[source,ruby] +---- +# bad +if some_var = value + do_something +end + +# good +if some_var == value + do_something +end +---- + +[#allowsafeassignment_-true-_default_-lintassignmentincondition] +==== AllowSafeAssignment: true (default) + +[source,ruby] +---- +# good +if (some_var = value) + do_something +end +---- + +[#allowsafeassignment_-false-lintassignmentincondition] +==== AllowSafeAssignment: false + +[source,ruby] +---- +# bad +if (some_var = value) + do_something +end +---- + +[#configurable-attributes-lintassignmentincondition] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowSafeAssignment +| `true` +| Boolean +|=== + +[#references-lintassignmentincondition] +=== References + +* https://rubystyle.guide#safe-assignment-in-condition + +[#lintbigdecimalnew] +== Lint/BigDecimalNew + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.53 +| - +|=== + +`BigDecimal.new()` is deprecated since BigDecimal 1.3.3. +This cop identifies places where `BigDecimal.new()` +can be replaced by `BigDecimal()`. + +[#examples-lintbigdecimalnew] +=== Examples + +[source,ruby] +---- +# bad +BigDecimal.new(123.456, 3) + +# good +BigDecimal(123.456, 3) +---- + +[#lintbinaryoperatorwithidenticaloperands] +== Lint/BinaryOperatorWithIdenticalOperands + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| No +| 0.89 +| 1.69 +|=== + +Checks for places where binary operator has identical operands. + +It covers comparison operators: `==`, `===`, `=~`, `>`, `>=`, `<`, ``<=``; +bitwise operators: `|`, `^`, `&`; +boolean operators: `&&`, `||` +and "spaceship" operator - ``<=>``. + +Simple arithmetic operations are allowed by this cop: `+`, `*`, `**`, `<<` and `>>`. +Although these can be rewritten in a different way, it should not be necessary to +do so. Operations such as `-` or `/` where the result will always be the same +(`x - x` will always be 0; `x / x` will always be 1) are offenses, but these +are covered by `Lint/NumericOperationWithConstantResult` instead. + +[#safety-lintbinaryoperatorwithidenticaloperands] +=== Safety + +This cop is unsafe as it does not consider side effects when calling methods +and thus can generate false positives, for example: + +[source,ruby] +---- +if wr.take_char == '\0' && wr.take_char == '\0' + # ... +end +---- + +[#examples-lintbinaryoperatorwithidenticaloperands] +=== Examples + +[source,ruby] +---- +# bad +x.top >= x.top + +if a.x != 0 && a.x != 0 + do_something +end + +def child? + left_child || left_child +end + +# good +x + x +1 << 1 +---- + +[#lintbooleansymbol] +== Lint/BooleanSymbol + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always (Unsafe) +| 0.50 +| 1.22 +|=== + +Checks for `:true` and `:false` symbols. +In most cases it would be a typo. + +[#safety-lintbooleansymbol] +=== Safety + +Autocorrection is unsafe for this cop because code relying +on `:true` or `:false` symbols will break when those are +changed to actual booleans. + +[#examples-lintbooleansymbol] +=== Examples + +[source,ruby] +---- +# bad +:true + +# good +true + +# bad +:false + +# good +false +---- + +[#lintcircularargumentreference] +== Lint/CircularArgumentReference + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.33 +| - +|=== + +Checks for circular argument references in optional keyword +arguments and optional ordinal arguments. + +NOTE: This syntax was made invalid on Ruby 2.7 - Ruby 3.3 but is allowed +again since Ruby 3.4. + +[#examples-lintcircularargumentreference] +=== Examples + +[source,ruby] +---- +# bad +def bake(pie: pie) + pie.heat_up +end + +# good +def bake(pie:) + pie.refrigerate +end + +# good +def bake(pie: self.pie) + pie.feed_to(user) +end + +# bad +def cook(dry_ingredients = dry_ingredients) + dry_ingredients.reduce(&:+) +end + +# good +def cook(dry_ingredients = self.dry_ingredients) + dry_ingredients.combine +end +---- + +[#lintconstantdefinitioninblock] +== Lint/ConstantDefinitionInBlock + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.91 +| 1.3 +|=== + +Do not define constants within a block, since the block's scope does not +isolate or namespace the constant in any way. + +If you are trying to define that constant once, define it outside of +the block instead, or use a variable or method if defining the constant +in the outer scope would be problematic. + +For meta-programming, use `const_set`. + +[#examples-lintconstantdefinitioninblock] +=== Examples + +[source,ruby] +---- +# bad +task :lint do + FILES_TO_LINT = Dir['lib/*.rb'] +end + +# bad +describe 'making a request' do + class TestRequest; end +end + +# bad +module M + extend ActiveSupport::Concern + included do + LIST = [] + end +end + +# good +task :lint do + files_to_lint = Dir['lib/*.rb'] +end + +# good +describe 'making a request' do + let(:test_request) { Class.new } + # see also `stub_const` for RSpec +end + +# good +module M + extend ActiveSupport::Concern + included do + const_set(:LIST, []) + end +end +---- + +[#allowedmethods_-__enums__-_default_-lintconstantdefinitioninblock] +==== AllowedMethods: ['enums'] (default) + +[source,ruby] +---- +# good + +# `enums` for Typed Enums via `T::Enum` in Sorbet. +# https://sorbet.org/docs/tenum +class TestEnum < T::Enum + enums do + Foo = new("foo") + end +end +---- + +[#configurable-attributes-lintconstantdefinitioninblock] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedMethods +| `enums` +| Array +|=== + +[#references-lintconstantdefinitioninblock] +=== References + +* https://rubystyle.guide#no-constant-definition-in-block + +[#lintconstantoverwritteninrescue] +== Lint/ConstantOverwrittenInRescue + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.31 +| - +|=== + +Checks for overwriting an exception with an exception result by use ``rescue =>``. + +You intended to write as `rescue StandardError`. +However, you have written `rescue => StandardError`. +In that case, the result of `rescue` will overwrite `StandardError`. + +[#examples-lintconstantoverwritteninrescue] +=== Examples + +[source,ruby] +---- +# bad +begin + something +rescue => StandardError +end + +# good +begin + something +rescue StandardError +end +---- + +[#lintconstantreassignment] +== Lint/ConstantReassignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.70 +| - +|=== + +Checks for constant reassignments. + +Emulates Ruby's runtime warning "already initialized constant X" +when a constant is reassigned in the same file and namespace using the +`NAME = value` syntax. + +The cop cannot catch all offenses, like, for example, when a constant +is reassigned in another file, or when using metaprogramming (`Module#const_set`). + +The cop only takes into account constants assigned in a "simple" way: directly +inside class/module definition, or within another constant. Other type of assignments +(e.g., inside a conditional) are disregarded. + +The cop also tracks constant removal using `Module#remove_const` with symbol +or string argument. + +[#examples-lintconstantreassignment] +=== Examples + +[source,ruby] +---- +# bad +X = :foo +X = :bar + +# bad +class A + X = :foo + X = :bar +end + +# bad +module A + X = :foo + X = :bar +end + +# good - keep only one assignment +X = :bar + +class A + X = :bar +end + +module A + X = :bar +end + +# good - use OR assignment +X = :foo +X ||= :bar + +# good - use conditional assignment +X = :foo +X = :bar unless defined?(X) + +# good - remove the assigned constant first +class A + X = :foo + remove_const :X + X = :bar +end +---- + +[#lintconstantresolution] +== Lint/ConstantResolution + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| No +| 0.86 +| - +|=== + +Check that certain constants are fully qualified. + +This is not enabled by default because it would mark a lot of offenses +unnecessarily. + +Generally, gems should fully qualify all constants to avoid conflicts with +the code that uses the gem. Enable this cop without using `Only`/`Ignore` + +Large projects will over time end up with one or two constant names that +are problematic because of a conflict with a library or just internally +using the same name a namespace and a class. To avoid too many unnecessary +offenses, Enable this cop with `Only: [The, Constant, Names, Causing, Issues]` + +NOTE: `Style/RedundantConstantBase` cop is disabled if this cop is enabled to prevent +conflicting rules. Because it respects user configurations that want to enable +this cop which is disabled by default. + +[#examples-lintconstantresolution] +=== Examples + +[source,ruby] +---- +# By default checks every constant + +# bad +User + +# bad +User::Login + +# good +::User + +# good +::User::Login +---- + +[#only_-__login__-lintconstantresolution] +==== Only: ['Login'] + +[source,ruby] +---- +# Restrict this cop to only being concerned about certain constants + +# bad +Login + +# good +::Login + +# good +User::Login +---- + +[#ignore_-__login__-lintconstantresolution] +==== Ignore: ['Login'] + +[source,ruby] +---- +# Restrict this cop not being concerned about certain constants + +# bad +User + +# good +::User::Login + +# good +Login +---- + +[#configurable-attributes-lintconstantresolution] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Only +| `[]` +| Array + +| Ignore +| `[]` +| Array +|=== + +[#lintcopdirectivesyntax] +== Lint/CopDirectiveSyntax + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.72 +| - +|=== + +Checks that `# rubocop:enable ...` and `# rubocop:disable ...` statements +are strictly formatted. + +A comment can be added to the directive by prefixing it with `--`. + +[#examples-lintcopdirectivesyntax] +=== Examples + +[source,ruby] +---- +# bad +# rubocop:disable Layout/LineLength Style/Encoding +# ^ missing comma + +# bad +# rubocop:disable + +# bad +# rubocop:disable Layout/LineLength # rubocop:disable Style/Encoding + +# bad +# rubocop:wrongmode Layout/LineLength + +# good +# rubocop:disable Layout/LineLength + +# good +# rubocop:disable Layout/LineLength, Style/Encoding + +# good +# rubocop:disable all + +# good +# rubocop:disable Layout/LineLength -- This is a good comment. +---- + +[#lintdebugger] +== Lint/Debugger + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.14 +| 1.63 +|=== + +Checks for debug calls (such as `debugger` or `binding.pry`) that should +not be kept for production code. + +The cop can be configured using `DebuggerMethods`. By default, a number of gems +debug entrypoints are configured (`Kernel`, `Byebug`, `Capybara`, `debug.rb`, +`Pry`, `Rails`, `RubyJard`, and `WebConsole`). Additional methods can be added. + +Specific default groups can be disabled if necessary: + +[source,yaml] +---- +Lint/Debugger: + DebuggerMethods: + WebConsole: ~ +---- + +You can also add your own methods by adding a new category: + +[source,yaml] +---- +Lint/Debugger: + DebuggerMethods: + MyDebugger: + MyDebugger.debug_this +---- + +Some gems also ship files that will start a debugging session when required, +for example `require 'debug/start'` from `ruby/debug`. These requires can +be configured through `DebuggerRequires`. It has the same structure as +`DebuggerMethods`, which you can read about above. + +[#examples-lintdebugger] +=== Examples + +[source,ruby] +---- +# bad (ok during development) + +# using pry +def some_method + binding.pry + do_something +end + +# bad (ok during development) + +# using byebug +def some_method + byebug + do_something +end + +# good + +def some_method + do_something +end +---- + +[#debuggermethods_-_my_debugger_-lintdebugger] +==== DebuggerMethods: [my_debugger] + +[source,ruby] +---- +# bad (ok during development) + +def some_method + my_debugger +end +---- + +[#debuggerrequires_-_my_debuggerstart_-lintdebugger] +==== DebuggerRequires: [my_debugger/start] + +[source,ruby] +---- +# bad (ok during development) + +require 'my_debugger/start' +---- + +[#configurable-attributes-lintdebugger] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| DebuggerMethods +| `{"Kernel" => ["binding.irb", "Kernel.binding.irb"], "Byebug" => ["byebug", "remote_byebug", "Kernel.byebug", "Kernel.remote_byebug"], "Capybara" => ["page.save_and_open_page", "page.save_and_open_screenshot", "page.save_page", "page.save_screenshot", "save_and_open_page", "save_and_open_screenshot", "save_page", "save_screenshot"], "debug.rb" => ["binding.b", "binding.break", "Kernel.binding.b", "Kernel.binding.break"], "Pry" => ["binding.pry", "binding.remote_pry", "binding.pry_remote", "Kernel.binding.pry", "Kernel.binding.remote_pry", "Kernel.binding.pry_remote", "Pry.rescue", "pry"], "Rails" => ["debugger", "Kernel.debugger"], "RubyJard" => ["jard"], "WebConsole" => ["binding.console"]}` +| + +| DebuggerRequires +| `{"debug.rb" => ["debug/open", "debug/start"]}` +| +|=== + +[#lintdeprecatedclassmethods] +== Lint/DeprecatedClassMethods + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.19 +| - +|=== + +Checks for uses of the deprecated class method usages. + +[#examples-lintdeprecatedclassmethods] +=== Examples + +[source,ruby] +---- +# bad +File.exists?(some_path) +Dir.exists?(some_path) +iterator? +attr :name, true +attr :name, false +ENV.freeze # Calling `Env.freeze` raises `TypeError` since Ruby 2.7. +ENV.clone +ENV.dup # Calling `Env.dup` raises `TypeError` since Ruby 3.1. +Socket.gethostbyname(host) +Socket.gethostbyaddr(host) + +# good +File.exist?(some_path) +Dir.exist?(some_path) +block_given? +attr_accessor :name +attr_reader :name +ENV # `ENV.freeze` cannot prohibit changes to environment variables. +ENV.to_h +ENV.to_h # `ENV.dup` cannot dup `ENV`, use `ENV.to_h` to get a copy of `ENV` as a hash. +Addrinfo.getaddrinfo(nodename, service) +Addrinfo.tcp(host, port).getnameinfo +---- + +[#lintdeprecatedconstants] +== Lint/DeprecatedConstants + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.8 +| 1.40 +|=== + +Checks for deprecated constants. + +It has `DeprecatedConstants` config. If there is an alternative method, you can set +alternative value as `Alternative`. And you can set the deprecated version as +`DeprecatedVersion`. These options can be omitted if they are not needed. + + DeprecatedConstants: + 'DEPRECATED_CONSTANT': + Alternative: 'alternative_value' + DeprecatedVersion: 'deprecated_version' + +By default, `NIL`, `TRUE`, `FALSE`, `Net::HTTPServerException, `Random::DEFAULT`, +`Struct::Group`, and `Struct::Passwd` are configured. + +[#examples-lintdeprecatedconstants] +=== Examples + +[source,ruby] +---- +# bad +NIL +TRUE +FALSE +Net::HTTPServerException +Random::DEFAULT # Return value of Ruby 2 is `Random` instance, Ruby 3.0 is `Random` class. +Struct::Group +Struct::Passwd + +# good +nil +true +false +Net::HTTPClientException +Random.new # `::DEFAULT` has been deprecated in Ruby 3, `.new` is compatible with Ruby 2. +Etc::Group +Etc::Passwd +---- + +[#configurable-attributes-lintdeprecatedconstants] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| DeprecatedConstants +| `{"NIL" => {"Alternative" => "nil", "DeprecatedVersion" => "2.4"}, "TRUE" => {"Alternative" => "true", "DeprecatedVersion" => "2.4"}, "FALSE" => {"Alternative" => "false", "DeprecatedVersion" => "2.4"}, "Net::HTTPServerException" => {"Alternative" => "Net::HTTPClientException", "DeprecatedVersion" => "2.6"}, "Random::DEFAULT" => {"Alternative" => "Random.new", "DeprecatedVersion" => "3.0"}, "Struct::Group" => {"Alternative" => "Etc::Group", "DeprecatedVersion" => "3.0"}, "Struct::Passwd" => {"Alternative" => "Etc::Passwd", "DeprecatedVersion" => "3.0"}}` +| +|=== + +[#lintdeprecatedopensslconstant] +== Lint/DeprecatedOpenSSLConstant + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.84 +| - +|=== + +Algorithmic constants for `OpenSSL::Cipher` and `OpenSSL::Digest` +deprecated since OpenSSL version 2.2.0. Prefer passing a string +instead. + +[#examples-lintdeprecatedopensslconstant] +=== Examples + +[source,ruby] +---- +# bad +OpenSSL::Cipher::AES.new(128, :GCM) + +# good +OpenSSL::Cipher.new('aes-128-gcm') + +# bad +OpenSSL::Digest::SHA256.new + +# good +OpenSSL::Digest.new('SHA256') + +# bad +OpenSSL::Digest::SHA256.digest('foo') + +# good +OpenSSL::Digest.digest('SHA256', 'foo') +---- + +[#lintdisjunctiveassignmentinconstructor] +== Lint/DisjunctiveAssignmentInConstructor + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| Always (Unsafe) +| 0.62 +| 0.88 +|=== + +Checks constructors for disjunctive assignments (`||=`) that should +be plain assignments. + +So far, this cop is only concerned with disjunctive assignment of +instance variables. + +In ruby, an instance variable is nil until a value is assigned, so the +disjunction is unnecessary. A plain assignment has the same effect. + +[#safety-lintdisjunctiveassignmentinconstructor] +=== Safety + +This cop is unsafe because it can register a false positive when a +method is redefined in a subclass that calls super. For example: + +[source,ruby] +---- +class Base + def initialize + @config ||= 'base' + end +end + +class Derived < Base + def initialize + @config = 'derived' + super + end +end +---- + +Without the disjunctive assignment, `Derived` will be unable to override +the value for `@config`. + +[#examples-lintdisjunctiveassignmentinconstructor] +=== Examples + +[source,ruby] +---- +# bad +def initialize + @x ||= 1 +end + +# good +def initialize + @x = 1 +end +---- + +[#lintduplicatebranch] +== Lint/DuplicateBranch + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.3 +| 1.7 +|=== + +Checks that there are no repeated bodies +within `if/unless`, `case-when`, `case-in` and `rescue` constructs. + +With `IgnoreLiteralBranches: true`, branches are not registered +as offenses if they return a basic literal value (string, symbol, +integer, float, rational, complex, `true`, `false`, or `nil`), or +return an array, hash, regexp or range that only contains one of +the above basic literal values. + +With `IgnoreConstantBranches: true`, branches are not registered +as offenses if they return a constant value. + +With `IgnoreDuplicateElseBranch: true`, in conditionals with multiple branches, +duplicate 'else' branches are not registered as offenses. + +[#examples-lintduplicatebranch] +=== Examples + +[source,ruby] +---- +# bad +if foo + do_foo + do_something_else +elsif bar + do_foo + do_something_else +end + +# good +if foo || bar + do_foo + do_something_else +end + +# bad +case x +when foo + do_foo +when bar + do_foo +else + do_something_else +end + +# good +case x +when foo, bar + do_foo +else + do_something_else +end + +# bad +begin + do_something +rescue FooError + handle_error +rescue BarError + handle_error +end + +# good +begin + do_something +rescue FooError, BarError + handle_error +end +---- + +[#ignoreliteralbranches_-true-lintduplicatebranch] +==== IgnoreLiteralBranches: true + +[source,ruby] +---- +# good +case size +when "small" then 100 +when "medium" then 250 +when "large" then 1000 +else 250 +end +---- + +[#ignoreconstantbranches_-true-lintduplicatebranch] +==== IgnoreConstantBranches: true + +[source,ruby] +---- +# good +case size +when "small" then SMALL_SIZE +when "medium" then MEDIUM_SIZE +when "large" then LARGE_SIZE +else MEDIUM_SIZE +end +---- + +[#ignoreduplicateelsebranch_-true-lintduplicatebranch] +==== IgnoreDuplicateElseBranch: true + +[source,ruby] +---- +# good +if foo + do_foo +elsif bar + do_bar +else + do_foo +end +---- + +[#configurable-attributes-lintduplicatebranch] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| IgnoreLiteralBranches +| `false` +| Boolean + +| IgnoreConstantBranches +| `false` +| Boolean + +| IgnoreDuplicateElseBranch +| `false` +| Boolean +|=== + +[#lintduplicatecasecondition] +== Lint/DuplicateCaseCondition + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.45 +| - +|=== + +Checks that there are no repeated conditions +used in case 'when' expressions. + +[#examples-lintduplicatecasecondition] +=== Examples + +[source,ruby] +---- +# bad +case x +when 'first' + do_something +when 'first' + do_something_else +end + +# good +case x +when 'first' + do_something +when 'second' + do_something_else +end +---- + +[#lintduplicateelsifcondition] +== Lint/DuplicateElsifCondition + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.88 +| - +|=== + +Checks that there are no repeated conditions used in if 'elsif'. + +[#examples-lintduplicateelsifcondition] +=== Examples + +[source,ruby] +---- +# bad +if x == 1 + do_something +elsif x == 1 + do_something_else +end + +# good +if x == 1 + do_something +elsif x == 2 + do_something_else +end +---- + +[#lintduplicatehashkey] +== Lint/DuplicateHashKey + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.34 +| 0.77 +|=== + +Checks for duplicated keys in hash literals. +This cop considers both primitive types and constants for the hash keys. + +This cop mirrors a warning in Ruby 2.2. + +[#examples-lintduplicatehashkey] +=== Examples + +[source,ruby] +---- +# bad +hash = { food: 'apple', food: 'orange' } + +# good +hash = { food: 'apple', other_food: 'orange' } +---- + +[#lintduplicatemagiccomment] +== Lint/DuplicateMagicComment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.37 +| - +|=== + +Checks for duplicated magic comments. + +[#examples-lintduplicatemagiccomment] +=== Examples + +[source,ruby] +---- +# bad + +# encoding: ascii +# encoding: ascii + +# good + +# encoding: ascii + +# bad + +# frozen_string_literal: true +# frozen_string_literal: true + +# good + +# frozen_string_literal: true +---- + +[#lintduplicatematchpattern] +== Lint/DuplicateMatchPattern + +NOTE: Requires Ruby version 2.7 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.50 +| - +|=== + +Checks that there are no repeated patterns used in `in` keywords. + +[#examples-lintduplicatematchpattern] +=== Examples + +[source,ruby] +---- +# bad +case x +in 'first' + do_something +in 'first' + do_something_else +end + +# good +case x +in 'first' + do_something +in 'second' + do_something_else +end + +# bad - repeated alternate patterns with the same conditions don't depend on the order +case x +in foo | bar + first_method +in bar | foo + second_method +end + +# good +case x +in foo | bar + first_method +in bar | baz + second_method +end + +# bad - repeated hash patterns with the same conditions don't depend on the order +case x +in foo: a, bar: b + first_method +in bar: b, foo: a + second_method +end + +# good +case x +in foo: a, bar: b + first_method +in bar: b, baz: c + second_method +end + +# bad - repeated array patterns with elements in the same order +case x +in [foo, bar] + first_method +in [foo, bar] + second_method +end + +# good +case x +in [foo, bar] + first_method +in [bar, foo] + second_method +end + +# bad - repeated the same patterns and guard conditions +case x +in foo if bar + first_method +in foo if bar + second_method +end + +# good +case x +in foo if bar + first_method +in foo if baz + second_method +end +---- + +[#lintduplicatemethods] +== Lint/DuplicateMethods + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.29 +| - +|=== + +Checks for duplicated instance (or singleton) method +definitions. + +NOTE: Aliasing a method to itself is allowed, as it indicates that +the developer intends to suppress Ruby's method redefinition warnings. +See https://bugs.ruby-lang.org/issues/13574. + +[#examples-lintduplicatemethods] +=== Examples + +[source,ruby] +---- +# bad +def foo + 1 +end + +def foo + 2 +end + +# bad +def foo + 1 +end + +alias foo bar + +# good +def foo + 1 +end + +def bar + 2 +end + +# good +def foo + 1 +end + +alias bar foo + +# good +alias foo foo +def foo + 1 +end + +# good +alias_method :foo, :foo +def foo + 1 +end +---- + +[#allcops_activesupportextensionsenabled_-false-_default_-lintduplicatemethods] +==== AllCops:ActiveSupportExtensionsEnabled: false (default) + +[source,ruby] +---- +# good +def foo + 1 +end + +delegate :foo, to: :bar +---- + +[#allcops_activesupportextensionsenabled_-true-lintduplicatemethods] +==== AllCops:ActiveSupportExtensionsEnabled: true + +[source,ruby] +---- +# bad +def foo + 1 +end + +delegate :foo, to: :bar + +# good +def foo + 1 +end + +delegate :baz, to: :bar + +# good - delegate with splat arguments is ignored +def foo + 1 +end + +delegate :foo, **options + +# good - delegate inside a condition is ignored +def foo + 1 +end + +if cond + delegate :foo, to: :bar +end +---- + +[#lintduplicateregexpcharacterclasselement] +== Lint/DuplicateRegexpCharacterClassElement + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.1 +| - +|=== + +Checks for duplicate elements in `Regexp` character classes. + +[#examples-lintduplicateregexpcharacterclasselement] +=== Examples + +[source,ruby] +---- +# bad +r = /[xyx]/ + +# bad +r = /[0-9x0-9]/ + +# good +r = /[xy]/ + +# good +r = /[0-9x]/ +---- + +[#lintduplicaterequire] +== Lint/DuplicateRequire + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always (Unsafe) +| 0.90 +| 1.28 +|=== + +Checks for duplicate ``require``s and ``require_relative``s. + +[#safety-lintduplicaterequire] +=== Safety + +This cop's autocorrection is unsafe because it may break the dependency order +of `require`. + +[#examples-lintduplicaterequire] +=== Examples + +[source,ruby] +---- +# bad +require 'foo' +require 'bar' +require 'foo' + +# good +require 'foo' +require 'bar' + +# good +require 'foo' +require_relative 'foo' +---- + +[#lintduplicaterescueexception] +== Lint/DuplicateRescueException + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.89 +| - +|=== + +Checks that there are no repeated exceptions +used in 'rescue' expressions. + +[#examples-lintduplicaterescueexception] +=== Examples + +[source,ruby] +---- +# bad +begin + something +rescue FirstException + handle_exception +rescue FirstException + handle_other_exception +end + +# good +begin + something +rescue FirstException + handle_exception +rescue SecondException + handle_other_exception +end +---- + +[#lintduplicatesetelement] +== Lint/DuplicateSetElement + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.67 +| - +|=== + +Checks for duplicate literal, constant, or variable elements in `Set` and `SortedSet`. + +[#examples-lintduplicatesetelement] +=== Examples + +[source,ruby] +---- +# bad +Set[:foo, :bar, :foo] + +# good +Set[:foo, :bar] + +# bad +Set.new([:foo, :bar, :foo]) + +# good +Set.new([:foo, :bar]) + +# bad +[:foo, :bar, :foo].to_set + +# good +[:foo, :bar].to_set + +# bad +SortedSet[:foo, :bar, :foo] + +# good +SortedSet[:foo, :bar] + +# bad +SortedSet.new([:foo, :bar, :foo]) + +# good +SortedSet.new([:foo, :bar]) +---- + +[#linteachwithobjectargument] +== Lint/EachWithObjectArgument + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.31 +| - +|=== + +Checks if each_with_object is called with an immutable +argument. Since the argument is the object that the given block shall +make calls on to build something based on the enumerable that +each_with_object iterates over, an immutable argument makes no sense. +It's definitely a bug. + +[#examples-linteachwithobjectargument] +=== Examples + +[source,ruby] +---- +# bad +sum = numbers.each_with_object(0) { |e, a| a += e } + +# good +num = 0 +sum = numbers.each_with_object(num) { |e, a| a += e } +---- + +[#lintelselayout] +== Lint/ElseLayout + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.17 +| 1.2 +|=== + +Checks for odd `else` block layout - like +having an expression on the same line as the `else` keyword, +which is usually a mistake. + +Its autocorrection tweaks layout to keep the syntax. So, this autocorrection +is compatible correction for bad case syntax, but if your code makes a mistake +with `elsif` and `else`, you will have to correct it manually. + +[#examples-lintelselayout] +=== Examples + +[source,ruby] +---- +# bad + +if something + # ... +else do_this + do_that +end + +# good + +# This code is compatible with the bad case. It will be autocorrected like this. +if something + # ... +else + do_this + do_that +end + +# This code is incompatible with the bad case. +# If `do_this` is a condition, `elsif` should be used instead of `else`. +if something + # ... +elsif do_this + do_that +end +---- + +[#lintemptyblock] +== Lint/EmptyBlock + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.1 +| 1.15 +|=== + +Checks for blocks without a body. +Such empty blocks are typically an oversight or we should provide a comment +to clarify what we're aiming for. + +Empty lambdas and procs are ignored by default. + +NOTE: For backwards compatibility, the configuration that allows/disallows +empty lambdas and procs is called `AllowEmptyLambdas`, even though it also +applies to procs. + +[#examples-lintemptyblock] +=== Examples + +[source,ruby] +---- +# bad +items.each { |item| } + +# good +items.each { |item| puts item } +---- + +[#allowcomments_-true-_default_-lintemptyblock] +==== AllowComments: true (default) + +[source,ruby] +---- +# good +items.each do |item| + # TODO: implement later (inner comment) +end + +items.each { |item| } # TODO: implement later (inline comment) +---- + +[#allowcomments_-false-lintemptyblock] +==== AllowComments: false + +[source,ruby] +---- +# bad +items.each do |item| + # TODO: implement later (inner comment) +end + +items.each { |item| } # TODO: implement later (inline comment) +---- + +[#allowemptylambdas_-true-_default_-lintemptyblock] +==== AllowEmptyLambdas: true (default) + +[source,ruby] +---- +# good +allow(subject).to receive(:callable).and_return(-> {}) + +placeholder = lambda do +end +(callable || placeholder).call + +proc { } + +Proc.new { } +---- + +[#allowemptylambdas_-false-lintemptyblock] +==== AllowEmptyLambdas: false + +[source,ruby] +---- +# bad +allow(subject).to receive(:callable).and_return(-> {}) + +placeholder = lambda do +end +(callable || placeholder).call + +proc { } + +Proc.new { } +---- + +[#configurable-attributes-lintemptyblock] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowComments +| `true` +| Boolean + +| AllowEmptyLambdas +| `true` +| Boolean +|=== + +[#lintemptyclass] +== Lint/EmptyClass + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.3 +| - +|=== + +Checks for classes and metaclasses without a body. +Such empty classes and metaclasses are typically an oversight or we should provide a comment +to be clearer what we're aiming for. + +[#examples-lintemptyclass] +=== Examples + +[source,ruby] +---- +# bad +class Foo +end + +class Bar + class << self + end +end + +class << obj +end + +# good +class Foo + def do_something + # ... code + end +end + +class Bar + class << self + attr_reader :bar + end +end + +class << obj + attr_reader :bar +end +---- + +[#allowcomments_-false-_default_-lintemptyclass] +==== AllowComments: false (default) + +[source,ruby] +---- +# bad +class Foo + # TODO: implement later +end + +class Bar + class << self + # TODO: implement later + end +end + +class << obj + # TODO: implement later +end +---- + +[#allowcomments_-true-lintemptyclass] +==== AllowComments: true + +[source,ruby] +---- +# good +class Foo + # TODO: implement later +end + +class Bar + class << self + # TODO: implement later + end +end + +class << obj + # TODO: implement later +end +---- + +[#configurable-attributes-lintemptyclass] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowComments +| `false` +| Boolean +|=== + +[#lintemptyconditionalbody] +== Lint/EmptyConditionalBody + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Command-line only +| 0.89 +| 1.73 +|=== + +Checks for the presence of `if`, `elsif` and `unless` branches without a body. + +NOTE: empty `else` branches are handled by `Style/EmptyElse`. + +[#examples-lintemptyconditionalbody] +=== Examples + +[source,ruby] +---- +# bad +if condition +end + +# bad +unless condition +end + +# bad +if condition + do_something +elsif other_condition +end + +# good +if condition + do_something +end + +# good +unless condition + do_something +end + +# good +if condition + do_something +elsif other_condition + nil +end + +# good +if condition + do_something +elsif other_condition + do_something_else +end +---- + +[#allowcomments_-true-_default_-lintemptyconditionalbody] +==== AllowComments: true (default) + +[source,ruby] +---- +# good +if condition + do_something +elsif other_condition + # noop +end +---- + +[#allowcomments_-false-lintemptyconditionalbody] +==== AllowComments: false + +[source,ruby] +---- +# bad +if condition + do_something +elsif other_condition + # noop +end +---- + +[#configurable-attributes-lintemptyconditionalbody] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowComments +| `true` +| Boolean +|=== + +[#lintemptyensure] +== Lint/EmptyEnsure + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Command-line only +| 0.10 +| 1.61 +|=== + +Checks for empty `ensure` blocks. + +[#examples-lintemptyensure] +=== Examples + +[source,ruby] +---- +# bad +def some_method + do_something +ensure +end + +# bad +begin + do_something +ensure +end + +# good +def some_method + do_something +ensure + do_something_else +end + +# good +begin + do_something +ensure + do_something_else +end +---- + +[#lintemptyexpression] +== Lint/EmptyExpression + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.45 +| - +|=== + +Checks for the presence of empty expressions. + +[#examples-lintemptyexpression] +=== Examples + +[source,ruby] +---- +# bad + +foo = () +if () + bar +end + +# good + +foo = (some_expression) +if (some_expression) + bar +end +---- + +[#lintemptyfile] +== Lint/EmptyFile + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.90 +| - +|=== + +Enforces that Ruby source files are not empty. + +[#examples-lintemptyfile] +=== Examples + +[source,ruby] +---- +# bad +# Empty file + +# good +# File containing non commented source lines +---- + +[#allowcomments_-true-_default_-lintemptyfile] +==== AllowComments: true (default) + +[source,ruby] +---- +# good +# File consisting only of comments +---- + +[#allowcomments_-false-lintemptyfile] +==== AllowComments: false + +[source,ruby] +---- +# bad +# File consisting only of comments +---- + +[#configurable-attributes-lintemptyfile] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowComments +| `true` +| Boolean +|=== + +[#lintemptyinpattern] +== Lint/EmptyInPattern + +NOTE: Requires Ruby version 2.7 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.16 +| - +|=== + +Checks for the presence of `in` pattern branches without a body. + +[#examples-lintemptyinpattern] +=== Examples + +[source,ruby] +---- +# bad +case condition +in [a] + do_something +in [a, b] +end + +# good +case condition +in [a] + do_something +in [a, b] + nil +end +---- + +[#allowcomments_-true-_default_-lintemptyinpattern] +==== AllowComments: true (default) + +[source,ruby] +---- +# good +case condition +in [a] + do_something +in [a, b] + # noop +end +---- + +[#allowcomments_-false-lintemptyinpattern] +==== AllowComments: false + +[source,ruby] +---- +# bad +case condition +in [a] + do_something +in [a, b] + # noop +end +---- + +[#configurable-attributes-lintemptyinpattern] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowComments +| `true` +| Boolean +|=== + +[#lintemptyinterpolation] +== Lint/EmptyInterpolation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Command-line only +| 0.20 +| 1.76 +|=== + +Checks for empty interpolation. + +[#examples-lintemptyinterpolation] +=== Examples + +[source,ruby] +---- +# bad +"result is #{}" + +# good +"result is #{some_result}" +---- + +[#lintemptywhen] +== Lint/EmptyWhen + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.45 +| 0.83 +|=== + +Checks for the presence of `when` branches without a body. + +[#examples-lintemptywhen] +=== Examples + +[source,ruby] +---- +# bad +case foo +when bar + do_something +when baz +end + +# good +case condition +when foo + do_something +when bar + nil +end +---- + +[#allowcomments_-true-_default_-lintemptywhen] +==== AllowComments: true (default) + +[source,ruby] +---- +# good +case condition +when foo + do_something +when bar + # noop +end +---- + +[#allowcomments_-false-lintemptywhen] +==== AllowComments: false + +[source,ruby] +---- +# bad +case condition +when foo + do_something +when bar + # do nothing +end +---- + +[#configurable-attributes-lintemptywhen] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowComments +| `true` +| Boolean +|=== + +[#lintensurereturn] +== Lint/EnsureReturn + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.9 +| 0.83 +|=== + +Checks for `return` from an `ensure` block. +`return` from an ensure block is a dangerous code smell as it +will take precedence over any exception being raised, +and the exception will be silently thrown away as if it were rescued. + +If you want to rescue some (or all) exceptions, best to do it explicitly + +[#examples-lintensurereturn] +=== Examples + +[source,ruby] +---- +# bad +def foo + do_something +ensure + cleanup + return self +end + +# good +def foo + do_something + self +ensure + cleanup +end + +# good +def foo + begin + do_something + rescue SomeException + # Let's ignore this exception + end + self +ensure + cleanup +end +---- + +[#references-lintensurereturn] +=== References + +* https://rubystyle.guide#no-return-ensure + +[#linterbnewarguments] +== Lint/ErbNewArguments + +NOTE: Requires Ruby version 2.6 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.56 +| - +|=== + +Emulates the following Ruby warnings in Ruby 2.6. + +[source,console] +---- +$ cat example.rb +ERB.new('hi', nil, '-', '@output_buffer') +$ ruby -rerb example.rb +example.rb:1: warning: Passing safe_level with the 2nd argument of ERB.new is +deprecated. Do not use it, and specify other arguments as keyword arguments. +example.rb:1: warning: Passing trim_mode with the 3rd argument of ERB.new is +deprecated. Use keyword argument like ERB.new(str, trim_mode:...) instead. +example.rb:1: warning: Passing eoutvar with the 4th argument of ERB.new is +deprecated. Use keyword argument like ERB.new(str, eoutvar: ...) instead. +---- + +Now non-keyword arguments other than first one are softly deprecated +and will be removed when Ruby 2.5 becomes EOL. +`ERB.new` with non-keyword arguments is deprecated since ERB 2.2.0. +Use `:trim_mode` and `:eoutvar` keyword arguments to `ERB.new`. +This cop identifies places where `ERB.new(str, trim_mode, eoutvar)` can +be replaced by `ERB.new(str, :trim_mode: trim_mode, eoutvar: eoutvar)`. + +[#examples-linterbnewarguments] +=== Examples + +[source,ruby] +---- +# Target codes supports Ruby 2.6 and higher only +# bad +ERB.new(str, nil, '-', '@output_buffer') + +# good +ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') + +# Target codes supports Ruby 2.5 and lower only +# good +ERB.new(str, nil, '-', '@output_buffer') + +# Target codes supports Ruby 2.6, 2.5 and lower +# bad +ERB.new(str, nil, '-', '@output_buffer') + +# good +# Ruby standard library style +# https://github.com/ruby/ruby/commit/3406c5d +if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+ + ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') +else + ERB.new(str, nil, '-', '@output_buffer') +end + +# good +# Use `RUBY_VERSION` style +if RUBY_VERSION >= '2.6' + ERB.new(str, trim_mode: '-', eoutvar: '@output_buffer') +else + ERB.new(str, nil, '-', '@output_buffer') +end +---- + +[#lintflipflop] +== Lint/FlipFlop + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.16 +| - +|=== + +Looks for uses of flip-flop operator +based on the Ruby Style Guide. + +Here is the history of flip-flops in Ruby. +flip-flop operator is deprecated in Ruby 2.6.0 and +the deprecation has been reverted by Ruby 2.7.0 and +backported to Ruby 2.6. +See: https://bugs.ruby-lang.org/issues/5400 + +[#examples-lintflipflop] +=== Examples + +[source,ruby] +---- +# bad +(1..20).each do |x| + puts x if (x == 5) .. (x == 10) +end + +# good +(1..20).each do |x| + puts x if (x >= 5) && (x <= 10) +end +---- + +[#references-lintflipflop] +=== References + +* https://rubystyle.guide#no-flip-flops + +[#lintfloatcomparison] +== Lint/FloatComparison + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.89 +| - +|=== + +Checks for the presence of precise comparison of floating point numbers. + +Floating point values are inherently inaccurate, and comparing them for exact equality +is almost never the desired semantics. Comparison via the `==/!=` operators checks +floating-point value representation to be exactly the same, which is very unlikely +if you perform any arithmetic operations involving precision loss. + +[#examples-lintfloatcomparison] +=== Examples + +[source,ruby] +---- +# bad +x == 0.1 +x != 0.1 + +# bad +case value +when 1.0 + foo +when 2.0 + bar +end + +# good - using BigDecimal +x.to_d == 0.1.to_d + +# good - comparing against zero +x == 0.0 +x != 0.0 + +# good +(x - 0.1).abs < Float::EPSILON + +# good +tolerance = 0.0001 +(x - 0.1).abs < tolerance + +# good - comparing against nil +Float(x, exception: false) == nil + +# good - using epsilon comparison in case expression +case +when (value - 1.0).abs < Float::EPSILON + foo +when (value - 2.0).abs < Float::EPSILON + bar +end + +# Or some other epsilon based type of comparison: +# https://www.embeddeduse.com/2019/08/26/qt-compare-two-floats/ +---- + +[#references-lintfloatcomparison] +=== References + +* https://rubystyle.guide#float-comparison + +[#lintfloatoutofrange] +== Lint/FloatOutOfRange + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.36 +| - +|=== + +Identifies `Float` literals which are, like, really really really +really really really really really big. Too big. No-one needs Floats +that big. If you need a float that big, something is wrong with you. + +[#examples-lintfloatoutofrange] +=== Examples + +[source,ruby] +---- +# bad +float = 3.0e400 + +# good +float = 42.9 +---- + +[#lintformatparametermismatch] +== Lint/FormatParameterMismatch + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.33 +| - +|=== + +This lint sees if there is a mismatch between the number of +expected fields for format/sprintf/#% and what is actually +passed as arguments. + +In addition, it checks whether different formats are used in the same +format string. Do not mix numbered, unnumbered, and named formats in +the same format string. + +[#examples-lintformatparametermismatch] +=== Examples + +[source,ruby] +---- +# bad +format('A value: %s and another: %i', a_value) + +# good +format('A value: %s and another: %i', a_value, another) + +# bad +format('Unnumbered format: %s and numbered: %2$s', a_value, another) + +# good +format('Numbered format: %1$s and numbered %2$s', a_value, another) +---- + +[#linthashcomparebyidentity] +== Lint/HashCompareByIdentity + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| No +| 0.93 +| - +|=== + +Prefer using `Hash#compare_by_identity` rather than using `object_id` +for hash keys. + +This cop looks for hashes being keyed by objects' `object_id`, using +one of these methods: `key?`, `has_key?`, `fetch`, `[]` and `[]=`. + +[#safety-linthashcomparebyidentity] +=== Safety + +This cop is unsafe. Although unlikely, the hash could store both object +ids and other values that need be compared by value, and thus +could be a false positive. + +Furthermore, this cop cannot guarantee that the receiver of one of the +methods (`key?`, etc.) is actually a hash. + +[#examples-linthashcomparebyidentity] +=== Examples + +[source,ruby] +---- +# bad +hash = {} +hash[foo.object_id] = :bar +hash.key?(baz.object_id) + +# good +hash = {}.compare_by_identity +hash[foo] = :bar +hash.key?(baz) +---- + +[#references-linthashcomparebyidentity] +=== References + +* https://rubystyle.guide#identity-comparison + +[#linthashnewwithkeywordargumentsasdefault] +== Lint/HashNewWithKeywordArgumentsAsDefault + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.69 +| - +|=== + +Checks for the deprecated use of keyword arguments as a default in `Hash.new`. + +This usage raises a warning in Ruby 3.3 and results in an error in Ruby 3.4. +In Ruby 3.4, keyword arguments will instead be used to change the behavior of a hash. +For example, the capacity option can be passed to create a hash with a certain size +if you know it in advance, for better performance. + +NOTE: The following corner case may result in a false negative when upgrading from Ruby 3.3 +or earlier, but it is intentionally not detected to respect the expected usage in Ruby 3.4. + +[source,ruby] +---- +Hash.new(capacity: 42) +---- + +[#examples-linthashnewwithkeywordargumentsasdefault] +=== Examples + +[source,ruby] +---- +# bad +Hash.new(key: :value) + +# good +Hash.new({key: :value}) +---- + +[#lintheredocmethodcallposition] +== Lint/HeredocMethodCallPosition + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 0.68 +| - +|=== + +Checks for the ordering of a method call where +the receiver of the call is a HEREDOC. + +[#examples-lintheredocmethodcallposition] +=== Examples + +[source,ruby] +---- +# bad +<<-SQL + bar +SQL +.strip_indent + +<<-SQL + bar +SQL +.strip_indent +.trim + +# good +<<~SQL + bar +SQL + +<<~SQL.trim + bar +SQL +---- + +[#references-lintheredocmethodcallposition] +=== References + +* https://rubystyle.guide#heredoc-method-calls + +[#lintidentitycomparison] +== Lint/IdentityComparison + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.91 +| - +|=== + +Prefer `equal?` over `==` when comparing `object_id`. + +`Object#equal?` is provided to compare objects for identity, and in contrast +`Object#==` is provided for the purpose of doing value comparison. + +[#examples-lintidentitycomparison] +=== Examples + +[source,ruby] +---- +# bad +foo.object_id == bar.object_id +foo.object_id != baz.object_id + +# good +foo.equal?(bar) +!foo.equal?(baz) +---- + +[#references-lintidentitycomparison] +=== References + +* https://rubystyle.guide#identity-comparison + +[#lintimplicitstringconcatenation] +== Lint/ImplicitStringConcatenation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.36 +| - +|=== + +Checks for implicit string concatenation of string literals +which are on the same line. + +[#examples-lintimplicitstringconcatenation] +=== Examples + +[source,ruby] +---- +# bad +array = ['Item 1' 'Item 2'] + +# good +array = ['Item 1Item 2'] +array = ['Item 1' + 'Item 2'] +array = [ + 'Item 1' \ + 'Item 2' +] +---- + +[#lintincompatibleioselectwithfiberscheduler] +== Lint/IncompatibleIoSelectWithFiberScheduler + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always (Unsafe) +| 1.21 +| 1.24 +|=== + +Checks for `IO.select` that is incompatible with Fiber Scheduler since Ruby 3.0. + +When an array of IO objects waiting for an exception (the third argument of `IO.select`) +is used as an argument, there is no alternative API, so offenses are not registered. + +NOTE: When the method is successful the return value of `IO.select` is `[[IO]]`, +and the return value of `io.wait_readable` and `io.wait_writable` are `self`. +They are not autocorrected when assigning a return value because these types are different. +It's up to user how to handle the return value. + +[#safety-lintincompatibleioselectwithfiberscheduler] +=== Safety + +This cop's autocorrection is unsafe because `NoMethodError` occurs +if `require 'io/wait'` is not called. + +[#examples-lintincompatibleioselectwithfiberscheduler] +=== Examples + +[source,ruby] +---- +# bad +IO.select([io], [], [], timeout) + +# good +io.wait_readable(timeout) + +# bad +IO.select([], [io], [], timeout) + +# good +io.wait_writable(timeout) +---- + +[#lintineffectiveaccessmodifier] +== Lint/IneffectiveAccessModifier + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.36 +| - +|=== + +Checks for `private` or `protected` access modifiers which are +applied to a singleton method. These access modifiers do not make +singleton methods private/protected. `private_class_method` can be +used for that. + +[#examples-lintineffectiveaccessmodifier] +=== Examples + +[source,ruby] +---- +# bad +class C + private + + def self.method + puts 'hi' + end +end + +# good +class C + def self.method + puts 'hi' + end + + private_class_method :method +end + +# good +class C + class << self + private + + def method + puts 'hi' + end + end +end +---- + +[#lintinheritexception] +== Lint/InheritException + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always (Unsafe) +| 0.41 +| 1.26 +|=== + +Looks for error classes inheriting from `Exception`. +It is configurable to suggest using either `StandardError` (default) or +`RuntimeError` instead. + +[#safety-lintinheritexception] +=== Safety + +This cop's autocorrection is unsafe because `rescue` that omit +exception class handle `StandardError` and its subclasses, +but not `Exception` and its subclasses. + +[#examples-lintinheritexception] +=== Examples + +[#enforcedstyle_-standard_error-_default_-lintinheritexception] +==== EnforcedStyle: standard_error (default) + +[source,ruby] +---- +# bad + +class C < Exception; end + +C = Class.new(Exception) + +# good + +class C < StandardError; end + +C = Class.new(StandardError) +---- + +[#enforcedstyle_-runtime_error-lintinheritexception] +==== EnforcedStyle: runtime_error + +[source,ruby] +---- +# bad + +class C < Exception; end + +C = Class.new(Exception) + +# good + +class C < RuntimeError; end + +C = Class.new(RuntimeError) +---- + +[#configurable-attributes-lintinheritexception] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `standard_error` +| `standard_error`, `runtime_error` +|=== + +[#lintinterpolationcheck] +== Lint/InterpolationCheck + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always (Unsafe) +| 0.50 +| 1.40 +|=== + +Checks for interpolation in a single quoted string. + +[#safety-lintinterpolationcheck] +=== Safety + +This cop's autocorrection is unsafe because although it always replaces single quotes as +if it were miswritten double quotes, it is not always the case. For example, +`'#{foo} bar'` would be replaced by `"#{foo} bar"`, so the replaced code would evaluate +the expression `foo`. + +[#examples-lintinterpolationcheck] +=== Examples + +[source,ruby] +---- +# bad +foo = 'something with #{interpolation} inside' + +# good +foo = "something with #{interpolation} inside" +---- + +[#lintitwithoutargumentsinblock] +== Lint/ItWithoutArgumentsInBlock + +NOTE: Requires Ruby version <= 3.3 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.59 +| - +|=== + +Emulates the following Ruby warning in Ruby 3.3. + +[source,ruby] +---- +$ ruby -e '0.times { it }' +-e:1: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4; +use it() or self.it +---- + +`it` calls without arguments will refer to the first block param in Ruby 3.4. +So use `it()` or `self.it` to ensure compatibility. + +[#examples-lintitwithoutargumentsinblock] +=== Examples + +[source,ruby] +---- +# bad +do_something { it } + +# good +do_something { it() } +do_something { self.it } +---- + +[#references-lintitwithoutargumentsinblock] +=== References + +* https://bugs.ruby-lang.org/issues/18980 + +[#lintlambdawithoutliteralblock] +== Lint/LambdaWithoutLiteralBlock + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.8 +| - +|=== + +Checks uses of lambda without a literal block. +It emulates the following warning in Ruby 3.0: + + $ ruby -vwe 'lambda(&proc {})' + ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19] + -e:1: warning: lambda without a literal block is deprecated; use the proc without + lambda instead + +This way, proc object is never converted to lambda. +Autocorrection replaces with compatible proc argument. + +[#examples-lintlambdawithoutliteralblock] +=== Examples + +[source,ruby] +---- +# bad +lambda(&proc { do_something }) +lambda(&Proc.new { do_something }) + +# good +proc { do_something } +Proc.new { do_something } +lambda { do_something } # If you use lambda. +---- + +[#lintliteralascondition] +== Lint/LiteralAsCondition + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Command-line only +| 0.51 +| - +|=== + +Checks for literals used as the conditions or as +operands in and/or expressions serving as the conditions of +if/while/until/case-when/case-in. + +NOTE: Literals in `case-in` condition where the match variable is used in +`in` are accepted as a pattern matching. + +[#examples-lintliteralascondition] +=== Examples + +[source,ruby] +---- +# bad +if 20 + do_something +end + +# bad +# We're only interested in the left hand side being a truthy literal, +# because it affects the evaluation of the &&, whereas the right hand +# side will be conditionally executed/called and can be a literal. +if true && some_var + do_something +end + +# good +if some_var + do_something +end + +# good +# When using a boolean value for an infinite loop. +while true + break if condition +end +---- + +[#lintliteralassignmentincondition] +== Lint/LiteralAssignmentInCondition + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.58 +| - +|=== + +Checks for literal assignments in the conditions of `if`, `while`, and `until`. +It emulates the following Ruby warning: + +[source,console] +---- +$ ruby -we 'if x = true; end' +-e:1: warning: found `= literal' in conditional, should be == +---- + +As a lint cop, it cannot be determined if `==` is appropriate as intended, +therefore this cop does not provide autocorrection. + +[#examples-lintliteralassignmentincondition] +=== Examples + +[source,ruby] +---- +# bad +if x = 42 + do_something +end + +# good +if x == 42 + do_something +end + +# good +if x = y + do_something +end +---- + +[#lintliteralininterpolation] +== Lint/LiteralInInterpolation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.19 +| 0.32 +|=== + +Checks for interpolated literals. + +NOTE: Array literals interpolated in regexps are not handled by this cop, but +by `Lint/ArrayLiteralInRegexp` instead. + +[#examples-lintliteralininterpolation] +=== Examples + +[source,ruby] +---- +# bad +"result is #{10}" + +# good +"result is 10" +---- + +[#lintloop] +== Lint/Loop + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| Always (Unsafe) +| 0.9 +| 1.3 +|=== + +Checks for uses of `begin...end while/until something`. + +[#safety-lintloop] +=== Safety + +The cop is unsafe because behavior can change in some cases, including +if a local variable inside the loop body is accessed outside of it, or if the +loop body raises a `StopIteration` exception (which `Kernel#loop` rescues). + +[#examples-lintloop] +=== Examples + +[source,ruby] +---- +# bad + +# using while +begin + do_something +end while some_condition + +# good + +# while replacement +loop do + do_something + break unless some_condition +end + +# bad + +# using until +begin + do_something +end until some_condition + +# good + +# until replacement +loop do + do_something + break if some_condition +end +---- + +[#references-lintloop] +=== References + +* https://rubystyle.guide#loop-with-break + +[#lintmissingcopenabledirective] +== Lint/MissingCopEnableDirective + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.52 +| - +|=== + +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. + +[#examples-lintmissingcopenabledirective] +=== Examples + +[source,ruby] +---- +# 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 +---- + +[source,ruby] +---- +# 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 +---- + +[#configurable-attributes-lintmissingcopenabledirective] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| MaximumRangeSize +| `Infinity` +| Float +|=== + +[#lintmissingsuper] +== Lint/MissingSuper + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.89 +| 1.4 +|=== + +Checks for the presence of constructors and lifecycle callbacks +without calls to `super`. + +This cop does not consider `method_missing` (and `respond_to_missing?`) +because in some cases it makes sense to overtake what is considered a +missing method. In other cases, the theoretical ideal handling could be +challenging or verbose for no actual gain. + +Autocorrection is not supported because the position of `super` cannot be +determined automatically. + +`Object` and `BasicObject` are allowed by this cop because of their +stateless nature. However, sometimes you might want to allow other parent +classes from this cop, for example in the case of an abstract class that is +not meant to be called with `super`. In those cases, you can use the +`AllowedParentClasses` option to specify which classes should be allowed +*in addition to* `Object` and `BasicObject`. + +[#examples-lintmissingsuper] +=== Examples + +[source,ruby] +---- +# bad +class Employee < Person + def initialize(name, salary) + @salary = salary + end +end + +# good +class Employee < Person + def initialize(name, salary) + super(name) + @salary = salary + end +end + +# bad +Employee = Class.new(Person) do + def initialize(name, salary) + @salary = salary + end +end + +# good +Employee = Class.new(Person) do + def initialize(name, salary) + super(name) + @salary = salary + end +end + +# bad +class Parent + def self.inherited(base) + do_something + end +end + +# good +class Parent + def self.inherited(base) + super + do_something + end +end + +# good +class ClassWithNoParent + def initialize + do_something + end +end +---- + +[#allowedparentclasses_-_myabstractclass_-lintmissingsuper] +==== AllowedParentClasses: [MyAbstractClass] + +[source,ruby] +---- +# good +class MyConcreteClass < MyAbstractClass + def initialize + do_something + end +end +---- + +[#configurable-attributes-lintmissingsuper] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedParentClasses +| `[]` +| Array +|=== + +[#lintmixedcaserange] +== Lint/MixedCaseRange + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always (Unsafe) +| 1.53 +| - +|=== + +Checks for mixed-case character ranges since they include likely unintended characters. + +Offenses are registered for regexp character classes like `/[A-z]/` +as well as range objects like `('A'..'z')`. + +NOTE: `Range` objects cannot be autocorrected. + +[#safety-lintmixedcaserange] +=== Safety + +The cop autocorrects regexp character classes +by replacing one character range with two: `A-z` becomes `A-Za-z`. +In most cases this is probably what was originally intended +but it changes the regexp to no longer match symbols it used to include. +For this reason, this cop's autocorrect is unsafe (it will +change the behavior of the code). + +[#examples-lintmixedcaserange] +=== Examples + +[source,ruby] +---- +# bad +r = /[A-z]/ + +# good +r = /[A-Za-z]/ +---- + +[#lintmixedregexpcapturetypes] +== Lint/MixedRegexpCaptureTypes + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.85 +| - +|=== + +Do not mix named captures and numbered captures in a `Regexp` literal +because numbered capture is ignored if they're mixed. +Replace numbered captures with non-capturing groupings or +named captures. + +[#examples-lintmixedregexpcapturetypes] +=== Examples + +[source,ruby] +---- +# bad +/(?FOO)(BAR)/ + +# good +/(?FOO)(?BAR)/ + +# good +/(?FOO)(?:BAR)/ + +# good +/(FOO)(BAR)/ +---- + +[#lintmultiplecomparison] +== Lint/MultipleComparison + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.47 +| 1.1 +|=== + +In math and Python, we can use `x < y < z` style comparison to compare +multiple value. However, we can't use the comparison in Ruby. However, +the comparison is not syntax error. This cop checks the bad usage of +comparison operators. + +[#examples-lintmultiplecomparison] +=== Examples + +[source,ruby] +---- +# bad +x < y < z +10 <= x <= 20 + +# good +x < y && y < z +10 <= x && x <= 20 +---- + +[#lintnestedmethoddefinition] +== Lint/NestedMethodDefinition + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.32 +| - +|=== + +Checks for nested method definitions. + +[#examples-lintnestedmethoddefinition] +=== Examples + +[source,ruby] +---- +# bad + +# `bar` definition actually produces methods in the same scope +# as the outer `foo` method. Furthermore, the `bar` method +# will be redefined every time `foo` is invoked. +def foo + def bar + end +end + +# good + +def foo + bar = -> { puts 'hello' } + bar.call +end + +# good + +# `class_eval`, `instance_eval`, `module_eval`, `class_exec`, `instance_exec`, and +# `module_exec` blocks are allowed by default. + +def foo + self.class.class_eval do + def bar + end + end +end + +def foo + self.class.module_exec do + def bar + end + end +end + +# good + +def foo + class << self + def bar + end + end +end +---- + +[#allowedmethods_-__-_default_-lintnestedmethoddefinition] +==== AllowedMethods: [] (default) + +[source,ruby] +---- +# bad +def do_something + has_many :articles do + def find_or_create_by_name(name) + end + end +end +---- + +[#allowedmethods_-__has_many__-lintnestedmethoddefinition] +==== AllowedMethods: ['has_many'] + +[source,ruby] +---- +# bad +def do_something + has_many :articles do + def find_or_create_by_name(name) + end + end +end +---- + +[#allowedpatterns_-__-_default_-lintnestedmethoddefinition] +==== AllowedPatterns: [] (default) + +[source,ruby] +---- +# bad +def foo(obj) + obj.do_baz do + def bar + end + end +end +---- + +[#allowedpatterns_-__baz__-lintnestedmethoddefinition] +==== AllowedPatterns: ['baz'] + +[source,ruby] +---- +# good +def foo(obj) + obj.do_baz do + def bar + end + end +end +---- + +[#configurable-attributes-lintnestedmethoddefinition] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedMethods +| `[]` +| Array + +| AllowedPatterns +| `[]` +| Array +|=== + +[#references-lintnestedmethoddefinition] +=== References + +* https://rubystyle.guide#no-nested-methods + +[#lintnestedpercentliteral] +== Lint/NestedPercentLiteral + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.52 +| - +|=== + +Checks for nested percent literals. + +[#examples-lintnestedpercentliteral] +=== Examples + +[source,ruby] +---- +# bad + +# The percent literal for nested_attributes is parsed as four tokens, +# yielding the array [:name, :content, :"%i[incorrectly", :"nested]"]. +attributes = { + valid_attributes: %i[name content], + nested_attributes: %i[name content %i[incorrectly nested]] +} + +# good + +# Neither is incompatible with the bad case, but probably the intended code. +attributes = { + valid_attributes: %i[name content], + nested_attributes: [:name, :content, %i[incorrectly nested]] +} + +attributes = { + valid_attributes: %i[name content], + nested_attributes: [:name, :content, [:incorrectly, :nested]] +} +---- + +[#lintnextwithoutaccumulator] +== Lint/NextWithoutAccumulator + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.36 +| - +|=== + +Don't omit the accumulator when calling `next` in a `reduce` block. + +[#examples-lintnextwithoutaccumulator] +=== Examples + +[source,ruby] +---- +# bad +result = (1..4).reduce(0) do |acc, i| + next if i.odd? + acc + i +end + +# good +result = (1..4).reduce(0) do |acc, i| + next acc if i.odd? + acc + i +end +---- + +[#lintnoreturninbeginendblocks] +== Lint/NoReturnInBeginEndBlocks + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.2 +| - +|=== + +Checks for the presence of a `return` inside a `begin..end` block +in assignment contexts. +In this situation, the `return` will result in an exit from the current +method, possibly leading to unexpected behavior. + +[#examples-lintnoreturninbeginendblocks] +=== Examples + +[source,ruby] +---- +# bad +@some_variable ||= begin + return some_value if some_condition_is_met + + do_something +end + +# good +@some_variable ||= begin + if some_condition_is_met + some_value + else + do_something + end +end + +# good +some_variable = if some_condition_is_met + return if another_condition_is_met + + some_value + else + do_something + end +---- + +[#lintnonatomicfileoperation] +== Lint/NonAtomicFileOperation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always (Unsafe) +| 1.31 +| - +|=== + +Checks for non-atomic file operation. +And then replace it with a nearly equivalent and atomic method. + +These can cause problems that are difficult to reproduce, +especially in cases of frequent file operations in parallel, +such as test runs with parallel_rspec. + +For examples: creating a directory if there is none, has the following problems + +An exception occurs when the directory didn't exist at the time of `exist?`, +but someone else created it before `mkdir` was executed. + +Subsequent processes are executed without the directory that should be there +when the directory existed at the time of `exist?`, +but someone else deleted it shortly afterwards. + +[#safety-lintnonatomicfileoperation] +=== Safety + +This cop is unsafe, because autocorrection change to atomic processing. +The atomic processing of the replacement destination is not guaranteed +to be strictly equivalent to that before the replacement. + +[#examples-lintnonatomicfileoperation] +=== Examples + +[source,ruby] +---- +# bad - race condition with another process may result in an error in `mkdir` +unless Dir.exist?(path) + FileUtils.mkdir(path) +end + +# good - atomic and idempotent creation +FileUtils.mkdir_p(path) + +# bad - race condition with another process may result in an error in `remove` +if File.exist?(path) + FileUtils.remove(path) +end + +# good - atomic and idempotent removal +FileUtils.rm_f(path) +---- + +[#references-lintnonatomicfileoperation] +=== References + +* https://rubystyle.guide#atomic-file-operations + +[#lintnondeterministicrequireorder] +== Lint/NonDeterministicRequireOrder + +NOTE: Requires Ruby version <= 2.7 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| Always (Unsafe) +| 0.78 +| - +|=== + +`Dir[...]` and `Dir.glob(...)` do not make any guarantees about +the order in which files are returned. The final order is +determined by the operating system and file system. +This means that using them in cases where the order matters, +such as requiring files, can lead to intermittent failures +that are hard to debug. To ensure this doesn't happen, +always sort the list. + +`Dir.glob` and `Dir[]` sort globbed results by default in Ruby 3.0. +So all bad cases are acceptable when Ruby 3.0 or higher are used. + +NOTE: This cop will be deprecated and removed when supporting only Ruby 3.0 and higher. + +[#safety-lintnondeterministicrequireorder] +=== Safety + +This cop is unsafe in the case where sorting files changes existing +expected behavior. + +[#examples-lintnondeterministicrequireorder] +=== Examples + +[source,ruby] +---- +# bad +Dir["./lib/**/*.rb"].each do |file| + require file +end + +# good +Dir["./lib/**/*.rb"].sort.each do |file| + require file +end + +# bad +Dir.glob(Rails.root.join(__dir__, 'test', '*.rb')) do |file| + require file +end + +# good +Dir.glob(Rails.root.join(__dir__, 'test', '*.rb')).sort.each do |file| + require file +end + +# bad +Dir['./lib/**/*.rb'].each(&method(:require)) + +# good +Dir['./lib/**/*.rb'].sort.each(&method(:require)) + +# bad +Dir.glob(Rails.root.join('test', '*.rb'), &method(:require)) + +# good +Dir.glob(Rails.root.join('test', '*.rb')).sort.each(&method(:require)) + +# good - Respect intent if `sort` keyword option is specified in Ruby 3.0 or higher. +Dir.glob(Rails.root.join(__dir__, 'test', '*.rb'), sort: false).each(&method(:require)) +---- + +[#lintnonlocalexitfromiterator] +== Lint/NonLocalExitFromIterator + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.30 +| - +|=== + +Checks for non-local exits from iterators without a return +value. It registers an offense under these conditions: + +* No value is returned, +* the block is preceded by a method chain, +* the block has arguments, +* the method which receives the block is not `define_method` +or `define_singleton_method`, +* the return is not contained in an inner scope, e.g. a lambda or a +method definition. + +[#examples-lintnonlocalexitfromiterator] +=== Examples + +[source,ruby] +---- +class ItemApi + rescue_from ValidationError do |e| # non-iteration block with arg + return { message: 'validation error' } unless e.errors # allowed + error_array = e.errors.map do |error| # block with method chain + return if error.suppress? # warned + return "#{error.param}: invalid" unless error.message # allowed + "#{error.param}: #{error.message}" + end + { message: 'validation error', errors: error_array } + end + + def update_items + transaction do # block without arguments + return unless update_necessary? # allowed + find_each do |item| # block without method chain + return if item.stock == 0 # false-negative... + item.update!(foobar: true) + end + end + end +end +---- + +[#lintnumberconversion] +== Lint/NumberConversion + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always (Unsafe) +| 0.53 +| 1.1 +|=== + +Warns the usage of unsafe number conversions. Unsafe +number conversion can cause unexpected error if auto type conversion +fails. Cop prefer parsing with number class instead. + +Conversion with `Integer`, `Float`, etc. will raise an `ArgumentError` +if given input that is not numeric (eg. an empty string), whereas +`to_i`, etc. will try to convert regardless of input (``''.to_i => 0``). +As such, this cop is disabled by default because it's not necessarily +always correct to raise if a value is not numeric. + +NOTE: Some values cannot be converted properly using one of the `Kernel` +method (for instance, `Time` and `DateTime` values are allowed by this +cop by default). Similarly, Rails' duration methods do not work well +with `Integer()` and can be allowed with `AllowedMethods`. By default, +there are no methods to allowed. + +[#safety-lintnumberconversion] +=== Safety + +Autocorrection is unsafe because it is not guaranteed that the +replacement `Kernel` methods are able to properly handle the +input if it is not a standard class. + +[#examples-lintnumberconversion] +=== Examples + +[source,ruby] +---- +# bad + +'10'.to_i +'10.2'.to_f +'10'.to_c +'1/3'.to_r +['1', '2', '3'].map(&:to_i) +foo.try(:to_f) +bar.send(:to_c) + +# good + +Integer('10', 10) +Float('10.2') +Complex('10') +Rational('1/3') +['1', '2', '3'].map { |i| Integer(i, 10) } +foo.try { |i| Float(i) } +bar.send { |i| Complex(i) } +---- + +[#allowedmethods_-__-_default_-lintnumberconversion] +==== AllowedMethods: [] (default) + +[source,ruby] +---- +# bad +10.minutes.to_i +---- + +[#allowedmethods_-_minutes_-lintnumberconversion] +==== AllowedMethods: [minutes] + +[source,ruby] +---- +# good +10.minutes.to_i +---- + +[#allowedpatterns_-__-_default_-lintnumberconversion] +==== AllowedPatterns: [] (default) + +[source,ruby] +---- +# bad +10.minutes.to_i +---- + +[#allowedpatterns_-__min___-lintnumberconversion] +==== AllowedPatterns: ['min*'] + +[source,ruby] +---- +# good +10.minutes.to_i +---- + +[#ignoredclasses_-_time_-datetime_-_default_-lintnumberconversion] +==== IgnoredClasses: [Time, DateTime] (default) + +[source,ruby] +---- +# good +Time.now.to_datetime.to_i +---- + +[#configurable-attributes-lintnumberconversion] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedMethods +| `[]` +| Array + +| AllowedPatterns +| `[]` +| Array + +| IgnoredClasses +| `Time`, `DateTime` +| Array +|=== + +[#lintnumberedparameterassignment] +== Lint/NumberedParameterAssignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.9 +| - +|=== + +Checks for uses of numbered parameter assignment. +It emulates the following warning in Ruby 2.7: + + $ ruby -ve '_1 = :value' + ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19] + -e:1: warning: `_1' is reserved for numbered parameter; consider another name + +Assigning to a numbered parameter (from `_1` to `_9`) causes an error in Ruby 3.0. + + $ ruby -ve '_1 = :value' + ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19] + -e:1: _1 is reserved for numbered parameter + +NOTE: The parametered parameters are from `_1` to `_9`. This cop checks `_0`, and over `_10` +as well to prevent confusion. + +[#examples-lintnumberedparameterassignment] +=== Examples + +[source,ruby] +---- +# bad +_1 = :value + +# good +non_numbered_parameter_name = :value +---- + +[#lintnumericoperationwithconstantresult] +== Lint/NumericOperationWithConstantResult + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.69 +| - +|=== + +Certain numeric operations have a constant result, usually 0 or 1. +Multiplying a number by 0 will always return 0. +Dividing a number by itself or raising it to the power of 0 will always return 1. +As such, they can be replaced with that result. +These are probably leftover from debugging, or are mistakes. +Other numeric operations that are similarly leftover from debugging or mistakes +are handled by `Lint/UselessNumericOperation`. + +NOTE: This cop doesn't detect offenses for the `-` and `%` operator because it +can't determine the type of `x`. If `x` is an `Array` or `String`, it doesn't perform +a numeric operation. + +[#examples-lintnumericoperationwithconstantresult] +=== Examples + +[source,ruby] +---- +# bad +x * 0 + +# good +0 + +# bad +x *= 0 + +# good +x = 0 + +# bad +x / x +x ** 0 + +# good +1 + +# bad +x /= x +x **= 0 + +# good +x = 1 +---- + +[#lintorassignmenttoconstant] +== Lint/OrAssignmentToConstant + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| No +| Always (Unsafe) +| 1.9 +| - +|=== + +Checks for unintended or-assignment to a constant. + +Constants should always be assigned in the same location. And its value +should always be the same. If constants are assigned in multiple +locations, the result may vary depending on the order of `require`. + +[#safety-lintorassignmenttoconstant] +=== Safety + +This cop is unsafe because code that is already conditionally +assigning a constant may have its behavior changed by autocorrection. + +[#examples-lintorassignmenttoconstant] +=== Examples + +[source,ruby] +---- +# bad +CONST ||= 1 + +# good +CONST = 1 +---- + +[#lintorderedmagiccomments] +== Lint/OrderedMagicComments + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always (Unsafe) +| 0.53 +| 1.37 +|=== + +Checks the proper ordering of magic comments and whether +a magic comment is not placed before a shebang. + +[#safety-lintorderedmagiccomments] +=== Safety + +This cop's autocorrection is unsafe because file encoding may change. + +[#examples-lintorderedmagiccomments] +=== Examples + +[source,ruby] +---- +# bad + +# frozen_string_literal: true +# encoding: ascii +p [''.frozen?, ''.encoding] #=> [true, #] + +# good + +# encoding: ascii +# frozen_string_literal: true +p [''.frozen?, ''.encoding] #=> [true, #] + +# good + +#!/usr/bin/env ruby +# encoding: ascii +# frozen_string_literal: true +p [''.frozen?, ''.encoding] #=> [true, #] +---- + +[#lintoutofrangeregexpref] +== Lint/OutOfRangeRegexpRef + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| No +| 0.89 +| - +|=== + +Looks for references of `Regexp` captures that are out of range +and thus always returns nil. + +[#safety-lintoutofrangeregexpref] +=== Safety + +This cop is unsafe because it is naive in how it determines what +references are available based on the last encountered regexp, but +it cannot handle some cases, such as conditional regexp matches, which +leads to false positives, such as: + +[source,ruby] +---- +foo ? /(c)(b)/ =~ str : /(b)/ =~ str +do_something if $2 +# $2 is defined for the first condition but not the second, however +# the cop will mark this as an offense. +---- + +This might be a good indication of code that should be refactored, +however. + +[#examples-lintoutofrangeregexpref] +=== Examples + +[source,ruby] +---- +/(foo)bar/ =~ 'foobar' + +# bad - always returns nil + +puts $2 # => nil + +# good + +puts $1 # => foo +---- + +[#lintparenthesesasgroupedexpression] +== Lint/ParenthesesAsGroupedExpression + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.12 +| 0.83 +|=== + +Checks for space between the name of a called method and a left +parenthesis. + +[#examples-lintparenthesesasgroupedexpression] +=== Examples + +[source,ruby] +---- +# bad +do_something (foo) + +# good +do_something(foo) +do_something (2 + 3) * 4 +do_something (foo * bar).baz +---- + +[#references-lintparenthesesasgroupedexpression] +=== References + +* https://rubystyle.guide#parens-no-spaces + +[#lintpercentstringarray] +== Lint/PercentStringArray + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| Always (Unsafe) +| 0.41 +| - +|=== + +Checks for quotes and commas in %w, e.g. `%w('foo', "bar")` + +It is more likely that the additional characters are unintended (for +example, mistranslating an array of literals to percent string notation) +rather than meant to be part of the resulting strings. + +[#safety-lintpercentstringarray] +=== Safety + +The cop is unsafe because the correction changes the values in the array +and that might have been done purposely. + +[source,ruby] +---- +%w('foo', "bar") #=> ["'foo',", '"bar"'] +%w(foo bar) #=> ['foo', 'bar'] +---- + +[#examples-lintpercentstringarray] +=== Examples + +[source,ruby] +---- +# bad +%w('foo', "bar") + +# good +%w(foo bar) +---- + +[#lintpercentsymbolarray] +== Lint/PercentSymbolArray + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.41 +| - +|=== + +Checks for colons and commas in %i, e.g. `%i(:foo, :bar)` + +It is more likely that the additional characters are unintended (for +example, mistranslating an array of literals to percent string notation) +rather than meant to be part of the resulting symbols. + +[#examples-lintpercentsymbolarray] +=== Examples + +[source,ruby] +---- +# bad +%i(:foo, :bar) + +# good +%i(foo bar) +---- + +[#lintraiseexception] +== Lint/RaiseException + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| Always (Unsafe) +| 0.81 +| 0.86 +|=== + +Checks for `raise` or `fail` statements which raise `Exception` or +`Exception.new`. Use `StandardError` or a specific exception class instead. + +If you have defined your own namespaced `Exception` class, it is possible +to configure the cop to allow it by setting `AllowedImplicitNamespaces` to +an array with the names of the namespaces to allow. By default, this is set to +`['Gem']`, which allows `Gem::Exception` to be raised without an explicit namespace. +If not allowed, a false positive may be registered if `raise Exception` is called +within the namespace. + +Alternatively, use a fully qualified name with `raise`/`fail` +(eg. `raise Namespace::Exception`). + +[#safety-lintraiseexception] +=== Safety + +This cop is unsafe because it will change the exception class being +raised, which is a change in behavior. + +[#examples-lintraiseexception] +=== Examples + +[source,ruby] +---- +# bad +raise Exception, 'Error message here' +raise Exception.new('Error message here') + +# good +raise StandardError, 'Error message here' +raise MyError.new, 'Error message here' +---- + +[#allowedimplicitnamespaces_-__gem__-_default_-lintraiseexception] +==== AllowedImplicitNamespaces: ['Gem'] (default) + +[source,ruby] +---- +# bad - `Foo` is not an allowed implicit namespace +module Foo + def self.foo + raise Exception # This is qualified to `Foo::Exception`. + end +end + +# good +module Gem + def self.foo + raise Exception # This is qualified to `Gem::Exception`. + end +end + +# good +module Foo + def self.foo + raise Foo::Exception + end +end +---- + +[#configurable-attributes-lintraiseexception] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedImplicitNamespaces +| `Gem` +| Array +|=== + +[#references-lintraiseexception] +=== References + +* https://rubystyle.guide#raise-exception + +[#lintrandone] +== Lint/RandOne + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.36 +| - +|=== + +Checks for `rand(1)` calls. +Such calls always return `0`. + +[#examples-lintrandone] +=== Examples + +[source,ruby] +---- +# bad +rand 1 +Kernel.rand(-1) +rand 1.0 +rand(-1.0) + +# good +0 # just use 0 instead +---- + +[#lintredundantcopdisabledirective] +== Lint/RedundantCopDisableDirective + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.76 +| - +|=== + +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. + +[#examples-lintredundantcopdisabledirective] +=== Examples + +[source,ruby] +---- +# bad +# rubocop:disable Layout/LineLength +x += 1 +# rubocop:enable Layout/LineLength + +# good +x += 1 +---- + +[#lintredundantcopenabledirective] +== Lint/RedundantCopEnableDirective + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.76 +| - +|=== + +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. + +[#examples-lintredundantcopenabledirective] +=== Examples + +[source,ruby] +---- +# bad +foo = 1 +# rubocop:enable Layout/LineLength + +# good +foo = 1 + +# 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 +---- + +[#lintredundantdirglobsort] +== Lint/RedundantDirGlobSort + +NOTE: Requires Ruby version 3.0 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always (Unsafe) +| 1.8 +| 1.26 +|=== + +Sort globbed results by default in Ruby 3.0. +This cop checks for redundant `sort` method to `Dir.glob` and `Dir[]`. + +[#safety-lintredundantdirglobsort] +=== Safety + +This cop is unsafe, in case of having a file and a directory with +identical names, since directory will be loaded before the file, which +will break `exe/files.rb` that rely on `exe.rb` file. + +[#examples-lintredundantdirglobsort] +=== Examples + +[source,ruby] +---- +# bad +Dir.glob('./lib/**/*.rb').sort.each do |file| +end + +Dir['./lib/**/*.rb'].sort.each do |file| +end + +# good +Dir.glob('./lib/**/*.rb').each do |file| +end + +Dir['./lib/**/*.rb'].each do |file| +end +---- + +[#lintredundantregexpquantifiers] +== Lint/RedundantRegexpQuantifiers + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.53 +| - +|=== + +Checks for redundant quantifiers inside `Regexp` literals. + +It is always allowed when interpolation is used in a regexp literal, +because it's unknown what kind of string will be expanded as a result: + +[source,ruby] +---- +/(?:a*#{interpolation})?/x +---- + +[#examples-lintredundantregexpquantifiers] +=== Examples + +[source,ruby] +---- +# bad +/(?:x+)+/ + +# good +/(?:x)+/ + +# good +/(?:x+)/ + +# bad +/(?:x+)?/ + +# good +/(?:x)*/ + +# good +/(?:x*)/ +---- + +[#lintredundantrequirestatement] +== Lint/RedundantRequireStatement + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.76 +| 1.73 +|=== + +Checks for unnecessary `require` statement. + +The following features are unnecessary `require` statement because +they are already loaded. e.g. Ruby 2.2: + + ruby -ve 'p $LOADED_FEATURES.reject { |feature| %r|/| =~ feature }' + ruby 2.2.8p477 (2017-09-14 revision 59906) [x86_64-darwin13] + ["enumerator.so", "rational.so", "complex.so", "thread.rb"] + +Below are the features that each `TargetRubyVersion` targets. + + * 2.0+ ... `enumerator` + * 2.1+ ... `thread` + * 2.2+ ... Add `rational` and `complex` above + * 2.7+ ... Add `ruby2_keywords` above + * 3.1+ ... Add `fiber` above + * 3.2+ ... `set` + +This cop target those features. + +[#examples-lintredundantrequirestatement] +=== Examples + +[source,ruby] +---- +# bad +require 'unloaded_feature' +require 'thread' + +# good +require 'unloaded_feature' +---- + +[#lintredundantsafenavigation] +== Lint/RedundantSafeNavigation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| Always (Unsafe) +| 0.93 +| 1.79 +|=== + +Checks for redundant safe navigation calls. +Use cases where a constant, named in camel case for classes and modules is `nil` are rare, +and an offense is not detected when the receiver is a constant. The detection also applies +to `self`, and to literal receivers, except for `nil`. + +For all receivers, the `instance_of?`, `kind_of?`, `is_a?`, `eql?`, `respond_to?`, +and `equal?` methods are checked by default. +These are customizable with `AllowedMethods` option. + +The `AllowedMethods` option specifies nil-safe methods, +in other words, it is a method that is allowed to skip safe navigation. +Note that the `AllowedMethod` option is not an option that specifies methods +for which to suppress (allow) this cop's check. + +In the example below, the safe navigation operator (`&.`) is unnecessary +because `NilClass` has methods like `respond_to?` and `is_a?`. + +The `InferNonNilReceiver` option specifies whether to look into previous code +paths to infer if the receiver can't be nil. This check is unsafe because the receiver +can be redefined between the safe navigation call and previous regular method call. +It does the inference only in the current scope, e.g. within the same method definition etc. + +The `AdditionalNilMethods` option specifies additional custom methods which are +defined on `NilClass`. When `InferNonNilReceiver` is set, they are used to determine +whether the receiver can be nil. + +[#safety-lintredundantsafenavigation] +=== Safety + +This cop is unsafe, because autocorrection can change the return type of +the expression. An offending expression that previously could return `nil` +will be autocorrected to never return `nil`. + +[#examples-lintredundantsafenavigation] +=== Examples + +[source,ruby] +---- +# bad +CamelCaseConst&.do_something + +# good +CamelCaseConst.do_something + +# bad +foo.to_s&.strip +foo.to_i&.zero? +foo.to_f&.zero? +foo.to_a&.size +foo.to_h&.size + +# good +foo.to_s.strip +foo.to_i.zero? +foo.to_f.zero? +foo.to_a.size +foo.to_h.size + +# bad +do_something if attrs&.respond_to?(:[]) + +# good +do_something if attrs.respond_to?(:[]) + +# bad +while node&.is_a?(BeginNode) + node = node.parent +end + +# good +while node.is_a?(BeginNode) + node = node.parent +end + +# good - without `&.` this will always return `true` +foo&.respond_to?(:to_a) + +# bad - for `nil`s conversion methods return default values for the type +foo&.to_h || {} +foo&.to_h { |k, v| [k, v] } || {} +foo&.to_a || [] +foo&.to_i || 0 +foo&.to_f || 0.0 +foo&.to_s || '' + +# good +foo.to_h +foo.to_h { |k, v| [k, v] } +foo.to_a +foo.to_i +foo.to_f +foo.to_s + +# bad +self&.foo + +# good +self.foo +---- + +[#allowedmethods_-_nil_safe_method_-lintredundantsafenavigation] +==== AllowedMethods: [nil_safe_method] + +[source,ruby] +---- +# bad +do_something if attrs&.nil_safe_method(:[]) + +# good +do_something if attrs.nil_safe_method(:[]) +do_something if attrs&.not_nil_safe_method(:[]) +---- + +[#infernonnilreceiver_-false-_default_-lintredundantsafenavigation] +==== InferNonNilReceiver: false (default) + +[source,ruby] +---- +# good +foo.bar +foo&.baz +---- + +[#infernonnilreceiver_-true-lintredundantsafenavigation] +==== InferNonNilReceiver: true + +[source,ruby] +---- +# bad +foo.bar +foo&.baz # would raise on previous line if `foo` is nil + +# good +foo.bar +foo.baz + +# bad +if foo.condition? + foo&.bar +end + +# good +if foo.condition? + foo.bar +end + +# good (different scopes) +def method1 + foo.bar +end + +def method2 + foo&.bar +end +---- + +[#additionalnilmethods_-_present__-lintredundantsafenavigation] +==== AdditionalNilMethods: [present?] + +[source,ruby] +---- +# good +foo.present? +foo&.bar +---- + +[#configurable-attributes-lintredundantsafenavigation] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedMethods +| `instance_of?`, `kind_of?`, `is_a?`, `eql?`, `respond_to?`, `equal?` +| Array + +| InferNonNilReceiver +| `false` +| Boolean + +| AdditionalNilMethods +| `present?`, `blank?`, `try`, `try!` +| Array +|=== + +[#lintredundantsplatexpansion] +== Lint/RedundantSplatExpansion + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.76 +| 1.7 +|=== + +Checks for unneeded usages of splat expansion. + +[#examples-lintredundantsplatexpansion] +=== Examples + +[source,ruby] +---- +# bad +a = *[1, 2, 3] +a = *'a' +a = *1 +['a', 'b', *%w(c d e), 'f', 'g'] + +# good +c = [1, 2, 3] +a = *c +a, b = *c +a, *b = *c +a = *1..10 +a = ['a'] +['a', 'b', 'c', 'd', 'e', 'f', 'g'] + +# bad +do_something(*['foo', 'bar', 'baz']) + +# good +do_something('foo', 'bar', 'baz') + +# bad +begin + foo +rescue *[StandardError, ApplicationError] + bar +end + +# good +begin + foo +rescue StandardError, ApplicationError + bar +end + +# bad +case foo +when *[1, 2, 3] + bar +else + baz +end + +# good +case foo +when 1, 2, 3 + bar +else + baz +end +---- + +[#allowpercentliteralarrayargument_-true-_default_-lintredundantsplatexpansion] +==== AllowPercentLiteralArrayArgument: true (default) + +[source,ruby] +---- +# good +do_something(*%w[foo bar baz]) +---- + +[#allowpercentliteralarrayargument_-false-lintredundantsplatexpansion] +==== AllowPercentLiteralArrayArgument: false + +[source,ruby] +---- +# bad +do_something(*%w[foo bar baz]) +---- + +[#configurable-attributes-lintredundantsplatexpansion] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowPercentLiteralArrayArgument +| `true` +| Boolean +|=== + +[#lintredundantstringcoercion] +== Lint/RedundantStringCoercion + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.19 +| 0.77 +|=== + +Checks for string conversion in string interpolation, `print`, `puts`, and `warn` arguments, +which is redundant. + +[#examples-lintredundantstringcoercion] +=== Examples + +[source,ruby] +---- +# bad +"result is #{something.to_s}" +print something.to_s +puts something.to_s +warn something.to_s + +# good +"result is #{something}" +print something +puts something +warn something +---- + +[#references-lintredundantstringcoercion] +=== References + +* https://rubystyle.guide#no-to-s + +[#lintredundanttypeconversion] +== Lint/RedundantTypeConversion + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.72 +| - +|=== + +Checks for redundant uses of `to_s`, `to_sym`, `to_i`, `to_f`, `to_d`, `to_r`, `to_c`, +`to_a`, `to_h`, and `to_set`. + +When one of these methods is called on an object of the same type, that object +is returned, making the call unnecessary. The cop detects conversion methods called +on object literals, class constructors, class `[]` methods, and the `Kernel` methods +`String()`, `Integer()`, `Float()`, BigDecimal(), `Rational()`, `Complex()`, and `Array()`. + +Specifically, these cases are detected for each conversion method: + +* `to_s` when called on a string literal, interpolated string, heredoc, + or with `String.new` or `String()`. +* `to_sym` when called on a symbol literal or interpolated symbol. +* `to_i` when called on an integer literal or with `Integer()`. +* `to_f` when called on a float literal of with `Float()`. +* `to_r` when called on a rational literal or with `Rational()`. +* `to_c` when called on a complex literal of with `Complex()`. +* `to_a` when called on an array literal, or with `Array.new`, `Array()` or `Array[]`. +* `to_h` when called on a hash literal, or with `Hash.new`, `Hash()` or `Hash[]`. +* `to_set` when called on `Set.new` or `Set[]`. + +In all cases, chaining one same `to_*` conversion methods listed above is redundant. + +The cop can also register an offense for chaining conversion methods on methods that are +expected to return a specific type regardless of receiver (eg. `foo.inspect.to_s` and +`foo.to_json.to_s`). + +[#examples-lintredundanttypeconversion] +=== Examples + +[source,ruby] +---- +# bad +"text".to_s +:sym.to_sym +42.to_i +8.5.to_f +12r.to_r +1i.to_c +[].to_a +{}.to_h +Set.new.to_set + +# good +"text" +:sym +42 +8.5 +12r +1i +[] +{} +Set.new + +# bad +Integer(var).to_i + +# good +Integer(var) + +# good - chaining to a type constructor with exceptions suppressed +# in this case, `Integer()` could return `nil` +Integer(var, exception: false).to_i + +# bad - chaining the same conversion +foo.to_s.to_s + +# good +foo.to_s + +# bad - chaining a conversion to a method that is expected to return the same type +foo.inspect.to_s +foo.to_json.to_s + +# good +foo.inspect +foo.to_json +---- + +[#lintredundantwithindex] +== Lint/RedundantWithIndex + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.50 +| - +|=== + +Checks for redundant `with_index`. + +[#examples-lintredundantwithindex] +=== Examples + +[source,ruby] +---- +# bad +ary.each_with_index do |v| + v +end + +# good +ary.each do |v| + v +end + +# bad +ary.each.with_index do |v| + v +end + +# good +ary.each do |v| + v +end +---- + +[#lintredundantwithobject] +== Lint/RedundantWithObject + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.51 +| - +|=== + +Checks for redundant `with_object`. + +[#examples-lintredundantwithobject] +=== Examples + +[source,ruby] +---- +# bad +ary.each_with_object([]) do |v| + v +end + +# good +ary.each do |v| + v +end + +# bad +ary.each.with_object([]) do |v| + v +end + +# good +ary.each do |v| + v +end +---- + +[#lintrefinementimportmethods] +== Lint/RefinementImportMethods + +NOTE: Requires Ruby version 3.1 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.27 +| - +|=== + +Checks if `include` or `prepend` is called in `refine` block. +These methods are deprecated and should be replaced with `Refinement#import_methods`. + +It emulates deprecation warnings in Ruby 3.1. Functionality has been removed in Ruby 3.2. + +[#safety-lintrefinementimportmethods] +=== Safety + +This cop's autocorrection is unsafe because `include M` will affect the included class +if any changes are made to module `M`. +On the other hand, `import_methods M` uses a snapshot of method definitions, +thus it will not be affected if module `M` changes. + +[#examples-lintrefinementimportmethods] +=== Examples + +[source,ruby] +---- +# bad +refine Foo do + include Bar +end + +# bad +refine Foo do + prepend Bar +end + +# good +refine Foo do + import_methods Bar +end +---- + +[#lintregexpascondition] +== Lint/RegexpAsCondition + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.51 +| 0.86 +|=== + +Checks for regexp literals used as `match-current-line`. +If a regexp literal is in condition, the regexp matches `$_` implicitly. + +[#examples-lintregexpascondition] +=== Examples + +[source,ruby] +---- +# bad +if /foo/ + do_something +end + +# good +if /foo/ =~ $_ + do_something +end +---- + +[#lintrequireparentheses] +== Lint/RequireParentheses + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.18 +| - +|=== + +Checks for expressions where there is a call to a predicate +method with at least one argument, where no parentheses are used around +the parameter list, and a boolean operator, && or ||, is used in the +last argument. + +The idea behind warning for these constructs is that the user might +be under the impression that the return value from the method call is +an operand of &&/||. + +[#examples-lintrequireparentheses] +=== Examples + +[source,ruby] +---- +# bad +if day.is? :tuesday && month == :jan + # ... +end + +# good +if day.is?(:tuesday) && month == :jan + # ... +end +---- + +[#lintrequirerangeparentheses] +== Lint/RequireRangeParentheses + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.32 +| - +|=== + +Checks that a range literal is enclosed in parentheses when the end of the range is +at a line break. + +NOTE: The following is maybe intended for `(42..)`. But, compatible is `42..do_something`. +So, this cop does not provide autocorrection because it is left to user. + +[source,ruby] +---- +case condition +when 42.. + do_something +end +---- + +[#examples-lintrequirerangeparentheses] +=== Examples + +[source,ruby] +---- +# bad - Represents `(1..42)`, not endless range. +1.. +42 + +# good - It's incompatible, but your intentions when using endless range may be: +(1..) +42 + +# good +1..42 + +# good +(1..42) + +# good +(1.. +42) +---- + +[#lintrequirerelativeselfpath] +== Lint/RequireRelativeSelfPath + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.22 +| - +|=== + +Checks for uses a file requiring itself with `require_relative`. + +[#examples-lintrequirerelativeselfpath] +=== Examples + +[source,ruby] +---- +# bad + +# foo.rb +require_relative 'foo' +require_relative 'bar' + +# good + +# foo.rb +require_relative 'bar' +---- + +[#lintrescueexception] +== Lint/RescueException + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.9 +| 0.27 +|=== + +Checks for `rescue` blocks targeting the `Exception` class. + +[#examples-lintrescueexception] +=== Examples + +[source,ruby] +---- +# bad +begin + do_something +rescue Exception + handle_exception +end + +# good +begin + do_something +rescue ArgumentError + handle_exception +end +---- + +[#references-lintrescueexception] +=== References + +* https://rubystyle.guide#no-blind-rescues + +[#lintrescuetype] +== Lint/RescueType + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| - +|=== + +Checks for arguments to `rescue` that will result in a `TypeError` +if an exception is raised. + +[#examples-lintrescuetype] +=== Examples + +[source,ruby] +---- +# bad +begin + bar +rescue nil + baz +end + +# bad +def foo + bar +rescue 1, 'a', "#{b}", 0.0, [], {} + baz +end + +# good +begin + bar +rescue + baz +end + +# good +def foo + bar +rescue NameError + baz +end +---- + +[#lintreturninvoidcontext] +== Lint/ReturnInVoidContext + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.50 +| - +|=== + +Checks for the use of a return with a value in a context +where the value will be ignored. (initialize and setter methods) + +[#examples-lintreturninvoidcontext] +=== Examples + +[source,ruby] +---- +# bad +def initialize + foo + return :qux if bar? + baz +end + +def foo=(bar) + return 42 +end + +# good +def initialize + foo + return if bar? + baz +end + +def foo=(bar) + return +end +---- + +[#lintsafenavigationchain] +== Lint/SafeNavigationChain + +NOTE: Requires Ruby version 2.3 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.47 +| 0.77 +|=== + +The safe navigation operator returns nil if the receiver is +nil. If you chain an ordinary method call after a safe +navigation operator, it raises NoMethodError. We should use a +safe navigation operator after a safe navigation operator. +This cop checks for the problem outlined above. + +[#examples-lintsafenavigationchain] +=== Examples + +[source,ruby] +---- +# bad +x&.foo.bar +x&.foo + bar +x&.foo[bar] + +# good +x&.foo&.bar +x&.foo || bar +---- + +[#configurable-attributes-lintsafenavigationchain] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedMethods +| `present?`, `blank?`, `presence`, `try`, `try!`, `in?` +| Array +|=== + +[#lintsafenavigationconsistency] +== Lint/SafeNavigationConsistency + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.55 +| 0.77 +|=== + +Check to make sure that if safe navigation is used in an `&&` or `||` condition, +consistent and appropriate safe navigation, without excess or deficiency, +is used for all method calls on the same object. + +[#examples-lintsafenavigationconsistency] +=== Examples + +[source,ruby] +---- +# bad +foo&.bar && foo&.baz + +# good +foo&.bar && foo.baz + +# bad +foo.bar && foo&.baz + +# good +foo.bar && foo.baz + +# bad +foo&.bar || foo.baz + +# good +foo&.bar || foo&.baz + +# bad +foo.bar || foo&.baz + +# good +foo.bar || foo.baz + +# bad +foo&.bar && (foobar.baz || foo&.baz) + +# good +foo&.bar && (foobar.baz || foo.baz) +---- + +[#configurable-attributes-lintsafenavigationconsistency] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedMethods +| `present?`, `blank?`, `presence`, `try`, `try!` +| Array +|=== + +[#lintsafenavigationwithempty] +== Lint/SafeNavigationWithEmpty + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.62 +| 0.87 +|=== + +Checks to make sure safe navigation isn't used with `empty?` in +a conditional. + +While the safe navigation operator is generally a good idea, when +checking `foo&.empty?` in a conditional, `foo` being `nil` will actually +do the opposite of what the author intends. + +[#examples-lintsafenavigationwithempty] +=== Examples + +[source,ruby] +---- +# bad +return if foo&.empty? +return unless foo&.empty? + +# good +return if foo && foo.empty? +return unless foo && foo.empty? +---- + +[#lintscriptpermission] +== Lint/ScriptPermission + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.49 +| 0.50 +|=== + +Checks if a file which has a shebang line as +its first line is granted execute permission. + +[#examples-lintscriptpermission] +=== Examples + +[source,ruby] +---- +# bad + +# A file which has a shebang line as its first line is not +# granted execute permission. + +#!/usr/bin/env ruby +puts 'hello, world' + +# good + +# A file which has a shebang line as its first line is +# granted execute permission. + +#!/usr/bin/env ruby +puts 'hello, world' + +# good + +# A file which has not a shebang line as its first line is not +# granted execute permission. + +puts 'hello, world' +---- + +[#lintselfassignment] +== Lint/SelfAssignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.89 +| - +|=== + +Checks for self-assignments. + +[#examples-lintselfassignment] +=== Examples + +[source,ruby] +---- +# bad +foo = foo +foo, bar = foo, bar +Foo = Foo +hash['foo'] = hash['foo'] +obj.attr = obj.attr + +# good +foo = bar +foo, bar = bar, foo +Foo = Bar +hash['foo'] = hash['bar'] +obj.attr = obj.attr2 + +# good (method calls possibly can return different results) +hash[foo] = hash[foo] +---- + +[#allowrbsinlineannotation_true-lintselfassignment] +==== AllowRBSInlineAnnotation:true + +[source,ruby] +---- +# good +foo = foo #: Integer +foo, bar = foo, bar #: Integer +Foo = Foo #: Integer +hash['foo'] = hash['foo'] #: Integer +obj.attr = obj.attr #: Integer +---- + +[#configurable-attributes-lintselfassignment] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowRBSInlineAnnotation +| `false` +| Boolean +|=== + +[#lintsendwithmixinargument] +== Lint/SendWithMixinArgument + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.75 +| - +|=== + +Checks for `send`, `public_send`, and `__send__` methods +when using mix-in. + +`include` and `prepend` methods were private methods until Ruby 2.0, +they were mixed-in via `send` method. This cop uses Ruby 2.1 or +higher style that can be called by public methods. +And `extend` method that was originally a public method is also targeted +for style unification. + +[#examples-lintsendwithmixinargument] +=== Examples + +[source,ruby] +---- +# bad +Foo.send(:include, Bar) +Foo.send(:prepend, Bar) +Foo.send(:extend, Bar) + +# bad +Foo.public_send(:include, Bar) +Foo.public_send(:prepend, Bar) +Foo.public_send(:extend, Bar) + +# bad +Foo.__send__(:include, Bar) +Foo.__send__(:prepend, Bar) +Foo.__send__(:extend, Bar) + +# good +Foo.include Bar +Foo.prepend Bar +Foo.extend Bar +---- + +[#lintshadowedargument] +== Lint/ShadowedArgument + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.52 +| - +|=== + +Checks for shadowed arguments. + +This cop has `IgnoreImplicitReferences` configuration option. +It means argument shadowing is used in order to pass parameters +to zero arity `super` when `IgnoreImplicitReferences` is `true`. + +[#examples-lintshadowedargument] +=== Examples + +[source,ruby] +---- +# bad +do_something do |foo| + foo = 42 + puts foo +end + +def do_something(foo) + foo = 42 + puts foo +end + +# good +do_something do |foo| + foo = foo + 42 + puts foo +end + +def do_something(foo) + foo = foo + 42 + puts foo +end + +def do_something(foo) + puts foo +end +---- + +[#ignoreimplicitreferences_-false-_default_-lintshadowedargument] +==== IgnoreImplicitReferences: false (default) + +[source,ruby] +---- +# bad +def do_something(foo) + foo = 42 + super +end + +def do_something(foo) + foo = super + bar +end +---- + +[#ignoreimplicitreferences_-true-lintshadowedargument] +==== IgnoreImplicitReferences: true + +[source,ruby] +---- +# good +def do_something(foo) + foo = 42 + super +end + +def do_something(foo) + foo = super + bar +end +---- + +[#configurable-attributes-lintshadowedargument] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| IgnoreImplicitReferences +| `false` +| Boolean +|=== + +[#lintshadowedexception] +== Lint/ShadowedException + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.41 +| - +|=== + +Checks for a rescued exception that get shadowed by a +less specific exception being rescued before a more specific +exception is rescued. + +An exception is considered shadowed if it is rescued after its +ancestor is, or if it and its ancestor are both rescued in the +same `rescue` statement. In both cases, the more specific rescue is +unnecessary because it is covered by rescuing the less specific +exception. (ie. `rescue Exception, StandardError` has the same behavior +whether `StandardError` is included or not, because all ``StandardError``s +are rescued by `rescue Exception`). + +[#examples-lintshadowedexception] +=== Examples + +[source,ruby] +---- +# bad + +begin + something +rescue Exception + handle_exception +rescue StandardError + handle_standard_error +end + +# bad +begin + something +rescue Exception, StandardError + handle_error +end + +# good + +begin + something +rescue StandardError + handle_standard_error +rescue Exception + handle_exception +end + +# good, however depending on runtime environment. +# +# This is a special case for system call errors. +# System dependent error code depends on runtime environment. +# For example, whether `Errno::EAGAIN` and `Errno::EWOULDBLOCK` are +# the same error code or different error code depends on environment. +# This good case is for `Errno::EAGAIN` and `Errno::EWOULDBLOCK` with +# the same error code. +begin + something +rescue Errno::EAGAIN, Errno::EWOULDBLOCK + handle_standard_error +end +---- + +[#lintshadowingouterlocalvariable] +== Lint/ShadowingOuterLocalVariable + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| No +| 0.9 +| 1.76 +|=== + +Checks for the use of local variable names from an outer scope +in block arguments or block-local variables. This mirrors the warning +given by `ruby -cw` prior to Ruby 2.6: +"shadowing outer local variable - foo". + +The cop is now disabled by default to match the upstream Ruby behavior. +It's useful, however, if you'd like to avoid shadowing variables from outer +scopes, which some people consider an anti-pattern that makes it harder +to keep track of what's going on in a program. + +NOTE: Shadowing of variables in block passed to `Ractor.new` is allowed +because `Ractor` should not access outer variables. +eg. following style is encouraged: + +[source,ruby] +---- +worker_id, pipe = env +Ractor.new(worker_id, pipe) do |worker_id, pipe| +end +---- + +[#examples-lintshadowingouterlocalvariable] +=== Examples + +[source,ruby] +---- +# bad +def some_method + foo = 1 + + 2.times do |foo| # shadowing outer `foo` + do_something(foo) + end +end + +# good +def some_method + foo = 1 + + 2.times do |bar| + do_something(bar) + end +end +---- + +[#lintsharedmutabledefault] +== Lint/SharedMutableDefault + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.70 +| - +|=== + +Checks for `Hash` creation with a mutable default value. +Creating a `Hash` in such a way will share the default value +across all keys, causing unexpected behavior when modifying it. + +For example, when the `Hash` was created with an `Array` as the argument, +calling `hash[:foo] << 'bar'` will also change the value of all +other keys that have not been explicitly assigned to. + +[#examples-lintsharedmutabledefault] +=== Examples + +[source,ruby] +---- +# bad +Hash.new([]) +Hash.new({}) +Hash.new(Array.new) +Hash.new(Hash.new) + +# okay -- In rare cases that intentionally have this behavior, +# without disabling the cop, you can set the default explicitly. +h = Hash.new +h.default = [] +h[:a] << 1 +h[:b] << 2 +h # => {:a => [1, 2], :b => [1, 2]} + +# okay -- beware this will discard mutations and only remember assignments +Hash.new { Array.new } +Hash.new { Hash.new } +Hash.new { {} } +Hash.new { [] } + +# good - frozen solution will raise an error when mutation attempted +Hash.new([].freeze) +Hash.new({}.freeze) + +# good - using a proc will create a new object for each key +h = Hash.new +h.default_proc = ->(h, k) { [] } +h.default_proc = ->(h, k) { {} } + +# good - using a block will create a new object for each key +Hash.new { |h, k| h[k] = [] } +Hash.new { |h, k| h[k] = {} } +---- + +[#references-lintsharedmutabledefault] +=== References + +* https://rubystyle.guide#no-mutable-defaults + +[#lintstructnewoverride] +== Lint/StructNewOverride + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.81 +| - +|=== + +Checks unexpected overrides of the `Struct` built-in methods +via `Struct.new`. + +[#examples-lintstructnewoverride] +=== Examples + +[source,ruby] +---- +# bad +Bad = Struct.new(:members, :clone, :count) +b = Bad.new([], true, 1) +b.members #=> [] (overriding `Struct#members`) +b.clone #=> true (overriding `Object#clone`) +b.count #=> 1 (overriding `Enumerable#count`) + +# good +Good = Struct.new(:id, :name) +g = Good.new(1, "foo") +g.members #=> [:id, :name] +g.clone #=> # +g.count #=> 2 +---- + +[#lintsuppressedexception] +== Lint/SuppressedException + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.9 +| 1.12 +|=== + +Checks for `rescue` blocks with no body. + +[#examples-lintsuppressedexception] +=== Examples + +[source,ruby] +---- +# bad +def some_method + do_something +rescue +end + +# bad +begin + do_something +rescue +end + +# good +def some_method + do_something +rescue + handle_exception +end + +# good +begin + do_something +rescue + handle_exception +end +---- + +[#allowcomments_-true-_default_-lintsuppressedexception] +==== AllowComments: true (default) + +[source,ruby] +---- +# good +def some_method + do_something +rescue + # do nothing +end + +# good +begin + do_something +rescue + # do nothing +end +---- + +[#allowcomments_-false-lintsuppressedexception] +==== AllowComments: false + +[source,ruby] +---- +# bad +def some_method + do_something +rescue + # do nothing +end + +# bad +begin + do_something +rescue + # do nothing +end +---- + +[#allownil_-true-_default_-lintsuppressedexception] +==== AllowNil: true (default) + +[source,ruby] +---- +# good +def some_method + do_something +rescue + nil +end + +# good +begin + do_something +rescue + # do nothing +end + +# good +do_something rescue nil +---- + +[#allownil_-false-lintsuppressedexception] +==== AllowNil: false + +[source,ruby] +---- +# bad +def some_method + do_something +rescue + nil +end + +# bad +begin + do_something +rescue + nil +end + +# bad +do_something rescue nil +---- + +[#configurable-attributes-lintsuppressedexception] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowComments +| `true` +| Boolean + +| AllowNil +| `true` +| Boolean +|=== + +[#references-lintsuppressedexception] +=== References + +* https://rubystyle.guide#dont-hide-exceptions + +[#lintsuppressedexceptioninnumberconversion] +== Lint/SuppressedExceptionInNumberConversion + +NOTE: Requires Ruby version 2.6 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always (Unsafe) +| 1.72 +| - +|=== + +Checks for cases where exceptions unrelated to the numeric constructors `Integer()`, +`Float()`, `BigDecimal()`, `Complex()`, and `Rational()` may be unintentionally swallowed. + +[#safety-lintsuppressedexceptioninnumberconversion] +=== Safety + +The cop is unsafe for autocorrection because unexpected errors occurring in the argument +passed to numeric constructor (e.g., `Integer()`) can lead to incompatible behavior. +For example, changing it to `Integer(potential_exception_method_call, exception: false)` +ensures that exceptions raised by `potential_exception_method_call` are not ignored. + +[source,ruby] +---- +Integer(potential_exception_method_call) rescue nil +---- + +[#examples-lintsuppressedexceptioninnumberconversion] +=== Examples + +[source,ruby] +---- +# bad +Integer(arg) rescue nil + +# bad +begin + Integer(arg) +rescue + nil +end + +# bad +begin + Integer(arg) +rescue +end + +# good +Integer(arg, exception: false) +---- + +[#lintsymbolconversion] +== Lint/SymbolConversion + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.9 +| 1.16 +|=== + +Checks for uses of literal strings converted to +a symbol where a literal symbol could be used instead. + +There are two possible styles for this cop. +`strict` (default) will register an offense for any incorrect usage. +`consistent` additionally requires hashes to use the same style for +every symbol key (ie. if any symbol key needs to be quoted it requires +all keys to be quoted). + +[#examples-lintsymbolconversion] +=== Examples + +[source,ruby] +---- +# bad +'string'.to_sym +:symbol.to_sym +'underscored_string'.to_sym +:'underscored_symbol' +'hyphenated-string'.to_sym +"string_#{interpolation}".to_sym + +# good +:string +:symbol +:underscored_string +:underscored_symbol +:'hyphenated-string' +:"string_#{interpolation}" +---- + +[#enforcedstyle_-strict-_default_-lintsymbolconversion] +==== EnforcedStyle: strict (default) + +[source,ruby] +---- +# bad +{ + 'a': 1, + "b": 2, + 'c-d': 3 +} + +# good (don't quote keys that don't require quoting) +{ + a: 1, + b: 2, + 'c-d': 3 +} +---- + +[#enforcedstyle_-consistent-lintsymbolconversion] +==== EnforcedStyle: consistent + +[source,ruby] +---- +# bad +{ + a: 1, + 'b-c': 2 +} + +# good (quote all keys if any need quoting) +{ + 'a': 1, + 'b-c': 2 +} + +# good (no quoting required) +{ + a: 1, + b: 2 +} +---- + +[#configurable-attributes-lintsymbolconversion] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `strict` +| `strict`, `consistent` +|=== + +[#lintsyntax] +== Lint/Syntax + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.9 +| - +|=== + +Repacks Parser's diagnostics/errors +into RuboCop's offenses. + +[#linttoenumarguments] +== Lint/ToEnumArguments + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.1 +| - +|=== + +Ensures that `to_enum`/`enum_for`, called for the current method, +has correct arguments. + +[#examples-linttoenumarguments] +=== Examples + +[source,ruby] +---- +# bad +def foo(x, y = 1) + return to_enum(__callee__, x) # `y` is missing +end + +# good +def foo(x, y = 1) + # Alternatives to `__callee__` are `__method__` and `:foo`. + return to_enum(__callee__, x, y) +end + +# good +def foo(x, y = 1) + # It is also allowed if it is wrapped in some method like Sorbet. + return to_enum(T.must(__callee__), x, y) +end +---- + +[#linttojson] +== Lint/ToJSON + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.66 +| - +|=== + +Checks to make sure `#to_json` includes an optional argument. +When overriding `#to_json`, callers may invoke JSON +generation via `JSON.generate(your_obj)`. Since `JSON#generate` allows +for an optional argument, your method should too. + +[#examples-linttojson] +=== Examples + +[source,ruby] +---- +class Point + attr_reader :x, :y + + # bad, incorrect arity + def to_json + JSON.generate([x, y]) + end + + # good, preserving args + def to_json(*args) + JSON.generate([x, y], *args) + end + + # good, discarding args + def to_json(*_args) + JSON.generate([x, y]) + end +end +---- + +[#linttoplevelreturnwithargument] +== Lint/TopLevelReturnWithArgument + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.89 +| - +|=== + +Checks for top level return with arguments. If there is a +top-level return statement with an argument, then the argument is +always ignored. This is detected automatically since Ruby 2.7. + +[#examples-linttoplevelreturnwithargument] +=== Examples + +[source,ruby] +---- +# bad +return 1 + +# good +return +---- + +[#configurable-attributes-linttoplevelreturnwithargument] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Exclude +| `+**/*.jb+` +| Array +|=== + +[#linttrailingcommainattributedeclaration] +== Lint/TrailingCommaInAttributeDeclaration + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Command-line only +| 0.90 +| 1.61 +|=== + +Checks for trailing commas in attribute declarations, such as +`#attr_reader`. Leaving a trailing comma will nullify the next method +definition by overriding it with a getter method. + +[#examples-linttrailingcommainattributedeclaration] +=== Examples + +[source,ruby] +---- +# bad +class Foo + attr_reader :foo, + + def bar + puts "Unreachable." + end +end + +# good +class Foo + attr_reader :foo + + def bar + puts "No problem!" + end +end +---- + +[#linttriplequotes] +== Lint/TripleQuotes + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.9 +| - +|=== + +Checks for "triple quotes" (strings delimited by any odd number +of quotes greater than 1). + +Ruby allows multiple strings to be implicitly concatenated by just +being adjacent in a statement (ie. `"foo""bar" == "foobar"`). This sometimes +gives the impression that there is something special about triple quotes, but +in fact it is just extra unnecessary quotes and produces the same string. Each +pair of quotes produces an additional concatenated empty string, so the result +is still only the "actual" string within the delimiters. + +NOTE: Although this cop is called triple quotes, the same behavior is present +for strings delimited by 5, 7, etc. quotation marks. + +[#examples-linttriplequotes] +=== Examples + +[source,ruby] +---- +# bad +""" + A string +""" + +# bad +''' + A string +''' + +# good +" + A string +" + +# good +< b } +values.sort { |*x| x[0] <=> x[1] } +---- + +[#configurable-attributes-lintunexpectedblockarity] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Methods +| `{"chunk_while" => 2, "each_with_index" => 2, "each_with_object" => 2, "inject" => 2, "max" => 2, "min" => 2, "minmax" => 2, "reduce" => 2, "slice_when" => 2, "sort" => 2}` +| +|=== + +[#lintunifiedinteger] +== Lint/UnifiedInteger + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.43 +| - +|=== + +Checks for using Fixnum or Bignum constant. + +[#examples-lintunifiedinteger] +=== Examples + +[source,ruby] +---- +# bad +1.is_a?(Fixnum) +1.is_a?(Bignum) + +# good +1.is_a?(Integer) +---- + +[#lintunmodifiedreduceaccumulator] +== Lint/UnmodifiedReduceAccumulator + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.1 +| 1.5 +|=== + +Looks for `reduce` or `inject` blocks where the value returned (implicitly or +explicitly) does not include the accumulator. A block is considered valid as +long as at least one return value includes the accumulator. + +If the accumulator is not included in the return value, then the entire +block will just return a transformation of the last element value, and +could be rewritten as such without a loop. + +Also catches instances where an index of the accumulator is returned, as +this may change the type of object being retained. + +NOTE: For the purpose of reducing false positives, this cop only flags +returns in `reduce` blocks where the element is the only variable in +the expression (since we will not be able to tell what other variables +relate to via static analysis). + +[#examples-lintunmodifiedreduceaccumulator] +=== Examples + +[source,ruby] +---- +# bad +(1..4).reduce(0) do |acc, el| + el * 2 +end + +# bad, may raise a NoMethodError after the first iteration +%w(a b c).reduce({}) do |acc, letter| + acc[letter] = true +end + +# good +(1..4).reduce(0) do |acc, el| + acc + el * 2 +end + +# good, element is returned but modified using the accumulator +values.reduce do |acc, el| + el << acc + el +end + +# good, returns the accumulator instead of the index +%w(a b c).reduce({}) do |acc, letter| + acc[letter] = true + acc +end + +# good, at least one branch returns the accumulator +values.reduce(nil) do |result, value| + break result if something? + value +end + +# good, recursive +keys.reduce(self) { |result, key| result[key] } + +# ignored as the return value cannot be determined +enum.reduce do |acc, el| + x = foo(acc, el) + bar(x) +end +---- + +[#lintunreachablecode] +== Lint/UnreachableCode + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.9 +| - +|=== + +Checks for unreachable code. +The check are based on the presence of flow of control +statement in non-final position in `begin` (implicit) blocks. + +[#examples-lintunreachablecode] +=== Examples + +[source,ruby] +---- +# bad +def some_method + return + do_something +end + +# bad +def some_method + if cond + return + else + return + end + do_something +end + +# good +def some_method + do_something +end +---- + +[#lintunreachableloop] +== Lint/UnreachableLoop + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.89 +| 1.7 +|=== + +Checks for loops that will have at most one iteration. + +A loop that can never reach the second iteration is a possible error in the code. +In rare cases where only one iteration (or at most one iteration) is intended behavior, +the code should be refactored to use `if` conditionals. + +NOTE: Block methods that are used with ``Enumerable``s are considered to be loops. + +`AllowedPatterns` can be used to match against the block receiver in order to allow +code that would otherwise be registered as an offense (eg. `times` used not in an +`Enumerable` context). + +[#examples-lintunreachableloop] +=== Examples + +[source,ruby] +---- +# bad +while node + do_something(node) + node = node.parent + break +end + +# good +while node + do_something(node) + node = node.parent +end + +# bad +def verify_list(head) + item = head + begin + if verify(item) + return true + else + return false + end + end while(item) +end + +# good +def verify_list(head) + item = head + begin + if verify(item) + item = item.next + else + return false + end + end while(item) + + true +end + +# bad +def find_something(items) + items.each do |item| + if something?(item) + return item + else + raise NotFoundError + end + end +end + +# good +def find_something(items) + items.each do |item| + if something?(item) + return item + end + end + raise NotFoundError +end + +# bad +2.times { raise ArgumentError } +---- + +[#allowedpatterns_-___exactly_at_least_at_most____d_____times__-_default_-lintunreachableloop] +==== AllowedPatterns: ['(exactly|at_least|at_most)\(\d+\)\.times'] (default) + +[source,ruby] +---- +# good +exactly(2).times { raise StandardError } +---- + +[#configurable-attributes-lintunreachableloop] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedPatterns +| `(?-mix:(exactly\|at_least\|at_most)\(\d+\)\.times)` +| Array +|=== + +[#lintunusedblockargument] +== Lint/UnusedBlockArgument + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Command-line only +| 0.21 +| 1.61 +|=== + +Checks for unused block arguments. + +[#examples-lintunusedblockargument] +=== Examples + +[source,ruby] +---- +# bad +do_something do |used, unused| + puts used +end + +do_something do |bar| + puts :foo +end + +define_method(:foo) do |bar| + puts :baz +end + +# good +do_something do |used, _unused| + puts used +end + +do_something do + puts :foo +end + +define_method(:foo) do |_bar| + puts :baz +end +---- + +[#ignoreemptyblocks_-true-_default_-lintunusedblockargument] +==== IgnoreEmptyBlocks: true (default) + +[source,ruby] +---- +# good +do_something { |unused| } +---- + +[#ignoreemptyblocks_-false-lintunusedblockargument] +==== IgnoreEmptyBlocks: false + +[source,ruby] +---- +# bad +do_something { |unused| } +---- + +[#allowunusedkeywordarguments_-false-_default_-lintunusedblockargument] +==== AllowUnusedKeywordArguments: false (default) + +[source,ruby] +---- +# bad +do_something do |unused: 42| + foo +end +---- + +[#allowunusedkeywordarguments_-true-lintunusedblockargument] +==== AllowUnusedKeywordArguments: true + +[source,ruby] +---- +# good +do_something do |unused: 42| + foo +end +---- + +[#configurable-attributes-lintunusedblockargument] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| IgnoreEmptyBlocks +| `true` +| Boolean + +| AllowUnusedKeywordArguments +| `false` +| Boolean +|=== + +[#references-lintunusedblockargument] +=== References + +* https://rubystyle.guide#underscore-unused-vars + +[#lintunusedmethodargument] +== Lint/UnusedMethodArgument + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Command-line only +| 0.21 +| 1.69 +|=== + +Checks for unused method arguments. + +[#examples-lintunusedmethodargument] +=== Examples + +[source,ruby] +---- +# bad +def some_method(used, unused, _unused_but_allowed) + puts used +end + +# good +def some_method(used, _unused, _unused_but_allowed) + puts used +end +---- + +[#allowunusedkeywordarguments_-false-_default_-lintunusedmethodargument] +==== AllowUnusedKeywordArguments: false (default) + +[source,ruby] +---- +# bad +def do_something(used, unused: 42) + used +end +---- + +[#allowunusedkeywordarguments_-true-lintunusedmethodargument] +==== AllowUnusedKeywordArguments: true + +[source,ruby] +---- +# good +def do_something(used, unused: 42) + used +end +---- + +[#ignoreemptymethods_-true-_default_-lintunusedmethodargument] +==== IgnoreEmptyMethods: true (default) + +[source,ruby] +---- +# good +def do_something(unused) +end +---- + +[#ignoreemptymethods_-false-lintunusedmethodargument] +==== IgnoreEmptyMethods: false + +[source,ruby] +---- +# bad +def do_something(unused) +end +---- + +[#ignorenotimplementedmethods_-true-_default_-lintunusedmethodargument] +==== IgnoreNotImplementedMethods: true (default) + +[source,ruby] +---- +# with default value of `NotImplementedExceptions: ['NotImplementedError']` + +# good +def do_something(unused) + raise NotImplementedError +end + +def do_something_else(unused) + fail "TODO" +end +---- + +[#ignorenotimplementedmethods_-true-lintunusedmethodargument] +==== IgnoreNotImplementedMethods: true + +[source,ruby] +---- +# with `NotImplementedExceptions: ['AbstractMethodError']` + +# good +def do_something(unused) + raise AbstractMethodError +end +---- + +[#ignorenotimplementedmethods_-false-lintunusedmethodargument] +==== IgnoreNotImplementedMethods: false + +[source,ruby] +---- +# bad +def do_something(unused) + raise NotImplementedError +end + +def do_something_else(unused) + fail "TODO" +end +---- + +[#configurable-attributes-lintunusedmethodargument] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowUnusedKeywordArguments +| `false` +| Boolean + +| IgnoreEmptyMethods +| `true` +| Boolean + +| IgnoreNotImplementedMethods +| `true` +| Boolean + +| NotImplementedExceptions +| `NotImplementedError` +| Array +|=== + +[#references-lintunusedmethodargument] +=== References + +* https://rubystyle.guide#underscore-unused-vars + +[#linturiescapeunescape] +== Lint/UriEscapeUnescape + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.50 +| - +|=== + +Identifies places where `URI.escape` can be replaced by +`CGI.escape`, `URI.encode_www_form`, or `URI.encode_www_form_component` +depending on your specific use case. +Also this cop identifies places where `URI.unescape` can be replaced by +`CGI.unescape`, `URI.decode_www_form`, +or `URI.decode_www_form_component` depending on your specific use case. + +[#examples-linturiescapeunescape] +=== Examples + +[source,ruby] +---- +# bad +URI.escape('http://example.com') +URI.encode('http://example.com') + +# good +CGI.escape('http://example.com') +URI.encode_www_form([['example', 'param'], ['lang', 'en']]) +URI.encode_www_form(page: 10, locale: 'en') +URI.encode_www_form_component('http://example.com') + +# bad +URI.unescape(enc_uri) +URI.decode(enc_uri) + +# good +CGI.unescape(enc_uri) +URI.decode_www_form(enc_uri) +URI.decode_www_form_component(enc_uri) +---- + +[#linturiregexp] +== Lint/UriRegexp + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.50 +| - +|=== + +Identifies places where `URI.regexp` is obsolete and should not be used. + +For Ruby 3.3 or lower, use `URI::DEFAULT_PARSER.make_regexp`. +For Ruby 3.4 or higher, use `URI::RFC2396_PARSER.make_regexp`. + +NOTE: If you need to support both Ruby 3.3 and lower as well as Ruby 3.4 and higher, +consider manually changing the code as follows: + +[source,ruby] +---- +defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::DEFAULT_PARSER +---- + +[#examples-linturiregexp] +=== Examples + +[source,ruby] +---- +# bad +URI.regexp('http://example.com') + +# good - Ruby 3.3 or lower +URI::DEFAULT_PARSER.make_regexp('http://example.com') + +# good - Ruby 3.4 or higher +URI::RFC2396_PARSER.make_regexp('http://example.com') +---- + +[#lintuselessaccessmodifier] +== Lint/UselessAccessModifier + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Command-line only +| 0.20 +| 1.61 +|=== + +Checks for redundant access modifiers, including those with no +code, those which are repeated, those which are on top-level, and +leading `public` modifiers in a class or module body. +Conditionally-defined methods are considered as always being defined, +and thus access modifiers guarding such methods are not redundant. + +This cop has `ContextCreatingMethods` option. The default setting value +is an empty array that means no method is specified. +This setting is an array of methods which, when called, are known to +create its own context in the module's current access context. + +It also has `MethodCreatingMethods` option. The default setting value +is an empty array that means no method is specified. +This setting is an array of methods which, when called, are known to +create other methods in the module's current access context. + +[#examples-lintuselessaccessmodifier] +=== Examples + +[source,ruby] +---- +# bad +class Foo + public # this is redundant (default access is public) + + def method + end +end + +# bad +class Foo + # The following is redundant (methods defined on the class' + # singleton class are not affected by the private modifier) + private + + def self.method3 + end +end + +# bad +class Foo + protected + + define_method(:method2) do + end + + protected # this is redundant (repeated from previous modifier) + + [1,2,3].each do |i| + define_method("foo#{i}") do + end + end +end + +# bad +class Foo + private # this is redundant (no following methods are defined) +end + +# bad +private # this is useless (access modifiers have no effect on top-level) + +def method +end + +# good +class Foo + private # this is not redundant (a method is defined) + + def method2 + end +end + +# good +class Foo + # The following is not redundant (conditionally defined methods are + # considered as always defining a method) + private + + if condition? + def method + end + end +end + +# good +class Foo + protected # this is not redundant (a method is defined) + + define_method(:method2) do + end +end +---- + +[#contextcreatingmethods_-concerning-lintuselessaccessmodifier] +==== ContextCreatingMethods: concerning + +[source,ruby] +---- +# Lint/UselessAccessModifier: +# ContextCreatingMethods: +# - concerning + +# good +require 'active_support/concern' +class Foo + concerning :Bar do + def some_public_method + end + + private + + def some_private_method + end + end + + # this is not redundant because `concerning` created its own context + private + + def some_other_private_method + end +end +---- + +[#methodcreatingmethods_-delegate-lintuselessaccessmodifier] +==== MethodCreatingMethods: delegate + +[source,ruby] +---- +# Lint/UselessAccessModifier: +# MethodCreatingMethods: +# - delegate + +# good +require 'active_support/core_ext/module/delegation' +class Foo + # this is not redundant because `delegate` creates methods + private + + delegate :method_a, to: :method_b +end +---- + +[#configurable-attributes-lintuselessaccessmodifier] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| ContextCreatingMethods +| `[]` +| Array + +| MethodCreatingMethods +| `[]` +| Array +|=== + +[#lintuselessassignment] +== Lint/UselessAssignment + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Command-line only +| 0.11 +| 1.66 +|=== + +Checks for every useless assignment to local variable in every +scope. +The basic idea for this cop was from the warning of `ruby -cw`: + +[source,console] +---- +assigned but unused variable - foo +---- + +Currently this cop has advanced logic that detects unreferenced +reassignments and properly handles varied cases such as branch, loop, +rescue, ensure, etc. + +This cop's autocorrection avoids cases like `a ||= 1` because removing assignment from +operator assignment can cause `NameError` if this assignment has been used to declare +a local variable. For example, replacing `a ||= 1` with `a || 1` may cause +"undefined local variable or method `a' for main:Object (NameError)". + +NOTE: Given the assignment `foo = 1, bar = 2`, removing unused variables +can lead to a syntax error, so this case is not autocorrected. + +[#examples-lintuselessassignment] +=== Examples + +[source,ruby] +---- +# bad +def some_method + some_var = 1 + do_something +end + +# good +def some_method + some_var = 1 + do_something(some_var) +end +---- + +[#references-lintuselessassignment] +=== References + +* https://rubystyle.guide#underscore-unused-vars + +[#lintuselessconstantscoping] +== Lint/UselessConstantScoping + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.72 +| - +|=== + +Checks for useless constant scoping. Private constants must be defined using +`private_constant`. Even if `private` access modifier is used, it is public scope despite +its appearance. + +It does not support autocorrection due to behavior change and multiple ways to fix it. +Or a public constant may be intended. + +[#examples-lintuselessconstantscoping] +=== Examples + +[source,ruby] +---- +# bad +class Foo + private + PRIVATE_CONST = 42 +end + +# good +class Foo + PRIVATE_CONST = 42 + private_constant :PRIVATE_CONST +end + +# good +class Foo + PUBLIC_CONST = 42 # If private scope is not intended. +end +---- + +[#lintuselessdefaultvalueargument] +== Lint/UselessDefaultValueArgument + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| No +| Always (Unsafe) +| 1.76 +| - +|=== + +Checks for usage of method `fetch` or `Array.new` with default value argument +and block. In such cases, block will always be used as default value. + +This cop emulates Ruby warning "block supersedes default value argument" which +applies to `Array.new`, `Array#fetch`, `Hash#fetch`, `ENV.fetch` and +`Thread#fetch`. + +A `fetch` call without a receiver is considered a custom method and does not register +an offense. + +[#safety-lintuselessdefaultvalueargument] +=== Safety + +This cop is unsafe because the receiver could have nonstandard implementation +of `fetch`, or be a class other than the one listed above. + +It is also unsafe because default value argument could have side effects: + +[source,ruby] +---- +def x(a) = puts "side effect" +Array.new(5, x(1)) { 2 } +---- + +so removing it would change behavior. + +[#examples-lintuselessdefaultvalueargument] +=== Examples + +[source,ruby] +---- +# bad +x.fetch(key, default_value) { block_value } +Array.new(size, default_value) { block_value } + +# good +x.fetch(key) { block_value } +Array.new(size) { block_value } + +# also good - in case default value argument is desired instead +x.fetch(key, default_value) +Array.new(size, default_value) + +# good - keyword arguments aren't registered as offenses +x.fetch(key, keyword: :arg) { block_value } +---- + +[#allowedreceivers_-__rails_cache__-lintuselessdefaultvalueargument] +==== AllowedReceivers: ['Rails.cache'] + +[source,ruby] +---- +# good +Rails.cache.fetch(name, options) { block } +---- + +[#configurable-attributes-lintuselessdefaultvalueargument] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedReceivers +| `[]` +| Array +|=== + +[#lintuselessdefined] +== Lint/UselessDefined + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.69 +| - +|=== + +Checks for calls to `defined?` with strings or symbols as the argument. +Such calls will always return `'expression'`, you probably meant to +check for the existence of a constant, method, or variable instead. + +`defined?` is part of the Ruby syntax and doesn't behave like normal methods. +You can safely pass in what you are checking for directly, without encountering +a `NameError`. + +When interpolation is used, oftentimes it is not possible to write the +code with `defined?`. In these cases, switch to one of the more specific methods: + +* `class_variable_defined?` +* `const_defined?` +* `method_defined?` +* `instance_variable_defined?` +* `binding.local_variable_defined?` + +[#examples-lintuselessdefined] +=== Examples + +[source,ruby] +---- +# bad +defined?('FooBar') +defined?(:FooBar) +defined?(:foo_bar) +defined?('foo_bar') + +# good +defined?(FooBar) +defined?(foo_bar) + +# bad - interpolation +bar = 'Bar' +defined?("Foo::#{bar}::Baz") + +# good +bar = 'Bar' +defined?(Foo) && Foo.const_defined?(bar) && Foo.const_get(bar).const_defined?(:Baz) +---- + +[#lintuselesselsewithoutrescue] +== Lint/UselessElseWithoutRescue + +NOTE: Requires Ruby version <= 2.5 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.17 +| 1.31 +|=== + +Checks for useless `else` in `begin..end` without `rescue`. + +NOTE: This syntax is no longer valid on Ruby 2.6 or higher. + +[#examples-lintuselesselsewithoutrescue] +=== Examples + +[source,ruby] +---- +# bad +begin + do_something +else + do_something_else # This will never be run. +end + +# good +begin + do_something +rescue + handle_errors +else + do_something_else +end +---- + +[#lintuselessmethoddefinition] +== Lint/UselessMethodDefinition + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| Command-line only (Unsafe) +| 0.90 +| 1.61 +|=== + +Checks for useless method definitions, specifically: empty constructors +and methods just delegating to `super`. + +[#safety-lintuselessmethoddefinition] +=== Safety + +This cop is unsafe as it can register false positives for cases when an empty +constructor just overrides the parent constructor, which is bad anyway. + +[#examples-lintuselessmethoddefinition] +=== Examples + +[source,ruby] +---- +# bad +def initialize + super +end + +def method + super +end + +# good - with default arguments +def initialize(x = Object.new) + super +end + +# good +def initialize + super + initialize_internals +end + +def method(*args) + super(:extra_arg, *args) +end +---- + +[#lintuselessnumericoperation] +== Lint/UselessNumericOperation + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.66 +| - +|=== + +Certain numeric operations have no impact, being: +Adding or subtracting 0, multiplying or dividing by 1 or raising to the power of 1. +These are probably leftover from debugging, or are mistakes. + +[#examples-lintuselessnumericoperation] +=== Examples + +[source,ruby] +---- +# bad +x + 0 +x - 0 +x * 1 +x / 1 +x ** 1 + +# good +x + +# bad +x += 0 +x -= 0 +x *= 1 +x /= 1 +x **= 1 + +# good +x = x +---- + +[#lintuselessor] +== Lint/UselessOr + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.76 +| - +|=== + +Checks for useless OR (`||` and `or`) expressions. + +Some methods always return a truthy value, even when called +on `nil` (e.g. `nil.to_i` evaluates to `0`). Therefore, OR expressions +appended after these methods will never evaluate. + +[#examples-lintuselessor] +=== Examples + +[source,ruby] +---- +# bad +x.to_a || fallback +x.to_c || fallback +x.to_d || fallback +x.to_i || fallback +x.to_f || fallback +x.to_h || fallback +x.to_r || fallback +x.to_s || fallback +x.to_sym || fallback +x.intern || fallback +x.inspect || fallback +x.hash || fallback +x.object_id || fallback +x.__id__ || fallback + +x.to_s or fallback + +# good - if fallback is same as return value of method called on nil +x.to_a # nil.to_a returns [] +x.to_c # nil.to_c returns (0+0i) +x.to_d # nil.to_d returns 0.0 +x.to_i # nil.to_i returns 0 +x.to_f # nil.to_f returns 0.0 +x.to_h # nil.to_h returns {} +x.to_r # nil.to_r returns (0/1) +x.to_s # nil.to_s returns '' +x.to_sym # nil.to_sym raises an error +x.intern # nil.intern raises an error +x.inspect # nil.inspect returns "nil" +x.hash # nil.hash returns an Integer +x.object_id # nil.object_id returns an Integer +x.__id__ # nil.object_id returns an Integer + +# good - if the intention is not to call the method on nil +x&.to_a || fallback +x&.to_c || fallback +x&.to_d || fallback +x&.to_i || fallback +x&.to_f || fallback +x&.to_h || fallback +x&.to_r || fallback +x&.to_s || fallback +x&.to_sym || fallback +x&.intern || fallback +x&.inspect || fallback +x&.hash || fallback +x&.object_id || fallback +x&.__id__ || fallback + +x&.to_s or fallback +---- + +[#lintuselessrescue] +== Lint/UselessRescue + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.43 +| - +|=== + +Checks for useless ``rescue``s, which only reraise rescued exceptions. + +[#examples-lintuselessrescue] +=== Examples + +[source,ruby] +---- +# bad +def foo + do_something +rescue + raise +end + +# bad +def foo + do_something +rescue => e + raise # or 'raise e', or 'raise $!', or 'raise $ERROR_INFO' +end + +# good +def foo + do_something +rescue + do_cleanup + raise +end + +# bad (latest rescue) +def foo + do_something +rescue ArgumentError + # noop +rescue + raise +end + +# good (not the latest rescue) +def foo + do_something +rescue ArgumentError + raise +rescue + # noop +end +---- + +[#lintuselessruby2keywords] +== Lint/UselessRuby2Keywords + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.23 +| - +|=== + +Looks for `ruby2_keywords` calls for methods that do not need it. + +`ruby2_keywords` should only be called on methods that accept an argument splat +(`\*args`) but do not explicit keyword arguments (`k:` or `k: true`) or +a keyword splat (`**kwargs`). + +[#examples-lintuselessruby2keywords] +=== Examples + +[source,ruby] +---- +# good (splat argument without keyword arguments) +ruby2_keywords def foo(*args); end + +# bad (no arguments) +ruby2_keywords def foo; end + +# good +def foo; end + +# bad (positional argument) +ruby2_keywords def foo(arg); end + +# good +def foo(arg); end + +# bad (double splatted argument) +ruby2_keywords def foo(**args); end + +# good +def foo(**args); end + +# bad (keyword arguments) +ruby2_keywords def foo(i:, j:); end + +# good +def foo(i:, j:); end + +# bad (splat argument with keyword arguments) +ruby2_keywords def foo(*args, i:, j:); end + +# good +def foo(*args, i:, j:); end + +# bad (splat argument with double splat) +ruby2_keywords def foo(*args, **kwargs); end + +# good +def foo(*args, **kwargs); end + +# bad (ruby2_keywords given a symbol) +def foo; end +ruby2_keywords :foo + +# good +def foo; end + +# bad (ruby2_keywords with dynamic method) +define_method(:foo) { |arg| } +ruby2_keywords :foo + +# good +define_method(:foo) { |arg| } +---- + +[#lintuselesssettercall] +== Lint/UselessSetterCall + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| Always (Unsafe) +| 0.13 +| 1.2 +|=== + +Checks for setter call to local variable as the final +expression of a function definition. + +[#safety-lintuselesssettercall] +=== Safety + +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. + +As well, autocorrection is unsafe because the method's +return value will be changed. + +[#examples-lintuselesssettercall] +=== Examples + +[source,ruby] +---- +# bad +def something + x = Something.new + x.attr = 5 +end + +# good +def something + x = Something.new + x.attr = 5 + x +end +---- + +[#lintuselesstimes] +== Lint/UselessTimes + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| Command-line only (Unsafe) +| 0.91 +| 1.61 +|=== + +Checks for uses of `Integer#times` that will never yield +(when the integer ``<= 0``) or that will only ever yield once +(`1.times`). + +[#safety-lintuselesstimes] +=== Safety + +This cop is unsafe as `times` returns its receiver, which is +*usually* OK, but might change behavior. + +[#examples-lintuselesstimes] +=== Examples + +[source,ruby] +---- +# bad +-5.times { do_something } +0.times { do_something } +1.times { do_something } +1.times { |i| do_something(i) } + +# good +do_something +do_something(1) +---- + +[#lintvoid] +== Lint/Void + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Command-line only +| 0.9 +| 1.61 +|=== + +Checks for operators, variables, literals, lambda, proc and nonmutating +methods used in void context. + +`each` blocks are allowed to prevent false positives. +For example, the expression inside the `each` block below. +It's not void, especially when the receiver is an `Enumerator`: + +[source,ruby] +---- +enumerator = [1, 2, 3].filter +enumerator.each { |item| item >= 2 } #=> [2, 3] +---- + +[#examples-lintvoid] +=== Examples + +[#checkformethodswithnosideeffects_-false-_default_-lintvoid] +==== CheckForMethodsWithNoSideEffects: false (default) + +[source,ruby] +---- +# bad +def some_method + some_num * 10 + do_something +end + +def some_method(some_var) + some_var + do_something +end +---- + +[#checkformethodswithnosideeffects_-true-lintvoid] +==== CheckForMethodsWithNoSideEffects: true + +[source,ruby] +---- +# bad +def some_method(some_array) + some_array.sort + do_something(some_array) +end + +# good +def some_method + do_something + some_num * 10 +end + +def some_method(some_var) + do_something + some_var +end + +def some_method(some_array) + some_array.sort! + do_something(some_array) +end +---- + +[#configurable-attributes-lintvoid] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| CheckForMethodsWithNoSideEffects +| `false` +| Boolean +|=== diff --git a/docs/modules/ROOT/pages/cops_metrics.adoc b/docs/modules/ROOT/pages/cops_metrics.adoc new file mode 100644 index 000000000000..c92f5398407e --- /dev/null +++ b/docs/modules/ROOT/pages/cops_metrics.adoc @@ -0,0 +1,791 @@ +//// + Do NOT edit this file by hand directly, as it is automatically generated. + + Please make any necessary changes to the cop documentation within the source files themselves. +//// + += Metrics + +[#metricsabcsize] +== Metrics/AbcSize + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.27 +| 1.5 +|=== + +Checks that the ABC size of methods is not higher than the +configured maximum. The ABC size is based on assignments, branches +(method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric +and https://en.wikipedia.org/wiki/ABC_Software_Metric. + +Interpreting ABC size: + +* ``<= 17`` satisfactory +* `18..30` unsatisfactory +* `>` 30 dangerous + +You can have repeated "attributes" calls count as a single "branch". +For this purpose, attributes are any method with no argument; no attempt +is meant to distinguish actual `attr_reader` from other methods. + +This cop also takes into account `AllowedMethods` (defaults to `[]`) +And `AllowedPatterns` (defaults to `[]`) + +[#examples-metricsabcsize] +=== Examples + +[#countrepeatedattributes_-false-_default-is-true_-metricsabcsize] +==== CountRepeatedAttributes: false (default is true) + +[source,ruby] +---- +# `model` and `current_user`, referenced 3 times each, +# are each counted as only 1 branch each if +# `CountRepeatedAttributes` is set to 'false' + +def search + @posts = model.active.visible_by(current_user) + .search(params[:q]) + @posts = model.some_process(@posts, current_user) + @posts = model.another_process(@posts, current_user) + + render 'pages/search/page' +end +---- + +[#configurable-attributes-metricsabcsize] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedMethods +| `[]` +| Array + +| AllowedPatterns +| `[]` +| Array + +| CountRepeatedAttributes +| `true` +| Boolean + +| Max +| `17` +| Integer +|=== + +[#references-metricsabcsize] +=== References + +* https://wiki.c2.com/?AbcMetric +* https://en.wikipedia.org/wiki/ABC_Software_Metric + +[#metricsblocklength] +== Metrics/BlockLength + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.44 +| 1.5 +|=== + +Checks if the length of a block exceeds some maximum value. +Comment lines can optionally be ignored. +The maximum allowed length is configurable. +The cop can be configured to ignore blocks passed to certain methods. + +You can set constructs you want to fold with `CountAsOne`. + +Available are: 'array', 'hash', 'heredoc', and 'method_call'. +Each construct will be counted as one line regardless of its actual size. + +NOTE: This cop does not apply for `Struct` definitions. + +NOTE: The `ExcludedMethods` configuration is deprecated and only kept +for backwards compatibility. Please use `AllowedMethods` and `AllowedPatterns` +instead. By default, there are no methods to allowed. + +[#examples-metricsblocklength] +=== Examples + +[#countasone_-__array__-_hash__-_heredoc__-_method_call__-metricsblocklength] +==== CountAsOne: ['array', 'hash', 'heredoc', 'method_call'] + +[source,ruby] +---- +something do + array = [ # +1 + 1, + 2 + ] + + hash = { # +1 + key: 'value' + } + + msg = <<~HEREDOC # +1 + Heredoc + content. + HEREDOC + + foo( # +1 + 1, + 2 + ) +end # 4 points +---- + +[#configurable-attributes-metricsblocklength] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| CountComments +| `false` +| Boolean + +| Max +| `25` +| Integer + +| CountAsOne +| `[]` +| Array + +| AllowedMethods +| `refine` +| Array + +| AllowedPatterns +| `[]` +| Array + +| Exclude +| `+**/*.gemspec+` +| Array +|=== + +[#metricsblocknesting] +== Metrics/BlockNesting + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.25 +| 1.65 +|=== + +Checks for excessive nesting of conditional and looping constructs. + +You can configure if blocks are considered using the `CountBlocks` and `CountModifierForms` +options. When both are set to `false` (the default) blocks and modifier forms are not +counted towards the nesting level. Set them to `true` to include these in the nesting level +calculation as well. + +The maximum level of nesting allowed is configurable. + +[#configurable-attributes-metricsblocknesting] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| CountBlocks +| `false` +| Boolean + +| CountModifierForms +| `false` +| Boolean + +| Max +| `3` +| Integer +|=== + +[#references-metricsblocknesting] +=== References + +* https://rubystyle.guide#three-is-the-number-thou-shalt-count + +[#metricsclasslength] +== Metrics/ClassLength + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.25 +| 0.87 +|=== + +Checks if the length of a class exceeds some maximum value. +Comment lines can optionally be ignored. +The maximum allowed length is configurable. + +You can set constructs you want to fold with `CountAsOne`. + +Available are: 'array', 'hash', 'heredoc', and 'method_call'. +Each construct will be counted as one line regardless of its actual size. + +NOTE: This cop also applies for `Struct` definitions. + +[#examples-metricsclasslength] +=== Examples + +[#countasone_-__array__-_hash__-_heredoc__-_method_call__-metricsclasslength] +==== CountAsOne: ['array', 'hash', 'heredoc', 'method_call'] + +[source,ruby] +---- +class Foo + ARRAY = [ # +1 + 1, + 2 + ] + + HASH = { # +1 + key: 'value' + } + + MSG = <<~HEREDOC # +1 + Heredoc + content. + HEREDOC + + foo( # +1 + 1, + 2 + ) +end # 4 points +---- + +[#configurable-attributes-metricsclasslength] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| CountComments +| `false` +| Boolean + +| Max +| `100` +| Integer + +| CountAsOne +| `[]` +| Array +|=== + +[#metricscollectionliterallength] +== Metrics/CollectionLiteralLength + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.47 +| - +|=== + +Checks for literals with extremely many entries. This is indicative of +configuration or data that may be better extracted somewhere else, like +a database, fetched from an API, or read from a non-code file (CSV, +JSON, YAML, etc.). + +[#examples-metricscollectionliterallength] +=== Examples + +[source,ruby] +---- +# bad +# Huge Array literal +[1, 2, '...', 999_999_999] + +# bad +# Huge Hash literal +{ 1 => 1, 2 => 2, '...' => '...', 999_999_999 => 999_999_999} + +# bad +# Huge Set "literal" +Set[1, 2, '...', 999_999_999] + +# good +# Reasonably sized Array literal +[1, 2, '...', 10] + +# good +# Reading huge Array from external data source +# File.readlines('numbers.txt', chomp: true).map!(&:to_i) + +# good +# Reasonably sized Hash literal +{ 1 => 1, 2 => 2, '...' => '...', 10 => 10} + +# good +# Reading huge Hash from external data source +CSV.foreach('numbers.csv', headers: true).each_with_object({}) do |row, hash| + hash[row["key"].to_i] = row["value"].to_i +end + +# good +# Reasonably sized Set "literal" +Set[1, 2, '...', 10] + +# good +# Reading huge Set from external data source +SomeFramework.config_for(:something)[:numbers].to_set +---- + +[#configurable-attributes-metricscollectionliterallength] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| LengthThreshold +| `250` +| Integer +|=== + +[#metricscyclomaticcomplexity] +== Metrics/CyclomaticComplexity + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.25 +| 0.81 +|=== + +Checks that the cyclomatic complexity of methods is not higher +than the configured maximum. The cyclomatic complexity is the number of +linearly independent paths through a method. The algorithm counts +decision points and adds one. + +An if statement (or unless or ?:) increases the complexity by one. An +else branch does not, since it doesn't add a decision point. The && +operator (or keyword and) can be converted to a nested if statement, +and ||/or is shorthand for a sequence of ifs, so they also add one. +Loops can be said to have an exit condition, so they add one. +Blocks that are calls to builtin iteration methods +(e.g. `ary.map{...}`) also add one, others are ignored. + +[#examples-metricscyclomaticcomplexity] +=== Examples + +[source,ruby] +---- +def each_child_node(*types) # count begins: 1 + unless block_given? # unless: +1 + return to_enum(__method__, *types) + end + + children.each do |child| # each{}: +1 + next unless child.is_a?(Node) # unless: +1 + + yield child if types.empty? || # if: +1, ||: +1 + types.include?(child.type) + end + + self +end # total: 6 +---- + +[#configurable-attributes-metricscyclomaticcomplexity] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedMethods +| `[]` +| Array + +| AllowedPatterns +| `[]` +| Array + +| Max +| `7` +| Integer +|=== + +[#metricsmethodlength] +== Metrics/MethodLength + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.25 +| 1.5 +|=== + +Checks if the length of a method exceeds some maximum value. +Comment lines can optionally be allowed. +The maximum allowed length is configurable. + +You can set constructs you want to fold with `CountAsOne`. + +Available are: 'array', 'hash', 'heredoc', and 'method_call'. +Each construct will be counted as one line regardless of its actual size. + +NOTE: The `ExcludedMethods` and `IgnoredMethods` configuration is +deprecated and only kept for backwards compatibility. +Please use `AllowedMethods` and `AllowedPatterns` instead. +By default, there are no methods to allowed. + +[#examples-metricsmethodlength] +=== Examples + +[#countasone_-__array__-_hash__-_heredoc__-_method_call__-metricsmethodlength] +==== CountAsOne: ['array', 'hash', 'heredoc', 'method_call'] + +[source,ruby] +---- +def m + array = [ # +1 + 1, + 2 + ] + + hash = { # +1 + key: 'value' + } + + <<~HEREDOC # +1 + Heredoc + content. + HEREDOC + + foo( # +1 + 1, + 2 + ) +end # 4 points +---- + +[#configurable-attributes-metricsmethodlength] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| CountComments +| `false` +| Boolean + +| Max +| `10` +| Integer + +| CountAsOne +| `[]` +| Array + +| AllowedMethods +| `[]` +| Array + +| AllowedPatterns +| `[]` +| Array +|=== + +[#references-metricsmethodlength] +=== References + +* https://rubystyle.guide#short-methods + +[#metricsmodulelength] +== Metrics/ModuleLength + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.31 +| 0.87 +|=== + +Checks if the length of a module exceeds some maximum value. +Comment lines can optionally be ignored. +The maximum allowed length is configurable. + +You can set constructs you want to fold with `CountAsOne`. + +Available are: 'array', 'hash', 'heredoc', and 'method_call'. +Each construct will be counted as one line regardless of its actual size. + +[#examples-metricsmodulelength] +=== Examples + +[#countasone_-__array__-_hash__-_heredoc__-_method_call__-metricsmodulelength] +==== CountAsOne: ['array', 'hash', 'heredoc', 'method_call'] + +[source,ruby] +---- +module M + ARRAY = [ # +1 + 1, + 2 + ] + + HASH = { # +1 + key: 'value' + } + + MSG = <<~HEREDOC # +1 + Heredoc + content. + HEREDOC + + foo( # +1 + 1, + 2 + ) +end # 4 points +---- + +[#configurable-attributes-metricsmodulelength] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| CountComments +| `false` +| Boolean + +| Max +| `100` +| Integer + +| CountAsOne +| `[]` +| Array +|=== + +[#metricsparameterlists] +== Metrics/ParameterLists + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.25 +| 1.5 +|=== + +Checks for methods with too many parameters. + +The maximum number of parameters is configurable. +Keyword arguments can optionally be excluded from the total count, +as they add less complexity than positional or optional parameters. + +Any number of arguments for `initialize` method inside a block of +`Struct.new` and `Data.define` like this is always allowed: + +[source,ruby] +---- +Struct.new(:one, :two, :three, :four, :five, keyword_init: true) do + def initialize(one:, two:, three:, four:, five:) + end +end +---- + +This is because checking the number of arguments of the `initialize` method +does not make sense. + +NOTE: Explicit block argument `&block` is not counted to prevent +erroneous change that is avoided by making block argument implicit. + +This cop also checks for the maximum number of optional parameters. +This can be configured using the `MaxOptionalParameters` config option. + +[#examples-metricsparameterlists] +=== Examples + +[#max_-3-metricsparameterlists] +==== Max: 3 + +[source,ruby] +---- +# good +def foo(a, b, c = 1) +end +---- + +[#max_-2-metricsparameterlists] +==== Max: 2 + +[source,ruby] +---- +# bad +def foo(a, b, c = 1) +end +---- + +[#countkeywordargs_-true-_default_-metricsparameterlists] +==== CountKeywordArgs: true (default) + +[source,ruby] +---- +# counts keyword args towards the maximum + +# bad (assuming Max is 3) +def foo(a, b, c, d: 1) +end + +# good (assuming Max is 3) +def foo(a, b, c: 1) +end +---- + +[#countkeywordargs_-false-metricsparameterlists] +==== CountKeywordArgs: false + +[source,ruby] +---- +# don't count keyword args towards the maximum + +# good (assuming Max is 3) +def foo(a, b, c, d: 1) +end +---- + +[#maxoptionalparameters_-3-_default_-metricsparameterlists] +==== MaxOptionalParameters: 3 (default) + +[source,ruby] +---- +# good +def foo(a = 1, b = 2, c = 3) +end +---- + +[#maxoptionalparameters_-2-metricsparameterlists] +==== MaxOptionalParameters: 2 + +[source,ruby] +---- +# bad +def foo(a = 1, b = 2, c = 3) +end +---- + +[#configurable-attributes-metricsparameterlists] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Max +| `5` +| Integer + +| CountKeywordArgs +| `true` +| Boolean + +| MaxOptionalParameters +| `3` +| Integer +|=== + +[#references-metricsparameterlists] +=== References + +* https://rubystyle.guide#too-many-params + +[#metricsperceivedcomplexity] +== Metrics/PerceivedComplexity + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.25 +| 0.81 +|=== + +Tries to produce a complexity score that's a measure of the +complexity the reader experiences when looking at a method. For that +reason it considers `when` nodes as something that doesn't add as much +complexity as an `if` or a `&&`. Except if it's one of those special +`case`/`when` constructs where there's no expression after `case`. Then +the cop treats it as an `if`/`elsif`/`elsif`... and lets all the `when` +nodes count. In contrast to the CyclomaticComplexity cop, this cop +considers `else` nodes as adding complexity. + +[#examples-metricsperceivedcomplexity] +=== Examples + +[source,ruby] +---- +def my_method # 1 + if cond # 1 + case var # 2 (0.8 + 4 * 0.2, rounded) + when 1 then func_one + when 2 then func_two + when 3 then func_three + when 4..10 then func_other + end + else # 1 + do_something until a && b # 2 + end # === +end # 7 complexity points +---- + +[#configurable-attributes-metricsperceivedcomplexity] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedMethods +| `[]` +| Array + +| AllowedPatterns +| `[]` +| Array + +| Max +| `8` +| Integer +|=== diff --git a/docs/modules/ROOT/pages/cops_migration.adoc b/docs/modules/ROOT/pages/cops_migration.adoc new file mode 100644 index 000000000000..a2b5e7139e79 --- /dev/null +++ b/docs/modules/ROOT/pages/cops_migration.adoc @@ -0,0 +1,23 @@ +//// + Do NOT edit this file by hand directly, as it is automatically generated. + + Please make any necessary changes to the cop documentation within the source files themselves. +//// + += Migration + +[#migrationdepartmentname] +== Migration/DepartmentName + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.75 +| - +|=== + +Check that cop names in rubocop:disable comments are given with +department name. diff --git a/docs/modules/ROOT/pages/cops_naming.adoc b/docs/modules/ROOT/pages/cops_naming.adoc new file mode 100644 index 000000000000..d4fcc9cbeda4 --- /dev/null +++ b/docs/modules/ROOT/pages/cops_naming.adoc @@ -0,0 +1,2005 @@ +//// + Do NOT edit this file by hand directly, as it is automatically generated. + + Please make any necessary changes to the cop documentation within the source files themselves. +//// + += Naming + +[#namingaccessormethodname] +== Naming/AccessorMethodName + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.50 +| - +|=== + +Avoid prefixing accessor method names with `get_` or `set_`. +Applies to both instance and class methods. + +NOTE: Method names starting with `get_` or `set_` only register an offense +when the methods match the expected arity for getters and setters respectively. +Getters (`get_attribute`) must have no arguments to be registered, +and setters (`set_attribute(value)`) must have exactly one. + +[#examples-namingaccessormethodname] +=== Examples + +[source,ruby] +---- +# bad +def set_attribute(value) +end + +# good +def attribute=(value) +end + +# bad +def get_attribute +end + +# good +def attribute +end + +# accepted, incorrect arity for getter +def get_value(attr) +end + +# accepted, incorrect arity for setter +def set_value +end +---- + +[#references-namingaccessormethodname] +=== References + +* https://rubystyle.guide#accessor_mutator_method_names + +[#namingasciiidentifiers] +== Naming/AsciiIdentifiers + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.50 +| 0.87 +|=== + +Checks for non-ascii characters in identifier and constant names. +Identifiers are always checked and whether constants are checked +can be controlled using AsciiConstants config. + +[#examples-namingasciiidentifiers] +=== Examples + +[source,ruby] +---- +# bad +def καλημερα # Greek alphabet (non-ascii) +end + +# bad +def こんにちはと言う # Japanese character (non-ascii) +end + +# bad +def hello_🍣 # Emoji (non-ascii) +end + +# good +def say_hello +end + +# bad +신장 = 10 # Hangul character (non-ascii) + +# good +height = 10 + +# bad +params[:عرض_gteq] # Arabic character (non-ascii) + +# good +params[:width_gteq] +---- + +[#asciiconstants_-true-_default_-namingasciiidentifiers] +==== AsciiConstants: true (default) + +[source,ruby] +---- +# bad +class Foö +end + +FOÖ = "foo" +---- + +[#asciiconstants_-false-namingasciiidentifiers] +==== AsciiConstants: false + +[source,ruby] +---- +# good +class Foö +end + +FOÖ = "foo" +---- + +[#configurable-attributes-namingasciiidentifiers] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AsciiConstants +| `true` +| Boolean +|=== + +[#references-namingasciiidentifiers] +=== References + +* https://rubystyle.guide#english-identifiers + +[#namingbinaryoperatorparametername] +== Naming/BinaryOperatorParameterName + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.50 +| 1.2 +|=== + +Makes sure that certain binary operator methods have their +sole parameter named `other`. + +[#examples-namingbinaryoperatorparametername] +=== Examples + +[source,ruby] +---- +# bad +def +(amount); end + +# good +def +(other); end +---- + +[#references-namingbinaryoperatorparametername] +=== References + +* https://rubystyle.guide#other-arg + +[#namingblockforwarding] +== Naming/BlockForwarding + +NOTE: Requires Ruby version 3.1 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.24 +| - +|=== + +In Ruby 3.1, anonymous block forwarding has been added. + +This cop identifies places where `do_something(&block)` can be replaced +by `do_something(&)`. + +It also supports the opposite style by alternative `explicit` option. +You can specify the block variable name for autocorrection with `BlockForwardingName`. +The default variable name is `block`. If the name is already in use, it will not be +autocorrected. + +[NOTE] +==== +Because of a bug in Ruby 3.3.0, when a block is referenced inside of another block, +no offense will be registered until Ruby 3.4: + +[source,ruby] +---- +def foo(&block) + # Using an anonymous block would be a syntax error on Ruby 3.3.0 + block_method { bar(&block) } +end +---- +==== + +[#examples-namingblockforwarding] +=== Examples + +[#enforcedstyle_-anonymous-_default_-namingblockforwarding] +==== EnforcedStyle: anonymous (default) + +[source,ruby] +---- +# bad +def foo(&block) + bar(&block) +end + +# good +def foo(&) + bar(&) +end +---- + +[#enforcedstyle_-explicit-namingblockforwarding] +==== EnforcedStyle: explicit + +[source,ruby] +---- +# bad +def foo(&) + bar(&) +end + +# good +def foo(&block) + bar(&block) +end +---- + +[#configurable-attributes-namingblockforwarding] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `anonymous` +| `anonymous`, `explicit` + +| BlockForwardingName +| `block` +| String +|=== + +[#references-namingblockforwarding] +=== References + +* https://rubystyle.guide#block-forwarding + +[#namingblockparametername] +== Naming/BlockParameterName + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.53 +| 0.77 +|=== + +Checks block parameter names for how descriptive they +are. It is highly configurable. + +The `MinNameLength` config option takes an integer. It represents +the minimum amount of characters the name must be. Its default is 1. +The `AllowNamesEndingInNumbers` config option takes a boolean. When +set to false, this cop will register offenses for names ending with +numbers. Its default is false. The `AllowedNames` config option +takes an array of permitted names that will never register an +offense. The `ForbiddenNames` config option takes an array of +restricted names that will always register an offense. + +[#examples-namingblockparametername] +=== Examples + +[source,ruby] +---- +# bad +bar do |varOne, varTwo| + varOne + varTwo +end + +# With `AllowNamesEndingInNumbers` set to false +foo { |num1, num2| num1 * num2 } + +# With `MinNameLength` set to number greater than 1 +baz { |a, b, c| do_stuff(a, b, c) } + +# good +bar do |thud, fred| + thud + fred +end + +foo { |speed, distance| speed * distance } + +baz { |age, height, gender| do_stuff(age, height, gender) } +---- + +[#configurable-attributes-namingblockparametername] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| MinNameLength +| `1` +| Integer + +| AllowNamesEndingInNumbers +| `true` +| Boolean + +| AllowedNames +| `[]` +| Array + +| ForbiddenNames +| `[]` +| Array +|=== + +[#namingclassandmodulecamelcase] +== Naming/ClassAndModuleCamelCase + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.50 +| 0.85 +|=== + +Checks for class and module names with +an underscore in them. + +`AllowedNames` config takes an array of permitted names. +Its default value is `['module_parent']`. +These names can be full class/module names or part of the name. +eg. Adding `my_class` to the `AllowedNames` config will allow names like +`my_class`, `my_class::User`, `App::my_class`, `App::my_class::User`, etc. + +[#examples-namingclassandmodulecamelcase] +=== Examples + +[source,ruby] +---- +# bad +class My_Class +end +module My_Module +end + +# good +class MyClass +end +module MyModule +end +class module_parent::MyModule +end +---- + +[#configurable-attributes-namingclassandmodulecamelcase] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowedNames +| `module_parent` +| Array +|=== + +[#references-namingclassandmodulecamelcase] +=== References + +* https://rubystyle.guide#camelcase-classes + +[#namingconstantname] +== Naming/ConstantName + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.50 +| - +|=== + +Checks whether constant names are written using +SCREAMING_SNAKE_CASE. + +To avoid false positives, it ignores cases in which we cannot know +for certain the type of value that would be assigned to a constant. + +[#examples-namingconstantname] +=== Examples + +[source,ruby] +---- +# bad +InchInCm = 2.54 +INCHinCM = 2.54 +Inch_In_Cm = 2.54 + +# good +INCH_IN_CM = 2.54 +---- + +[#references-namingconstantname] +=== References + +* https://rubystyle.guide#screaming-snake-case + +[#namingfilename] +== Naming/FileName + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.50 +| 1.23 +|=== + +Makes sure that Ruby source files have snake_case +names. Ruby scripts (i.e. source files with a shebang in the +first line) are ignored. + +The cop also ignores `.gemspec` files, because Bundler +recommends using dashes to separate namespaces in nested gems +(i.e. `bundler-console` becomes `Bundler::Console`). As such, the +gemspec is supposed to be named `bundler-console.gemspec`. + +When `ExpectMatchingDefinition` (default: `false`) is `true`, the cop requires +each file to have a class, module or `Struct` defined in it that matches +the filename. This can be further configured using +`CheckDefinitionPathHierarchy` (default: `true`) to determine whether the +path should match the namespace of the above definition. + +When `IgnoreExecutableScripts` (default: `true`) is `true`, files that start +with a shebang line are not considered by the cop. + +When `Regex` is set, the cop will flag any filename that does not match +the regular expression. + +[#examples-namingfilename] +=== Examples + +[source,ruby] +---- +# bad +lib/layoutManager.rb + +anything/usingCamelCase + +# good +lib/layout_manager.rb + +anything/using_snake_case.rake +---- + +[#configurable-attributes-namingfilename] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Exclude +| `Rakefile.rb` +| Array + +| ExpectMatchingDefinition +| `false` +| Boolean + +| CheckDefinitionPathHierarchy +| `true` +| Boolean + +| CheckDefinitionPathHierarchyRoots +| `lib`, `spec`, `test`, `src` +| Array + +| Regex +| `` +| + +| IgnoreExecutableScripts +| `true` +| Boolean + +| AllowedAcronyms +| `CLI`, `DSL`, `ACL`, `API`, `ASCII`, `CPU`, `CSS`, `DNS`, `EOF`, `GUID`, `HTML`, `HTTP`, `HTTPS`, `ID`, `IP`, `JSON`, `LHS`, `QPS`, `RAM`, `RHS`, `RPC`, `SLA`, `SMTP`, `SQL`, `SSH`, `TCP`, `TLS`, `TTL`, `UDP`, `UI`, `UID`, `UUID`, `URI`, `URL`, `UTF8`, `VM`, `XML`, `XMPP`, `XSRF`, `XSS` +| Array +|=== + +[#references-namingfilename] +=== References + +* https://rubystyle.guide#snake-case-files + +[#namingheredocdelimitercase] +== Naming/HeredocDelimiterCase + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.50 +| 1.2 +|=== + +Checks that your heredocs are using the configured case. +By default it is configured to enforce uppercase heredocs. + +[#examples-namingheredocdelimitercase] +=== Examples + +[#enforcedstyle_-uppercase-_default_-namingheredocdelimitercase] +==== EnforcedStyle: uppercase (default) + +[source,ruby] +---- +# bad +<<-sql + SELECT * FROM foo +sql + +# good +<<-SQL + SELECT * FROM foo +SQL +---- + +[#enforcedstyle_-lowercase-namingheredocdelimitercase] +==== EnforcedStyle: lowercase + +[source,ruby] +---- +# bad +<<-SQL + SELECT * FROM foo +SQL + +# good +<<-sql + SELECT * FROM foo +sql +---- + +[#configurable-attributes-namingheredocdelimitercase] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `uppercase` +| `lowercase`, `uppercase` +|=== + +[#references-namingheredocdelimitercase] +=== References + +* https://rubystyle.guide#heredoc-delimiters + +[#namingheredocdelimiternaming] +== Naming/HeredocDelimiterNaming + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.50 +| - +|=== + +Checks that your heredocs are using meaningful delimiters. +By default it disallows `END` and `EO*`, and can be configured through +forbidden listing additional delimiters. + +[#examples-namingheredocdelimiternaming] +=== Examples + +[source,ruby] +---- +# good +<<-SQL + SELECT * FROM foo +SQL + +# bad +<<-END + SELECT * FROM foo +END + +# bad +<<-EOS + SELECT * FROM foo +EOS +---- + +[#configurable-attributes-namingheredocdelimiternaming] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| ForbiddenDelimiters +| `(?i-mx:(^\|\s)(EO[A-Z]{1}\|END)(\s\|$))` +| Array +|=== + +[#references-namingheredocdelimiternaming] +=== References + +* https://rubystyle.guide#heredoc-delimiters + +[#naminginclusivelanguage] +== Naming/InclusiveLanguage + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| Yes +| Always +| 1.18 +| 1.49 +|=== + +Recommends the use of inclusive language instead of problematic terms. +The cop can check the following locations for offenses: + +- identifiers +- constants +- variables +- strings +- symbols +- comments +- file paths + +Each of these locations can be individually enabled/disabled via configuration, +for example CheckIdentifiers = true/false. + +Flagged terms are configurable for the cop. For each flagged term an optional +Regex can be specified to identify offenses. Suggestions for replacing a flagged term can +be configured and will be displayed as part of the offense message. +An AllowedRegex can be specified for a flagged term to exempt allowed uses of the term. +`WholeWord: true` can be set on a flagged term to indicate the cop should only match when +a term matches the whole word (partial matches will not be offenses). + +The cop supports autocorrection when there is only one suggestion. When there are multiple +suggestions, the best suggestion cannot be identified and will not be autocorrected. + +[#examples-naminginclusivelanguage] +=== Examples + +[#flaggedterms_-_-whitelist_-_-suggestions_-__allowlist__-_-_-naminginclusivelanguage] +==== FlaggedTerms: { whitelist: { Suggestions: ['allowlist'] } } + +[source,ruby] +---- +# Suggest replacing identifier whitelist with allowlist + +# bad +whitelist_users = %w(user1 user1) + +# good +allowlist_users = %w(user1 user2) +---- + +[#flaggedterms_-_-master_-_-suggestions_-__main__-_primary__-_leader__-_-_-naminginclusivelanguage] +==== FlaggedTerms: { master: { Suggestions: ['main', 'primary', 'leader'] } } + +[source,ruby] +---- +# Suggest replacing master in an instance variable name with main, primary, or leader + +# bad +@master_node = 'node1.example.com' + +# good +@primary_node = 'node1.example.com' +---- + +[#flaggedterms_-_-whitelist_-_-regex_-_rubyregexp-_white_-__s__list_-_-_-naminginclusivelanguage] +==== FlaggedTerms: { whitelist: { Regex: !ruby/regexp '/white[-_\s]?list' } } + +[source,ruby] +---- +# Identify problematic terms using a Regexp + +# bad +white_list = %w(user1 user2) + +# good +allow_list = %w(user1 user2) +---- + +[#flaggedterms_-_-master_-_-allowedregex_-_master___s-degree_-_-_-naminginclusivelanguage] +==== FlaggedTerms: { master: { AllowedRegex: 'master\'?s degree' } } + +[source,ruby] +---- +# Specify allowed uses of the flagged term as a string or regexp. + +# bad +# They had a masters + +# good +# They had a master's degree +---- + +[#flaggedterms_-_-slave_-_-wholeword_-true-_-_-naminginclusivelanguage] +==== FlaggedTerms: { slave: { WholeWord: true } } + +[source,ruby] +---- +# Specify that only terms that are full matches will be flagged. + +# bad +Slave + +# good (won't be flagged despite containing `slave`) +TeslaVehicle +---- + +[#configurable-attributes-naminginclusivelanguage] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| CheckIdentifiers +| `true` +| Boolean + +| CheckConstants +| `true` +| Boolean + +| CheckVariables +| `true` +| Boolean + +| CheckStrings +| `false` +| Boolean + +| CheckSymbols +| `true` +| Boolean + +| CheckComments +| `true` +| Boolean + +| CheckFilepaths +| `true` +| Boolean + +| FlaggedTerms +| `{"whitelist" => {"Regex" => /white[-_\s]?list/, "Suggestions" => ["allowlist", "permit"]}, "blacklist" => {"Regex" => /black[-_\s]?list/, "Suggestions" => ["denylist", "block"]}, "slave" => {"WholeWord" => true, "Suggestions" => ["replica", "secondary", "follower"]}}` +| +|=== + +[#namingmemoizedinstancevariablename] +== Naming/MemoizedInstanceVariableName + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| Always (Unsafe) +| 0.53 +| 1.2 +|=== + +Checks for memoized methods whose instance variable name +does not match the method name. Applies to both regular methods +(defined with `def`) and dynamic methods (defined with +`define_method` or `define_singleton_method`). + +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 referenced outside of the memoization method. + +[#safety-namingmemoizedinstancevariablename] +=== Safety + +This cop relies on the pattern `@instance_var ||= ...`, +but this is sometimes used for other purposes than memoization +so this cop is considered unsafe. Also, its autocorrection is unsafe +because it may conflict with instance variable names already in use. + +[#examples-namingmemoizedinstancevariablename] +=== Examples + +[#enforcedstyleforleadingunderscores_-disallowed-_default_-namingmemoizedinstancevariablename] +==== EnforcedStyleForLeadingUnderscores: disallowed (default) + +[source,ruby] +---- +# bad +# Method foo is memoized using an instance variable that is +# not `@foo`. This can cause confusion and bugs. +def foo + @something ||= calculate_expensive_thing +end + +def foo + return @something if defined?(@something) + @something = calculate_expensive_thing +end + +# good +def _foo + @foo ||= calculate_expensive_thing +end + +# good +def foo + @foo ||= calculate_expensive_thing +end + +# good +def foo + @foo ||= begin + calculate_expensive_thing + end +end + +# good +def foo + helper_variable = something_we_need_to_calculate_foo + @foo ||= calculate_expensive_thing(helper_variable) +end + +# good +define_method(:foo) do + @foo ||= calculate_expensive_thing +end + +# good +define_method(:foo) do + return @foo if defined?(@foo) + @foo = calculate_expensive_thing +end +---- + +[#enforcedstyleforleadingunderscores_-required-namingmemoizedinstancevariablename] +==== EnforcedStyleForLeadingUnderscores: required + +[source,ruby] +---- +# bad +def foo + @something ||= calculate_expensive_thing +end + +# bad +def foo + @foo ||= calculate_expensive_thing +end + +def foo + return @foo if defined?(@foo) + @foo = calculate_expensive_thing +end + +# good +def foo + @_foo ||= calculate_expensive_thing +end + +# good +def _foo + @_foo ||= calculate_expensive_thing +end + +def foo + return @_foo if defined?(@_foo) + @_foo = calculate_expensive_thing +end + +# good +define_method(:foo) do + @_foo ||= calculate_expensive_thing +end + +# good +define_method(:foo) do + return @_foo if defined?(@_foo) + @_foo = calculate_expensive_thing +end +---- + +[#enforcedstyleforleadingunderscores-_optional-namingmemoizedinstancevariablename] +==== EnforcedStyleForLeadingUnderscores :optional + +[source,ruby] +---- +# bad +def foo + @something ||= calculate_expensive_thing +end + +# good +def foo + @foo ||= calculate_expensive_thing +end + +# good +def foo + @_foo ||= calculate_expensive_thing +end + +# good +def _foo + @_foo ||= calculate_expensive_thing +end + +# good +def foo + return @_foo if defined?(@_foo) + @_foo = calculate_expensive_thing +end + +# good +define_method(:foo) do + @foo ||= calculate_expensive_thing +end + +# good +define_method(:foo) do + @_foo ||= calculate_expensive_thing +end +---- + +[#configurable-attributes-namingmemoizedinstancevariablename] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyleForLeadingUnderscores +| `disallowed` +| `disallowed`, `required`, `optional` +|=== + +[#namingmethodname] +== Naming/MethodName + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.50 +| 1.75 +|=== + +Makes sure that all methods use the configured style, +snake_case or camelCase, for their names. + +Method names matching patterns are always allowed. + +The cop can be configured with `AllowedPatterns` to allow certain regexp patterns: + +[source,yaml] +---- +Naming/MethodName: + AllowedPatterns: + - '\AonSelectionBulkChange\z' + - '\AonSelectionCleared\z' +---- + +As well, you can also forbid specific method names or regexp patterns +using `ForbiddenIdentifiers` or `ForbiddenPatterns`: + +[source,yaml] +---- +Naming/MethodName: + ForbiddenIdentifiers: + - 'def' + - 'super' + ForbiddenPatterns: + - '_v1\z' + - '_gen1\z' +---- + +[#examples-namingmethodname] +=== Examples + +[#enforcedstyle_-snake_case-_default_-namingmethodname] +==== EnforcedStyle: snake_case (default) + +[source,ruby] +---- +# bad +def fooBar; end + +# good +def foo_bar; end + +# bad +define_method :fooBar do +end + +# good +define_method :foo_bar do +end + +# bad +Struct.new(:fooBar) + +# good +Struct.new(:foo_bar) +---- + +[#enforcedstyle_-camelcase-namingmethodname] +==== EnforcedStyle: camelCase + +[source,ruby] +---- +# bad +def foo_bar; end + +# good +def fooBar; end + +# bad +define_method :foo_bar do +end + +# good +define_method :fooBar do +end + +# bad +Struct.new(:foo_bar) + +# good +Struct.new(:fooBar) +---- + +[#forbiddenidentifiers_-__def__-_super__-namingmethodname] +==== ForbiddenIdentifiers: ['def', 'super'] + +[source,ruby] +---- +# bad +def def; end +def super; end +---- + +[#forbiddenpatterns_-___v1_z__-__gen1_z__-namingmethodname] +==== ForbiddenPatterns: ['_v1\z', '_gen1\z'] + +[source,ruby] +---- +# bad +def release_v1; end +def api_gen1; end +---- + +[#configurable-attributes-namingmethodname] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `snake_case` +| `snake_case`, `camelCase` + +| AllowedPatterns +| `[]` +| Array + +| ForbiddenIdentifiers +| `__id__`, `__send__` +| Array + +| ForbiddenPatterns +| `[]` +| Array +|=== + +[#references-namingmethodname] +=== References + +* https://rubystyle.guide#snake-case-symbols-methods-vars + +[#namingmethodparametername] +== Naming/MethodParameterName + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.53 +| 0.77 +|=== + +Checks method parameter names for how descriptive they +are. It is highly configurable. + +The `MinNameLength` config option takes an integer. It represents +the minimum amount of characters the name must be. Its default is 3. +The `AllowNamesEndingInNumbers` config option takes a boolean. When +set to false, this cop will register offenses for names ending with +numbers. Its default is false. The `AllowedNames` config option +takes an array of permitted names that will never register an +offense. The `ForbiddenNames` config option takes an array of +restricted names that will always register an offense. + +[#examples-namingmethodparametername] +=== Examples + +[source,ruby] +---- +# bad +def bar(varOne, varTwo) + varOne + varTwo +end + +# With `AllowNamesEndingInNumbers` set to false +def foo(num1, num2) + num1 * num2 +end + +# With `MinNameLength` set to number greater than 1 +def baz(a, b, c) + do_stuff(a, b, c) +end + +# good +def bar(thud, fred) + thud + fred +end + +def foo(speed, distance) + speed * distance +end + +def baz(age_a, height_b, gender_c) + do_stuff(age_a, height_b, gender_c) +end +---- + +[#configurable-attributes-namingmethodparametername] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| MinNameLength +| `3` +| Integer + +| AllowNamesEndingInNumbers +| `true` +| Boolean + +| AllowedNames +| `as`, `at`, `by`, `cc`, `db`, `id`, `if`, `in`, `io`, `ip`, `of`, `on`, `os`, `pp`, `to` +| Array + +| ForbiddenNames +| `[]` +| Array +|=== + +[#namingpredicatemethod] +== Naming/PredicateMethod + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 1.76 +| 1.78 +|=== + +Checks that predicate methods end with `?` and non-predicate methods do not. + +The names of predicate methods (methods that return a boolean value) should end +in a question mark. Methods that don't return a boolean, shouldn't +end in a question mark. + +The cop assesses a predicate method as one that returns boolean values. Likewise, +a method that only returns literal values is assessed as non-predicate. Other predicate +method calls are assumed to return boolean values. The cop does not make an assessment +if the return type is unknown (non-predicate method calls, variables, etc.). + +NOTE: Operator methods (`def ==`, etc.) are ignored. + +By default, the cop runs in `conservative` mode, which allows a method to be named +with a question mark as long as at least one return value is boolean. In `aggressive` +mode, methods with a question mark will register an offense if any known non-boolean +return values are detected. + +The cop also has `AllowedMethods` configuration in order to prevent the cop from +registering an offense from a method name that does not confirm to the naming +guidelines. By default, `call` is allowed. The cop also has `AllowedPatterns` +configuration to allow method names by regular expression. + +Although returning a call to another predicate method is treated as a boolean value, +certain method names can be known to not return a boolean, despite ending in a `?` +(for example, `Numeric#nonzero?` returns `self` or `nil`). These methods can be +configured using `NonBooleanPredicates`. + +The cop can furthermore be configured to allow all bang methods (method names +ending with `!`), with `AllowBangMethods: true` (default false). + +[#examples-namingpredicatemethod] +=== Examples + +[#mode_-conservative-_default_-namingpredicatemethod] +==== Mode: conservative (default) + +[source,ruby] +---- +# bad +def foo + bar == baz +end + +# good +def foo? + bar == baz +end + +# bad +def foo? + 5 +end + +# good +def foo + 5 +end + +# bad +def foo + x == y +end + +# good +def foo? + x == y +end + +# bad +def foo + !x +end + +# good +def foo? + !x +end + +# bad - returns the value of another predicate method +def foo + bar? +end + +# good +def foo? + bar? +end + +# good - operator method +def ==(other) + hash == other.hash +end + +# good - at least one return value is boolean +def foo? + return unless bar? + true +end + +# ok - return type is not known +def foo? + bar +end + +# ok - return type is not known +def foo + bar? +end +---- + +[#mode_-aggressive-namingpredicatemethod] +==== Mode: aggressive + +[source,ruby] +---- +# bad - the method returns nil in some cases +def foo? + return unless bar? + true +end +---- + +[#allowbangmethods_-false-_default_-namingpredicatemethod] +==== AllowBangMethods: false (default) + +[source,ruby] +---- +# bad +def save! + true +end +---- + +[#allowbangmethods_-true-namingpredicatemethod] +==== AllowBangMethods: true + +[source,ruby] +---- +# good +def save! + true +end +---- + +[#configurable-attributes-namingpredicatemethod] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Mode +| `conservative` +| String + +| AllowedMethods +| `call` +| Array + +| AllowedPatterns +| `[]` +| Array + +| AllowBangMethods +| `false` +| Boolean + +| WaywardPredicates +| `nonzero?` +| Array +|=== + +[#namingpredicateprefix] +== Naming/PredicatePrefix + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.50 +| 1.75 +|=== + +Checks that predicate method names end with a question mark and +do not start with a forbidden prefix. + +A method is determined to be a predicate method if its name starts with +one of the prefixes listed in the `NamePrefix` configuration. The list +defaults to `is_`, `has_`, and `have_` but may be overridden. + +Predicate methods must end with a question mark. + +When `ForbiddenPrefixes` is also set (as it is by default), predicate +methods which begin with a forbidden prefix are not allowed, even if +they end with a `?`. These methods should be changed to remove the +prefix. + +When `UseSorbetSigs` set to true (optional), the cop will only report +offenses if the method has a Sorbet `sig` with a return type of +`T::Boolean`. Dynamic methods are not supported with this configuration. + +[#examples-namingpredicateprefix] +=== Examples + +[#nameprefix_-__is___-_has___-_have___-_default_-namingpredicateprefix] +==== NamePrefix: ['is_', 'has_', 'have_'] (default) + +[source,ruby] +---- +# bad +def is_even(value) +end + +# When ForbiddenPrefixes: ['is_', 'has_', 'have_'] (default) +# good +def even?(value) +end + +# When ForbiddenPrefixes: [] +# good +def is_even?(value) +end +---- + +[#nameprefix_-__seems_to_be___-namingpredicateprefix] +==== NamePrefix: ['seems_to_be_'] + +[source,ruby] +---- +# bad +def seems_to_be_even(value) +end + +# When ForbiddenPrefixes: ['seems_to_be_'] +# good +def even?(value) +end + +# When ForbiddenPrefixes: [] +# good +def seems_to_be_even?(value) +end +---- + +[#allowedmethods_-__is_a___-_default_-namingpredicateprefix] +==== AllowedMethods: ['is_a?'] (default) + +[source,ruby] +---- +# Despite starting with the `is_` prefix, this method is allowed +# good +def is_a?(value) +end +---- + +[#allowedmethods_-__is_even___-namingpredicateprefix] +==== AllowedMethods: ['is_even?'] + +[source,ruby] +---- +# good +def is_even?(value) +end +---- + +[#usesorbetsigs_-false-_default_-namingpredicateprefix] +==== UseSorbetSigs: false (default) + +[source,ruby] +---- +# bad +sig { returns(String) } +def is_this_thing_on + "yes" +end + +# good - Sorbet signature is not evaluated +sig { returns(String) } +def is_this_thing_on? + "yes" +end +---- + +[#usesorbetsigs_-true-namingpredicateprefix] +==== UseSorbetSigs: true + +[source,ruby] +---- +# bad +sig { returns(T::Boolean) } +def odd(value) +end + +# good +sig { returns(T::Boolean) } +def odd?(value) +end +---- + +[#methoddefinitionmacros_-__define_method__-_define_singleton_method__-_default_-namingpredicateprefix] +==== MethodDefinitionMacros: ['define_method', 'define_singleton_method'] (default) + +[source,ruby] +---- +# bad +define_method(:is_even) { |value| } + +# good +define_method(:even?) { |value| } +---- + +[#methoddefinitionmacros_-__def_node_matcher__-namingpredicateprefix] +==== MethodDefinitionMacros: ['def_node_matcher'] + +[source,ruby] +---- +# bad +def_node_matcher(:is_even) { |value| } + +# good +def_node_matcher(:even?) { |value| } +---- + +[#configurable-attributes-namingpredicateprefix] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| NamePrefix +| `is_`, `has_`, `have_`, `does_` +| Array + +| ForbiddenPrefixes +| `is_`, `has_`, `have_`, `does_` +| Array + +| AllowedMethods +| `is_a?` +| Array + +| MethodDefinitionMacros +| `define_method`, `define_singleton_method` +| Array + +| UseSorbetSigs +| `false` +| Boolean + +| Exclude +| `+spec/**/*+` +| Array +|=== + +[#references-namingpredicateprefix] +=== References + +* https://rubystyle.guide#bool-methods-qmark + +[#namingrescuedexceptionsvariablename] +== Naming/RescuedExceptionsVariableName + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.67 +| 0.68 +|=== + +Makes sure that rescued exceptions variables are named as +expected. + +The `PreferredName` config option takes a `String`. It represents +the required name of the variable. Its default is `e`. + +NOTE: This cop does not consider nested rescues because it cannot +guarantee that the variable from the outer rescue is not used within +the inner rescue (in which case, changing the inner variable would +shadow the outer variable). + +[#examples-namingrescuedexceptionsvariablename] +=== Examples + +[#preferredname_-e-_default_-namingrescuedexceptionsvariablename] +==== PreferredName: e (default) + +[source,ruby] +---- +# bad +begin + # do something +rescue MyException => exception + # do something +end + +# good +begin + # do something +rescue MyException => e + # do something +end + +# good +begin + # do something +rescue MyException => _e + # do something +end +---- + +[#preferredname_-exception-namingrescuedexceptionsvariablename] +==== PreferredName: exception + +[source,ruby] +---- +# bad +begin + # do something +rescue MyException => e + # do something +end + +# good +begin + # do something +rescue MyException => exception + # do something +end + +# good +begin + # do something +rescue MyException => _exception + # do something +end +---- + +[#configurable-attributes-namingrescuedexceptionsvariablename] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| PreferredName +| `e` +| String +|=== + +[#namingvariablename] +== Naming/VariableName + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.50 +| 1.73 +|=== + +Checks that the configured style (snake_case or camelCase) is used for all variable names. +This includes local variables, instance variables, class variables, method arguments +(positional, keyword, rest or block), and block arguments. + +The cop can also be configured to forbid using specific names for variables, using +`ForbiddenIdentifiers` or `ForbiddenPatterns`. In addition to the above, this applies +to global variables as well. + +Method definitions and method calls are not affected by this cop. + +[#examples-namingvariablename] +=== Examples + +[#enforcedstyle_-snake_case-_default_-namingvariablename] +==== EnforcedStyle: snake_case (default) + +[source,ruby] +---- +# bad +fooBar = 1 + +# good +foo_bar = 1 +---- + +[#enforcedstyle_-camelcase-namingvariablename] +==== EnforcedStyle: camelCase + +[source,ruby] +---- +# bad +foo_bar = 1 + +# good +fooBar = 1 +---- + +[#allowedidentifiers_-__foobar__-namingvariablename] +==== AllowedIdentifiers: ['fooBar'] + +[source,ruby] +---- +# good (with EnforcedStyle: snake_case) +fooBar = 1 +---- + +[#allowedpatterns_-___v_d__z__-namingvariablename] +==== AllowedPatterns: ['_v\d+\z'] + +[source,ruby] +---- +# good (with EnforcedStyle: camelCase) +release_v1 = true +---- + +[#forbiddenidentifiers_-__foobar__-namingvariablename] +==== ForbiddenIdentifiers: ['fooBar'] + +[source,ruby] +---- +# bad (in all cases) +fooBar = 1 +@fooBar = 1 +@@fooBar = 1 +$fooBar = 1 +---- + +[#forbiddenpatterns_-___v_d__z__-namingvariablename] +==== ForbiddenPatterns: ['_v\d+\z'] + +[source,ruby] +---- +# bad (in all cases) +release_v1 = true +@release_v1 = true +@@release_v1 = true +$release_v1 = true +---- + +[#configurable-attributes-namingvariablename] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `snake_case` +| `snake_case`, `camelCase` + +| AllowedIdentifiers +| `[]` +| Array + +| AllowedPatterns +| `[]` +| Array + +| ForbiddenIdentifiers +| `[]` +| Array + +| ForbiddenPatterns +| `[]` +| Array +|=== + +[#references-namingvariablename] +=== References + +* https://rubystyle.guide#snake-case-symbols-methods-vars + +[#namingvariablenumber] +== Naming/VariableNumber + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.50 +| 1.4 +|=== + +Makes sure that all numbered variables use the +configured style, snake_case, normalcase, or non_integer, +for their numbering. + +Additionally, `CheckMethodNames` and `CheckSymbols` configuration options +can be used to specify whether method names and symbols should be checked. +Both are enabled by default. + +[#examples-namingvariablenumber] +=== Examples + +[#enforcedstyle_-normalcase-_default_-namingvariablenumber] +==== EnforcedStyle: normalcase (default) + +[source,ruby] +---- +# bad +:some_sym_1 +variable_1 = 1 + +def some_method_1; end + +def some_method1(arg_1); end + +# good +:some_sym1 +variable1 = 1 + +def some_method1; end + +def some_method1(arg1); end +---- + +[#enforcedstyle_-snake_case-namingvariablenumber] +==== EnforcedStyle: snake_case + +[source,ruby] +---- +# bad +:some_sym1 +variable1 = 1 + +def some_method1; end + +def some_method_1(arg1); end + +# good +:some_sym_1 +variable_1 = 1 + +def some_method_1; end + +def some_method_1(arg_1); end +---- + +[#enforcedstyle_-non_integer-namingvariablenumber] +==== EnforcedStyle: non_integer + +[source,ruby] +---- +# bad +:some_sym1 +:some_sym_1 + +variable1 = 1 +variable_1 = 1 + +def some_method1; end + +def some_method_1; end + +def some_methodone(arg1); end +def some_methodone(arg_1); end + +# good +:some_symone +:some_sym_one + +variableone = 1 +variable_one = 1 + +def some_methodone; end + +def some_method_one; end + +def some_methodone(argone); end +def some_methodone(arg_one); end + +# In the following examples, we assume `EnforcedStyle: normalcase` (default). +---- + +[#checkmethodnames_-true-_default_-namingvariablenumber] +==== CheckMethodNames: true (default) + +[source,ruby] +---- +# bad +def some_method_1; end +---- + +[#checkmethodnames_-false-namingvariablenumber] +==== CheckMethodNames: false + +[source,ruby] +---- +# good +def some_method_1; end +---- + +[#checksymbols_-true-_default_-namingvariablenumber] +==== CheckSymbols: true (default) + +[source,ruby] +---- +# bad +:some_sym_1 +---- + +[#checksymbols_-false-namingvariablenumber] +==== CheckSymbols: false + +[source,ruby] +---- +# good +:some_sym_1 +---- + +[#allowedidentifiers_-_capture3_-namingvariablenumber] +==== AllowedIdentifiers: [capture3] + +[source,ruby] +---- +# good +expect(Open3).to receive(:capture3) +---- + +[#allowedpatterns_-___v_d__z__-namingvariablenumber] +==== AllowedPatterns: ['_v\d+\z'] + +[source,ruby] +---- +# good +:some_sym_v1 +---- + +[#configurable-attributes-namingvariablenumber] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `normalcase` +| `snake_case`, `normalcase`, `non_integer` + +| CheckMethodNames +| `true` +| Boolean + +| CheckSymbols +| `true` +| Boolean + +| AllowedIdentifiers +| `TLS1_1`, `TLS1_2`, `capture3`, `iso8601`, `rfc1123_date`, `rfc822`, `rfc2822`, `rfc3339`, `x86_64` +| Array + +| AllowedPatterns +| `[]` +| Array +|=== + +[#references-namingvariablenumber] +=== References + +* https://rubystyle.guide#snake-case-symbols-methods-vars-with-numbers diff --git a/docs/modules/ROOT/pages/cops_security.adoc b/docs/modules/ROOT/pages/cops_security.adoc new file mode 100644 index 000000000000..3440aa9735d1 --- /dev/null +++ b/docs/modules/ROOT/pages/cops_security.adoc @@ -0,0 +1,304 @@ +//// + Do NOT edit this file by hand directly, as it is automatically generated. + + Please make any necessary changes to the cop documentation within the source files themselves. +//// + += Security + +[#securitycompoundhash] +== Security/CompoundHash + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| No +| No +| 1.28 +| 1.51 +|=== + +Checks for implementations of the `hash` method which combine +values using custom logic instead of delegating to `Array#hash`. + +Manually combining hashes is error prone and hard to follow, especially +when there are many values. Poor implementations may also introduce +performance or security concerns if they are prone to collisions. +Delegating to `Array#hash` is clearer and safer, although it might be slower +depending on the use case. + +[#safety-securitycompoundhash] +=== Safety + +This cop may be unsafe if the application logic depends on the hash +value, however this is inadvisable anyway. + +[#examples-securitycompoundhash] +=== Examples + +[source,ruby] +---- +# bad +def hash + @foo ^ @bar +end + +# good +def hash + [@foo, @bar].hash +end +---- + +[#securityeval] +== Security/Eval + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.47 +| - +|=== + +Checks for the use of `Kernel#eval` and `Binding#eval`. + +[#examples-securityeval] +=== Examples + +[source,ruby] +---- +# bad + +eval(something) +binding.eval(something) +Kernel.eval(something) +---- + +[#securityiomethods] +== Security/IoMethods + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| No +| Always (Unsafe) +| 1.22 +| - +|=== + +Checks for the first argument to `IO.read`, `IO.binread`, `IO.write`, `IO.binwrite`, +`IO.foreach`, and `IO.readlines`. + +If argument starts with a pipe character (`'|'`) and the receiver is the `IO` class, +a subprocess is created in the same way as `Kernel#open`, and its output is returned. +`Kernel#open` may allow unintentional command injection, which is the reason these +`IO` methods are a security risk. +Consider to use `File.read` to disable the behavior of subprocess invocation. + +[#safety-securityiomethods] +=== Safety + +This cop is unsafe because false positive will occur if the variable passed as +the first argument is a command that is not a file path. + +[#examples-securityiomethods] +=== Examples + +[source,ruby] +---- +# bad +IO.read(path) +IO.read('path') + +# good +File.read(path) +File.read('path') +IO.read('| command') # Allow intentional command invocation. +---- + +[#securityjsonload] +== Security/JSONLoad + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always (Unsafe) +| 0.43 +| 1.22 +|=== + +Checks for the use of JSON class methods which have potential +security issues. + +[#safety-securityjsonload] +=== Safety + +This cop's autocorrection is unsafe because it's potentially dangerous. +If using a stream, like `JSON.load(open('file'))`, it will need to call +`#read` manually, like `JSON.parse(open('file').read)`. +If reading single values (rather than proper JSON objects), like +`JSON.load('false')`, it will need to pass the `quirks_mode: true` +option, like `JSON.parse('false', quirks_mode: true)`. +Other similar issues may apply. + +[#examples-securityjsonload] +=== Examples + +[source,ruby] +---- +# bad +JSON.load("{}") +JSON.restore("{}") + +# good +JSON.parse("{}") +---- + +[#references-securityjsonload] +=== References + +* https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load + +[#securitymarshalload] +== Security/MarshalLoad + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| No +| 0.47 +| - +|=== + +Checks for the use of Marshal class methods which have +potential security issues leading to remote code execution when +loading from an untrusted source. + +[#examples-securitymarshalload] +=== Examples + +[source,ruby] +---- +# bad +Marshal.load("{}") +Marshal.restore("{}") + +# good +Marshal.dump("{}") + +# okish - deep copy hack +Marshal.load(Marshal.dump({})) +---- + +[#references-securitymarshalload] +=== References + +* https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations + +[#securityopen] +== Security/Open + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| No +| No +| 0.53 +| 1.0 +|=== + +Checks for the use of `Kernel#open` and `URI.open` with dynamic +data. + +`Kernel#open` and `URI.open` enable not only file access but also process +invocation by prefixing a pipe symbol (e.g., `open("| ls")`). +So, it may lead to a serious security risk by using variable input to +the argument of `Kernel#open` and `URI.open`. It would be better to use +`File.open`, `IO.popen` or `URI.parse#open` explicitly. + +NOTE: `open` and `URI.open` with literal strings are not flagged by this +cop. + +[#safety-securityopen] +=== Safety + +This cop could register false positives if `open` is redefined +in a class and then used without a receiver in that class. + +[#examples-securityopen] +=== Examples + +[source,ruby] +---- +# bad +open(something) +open("| #{something}") +open("| foo") +URI.open(something) + +# good +File.open(something) +IO.popen(something) +URI.parse(something).open + +# good (literal strings) +open("foo.text") +URI.open("http://example.com") +URI.parse(url).open +---- + +[#securityyamlload] +== Security/YAMLLoad + +NOTE: Requires Ruby version <= 3.0 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always (Unsafe) +| 0.47 +| - +|=== + +Checks for the use of YAML class methods which have +potential security issues leading to remote code execution when +loading from an untrusted source. + +NOTE: Ruby 3.1+ (Psych 4) uses `Psych.load` as `Psych.safe_load` by default. + +[#safety-securityyamlload] +=== Safety + +The behavior of the code might change depending on what was +in the YAML payload, since `YAML.safe_load` is more restrictive. + +[#examples-securityyamlload] +=== Examples + +[source,ruby] +---- +# bad +YAML.load("--- !ruby/object:Foo {}") # Psych 3 is unsafe by default + +# good +YAML.safe_load("--- !ruby/object:Foo {}", [Foo]) # Ruby 2.5 (Psych 3) +YAML.safe_load("--- !ruby/object:Foo {}", permitted_classes: [Foo]) # Ruby 3.0- (Psych 3) +YAML.load("--- !ruby/object:Foo {}", permitted_classes: [Foo]) # Ruby 3.1+ (Psych 4) +YAML.dump(foo) +---- + +[#references-securityyamlload] +=== References + +* https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security diff --git a/docs/modules/ROOT/pages/cops_style.adoc b/docs/modules/ROOT/pages/cops_style.adoc new file mode 100644 index 000000000000..fb0047a5245e --- /dev/null +++ b/docs/modules/ROOT/pages/cops_style.adoc @@ -0,0 +1,19795 @@ +//// + Do NOT edit this file by hand directly, as it is automatically generated. + + Please make any necessary changes to the cop documentation within the source files themselves. +//// + += Style + +[#styleaccessmodifierdeclarations] +== Style/AccessModifierDeclarations + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always (Unsafe) +| 0.57 +| 1.70 +|=== + +Access modifiers should be declared to apply to a group of methods +or inline before each method, depending on configuration. +EnforcedStyle config covers only method definitions. +Applications of visibility methods to symbols can be controlled +using AllowModifiersOnSymbols config. +Also, the visibility of `attr*` methods can be controlled using +AllowModifiersOnAttrs config. + +In Ruby 3.0, `attr*` methods now return an array of defined method names +as symbols. So we can write the modifier and `attr*` in inline style. +AllowModifiersOnAttrs config allows `attr*` methods to be written in +inline style without modifying applications that have been maintained +for a long time in group style. Furthermore, developers who are not very +familiar with Ruby may know that the modifier applies to `def`, but they +may not know that it also applies to `attr*` methods. It would be easier +to understand if we could write `attr*` methods in inline style. + +[#safety-styleaccessmodifierdeclarations] +=== Safety + +Autocorrection is not safe, because the visibility of dynamically +defined methods can vary depending on the state determined by +the group access modifier. + +[#examples-styleaccessmodifierdeclarations] +=== Examples + +[#enforcedstyle_-group-_default_-styleaccessmodifierdeclarations] +==== EnforcedStyle: group (default) + +[source,ruby] +---- +# bad +class Foo + + private def bar; end + private def baz; end + +end + +# good +class Foo + + private + + def bar; end + def baz; end + +end +---- + +[#enforcedstyle_-inline-styleaccessmodifierdeclarations] +==== EnforcedStyle: inline + +[source,ruby] +---- +# bad +class Foo + + private + + def bar; end + def baz; end + +end + +# good +class Foo + + private def bar; end + private def baz; end + +end +---- + +[#allowmodifiersonsymbols_-true-_default_-styleaccessmodifierdeclarations] +==== AllowModifiersOnSymbols: true (default) + +[source,ruby] +---- +# good +class Foo + + private :bar, :baz + private *%i[qux quux] + private *METHOD_NAMES + private *private_methods + +end +---- + +[#allowmodifiersonsymbols_-false-styleaccessmodifierdeclarations] +==== AllowModifiersOnSymbols: false + +[source,ruby] +---- +# bad +class Foo + + private :bar, :baz + private *%i[qux quux] + private *METHOD_NAMES + private *private_methods + +end +---- + +[#allowmodifiersonattrs_-true-_default_-styleaccessmodifierdeclarations] +==== AllowModifiersOnAttrs: true (default) + +[source,ruby] +---- +# good +class Foo + + public attr_reader :bar + protected attr_writer :baz + private attr_accessor :qux + private attr :quux + + def public_method; end + + private + + def private_method; end + +end +---- + +[#allowmodifiersonattrs_-false-styleaccessmodifierdeclarations] +==== AllowModifiersOnAttrs: false + +[source,ruby] +---- +# bad +class Foo + + public attr_reader :bar + protected attr_writer :baz + private attr_accessor :qux + private attr :quux + +end +---- + +[#allowmodifiersonaliasmethod_-true-_default_-styleaccessmodifierdeclarations] +==== AllowModifiersOnAliasMethod: true (default) + +[source,ruby] +---- +# good +class Foo + + public alias_method :bar, :foo + protected alias_method :baz, :foo + private alias_method :qux, :foo + +end +---- + +[#allowmodifiersonaliasmethod_-false-styleaccessmodifierdeclarations] +==== AllowModifiersOnAliasMethod: false + +[source,ruby] +---- +# bad +class Foo + + public alias_method :bar, :foo + protected alias_method :baz, :foo + private alias_method :qux, :foo + +end +---- + +[#configurable-attributes-styleaccessmodifierdeclarations] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `group` +| `inline`, `group` + +| AllowModifiersOnSymbols +| `true` +| Boolean + +| AllowModifiersOnAttrs +| `true` +| Boolean + +| AllowModifiersOnAliasMethod +| `true` +| Boolean +|=== + +[#styleaccessorgrouping] +== Style/AccessorGrouping + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.87 +| - +|=== + +Checks for grouping of accessors in `class` and `module` bodies. +By default it enforces accessors to be placed in grouped declarations, +but it can be configured to enforce separating them in multiple declarations. + +NOTE: If there is a method call before the accessor method it is always allowed +as it might be intended like Sorbet. + +NOTE: If there is a RBS::Inline annotation comment just after the accessor method +it is always allowed. + +[#examples-styleaccessorgrouping] +=== Examples + +[#enforcedstyle_-grouped-_default_-styleaccessorgrouping] +==== EnforcedStyle: grouped (default) + +[source,ruby] +---- +# bad +class Foo + attr_reader :bar + attr_reader :bax + attr_reader :baz +end + +# good +class Foo + attr_reader :bar, :bax, :baz +end + +# good +class Foo + # may be intended comment for bar. + attr_reader :bar + + sig { returns(String) } + attr_reader :bax + + may_be_intended_annotation :baz + attr_reader :baz +end +---- + +[#enforcedstyle_-separated-styleaccessorgrouping] +==== EnforcedStyle: separated + +[source,ruby] +---- +# bad +class Foo + attr_reader :bar, :baz +end + +# good +class Foo + attr_reader :bar + attr_reader :baz +end +---- + +[#configurable-attributes-styleaccessorgrouping] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `grouped` +| `separated`, `grouped` +|=== + +[#stylealias] +== Style/Alias + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always +| 0.9 +| 0.36 +|=== + +Enforces the use of either `#alias` or `#alias_method` +depending on configuration. +It also flags uses of `alias :symbol` rather than `alias bareword`. + +However, it will always enforce `method_alias` when used `alias` +in an instance method definition and in a singleton method definition. +If used in a block, always enforce `alias_method` +unless it is an `instance_eval` block. + +[#examples-stylealias] +=== Examples + +[#enforcedstyle_-prefer_alias-_default_-stylealias] +==== EnforcedStyle: prefer_alias (default) + +[source,ruby] +---- +# bad +alias_method :bar, :foo +alias :bar :foo + +# good +alias bar foo +---- + +[#enforcedstyle_-prefer_alias_method-stylealias] +==== EnforcedStyle: prefer_alias_method + +[source,ruby] +---- +# bad +alias :bar :foo +alias bar foo + +# good +alias_method :bar, :foo +---- + +[#configurable-attributes-stylealias] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `prefer_alias` +| `prefer_alias`, `prefer_alias_method` +|=== + +[#references-stylealias] +=== References + +* https://rubystyle.guide#alias-method-lexically + +[#styleambiguousendlessmethoddefinition] +== Style/AmbiguousEndlessMethodDefinition + +NOTE: Requires Ruby version 3.0 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.68 +| - +|=== + +Looks for endless methods inside operations of lower precedence (`and`, `or`, and +modifier forms of `if`, `unless`, `while`, `until`) that are ambiguous due to +lack of parentheses. This may lead to unexpected behavior as the code may appear +to use these keywords as part of the method but in fact they modify +the method definition itself. + +In these cases, using a normal method definition is more clear. + +[#examples-styleambiguousendlessmethoddefinition] +=== Examples + +[source,ruby] +---- +# bad +def foo = true if bar + +# good - using a non-endless method is more explicit +def foo + true +end if bar + +# ok - method body is explicit +def foo = (true if bar) + +# ok - method definition is explicit +(def foo = true) if bar +---- + +[#references-styleambiguousendlessmethoddefinition] +=== References + +* https://rubystyle.guide#ambiguous-endless-method-defintions + +[#styleandor] +== Style/AndOr + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Enabled +| Yes +| Always (Unsafe) +| 0.9 +| 1.21 +|=== + +Checks for uses of `and` and `or`, and suggests using `&&` and +`||` instead. It can be configured to check only in conditions or in +all contexts. + +[#safety-styleandor] +=== Safety + +Autocorrection is unsafe because there is a different operator precedence +between logical operators (`&&` and `||`) and semantic operators (`and` and `or`), +and that might change the behavior. + +[#examples-styleandor] +=== Examples + +[#enforcedstyle_-conditionals-_default_-styleandor] +==== EnforcedStyle: conditionals (default) + +[source,ruby] +---- +# bad +if foo and bar +end + +# good +foo.save && return + +# good +foo.save and return + +# good +if foo && bar +end +---- + +[#enforcedstyle_-always-styleandor] +==== EnforcedStyle: always + +[source,ruby] +---- +# bad +foo.save and return + +# bad +if foo and bar +end + +# good +foo.save && return + +# good +if foo && bar +end +---- + +[#configurable-attributes-styleandor] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| EnforcedStyle +| `conditionals` +| `always`, `conditionals` +|=== + +[#references-styleandor] +=== References + +* https://rubystyle.guide#no-and-or-or + +[#styleargumentsforwarding] +== Style/ArgumentsForwarding + +NOTE: Requires Ruby version 2.7 + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Always +| 1.1 +| 1.58 +|=== + +In Ruby 2.7, arguments forwarding has been added. + +This cop identifies places where `do_something(*args, &block)` +can be replaced by `do_something(...)`. + +In Ruby 3.1, anonymous block forwarding has been added. + +This cop identifies places where `do_something(&block)` can be replaced +by `do_something(&)`; if desired, this functionality can be disabled +by setting `UseAnonymousForwarding: false`. + +In Ruby 3.2, anonymous args/kwargs forwarding has been added. + +This cop also identifies places where `+use_args(*args)+`/`+use_kwargs(**kwargs)+` can be +replaced by `+use_args(*)+`/`+use_kwargs(**)+`; if desired, this functionality can be +disabled by setting `UseAnonymousForwarding: false`. + +And this cop has `RedundantRestArgumentNames`, `RedundantKeywordRestArgumentNames`, +and `RedundantBlockArgumentNames` options. This configuration is a list of redundant names +that are sufficient for anonymizing meaningless naming. + +Meaningless names that are commonly used can be anonymized by default: +e.g., `+*args+`, `+**options+`, `&block`, and so on. + +Names not on this list are likely to be meaningful and are allowed by default. + +This cop handles not only method forwarding but also forwarding to `super`. + +[NOTE] +==== +Because of a bug in Ruby 3.3.0, when a block is referenced inside of another block, +no offense will be registered until Ruby 3.4: + +[source,ruby] +---- +def foo(&block) + # Using an anonymous block would be a syntax error on Ruby 3.3.0 + block_method { bar(&block) } +end +---- +==== + +[#examples-styleargumentsforwarding] +=== Examples + +[source,ruby] +---- +# bad +def foo(*args, &block) + bar(*args, &block) +end + +# bad +def foo(*args, **kwargs, &block) + bar(*args, **kwargs, &block) +end + +# good +def foo(...) + bar(...) +end +---- + +[#useanonymousforwarding_-true-_default_-only-relevant-for-ruby-__-3_2_-styleargumentsforwarding] +==== UseAnonymousForwarding: true (default, only relevant for Ruby >= 3.2) + +[source,ruby] +---- +# bad +def foo(*args, **kwargs, &block) + args_only(*args) + kwargs_only(**kwargs) + block_only(&block) +end + +# good +def foo(*, **, &) + args_only(*) + kwargs_only(**) + block_only(&) +end +---- + +[#useanonymousforwarding_-false-_only-relevant-for-ruby-__-3_2_-styleargumentsforwarding] +==== UseAnonymousForwarding: false (only relevant for Ruby >= 3.2) + +[source,ruby] +---- +# good +def foo(*args, **kwargs, &block) + args_only(*args) + kwargs_only(**kwargs) + block_only(&block) +end +---- + +[#allowonlyrestargument_-true-_default_-only-relevant-for-ruby-_-3_2_-styleargumentsforwarding] +==== AllowOnlyRestArgument: true (default, only relevant for Ruby < 3.2) + +[source,ruby] +---- +# good +def foo(*args) + bar(*args) +end + +def foo(**kwargs) + bar(**kwargs) +end +---- + +[#allowonlyrestargument_-false-_only-relevant-for-ruby-_-3_2_-styleargumentsforwarding] +==== AllowOnlyRestArgument: false (only relevant for Ruby < 3.2) + +[source,ruby] +---- +# bad +# The following code can replace the arguments with `...`, +# but it will change the behavior. Because `...` forwards block also. +def foo(*args) + bar(*args) +end + +def foo(**kwargs) + bar(**kwargs) +end +---- + +[#redundantrestargumentnames_-__args__-_arguments__-_default_-styleargumentsforwarding] +==== RedundantRestArgumentNames: ['args', 'arguments'] (default) + +[source,ruby] +---- +# bad +def foo(*args) + bar(*args) +end + +# good +def foo(*) + bar(*) +end +---- + +[#redundantkeywordrestargumentnames_-__kwargs__-_options__-_opts__-_default_-styleargumentsforwarding] +==== RedundantKeywordRestArgumentNames: ['kwargs', 'options', 'opts'] (default) + +[source,ruby] +---- +# bad +def foo(**kwargs) + bar(**kwargs) +end + +# good +def foo(**) + bar(**) +end +---- + +[#redundantblockargumentnames_-__blk__-_block__-_proc__-_default_-styleargumentsforwarding] +==== RedundantBlockArgumentNames: ['blk', 'block', 'proc'] (default) + +[source,ruby] +---- +# bad - But it is good with `EnforcedStyle: explicit` set for `Naming/BlockForwarding`. +def foo(&block) + bar(&block) +end + +# good +def foo(&) + bar(&) +end +---- + +[#configurable-attributes-styleargumentsforwarding] +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| AllowOnlyRestArgument +| `true` +| Boolean + +| UseAnonymousForwarding +| `true` +| Boolean + +| RedundantRestArgumentNames +| `args`, `arguments` +| Array + +| RedundantKeywordRestArgumentNames +| `kwargs`, `options`, `opts` +| Array + +| RedundantBlockArgumentNames +| `blk`, `block`, `proc` +| Array +|=== + +[#references-styleargumentsforwarding] +=== References + +* https://rubystyle.guide#arguments-forwarding + +[#stylearraycoercion] +== Style/ArrayCoercion + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Disabled +| No +| Always (Unsafe) +| 0.88 +| - +|=== + +Enforces the use of `Array()` instead of explicit `Array` check or `[*var]`. + +The cop is disabled by default due to safety concerns. + +[#safety-stylearraycoercion] +=== Safety + +This cop is unsafe because a false positive may occur if +the argument of `Array()` is (or could be) nil or depending +on how the argument is handled by `Array()` (which can be +different than just wrapping the argument in an array). + +For example: + +[source,ruby] +---- +[nil] #=> [nil] +Array(nil) #=> [] + +[{a: 'b'}] #= [{a: 'b'}] +Array({a: 'b'}) #=> [[:a, 'b']] + +[Time.now] #=> [#