Skip to content

Include seeds in Rubocop (plus fixes to seeds to satisfy Rubocop)#432

Merged
leesheppard merged 6 commits intorubyaustralia:mainfrom
lee-treehouse:include-seeds-in-rubocop
Jan 20, 2026
Merged

Include seeds in Rubocop (plus fixes to seeds to satisfy Rubocop)#432
leesheppard merged 6 commits intorubyaustralia:mainfrom
lee-treehouse:include-seeds-in-rubocop

Conversation

@lee-treehouse
Copy link
Contributor

Review after #431 is merged, as this branch branches off that branch.

The current state is that any file in the db directory or its subdirectories is not evaluated by Rubocop, but this makes it tedious to apply code formatting and check code quality as we add more seeding code (eg for Campaigns)

This change makes it more explicit where we do not care to use Rubocop (db migrations, schema.rb) so that Rubocop will evaluate everything else.

This change also includes the fixes to satisfy Rubocop.

This screenshot shows that the seeding works correctly after the changes.

CleanShot 2026-01-18 at 08 51 19@2x

Copilot AI review requested due to automatic review settings January 17, 2026 21:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables Rubocop analysis for seed files while explicitly excluding only migrations and schema.rb. The change includes fixes to existing seed files to satisfy Rubocop requirements.

Changes:

  • Modified .rubocop.yml to evaluate seed files while excluding only migrations and schema.rb
  • Refactored db/seeds/users.rb to address code quality issues and improve output formatting
  • Updated db/seeds/posts.rb to fix Rubocop violations and improve code style

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
.rubocop.yml Changed exclusion pattern from all db files to only migrations and schema.rb
db/seeds.rb Updated file path syntax to use consistent string format
db/seeds/users.rb Refactored user seeding logic with improved methods and Rubocop compliance
db/seeds/posts.rb Fixed various Rubocop violations including unused variables and code style issues

{
published_at: Faker::Time.between(from: 4.months.ago, to: 1.week.ago),
status: 2, # published
published_at: Faker::Time.between(from: 4.months.ago, to: 1.week.ago), status: 2, # published
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline comment placement after status: 2 makes the code harder to read. Consider moving the comment to a separate line above the hash or removing it since the context already makes it clear this is the published status.

Suggested change
published_at: Faker::Time.between(from: 4.months.ago, to: 1.week.ago), status: 2, # published
published_at: Faker::Time.between(from: 4.months.ago, to: 1.week.ago),
# published
status: 2,

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good bot, I generally agree - but choice was to disable the 10 line length rule, or refactor which didn't seem too valuable, so I thought this was a happy enough compromise.

If there's any humans feeling strongly let me know.

@@ -52,25 +50,24 @@ def post_content_enhanced
content += Faker::Lorem.paragraph(sentence_count: 8, supplemental: true, random_sentences_to_add: 4)
content += "<br /><br />"
end
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The post_content_enhanced method should explicitly return content at the end for clarity. While Ruby returns the last evaluated expression, an explicit return statement improves readability for methods that build up a result.

Suggested change
end
end
return content

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good bot, I generally agree - but choice was to disable the 10 line length rule, or refactor which didn't seem too valuable, so I thought this was a happy enough compromise.

If there's any humans feeling strongly let me know.

@leesheppard leesheppard merged commit f09991f into rubyaustralia:main Jan 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants