diff --git a/.rubocop.yml b/.rubocop.yml index 08ae1f2b..c8639713 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,27 +1,38 @@ +inherit_from: .rubocop_todo.yml + require: rubocop-jekyll inherit_gem: rubocop-jekyll: .rubocop.yml AllCops: - TargetRubyVersion: 2.4 - Include: - - lib/**/*.rb - + TargetRubyVersion: 2.5 + SuggestExtensions: false Exclude: - - .gitignore - - .rspec - - .rubocop.yml - - .travis.yml + - vendor/**/* - - Gemfile.lock - - History.markdown - - LICENSE.txt - - README.md +Layout/LineEndStringConcatenationIndentation: + Enabled: true - - script/**/* - - vendor/**/* +Lint/EmptyInPattern: + Enabled: false +Naming/InclusiveLanguage: + Enabled: false Naming/MemoizedInstanceVariableName: Exclude: - lib/jekyll-feed/page-without-a-file.rb + +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 new file mode 100644 index 00000000..500786af --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,65 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2021-09-17 11:44:51 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 +# Cop supports --auto-correct. +Layout/EmptyLines: + Exclude: + - 'spec/jekyll-feed_spec.rb' + +# Offense count: 15 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 144 + +# Offense count: 3 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'spec/jekyll-feed_spec.rb' + - 'spec/spec_helper.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Performance/RegexpMatch: + Exclude: + - 'spec/jekyll-feed_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect. +Performance/StringInclude: + Exclude: + - 'spec/jekyll-feed_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + Exclude: + - 'spec/jekyll-feed_spec.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'spec/jekyll-feed_spec.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'spec/jekyll-feed_spec.rb' diff --git a/Gemfile b/Gemfile index e1c7ddf3..1a27d6d2 100644 --- a/Gemfile +++ b/Gemfile @@ -3,9 +3,9 @@ source "https://rubygems.org" gemspec -gem "rss" if RUBY_VERSION >= "3.0.0" gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"] gem "kramdown-parser-gfm" if ENV["JEKYLL_VERSION"] == "~> 3.9" +gem "rss" if RUBY_VERSION >= "3.0.0" install_if -> { Gem.win_platform? } do gem "tzinfo", "~> 1.2" diff --git a/appveyor.yml b/appveyor.yml index e6716814..d9776686 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,6 @@ environment: - RUBY_FOLDER_VER: "26" JEKYLL_VERSION : ">= 4.0.0.pre.alpha1" - RUBY_FOLDER_VER: "26" - - RUBY_FOLDER_VER: "24" install: - SET PATH=C:\Ruby%RUBY_FOLDER_VER%-x64\bin;%PATH% diff --git a/jekyll-feed.gemspec b/jekyll-feed.gemspec index f96b9a32..cf1508e8 100644 --- a/jekyll-feed.gemspec +++ b/jekyll-feed.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r!^spec/!) spec.require_paths = ["lib"] - spec.required_ruby_version = ">= 2.4.0" + spec.required_ruby_version = ">= 2.5.0" spec.add_dependency "jekyll", ">= 3.7", "< 5.0" @@ -24,6 +24,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency "nokogiri", "~> 1.6" spec.add_development_dependency "rake", "~> 12.0" spec.add_development_dependency "rspec", "~> 3.0" - spec.add_development_dependency "rubocop-jekyll", "~> 0.5" + spec.add_development_dependency "rubocop-jekyll", "~> 0.12.0" spec.add_development_dependency "typhoeus", ">= 0.7", "< 2.0" end diff --git a/lib/jekyll-feed/generator.rb b/lib/jekyll-feed/generator.rb index ade634ae..3f285bef 100644 --- a/lib/jekyll-feed/generator.rb +++ b/lib/jekyll-feed/generator.rb @@ -54,9 +54,10 @@ def feed_path(collection: "posts", category: nil) def collections return @collections if defined?(@collections) - @collections = if config["collections"].is_a?(Array) + @collections = case config["collections"] + when Array config["collections"].map { |c| [c, {}] }.to_h - elsif config["collections"].is_a?(Hash) + when Hash config["collections"] else {} diff --git a/script/fmt b/script/fmt index c5351ecf..913591ad 100755 --- a/script/fmt +++ b/script/fmt @@ -1,7 +1,7 @@ #!/bin/bash set -e -echo "Rubocop $(bundle exec rubocop --version)" +echo "RuboCop $(bundle exec rubocop --version)" bundle exec rubocop -D -E $@ success=$? if ((success != 0)); then