From e824f6b9cc60f22d4e4eeb708f84ed354fe4501c Mon Sep 17 00:00:00 2001 From: jnozsc <470215+jnozsc@users.noreply.github.com> Date: Fri, 4 Sep 2020 13:10:41 -0700 Subject: [PATCH] Update rubocop gem to 0.90.0 (#8313) Merge pull request 8313 --- .rubocop.yml | 69 +++++++++++++++++++++++++++++--- .rubocop_todo.yml | 13 +++++- Gemfile | 2 +- lib/jekyll/commands/doctor.rb | 2 +- lib/jekyll/commands/new_theme.rb | 2 - lib/jekyll/document.rb | 2 - lib/jekyll/filters.rb | 8 ++-- lib/jekyll/tags/post_url.rb | 2 +- test/helper.rb | 2 +- test/test_tags.rb | 2 - 10 files changed, 83 insertions(+), 21 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a36c3f7d6..7b6bccf2d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -51,25 +51,53 @@ Layout/MultilineOperationIndentation: Layout/SpaceAroundMethodCallOperator: Enabled: true +Lint/BinaryOperatorWithIdenticalOperands: + Enabled: true +Lint/DeprecatedOpenSSLConstant: + Enabled: true +Lint/DuplicateElsifCondition: + Enabled: true +Lint/DuplicateRescueException: + Enabled: true +Lint/DuplicateRequire: + Enabled: true +Lint/EmptyConditionalBody: + Enabled: true +Lint/EmptyFile: + Enabled: true +Lint/FloatComparison: + Enabled: true +Lint/MissingSuper: + Enabled: false +Lint/MixedRegexpCaptureTypes: + Enabled: false Lint/NestedPercentLiteral: Exclude: - test/test_site.rb -Lint/DeprecatedOpenSSLConstant: +Lint/OutOfRangeRegexpRef: Enabled: true -Lint/MixedRegexpCaptureTypes: - Enabled: false Lint/RaiseException: Enabled: true +Lint/SelfAssignment: + Enabled: true Lint/StructNewOverride: Enabled: true +Lint/TopLevelReturnWithArgument: + Enabled: true +Lint/TrailingCommaInAttributeDeclaration: + Enabled: true Lint/UnreachableCode: Severity: error +Lint/UnreachableLoop: + Enabled: true +Lint/UselessMethodDefinition: + Enabled: true Lint/Void: Exclude: - lib/jekyll/site.rb Metrics/AbcSize: - Max: 21 + Max: 23 Metrics/BlockLength: Exclude: - test/**/*.rb @@ -100,7 +128,7 @@ Metrics/ModuleLength: Metrics/ParameterLists: Max: 4 Metrics/PerceivedComplexity: - Max: 8 + Max: 13 Naming/FileName: Enabled: false @@ -144,6 +172,8 @@ Security/YAMLLoad: - !ruby/regexp /features\/.*.rb/ - !ruby/regexp /test\/.*.rb$/ +Style/ArrayCoercion: + Enabled: true Style/AccessModifierDeclarations: Enabled: false Style/AccessorGrouping: @@ -154,15 +184,21 @@ Style/AndOr: Severity: error Style/BisectedAttrAccessor: Enabled: true +Style/CaseLikeIf: + Enabled: true Style/ClassAndModuleChildren: Exclude: - test/**/*.rb +Style/CombinableLoops: + Enabled: true Style/Documentation: Enabled: false Style/DoubleNegation: Enabled: false Style/ExponentialNotation: Enabled: true +Style/ExplicitBlockArgument: + Enabled: false Style/FormatStringToken: Exclude: - lib/jekyll/utils/ansi.rb @@ -170,10 +206,16 @@ Style/FormatStringToken: - lib/jekyll/profiler.rb Style/FrozenStringLiteralComment: EnforcedStyle: always +Style/GlobalStdStream: + Enabled: true Style/GuardClause: Enabled: false +Style/HashAsLastArrayItem: + Enabled: true Style/HashEachMethods: Enabled: true +Style/HashLikeCase: + Enabled: true Style/HashSyntax: EnforcedStyle: hash_rockets Severity: error @@ -181,6 +223,8 @@ Style/HashTransformKeys: Enabled: false Style/HashTransformValues: Enabled: true +Style/KeywordParametersOrder: + Enabled: true Style/MixinUsage: Exclude: - test/helper.rb @@ -188,6 +232,8 @@ Style/ModuleFunction: Enabled: false Style/MultilineTernaryOperator: Severity: error +Style/OptionalBooleanParameter: + Enabled: true Style/PercentLiteralDelimiters: PreferredDelimiters: "%q": "{}" @@ -201,10 +247,14 @@ Style/RedundantAssignment: Enabled: true Style/RedundantFetchBlock: Enabled: false +Style/RedundantFileExtensionInRequire: + Enabled: true Style/RedundantRegexpCharacterClass: Enabled: true Style/RedundantRegexpEscape: Enabled: true +Style/RedundantSelfAssignment: + Enabled: true Style/RegexpLiteral: EnforcedStyle: percent_r Style/RescueModifier: @@ -214,10 +264,19 @@ Style/SafeNavigation: - lib/jekyll/document.rb Style/SignalException: EnforcedStyle: only_raise +Style/SingleArgumentDig: + Enabled: true Style/SlicingWithRange: Enabled: false +Style/SoleNestedConditional: + Enabled: true Style/StringLiterals: EnforcedStyle: double_quotes +Style/StringConcatenation: + Enabled: true + Exclude: + - lib/jekyll/commands/*.rb + - test/**/*.rb Style/StringLiteralsInInterpolation: EnforcedStyle: double_quotes Style/SymbolArray: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ef600f8a9..74f29976a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-07-10 07:47:27 UTC using RuboCop version 0.87.1. +# on 2020-09-04 16:17:09 UTC using RuboCop version 0.90.0. # 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 @@ -14,3 +14,14 @@ Layout/SpaceAroundOperators: Exclude: - 'lib/jekyll/commands/build.rb' - 'test/test_configuration.rb' + +# Offense count: 1 +Style/CombinableLoops: + Exclude: + - 'lib/jekyll/tags/post_url.rb' + +# Offense count: 2 +Style/OptionalBooleanParameter: + Exclude: + - 'lib/jekyll/collection.rb' + - 'lib/jekyll/log_adapter.rb' diff --git a/Gemfile b/Gemfile index 2e22a25d4..d35472e47 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ group :test do gem "nokogiri", "~> 1.7" gem "rspec" gem "rspec-mocks" - gem "rubocop", "~> 0.87.1" + gem "rubocop", "~> 0.90.0" gem "rubocop-performance" gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__) gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__) diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index ca830576b..736f36164 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -84,7 +84,7 @@ module Jekyll return true unless Utils::Platforms.osx? if Dir.pwd != `pwd`.strip - Jekyll.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ") + Jekyll.logger.error <<~STR We have detected that there might be trouble using fsevent on your operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug) for possible work arounds or you can work around it immediately diff --git a/lib/jekyll/commands/new_theme.rb b/lib/jekyll/commands/new_theme.rb index b26dabe4c..f42514700 100644 --- a/lib/jekyll/commands/new_theme.rb +++ b/lib/jekyll/commands/new_theme.rb @@ -20,7 +20,6 @@ module Jekyll end end - # rubocop:disable Metrics/AbcSize def process(args, opts) if !args || args.empty? raise Jekyll::Errors::InvalidThemeName, "You must specify a theme name." @@ -35,7 +34,6 @@ module Jekyll " is ready for you in #{theme.path.to_s.cyan}!" Jekyll.logger.info "For help getting started, read #{theme.path}/README.md." end - # rubocop:enable Metrics/AbcSize end end end diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 80f7aab4e..11888f495 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -498,7 +498,6 @@ module Jekyll end end - # rubocop:disable Metrics/AbcSize def populate_title if relative_path =~ DATE_FILENAME_MATCHER date, slug, ext = Regexp.last_match.captures @@ -521,7 +520,6 @@ module Jekyll data["slug"] ||= slug data["ext"] ||= ext end - # rubocop:enable Metrics/AbcSize def modify_date(date) if !data["date"] || data["date"].to_i == site.time.to_i diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index ec40d1a9d..e2cdf45de 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -307,9 +307,10 @@ module Jekyll if property.nil? input.sort else - if nils == "first" + case nils + when "first" order = - 1 - elsif nils == "last" + when "last" order = + 1 else raise ArgumentError, "Invalid nils order: " \ @@ -399,7 +400,6 @@ module Jekyll # `where` filter helper # - # rubocop:disable Metrics/PerceivedComplexity def compare_property_vs_target(property, target) case target when NilClass @@ -421,8 +421,6 @@ module Jekyll false end - # rubocop:enable Metrics/PerceivedComplexity - def item_property(item, property) @item_property_cache ||= {} @item_property_cache[property] ||= {} diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index e6feb928e..039ab4f48 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -51,7 +51,7 @@ module Jekyll if path.nil? || path == "" other.data["slug"] else - path + "/" + other.data["slug"] + "#{path}/#{other.data["slug"]}" end end end diff --git a/test/helper.rb b/test/helper.rb index 479cdf9cc..158993a85 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -30,7 +30,7 @@ require "minitest/autorun" require "minitest/reporters" require "minitest/profile" require "rspec/mocks" -require_relative "../lib/jekyll.rb" +require_relative "../lib/jekyll" Jekyll.logger = Logger.new(StringIO.new, :error) diff --git a/test/test_tags.rb b/test/test_tags.rb index 18bba7046..4dc8bcc8a 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -7,7 +7,6 @@ class TestTags < JekyllUnitTest FileUtils.mkdir_p("tmp") end - # rubocop:disable Metrics/AbcSize def create_post(content, override = {}, converter_class = Jekyll::Converters::Markdown) site = fixture_site({ "highlighter" => "rouge" }.merge(override)) @@ -23,7 +22,6 @@ class TestTags < JekyllUnitTest @result = Liquid::Template.parse(content).render!(payload, info) @result = @converter.convert(@result) end - # rubocop:enable Metrics/AbcSize def fill_post(code, override = {}) content = <<~CONTENT