diff --git a/Gemfile b/Gemfile index 13e9895bf..3cc4ee32c 100644 --- a/Gemfile +++ b/Gemfile @@ -75,9 +75,9 @@ group :development, :test do ################################################################################ # Linters and Security gem "rubocop", "1.69", require: false - gem "rubocop-performance", "~> 1.13" - gem "rubocop-rails" - gem "rubocop-rspec", "~> 3.3" + gem "rubocop-performance", "1.23.1", require: false + gem "rubocop-rails", "2.29.1", require: false + gem "rubocop-rspec", "3.4.0", require: false # Critical that require: false be set! https://github.com/brigade/scss-lint/issues/278 gem "scss_lint", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 3637129be..92cc84f4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -81,7 +81,7 @@ GEM uri (>= 0.13.1) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) - ast (2.4.2) + ast (2.4.3) autoprefixer-rails (10.4.16.0) execjs (~> 2) awesome_print (1.9.2) @@ -167,8 +167,8 @@ GEM jbuilder (2.12.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) - json (2.7.2) - language_server-protocol (3.17.0.3) + json (2.14.1) + language_server-protocol (3.17.0.5) launchy (3.0.1) addressable (~> 2.8) childprocess (~> 5.0) @@ -208,14 +208,15 @@ GEM nokogiri (1.18.10-x86_64-linux-gnu) racc (~> 1.4) package_json (0.1.0) - parallel (1.26.3) - parser (3.3.3.0) + parallel (1.27.0) + parser (3.3.9.0) ast (~> 2.4.1) racc pg (1.5.6) pp (0.6.2) prettyprint prettyprint (0.2.0) + prism (1.5.1) protocol (2.0.0) ruby_parser (~> 3.0) pry (0.14.2) @@ -308,7 +309,7 @@ GEM redis-client (>= 0.22.0) redis-client (0.22.2) connection_pool - regexp_parser (2.9.2) + regexp_parser (2.11.3) reline (0.6.2) io-console (~> 0.5) require_all (3.0.0) @@ -341,16 +342,18 @@ GEM rubocop-ast (>= 1.36.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.36.1) - parser (>= 3.3.1.0) - rubocop-performance (1.19.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rails (2.15.2) + rubocop-ast (1.47.0) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-performance (1.23.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.29.1) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-rspec (3.3.0) + rubocop (>= 1.52.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rspec (3.4.0) rubocop (~> 1.61) ruby-progressbar (1.13.0) ruby_parser (3.21.0) @@ -428,9 +431,9 @@ GEM concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (3.1.2) - unicode-emoji (~> 4.0,>= 4.0.4) - unicode-emoji (4.0.4) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.1.0) uri (1.0.3) useragent (0.16.11) web-console (4.2.1) @@ -486,9 +489,9 @@ DEPENDENCIES redis (~> 5.0) rspec-rails (~> 6.0.0) rubocop (= 1.69) - rubocop-performance (~> 1.13) - rubocop-rails - rubocop-rspec (~> 3.3) + rubocop-performance (= 1.23.1) + rubocop-rails (= 2.29.1) + rubocop-rspec (= 3.4.0) sass-rails scss_lint sdoc diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 1a534a559..13f9cabb4 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -102,7 +102,7 @@ def inline_form private def set_comments - @comments = Comment.all.order("id DESC") + @comments = Comment.order("id DESC") end # Use callbacks to share common setup or constraints between actions. @@ -116,6 +116,6 @@ def new_comment # Never trust parameters from the scary internet, only allow the white list through. def comment_params - params.require(:comment).permit(:author, :text) + params.expect(comment: %i[author text]) end end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 9336df902..507cc6cf7 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -41,7 +41,7 @@ def rescript; end private def set_comments - @comments = Comment.all.order("id DESC") + @comments = Comment.order("id DESC") end def comments_json_string diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake index b8ac45cd2..30c25c5bd 100644 --- a/lib/tasks/ci.rake +++ b/lib/tasks/ci.rake @@ -1,6 +1,6 @@ # frozen_string_literal: true -if Rails.env.development? || Rails.env.test? +if Rails.env.local? # See tasks/linters.rake task js_tests: :environment do diff --git a/lib/tasks/daily.rake b/lib/tasks/daily.rake index 3770c6eab..1d49fb919 100644 --- a/lib/tasks/daily.rake +++ b/lib/tasks/daily.rake @@ -2,8 +2,8 @@ task daily: :environment do t = 1.day.ago - older_comments = Comment.where("created_at < ?", t) - newer_comments = Comment.where("created_at>= ?", t) + older_comments = Comment.where(created_at: ...t) + newer_comments = Comment.where(created_at: t..) puts "Deleting #{older_comments.count} comments older than #{t}" puts "Keeping #{newer_comments.count} comments newer than #{t}" older_comments.delete_all diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index b6b2c04fd..d68d821e0 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -35,7 +35,7 @@ # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. -Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f } +Rails.root.glob("spec/support/**/*.rb").sort.each { |f| require f } RSpec.configure do |config| config.include FactoryBot::Syntax::Methods diff --git a/spec/rescript/rescript_spec.rb b/spec/rescript/rescript_spec.rb index 9da1f3ef5..2d01444d4 100644 --- a/spec/rescript/rescript_spec.rb +++ b/spec/rescript/rescript_spec.rb @@ -46,7 +46,7 @@ end it "comment count increases with successful form submission" do - initital_comment_count = Comment.all.count + initital_comment_count = Comment.count new_comment_count = initital_comment_count + 1 fill_in author_field, with: comment.author fill_in text_field, with: comment.text @@ -54,33 +54,33 @@ page.driver.browser.manage.timeouts.implicit_wait = 1 - expect(Comment.all.count).to equal(new_comment_count) + expect(Comment.count).to equal(new_comment_count) end it "comment count remains the same when author field is empty" do - initial_comment_count = Comment.all.count + initial_comment_count = Comment.count fill_in text_field, with: comment.text click_button("Post") expect(page).to have_text(/Can't save the comment!/) - expect(Comment.all.count).to equal(initial_comment_count) + expect(Comment.count).to equal(initial_comment_count) end it "comment count remains the same when text field is empty" do - initial_comment_count = Comment.all.count + initial_comment_count = Comment.count fill_in author_field, with: comment.author click_button("Post") expect(page).to have_text(/Can't save the comment!/) - expect(Comment.all.count).to equal(initial_comment_count) + expect(Comment.count).to equal(initial_comment_count) end it "comment count remains the same when both form fields are empty" do - initial_comment_count = Comment.all.count + initial_comment_count = Comment.count click_button("Post") expect(page).to have_text(/Can't save the comment!/) - expect(Comment.all.count).to equal(initial_comment_count) + expect(Comment.count).to equal(initial_comment_count) end end end diff --git a/spec/stimulus/turbo_spec.rb b/spec/stimulus/turbo_spec.rb index 7faad82e5..8a9700e90 100644 --- a/spec/stimulus/turbo_spec.rb +++ b/spec/stimulus/turbo_spec.rb @@ -41,7 +41,7 @@ end it "adds a new comment to the page and database" do - initital_comment_count = Comment.all.count + initital_comment_count = Comment.count new_comment_count = initital_comment_count + 1 fill_in author_field, with: comment.author fill_in text_field, with: comment.text @@ -49,33 +49,33 @@ expect(page).to have_css("h2", text: comment.author) expect(page).to have_css("p", text: comment.text) - expect(Comment.all.count).to equal(new_comment_count) + expect(Comment.count).to equal(new_comment_count) end it "comment count remains the same when author field is empty" do - initial_comment_count = Comment.all.count + initial_comment_count = Comment.count fill_in text_field, with: comment.text click_button("Post") expect(page).to have_text("Author: can't be blank") - expect(Comment.all.count).to equal(initial_comment_count) + expect(Comment.count).to equal(initial_comment_count) end it "comment count remains the same when text field is empty" do - initial_comment_count = Comment.all.count + initial_comment_count = Comment.count fill_in author_field, with: comment.author click_button("Post") expect(page).to have_text("Text: can't be blank") - expect(Comment.all.count).to equal(initial_comment_count) + expect(Comment.count).to equal(initial_comment_count) end it "comment count remains the same when both form fields are empty" do - initial_comment_count = Comment.all.count + initial_comment_count = Comment.count click_button("Post") expect(page).to have_text("Author: can't be blank") - expect(Comment.all.count).to equal(initial_comment_count) + expect(Comment.count).to equal(initial_comment_count) end end end

AltStyle によって変換されたページ (->オリジナル) /