From 8b1401a3e12955b7b115496270df485b4dc04a2c Mon Sep 17 00:00:00 2001 From: waqarnazir Date: Sat, 25 Mar 2023 14:03:53 +0500 Subject: [PATCH 1/2] Change rubocop gem version to 1.48.x in gemfile --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 62ebbea8a13..2b9a5a5f89d 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ group :test do gem "nokogiri", "~> 1.7" gem "rspec" gem "rspec-mocks" - gem "rubocop", "~> 1.45.0" + gem "rubocop", "~> 1.48.0" gem "rubocop-minitest" gem "rubocop-performance" gem "rubocop-rake" From c5e450c29f8c05ed403ca169e74b9b32ab40d759 Mon Sep 17 00:00:00 2001 From: waqarnazir Date: Sat, 25 Mar 2023 14:43:17 +0500 Subject: [PATCH 2/2] Enable Min Max comparison cop and linted the respective code --- .rubocop.yml | 4 +++- lib/jekyll/site.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b79cbfc8503..a5c67dc973c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -368,7 +368,7 @@ Style/GuardClause: Style/HashAsLastArrayItem: Enabled: true Style/HashConversion: - Enabled: true + Enabled: true Style/HashEachMethods: Enabled: true Style/HashExcept: @@ -392,6 +392,8 @@ Style/MapCompactWithConditionalBlock: Enabled: true Style/MapToHash: Enabled: true +Style/MinMaxComparison: + Enabled: true Style/MixinUsage: Exclude: - test/helper.rb diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 9ef08c32438..06031bfdf6e 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -486,7 +486,7 @@ def load_theme_configuration(config) # Returns nothing def limit_posts! if limit_posts.positive? - limit = posts.docs.length < limit_posts ? posts.docs.length : limit_posts + limit = [posts.docs.length, limit_posts].min posts.docs = posts.docs[-limit, limit] end end