Skip to content

Commit 4821d71

Browse files
justin808claude
andcommitted
Fix all RuboCop violations with locked versions
Auto-fix 24 RuboCop offenses detected by the locked versions: - Update redundant .all method calls - Modernize strong parameters syntax - Improve Rails path methods - Update where clause usage - Use Rails.env.local? method This ensures the locked RuboCop versions pass CI while maintaining current code quality standards. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent aea5b9a commit 4821d71

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

app/controllers/comments_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def inline_form
102102
private
103103

104104
def set_comments
105-
@comments = Comment.all.order("id DESC")
105+
@comments = Comment.order("id DESC")
106106
end
107107

108108
# Use callbacks to share common setup or constraints between actions.
@@ -116,6 +116,6 @@ def new_comment
116116

117117
# Never trust parameters from the scary internet, only allow the white list through.
118118
def comment_params
119-
params.require(:comment).permit(:author, :text)
119+
params.expect(comment: %i[author text])
120120
end
121121
end

app/controllers/pages_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def rescript; end
4141
private
4242

4343
def set_comments
44-
@comments = Comment.all.order("id DESC")
44+
@comments = Comment.order("id DESC")
4545
end
4646

4747
def comments_json_string

lib/tasks/ci.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
if Rails.env.development? || Rails.env.test?
3+
if Rails.env.local?
44
# See tasks/linters.rake
55

66
task js_tests: :environment do

lib/tasks/daily.rake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
task daily: :environment do
44
t = 1.day.ago
5-
older_comments = Comment.where("created_at < ?", t)
6-
newer_comments = Comment.where("created_at >= ?", t)
5+
older_comments = Comment.where(created_at: ...t)
6+
newer_comments = Comment.where(created_at: t..)
77
puts "Deleting #{older_comments.count} comments older than #{t}"
88
puts "Keeping #{newer_comments.count} comments newer than #{t}"
99
older_comments.delete_all

spec/rails_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
# Requires supporting files with custom matchers and macros, etc,
3737
# in ./support/ and its subdirectories.
38-
Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f }
38+
Rails.root.glob("spec/support/**/*.rb").sort.each { |f| require f }
3939

4040
RSpec.configure do |config|
4141
config.include FactoryBot::Syntax::Methods

spec/rescript/rescript_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,41 +46,41 @@
4646
end
4747

4848
it "comment count increases with successful form submission" do
49-
initital_comment_count = Comment.all.count
49+
initital_comment_count = Comment.count
5050
new_comment_count = initital_comment_count + 1
5151
fill_in author_field, with: comment.author
5252
fill_in text_field, with: comment.text
5353
click_button("Post")
5454

5555
page.driver.browser.manage.timeouts.implicit_wait = 1
5656

57-
expect(Comment.all.count).to equal(new_comment_count)
57+
expect(Comment.count).to equal(new_comment_count)
5858
end
5959

6060
it "comment count remains the same when author field is empty" do
61-
initial_comment_count = Comment.all.count
61+
initial_comment_count = Comment.count
6262
fill_in text_field, with: comment.text
6363
click_button("Post")
6464

6565
expect(page).to have_text(/Can't save the comment!/)
66-
expect(Comment.all.count).to equal(initial_comment_count)
66+
expect(Comment.count).to equal(initial_comment_count)
6767
end
6868

6969
it "comment count remains the same when text field is empty" do
70-
initial_comment_count = Comment.all.count
70+
initial_comment_count = Comment.count
7171
fill_in author_field, with: comment.author
7272
click_button("Post")
7373

7474
expect(page).to have_text(/Can't save the comment!/)
75-
expect(Comment.all.count).to equal(initial_comment_count)
75+
expect(Comment.count).to equal(initial_comment_count)
7676
end
7777

7878
it "comment count remains the same when both form fields are empty" do
79-
initial_comment_count = Comment.all.count
79+
initial_comment_count = Comment.count
8080
click_button("Post")
8181

8282
expect(page).to have_text(/Can't save the comment!/)
83-
expect(Comment.all.count).to equal(initial_comment_count)
83+
expect(Comment.count).to equal(initial_comment_count)
8484
end
8585
end
8686
end

spec/stimulus/turbo_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,41 +41,41 @@
4141
end
4242

4343
it "adds a new comment to the page and database" do
44-
initital_comment_count = Comment.all.count
44+
initital_comment_count = Comment.count
4545
new_comment_count = initital_comment_count + 1
4646
fill_in author_field, with: comment.author
4747
fill_in text_field, with: comment.text
4848
click_button("Post")
4949

5050
expect(page).to have_css("h2", text: comment.author)
5151
expect(page).to have_css("p", text: comment.text)
52-
expect(Comment.all.count).to equal(new_comment_count)
52+
expect(Comment.count).to equal(new_comment_count)
5353
end
5454

5555
it "comment count remains the same when author field is empty" do
56-
initial_comment_count = Comment.all.count
56+
initial_comment_count = Comment.count
5757
fill_in text_field, with: comment.text
5858
click_button("Post")
5959

6060
expect(page).to have_text("Author: can't be blank")
61-
expect(Comment.all.count).to equal(initial_comment_count)
61+
expect(Comment.count).to equal(initial_comment_count)
6262
end
6363

6464
it "comment count remains the same when text field is empty" do
65-
initial_comment_count = Comment.all.count
65+
initial_comment_count = Comment.count
6666
fill_in author_field, with: comment.author
6767
click_button("Post")
6868

6969
expect(page).to have_text("Text: can't be blank")
70-
expect(Comment.all.count).to equal(initial_comment_count)
70+
expect(Comment.count).to equal(initial_comment_count)
7171
end
7272

7373
it "comment count remains the same when both form fields are empty" do
74-
initial_comment_count = Comment.all.count
74+
initial_comment_count = Comment.count
7575
click_button("Post")
7676

7777
expect(page).to have_text("Author: can't be blank")
78-
expect(Comment.all.count).to equal(initial_comment_count)
78+
expect(Comment.count).to equal(initial_comment_count)
7979
end
8080
end
8181
end

0 commit comments

Comments
 (0)