From 4ecbeb40638b001761a0740ad15aeda8afeede83 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Thu, 16 Feb 2023 17:56:21 +0530 Subject: [PATCH] Bump RuboCop to v1.45.x (#9305) Merge pull request 9305 --- .rubocop.yml | 1 + Gemfile | 2 +- lib/jekyll/static_file.rb | 10 ++++------ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8e311450..b79cbfc8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -447,6 +447,7 @@ Style/RescueModifier: Style/SafeNavigation: Exclude: - lib/jekyll/document.rb + - lib/jekyll/page.rb Style/SignalException: EnforcedStyle: only_raise Style/SingleArgumentDig: diff --git a/Gemfile b/Gemfile index 0593306c..62ebbea8 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ group :test do gem "nokogiri", "~> 1.7" gem "rspec" gem "rspec-mocks" - gem "rubocop", "~> 1.38.0" + gem "rubocop", "~> 1.45.0" gem "rubocop-minitest" gem "rubocop-performance" gem "rubocop-rake" diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index f7d99f6d..13479b0d 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -4,7 +4,9 @@ module Jekyll class StaticFile extend Forwardable - attr_reader :relative_path, :extname, :name + attr_reader :relative_path, :extname, + :type, # Returns the type of the collection if present, nil otherwise. + :name def_delegator :to_liquid, :to_json, :to_json @@ -34,6 +36,7 @@ module Jekyll @collection = collection @relative_path = File.join(*[@dir, @name].compact) @extname = File.extname(@name) + @type = @collection&.label&.to_sym end # rubocop: enable Metrics/ParameterLists @@ -171,11 +174,6 @@ module Jekyll end end - # Returns the type of the collection if present, nil otherwise. - def type - @type ||= @collection.nil? ? nil : @collection.label.to_sym - end - # Returns the front matter defaults defined for the file's URL and/or type # as defined in _config.yml. def defaults