Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubocop/rubocop-rails
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.27.0
Choose a base ref
...
head repository: rubocop/rubocop-rails
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.28.0
Choose a head ref
  • 20 commits
  • 38 files changed
  • 3 contributors

Commits on Oct 26, 2024

  1. Configuration menu
    Copy the full SHA
    1d7f0c4 View commit details
    Browse the repository at this point in the history

Commits on Oct 29, 2024

  1. Fix false negatives for Rails/RedundantActiveRecordAllMethod when u…

    …sing `all` method in block
    
    This PR fixes false negatives for `Rails/RedundantActiveRecordAllMethod` when methods in `POSSIBLE_ENUMERABLE_BLOCK_METHODS` are used in a block as following:
    
    ```
    expect { subject }.to change { User.all.count }
    ```
    masato-bkn committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    2d7e7a0 View commit details
    Browse the repository at this point in the history
  2. Merge pull request #1382 from masato-bkn/fix-redundant_active_record_…

    …all_method
    
    Fix false negatives for `Rails/RedundantActiveRecordAllMethod` when using `POSSIBLE_ENUMERABLE_BLOCK_METHODS` in a block
    koic authored Oct 29, 2024
    Configuration menu
    Copy the full SHA
    ad3287a View commit details
    Browse the repository at this point in the history

Commits on Nov 15, 2024

  1. Suppress a RuboCop offense

    This PR suppresses the following RuboCop offense:
    
    ```console
    $ bundle exec rubocop -a
    (snip)
    
    Offenses:
    
    lib/rubocop/cop/rails/save_bang.rb:247:11: C: [Corrected] InternalAffairs/OperatorKeyword: Use node.operator_keyword?.
    node.or_type? || node.and_type? || single_negative?(node)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ```
    koic committed Nov 15, 2024
    Configuration menu
    Copy the full SHA
    879f3b9 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d5b012f View commit details
    Browse the repository at this point in the history

Commits on Nov 23, 2024

  1. Modify Rails/Pluck to ignore map/collect when used inside blocks …

    …to prevent potential N+1 queries
    masato-bkn committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    24c7a77 View commit details
    Browse the repository at this point in the history

Commits on Nov 29, 2024

  1. Merge pull request #1388 from masato-bkn/modify_rails_pluck_to_ignore…

    …_map_when_used_inside_block
    
    Modify `Rails/Pluck` to ignore `map/collect` when used inside blocks to prevent potential N+1 queries
    koic authored Nov 29, 2024
    Configuration menu
    Copy the full SHA
    c3ddedf View commit details
    Browse the repository at this point in the history

Commits on Dec 1, 2024

  1. Fix an incorrect autocorrect for Rails/SelectMap when select has …

    …no receiver and method chains are used
    
    This commit fixes an incorrect autocorrect for `Rails/SelectMap` when `select` has no receiver and method chains are used between `select` and `map`, as follows:
    
    Before autocorrect
    ```ruby
    select(:column_name).where(conditions).map(&:column_name)
    ```
    
    After autocorrect (syntax error)
    ```ruby
    .where(conditions)pluck(:column_name)
    ```
    masato-bkn committed Dec 1, 2024
    Configuration menu
    Copy the full SHA
    02ea37f View commit details
    Browse the repository at this point in the history
  2. Merge pull request #1390 from masato-bkn/fix_incorrect_autocorrect_fo…

    …r_rails_select_map
    
    Fix an incorrect autocorrect for `Rails/SelectMap` when `select` has no receiver and method chains are used
    koic authored Dec 1, 2024
    Configuration menu
    Copy the full SHA
    e470d18 View commit details
    Browse the repository at this point in the history

Commits on Dec 13, 2024

  1. Apply rubocop --auto-gen-config

    This commit applies `rubocop --auto-gen-config` to suppress the following offense:
    
    ```console
    $ bundle exec rubocop
    (snip)
    
    Offenses:
    
    lib/rubocop/cop/rails/blank.rb:126:35: C: [Correctable] InternalAffairs/CopEnabled:
    Use config.cop_enabled?('Style/UnlessElse') instead of config.for_cop('Style/UnlessElse')['Enabled'].
              return if node.else? && config.for_cop('Style/UnlessElse')['Enabled']
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    lib/rubocop/cop/rails/present.rb:113:35: C: [Correctable] InternalAffairs/CopEnabled:
    Use config.cop_enabled?('Style/UnlessElse') instead of config.for_cop('Style/UnlessElse')['Enabled'].
              return if node.else? && config.for_cop('Style/UnlessElse')['Enabled']
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    296 files inspected, 2 offenses detected, 2 offenses autocorrectable
    RuboCop failed!
    ```
    
    In the future, the offense of `InternalAffairs/CopEnabled` can be autocorrected,
    but raising the minimum required RuboCop version just for that should be avoided.
    koic committed Dec 13, 2024
    Configuration menu
    Copy the full SHA
    0bbd218 View commit details
    Browse the repository at this point in the history
  2. Fix Rails/FilePath cop error with rescued Rails.root

    ```console
    echo '"#{Rails.root rescue "."}/config"' | rubocop --stdin bug.rb -d
    
    An error occurred while Rails/FilePath cop was inspecting bug.rb:1:0.
    undefined method `method?' for an instance of RuboCop::AST::RescueNode
    lib/rubocop/cop/rails/file_path.rb:156:in `autocorrect_slash_after_rails_root_in_dstr'
    lib/rubocop/cop/rails/file_path.rb:81:in `block in check_for_slash_after_rails_root_in_dstr'
    ```
    viralpraxis committed Dec 13, 2024
    Configuration menu
    Copy the full SHA
    bb03d6b View commit details
    Browse the repository at this point in the history
  3. Merge pull request #1392 from viralpraxis/fix-rails-file-path-cop-err…

    …or-with-rescued-rails-root
    
    Fix `Rails/FilePath` cop error with rescued `Rails.root`
    koic authored Dec 13, 2024
    Configuration menu
    Copy the full SHA
    c6f869b View commit details
    Browse the repository at this point in the history

Commits on Dec 22, 2024

  1. Fix Rails/FilePath cop error in case of extra operations in `Rails.…

    …root` interpolation
    
    Follow-up to #1392.
    Previous PR didn't fix cases like this
    
    ```
    "#{Rails.root || '.'}/config"
    ```
    
    (it makes sense in real code since `Rails.root` [can be nil](https://github.com/rails/rails/blob/main/railties/lib/rails.rb#L65-L67))
    
    I think it's safe to simply check if the entire expression is of `send` type.
    viralpraxis committed Dec 22, 2024
    Configuration menu
    Copy the full SHA
    e4aee6b View commit details
    Browse the repository at this point in the history

Commits on Dec 23, 2024

  1. Merge pull request #1399 from viralpraxis/fix-rails-file-path-cop-err…

    …or-on-extra-operations-in-rails-root-interpolation
    
    Fix `Rails/FilePath` cop error in case of extra operations in `Rails.root` interpolation
    koic authored Dec 23, 2024
    Configuration menu
    Copy the full SHA
    fecead8 View commit details
    Browse the repository at this point in the history
  2. Fix Rails/FilePath cop error on join method with implicit receiver

    ```console
    echo 'join(Rails.root, path)' | rubocop --only Rails/FilePath  --stdin bug.rb -d
    
    n error occurred while Rails/FilePath cop was inspecting bug.rb:1:0.
    undefined method `each_node' for nil
    lib/rubocop/cop/rails/file_path.rb:54:in `rails_root_nodes?'
    lib/rubocop/cop/rails/file_path.rb:60:in `rails_root_join_nodes?'
    lib/rubocop/cop/rails/file_path.rb:108:in `check_for_rails_root_join_with_string_arguments'
    lib/rubocop/cop/rails/file_path.rb:70:in `on_send'
    ```
    viralpraxis committed Dec 23, 2024
    Configuration menu
    Copy the full SHA
    815d119 View commit details
    Browse the repository at this point in the history
  3. Merge pull request #1398 from viralpraxis/fix-rails-file-path-cop-err…

    …or-on-join-method-implicit-receiver
    
    Fix `Rails/FilePath` cop error on `join` method with implicit receiver
    koic authored Dec 23, 2024
    Configuration menu
    Copy the full SHA
    2671fb4 View commit details
    Browse the repository at this point in the history

Commits on Dec 25, 2024

  1. Introduce AllCops: MigratedSchemaVersion config

    This PR introduces `AllCops: MigratedSchemaVersion` config.
    
    By specifying the `MigratedSchemaVersion` option, migration files that have already been run can be ignored.
    When `MigratedSchemaVersion: '20241225000000'` is set, migration files lower than or equal to '20241225000000' will be ignored.
    For example, to ignore db/migrate/20241225000000_create_articles.rb and earlier migrations you would configure it the following way:
    
    ```yaml
    AllCops
      MigratedSchemaVersion: '20241225000000'
    ```
    
    This prevents inspecting schema settings for already applied migration files.
    Changing already applied migrations should be avoided because it can lead to the schema getting out of sync
    between your local copy and what it actually is in production, depending on when `bin/rails db:migrate` was executed.
    If you want to modify your schema to comply with the cops, you should instead create new migrations.
    koic committed Dec 25, 2024
    Configuration menu
    Copy the full SHA
    86b7a55 View commit details
    Browse the repository at this point in the history
  2. Merge pull request #1383 from koic/intro_migrated_schema_version

    Introduce `AllCops: MigratedSchemaVersion` config
    koic authored Dec 25, 2024
    Configuration menu
    Copy the full SHA
    2c357f0 View commit details
    Browse the repository at this point in the history
  3. Update Changelog

    koic committed Dec 25, 2024
    Configuration menu
    Copy the full SHA
    bac0f3e View commit details
    Browse the repository at this point in the history
  4. Cut 2.28.0

    koic committed Dec 25, 2024
    Configuration menu
    Copy the full SHA
    fcc4cf6 View commit details
    Browse the repository at this point in the history
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy