Skip to content

Fix Rubocop offenses for Rails apps without Jbuilder#52928

Merged
byroot merged 1 commit intorails:mainfrom
jeromedalbert:fix-rubocop-when-skipping-jbuilder
Sep 14, 2024
Merged

Fix Rubocop offenses for Rails apps without Jbuilder#52928
byroot merged 1 commit intorails:mainfrom
jeromedalbert:fix-rubocop-when-skipping-jbuilder

Conversation

@jeromedalbert
Copy link
Contributor

@jeromedalbert jeromedalbert commented Sep 14, 2024

Follow-up to #51674.

Motivation / Background

This Pull Request has been created because if you currently create a new Rails main app with the --skip-jbuilder option, scaffolded controllers do not comply with rubocop-rails-omakase rules.

Steps to repro the issue:

  • Run the following
    rails new myapp --main --skip-jbuilder; cd myapp
    rails generate scaffold post title
    bundle exec rubocop
    
  • Expected behavior: there should be no Rubocop offenses
  • Actual behavior: the are Rubocop offenses:
    Inspecting 31 files
    ...C...........................
    
    Offenses:
    
    app/controllers/posts_controller.rb:56:27: C: [Correctable] Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
          params.expect(post: [:title])
                              ^
    app/controllers/posts_controller.rb:56:34: C: Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
          params.expect(post: [:title])
                                     ^
    

Detail

This Pull Request changes the controller generators to use spaces around [ and ].

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Format generated controllers correctly so that apps created with the
`--skip-jbuilder` option are compliant with rubocop-rails-omakase.
@jeromedalbert jeromedalbert force-pushed the fix-rubocop-when-skipping-jbuilder branch from f6b0980 to fcbfd7f Compare September 14, 2024 10:44
@byroot byroot merged commit a2159e1 into rails:main Sep 14, 2024
@jeromedalbert jeromedalbert deleted the fix-rubocop-when-skipping-jbuilder branch September 14, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants