From 64ebb301e5c1ebade4a57e368ff612ea05044711 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Fri, 17 Sep 2021 12:19:50 +0530 Subject: [PATCH] Bump RuboCop to v1.18.x --- .rubocop.yml | 25 +++++++++++++++++- .rubocop_todo.yml | 35 ++++++++++++++++++++++++- jekyll-seo-tag.gemspec | 4 +-- lib/jekyll-seo-tag/author_drop.rb | 8 +++--- lib/jekyll-seo-tag/image_drop.rb | 8 +++--- lib/jekyll-seo-tag/json_ld_drop.rb | 7 +++-- spec/jekyll_seo_tag_integration_spec.rb | 3 ++- 7 files changed, 73 insertions(+), 17 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7c33120c..6688e6d8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,15 +5,38 @@ inherit_gem: rubocop-jekyll: .rubocop.yml AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.5 + SuggestExtensions: false Exclude: - vendor/**/* +Layout/LineEndStringConcatenationIndentation: + Enabled: true Layout/LineLength: Exclude: - spec/**/* - jekyll-seo-tag.gemspec +Lint/EmptyInPattern: + Enabled: false + Metrics/BlockLength: Exclude: - spec/**/* + +Naming/InclusiveLanguage: + Enabled: false + +Performance/MapCompact: + Enabled: true +Performance/RedundantEqualityComparisonBlock: + Enabled: true +Performance/RedundantSplitRegexpArgument: + Enabled: true + +Style/InPatternThen: + Enabled: false +Style/MultilineInPatternThen: + Enabled: false +Style/QuotedSymbols: + Enabled: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cb469c1e..59fd59ba 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,13 +1,46 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude` -# on 2020-03-20 11:41:46 +0100 using RuboCop version 0.80.1. +# on 2021-09-17 06:40:32 UTC using RuboCop version 1.18.4. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 1 +# Configuration parameters: AllowComments. +Lint/EmptyClass: + Exclude: + - 'lib/jekyll-seo-tag/version.rb' + +# Offense count: 3 +Lint/NoReturnInBeginEndBlocks: + Exclude: + - 'lib/jekyll-seo-tag/author_drop.rb' + - 'lib/jekyll-seo-tag/drop.rb' + # Offense count: 1 # Cop supports --auto-correct. Lint/ToJSON: Exclude: - 'lib/jekyll-seo-tag/json_ld_drop.rb' + +# Offense count: 1 +# Configuration parameters: IgnoredMethods, Max. +Metrics/PerceivedComplexity: + Exclude: + - 'lib/jekyll-seo-tag/drop.rb' + +# Offense count: 1 +# Configuration parameters: MinSize. +Performance/CollectionLiteralInLoop: + Exclude: + - 'spec/jekyll_seo_tag/author_drop_spec.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +Style/RedundantBegin: + Exclude: + - 'lib/jekyll-seo-tag.rb' + - 'lib/jekyll-seo-tag/author_drop.rb' + - 'lib/jekyll-seo-tag/drop.rb' + - 'lib/jekyll-seo-tag/image_drop.rb' diff --git a/jekyll-seo-tag.gemspec b/jekyll-seo-tag.gemspec index 17eb92d9..487444b2 100644 --- a/jekyll-seo-tag.gemspec +++ b/jekyll-seo-tag.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| raise "RubyGems 2.0 or newer is required to protect against public gem pushes." end - spec.required_ruby_version = ">= 2.4.0" + spec.required_ruby_version = ">= 2.5.0" spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) } spec.bindir = "exe" @@ -30,5 +30,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler", ">= 1.15" spec.add_development_dependency "html-proofer", "~> 3.7" spec.add_development_dependency "rspec", "~> 3.5" - spec.add_development_dependency "rubocop-jekyll", "~> 0.11" + spec.add_development_dependency "rubocop-jekyll", "~> 0.12.0" end diff --git a/lib/jekyll-seo-tag/author_drop.rb b/lib/jekyll-seo-tag/author_drop.rb index 2baa95e2..9d534cba 100644 --- a/lib/jekyll-seo-tag/author_drop.rb +++ b/lib/jekyll-seo-tag/author_drop.rb @@ -41,8 +41,7 @@ def twitter private - attr_reader :page - attr_reader :site + attr_reader :site, :page # Finds the page author in the page.author, page.authors, or site.author # @@ -75,9 +74,10 @@ def site_data_hash # or an empty hash, if the author cannot be resolved def author_hash @author_hash ||= begin - if resolved_author.is_a? Hash + case resolved_author + when Hash resolved_author - elsif resolved_author.is_a? String + when String { "name" => resolved_author }.merge!(site_data_hash) else {} diff --git a/lib/jekyll-seo-tag/image_drop.rb b/lib/jekyll-seo-tag/image_drop.rb index 54273531..43367a45 100644 --- a/lib/jekyll-seo-tag/image_drop.rb +++ b/lib/jekyll-seo-tag/image_drop.rb @@ -34,17 +34,17 @@ def path private - attr_accessor :page - attr_accessor :context + attr_accessor :page, :context # The normalized image hash with a `path` key (which may be nil) def image_hash @image_hash ||= begin image_meta = page["image"] - if image_meta.is_a?(Hash) + case image_meta + when Hash { "path" => nil }.merge!(image_meta) - elsif image_meta.is_a?(String) + when String { "path" => image_meta } else { "path" => nil } diff --git a/lib/jekyll-seo-tag/json_ld_drop.rb b/lib/jekyll-seo-tag/json_ld_drop.rb index 88bb0e0a..11d04e3f 100644 --- a/lib/jekyll-seo-tag/json_ld_drop.rb +++ b/lib/jekyll-seo-tag/json_ld_drop.rb @@ -16,9 +16,8 @@ class JSONLDDrop < Jekyll::Drops::Drop def_delegator :page_drop, :type, :type # Expose #type and #logo as private methods and #@type as a public method - alias_method :"@type", :type - private :type - private :logo + alias_method :@type, :type + private :type, :logo VALID_ENTITY_TYPES = %w(BlogPosting CreativeWork).freeze VALID_AUTHOR_TYPES = %w(Organization Person).freeze @@ -84,7 +83,7 @@ def main_entity private :main_entity def to_json - to_h.reject { |_k, v| v.nil? }.to_json + to_h.compact.to_json end private diff --git a/spec/jekyll_seo_tag_integration_spec.rb b/spec/jekyll_seo_tag_integration_spec.rb index df2ebac0..b0b9d26e 100755 --- a/spec/jekyll_seo_tag_integration_spec.rb +++ b/spec/jekyll_seo_tag_integration_spec.rb @@ -26,7 +26,8 @@ end it "outputs meta generator" do - expect(output).to match(%r!Jekyll v#{Jekyll::VERSION}!i) + version = Jekyll::VERSION + expect(output).to match(%r!Jekyll v#{version}!i) end it "outputs valid HTML" do