From c6601e804feaae0baedd995a95ec96b90f4e8ed4 Mon Sep 17 00:00:00 2001 From: jasl Date: Fri, 15 Jan 2021 21:42:48 +0800 Subject: [PATCH 1/8] Set minimal Ruby 2.6 and update CI configuration --- .github/workflows/Specs.yml | 5 ++--- Gemfile.lock | 2 +- cocoapods-core.gemspec | 10 +++------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/Specs.yml b/.github/workflows/Specs.yml index a9fc42a44..d9c727ff8 100644 --- a/.github/workflows/Specs.yml +++ b/.github/workflows/Specs.yml @@ -4,8 +4,8 @@ jobs: specs: strategy: matrix: - os: [ubuntu-16.04] - ruby: [2.3.3, 2.4, 2.5, 2.6, 2.7, 3.0] + os: [ubuntu-20.04] + ruby: [2.6, 2.7, 3.0] include: - os: macos-10.15 ruby: system @@ -30,7 +30,6 @@ jobs: - name: Run bundle install run: | - gem install bundler -v "~> 1.17" bundle config path vendor/bundle bundle install --jobs 4 --retry 3 --without debugging documentation diff --git a/Gemfile.lock b/Gemfile.lock index 63b22e7cf..99bd9040e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,7 +9,7 @@ PATH fuzzy_match (~> 2.0.4) nap (~> 1.0) netrc (~> 0.11) - public_suffix + public_suffix (~> 4.0) typhoeus (~> 1.0) GEM diff --git a/cocoapods-core.gemspec b/cocoapods-core.gemspec index 7fa2ba408..ee3174b5c 100644 --- a/cocoapods-core.gemspec +++ b/cocoapods-core.gemspec @@ -27,14 +27,10 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'concurrent-ruby', '~> 1.1' s.add_runtime_dependency 'typhoeus', '~> 1.0' s.add_runtime_dependency 'netrc', '~> 0.11' - s.add_runtime_dependency "addressable", '~> 2.6' - s.add_runtime_dependency "public_suffix" + s.add_runtime_dependency 'addressable', '~> 2.6' + s.add_runtime_dependency 'public_suffix', '~> 4.0' s.add_development_dependency 'bacon', '~> 1.1' - ## Make sure you can build the gem on older versions of RubyGems too: - s.rubygems_version = "1.6.2" - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.required_ruby_version = '>= 2.3.3' - s.specification_version = 3 if s.respond_to? :specification_version + s.required_ruby_version = '>= 2.6' end From 9dcbcc903f0a71ab4c32e5efff6f7f2827c58334 Mon Sep 17 00:00:00 2001 From: jasl Date: Fri, 15 Jan 2021 21:44:47 +0800 Subject: [PATCH 2/8] Upgrade to Bundler 2 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 99bd9040e..e33f4f539 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -116,4 +116,4 @@ DEPENDENCIES webrick (~> 1.7.0) BUNDLED WITH - 1.17.3 + 2.2.3 From 6bca7ae99edd0a2fe1470d7af975ef0079e16e27 Mon Sep 17 00:00:00 2001 From: jasl Date: Fri, 15 Jan 2021 21:46:14 +0800 Subject: [PATCH 3/8] Upgrade to ActiveSupport 6 --- Gemfile.lock | 17 +++++++++-------- cocoapods-core.gemspec | 3 +-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e33f4f539..d807036b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ PATH remote: . specs: cocoapods-core (1.10.1) - activesupport (> 5.0, < 6) + activesupport (~> 6.0) addressable (~> 2.6) algoliasearch (~> 1.0) concurrent-ruby (~> 1.1) @@ -15,11 +15,12 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (5.2.4.4) + activesupport (6.1.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) algoliasearch (1.27.5) @@ -82,11 +83,10 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.10.1) - thread_safe (0.3.6) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (1.2.9) - thread_safe (~> 0.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) unicode-display_width (1.7.0) vcr (6.0.0) webmock (3.11.0) @@ -94,6 +94,7 @@ GEM crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) webrick (1.7.0) + zeitwerk (2.4.2) PLATFORMS ruby diff --git a/cocoapods-core.gemspec b/cocoapods-core.gemspec index ee3174b5c..54f30b771 100644 --- a/cocoapods-core.gemspec +++ b/cocoapods-core.gemspec @@ -19,8 +19,7 @@ Gem::Specification.new do |s| s.files = Dir["lib/**/*.rb"] + %w{ README.md LICENSE } s.require_paths = %w{ lib } - # 6.0 requires Ruby 2.5.0 - s.add_runtime_dependency 'activesupport', '> 5.0', '< 6' + s.add_runtime_dependency 'activesupport', '~> 6.0' s.add_runtime_dependency 'nap', '~> 1.0' s.add_runtime_dependency 'fuzzy_match', '~> 2.0.4' s.add_runtime_dependency 'algoliasearch', '~> 1.0' From d1fa25fec209304046d91f6bb2684b5b05f6374b Mon Sep 17 00:00:00 2001 From: jasl Date: Fri, 15 Jan 2021 22:20:47 +0800 Subject: [PATCH 4/8] Upgrade to Rubocop 1.8 --- .rubocop.yml | 7 +++- .rubocop_cocoapods.yml | 58 ++++++++++++++++------------- .rubocop_todo.yml | 13 ++++--- Gemfile | 3 +- Gemfile.lock | 37 +++++++++++------- lib/cocoapods-core/podfile.rb | 4 +- lib/cocoapods-core/requirement.rb | 2 +- lib/cocoapods-core/specification.rb | 4 +- 8 files changed, 76 insertions(+), 52 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0cdb10dfc..b1b1156da 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,12 +5,17 @@ inherit_from: #- Core ----------------------------------------------------------------------- AllCops: + TargetRubyVersion: 2.6 + # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop + # to ignore them, so only the ones explicitly set in this file are enabled. + DisabledByDefault: true + SuggestExtensions: false Exclude: - spec/fixtures/**/* - vendor/bundle/**/* - lib/cocoapods-core/vendor/**/* -FileName: +Naming/FileName: Exclude: - lib/cocoapods-core.rb diff --git a/.rubocop_cocoapods.yml b/.rubocop_cocoapods.yml index ebc2123e6..4dfa9b4d3 100644 --- a/.rubocop_cocoapods.yml +++ b/.rubocop_cocoapods.yml @@ -1,41 +1,45 @@ +require: + - rubocop-performance + AllCops: Include: - - ./Rakefile - - ./Gemfile - - ./*.gemspec + - lib/**/*.rb + - Rakefile + - Gemfile + - "*.gemspec" Exclude: - - ./spec/fixtures/**/* - - ./vendor/bundle/**/* + - spec/fixtures/**/* + - vendor/bundle/**/* # At the moment not ready to be used # https://github.com/bbatsov/rubocop/issues/947 -Documentation: +Style/Documentation: Enabled: false #- CocoaPods -----------------------------------------------------------------# # We adopted raise instead of fail. -SignalException: +Style/SignalException: EnforcedStyle: only_raise # They are idiomatic -AssignmentInCondition: +Lint/AssignmentInCondition: Enabled: false # Allow backticks -AsciiComments: +Style/AsciiComments: Enabled: false # Indentation clarifies logic branches in implementations -IfUnlessModifier: +Style/IfUnlessModifier: Enabled: false # No enforced convention here. -SingleLineBlockParams: +Style/SingleLineBlockParams: Enabled: false # We only add the comment when needed. -Encoding: +Style/Encoding: Enabled: false # Having these make it easier to *not* forget to add one when adding a new @@ -43,25 +47,27 @@ Encoding: Style/TrailingCommaInArguments: EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInHashLiteral: EnforcedStyleForMultiline: comma -Style/MultilineOperationIndentation: +Layout/MultilineOperationIndentation: EnforcedStyle: indented # Clashes with CLAide Command#validate! -GuardClause: +Style/GuardClause: Enabled: false # Not always desirable: lib/claide/command/plugins_helper.rb:12:15 -Next: +Style/Next: Enabled: false # Autocorrect makes this cop much more useful, taking away needless guessing -Lint/EndAlignment: +Layout/EndAlignment: AutoCorrect: true - # Arbitrary max lengths for classes simply do not work and enabling this will # lead to a never ending stream of annoyance and changes. Metrics/ClassLength: @@ -98,16 +104,16 @@ Metrics/PerceivedComplexity: #- CocoaPods support for Ruby 1.8.7 ------------------------------------------# -HashSyntax: +Style/HashSyntax: EnforcedStyle: hash_rockets -Lambda: +Style/Lambda: Enabled: false -DotPosition: +Layout/DotPosition: EnforcedStyle: trailing -EachWithObject: +Style/EachWithObject: Enabled: false Style/SpecialGlobalVars: @@ -116,7 +122,7 @@ Style/SpecialGlobalVars: #- CocoaPods specs -----------------------------------------------------------# # Allow for `should.match /regexp/`. -AmbiguousRegexpLiteral: +Lint/AmbiguousRegexpLiteral: Exclude: - spec/**/* @@ -125,14 +131,14 @@ Performance/RedundantMatch: - spec/**/* # Allow `object.should == object` syntax. -Void: +Lint/Void: Exclude: - spec/**/* -ClassAndModuleChildren: +Style/ClassAndModuleChildren: Exclude: - spec/**/* -UselessComparison: +Lint/BinaryOperatorWithIdenticalOperands: Exclude: - spec/**/* diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0eee4de2b..80d8a2a08 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,6 +6,9 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +require: + - rubocop-performance + # Offense count: 5 Lint/IneffectiveAccessModifier: Exclude: @@ -34,7 +37,7 @@ Lint/UselessAccessModifier: # Offense count: 474 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes. # URISchemes: http, https -Metrics/LineLength: +Layout/LineLength: Max: 175 # Offense count: 2 @@ -77,7 +80,7 @@ Style/ConditionalAssignment: # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. -Style/ExtraSpacing: +Layout/ExtraSpacing: Exclude: - 'spec/specification/dsl/attribute_support_spec.rb' @@ -89,7 +92,7 @@ Style/IfInsideElse: # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: IndentationWidth. -Style/IndentAssignment: +Layout/AssignmentIndentation: Exclude: - 'spec/specification/linter/result_spec.rb' @@ -97,7 +100,7 @@ Style/IndentAssignment: # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. # SupportedStyles: aligned, indented -Style/MultilineMethodCallIndentation: +Layout/MultilineMethodCallIndentation: Enabled: false # Offense count: 4 @@ -129,6 +132,6 @@ Style/RedundantSelf: # Offense count: 2 # Cop supports --auto-correct. -Style/UnneededInterpolation: +Style/RedundantInterpolation: Exclude: - 'lib/cocoapods-core/yaml_helper.rb' diff --git a/Gemfile b/Gemfile index d9e2e87de..ce48cf043 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,8 @@ group :development do gem 'webmock' gem 'webrick', '~> 1.7.0' - gem 'rubocop', '~> 0.38.0' + gem 'rubocop', '~> 1.8', :require => false + gem 'rubocop-performance', :require => false end group :debugging do diff --git a/Gemfile.lock b/Gemfile.lock index d807036b2..be45e234d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,7 +26,7 @@ GEM algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) - ast (2.4.0) + ast (2.4.1) awesome_print (1.8.0) bacon (1.2.0) coderay (1.1.3) @@ -58,36 +58,44 @@ GEM nap (1.1.0) netrc (0.11.0) notify (0.5.2) - parser (2.7.1.3) - ast (~> 2.4.0) - powerpack (0.1.2) + parallel (1.20.1) + parser (3.0.0.0) + ast (~> 2.4.1) prettybacon (0.0.2) bacon (~> 1.2) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) public_suffix (4.0.6) - rainbow (2.2.2) - rake + rainbow (3.0.0) rake (12.3.3) rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) rb-kqueue (0.2.5) ffi (>= 0.5.0) + regexp_parser (2.0.3) rexml (3.2.4) - rubocop (0.38.0) - parser (>= 2.3.0.6, < 3.0) - powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + rubocop (1.8.1) + parallel (~> 1.10) + parser (>= 3.0.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.2.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.10.1) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.4.0) + parser (>= 2.7.1.5) + rubocop-performance (1.9.2) + rubocop (>= 0.90.0, < 2.0) + rubocop-ast (>= 0.4.0) + ruby-progressbar (1.11.0) typhoeus (1.4.0) ethon (>= 0.9.0) tzinfo (2.0.4) concurrent-ruby (~> 1.0) - unicode-display_width (1.7.0) + unicode-display_width (2.0.0) vcr (6.0.0) webmock (3.11.0) addressable (>= 2.3.6) @@ -111,7 +119,8 @@ DEPENDENCIES rake (~> 12.0) rb-fsevent rexml (~> 3.2.4) - rubocop (~> 0.38.0) + rubocop (~> 1.8) + rubocop-performance vcr webmock webrick (~> 1.7.0) diff --git a/lib/cocoapods-core/podfile.rb b/lib/cocoapods-core/podfile.rb index a0390927b..427d00e6b 100644 --- a/lib/cocoapods-core/podfile.rb +++ b/lib/cocoapods-core/podfile.rb @@ -327,9 +327,9 @@ def self.from_ruby(path, contents = nil) podfile = Podfile.new(path) do # rubocop:disable Lint/RescueException begin - # rubocop:disable Eval + # rubocop:disable Security/Eval eval(contents, nil, path.to_s) - # rubocop:enable Eval + # rubocop:enable Security/Eval rescue Exception => e message = "Invalid `#{path.basename}` file: #{e.message}" raise DSLError.new(message, path, e, contents) diff --git a/lib/cocoapods-core/requirement.rb b/lib/cocoapods-core/requirement.rb index eac2cad54..d1591025d 100644 --- a/lib/cocoapods-core/requirement.rb +++ b/lib/cocoapods-core/requirement.rb @@ -15,7 +15,7 @@ class Requirement < Pod::Vendor::Gem::Requirement # PATTERN = /\A\s*(#{quoted_operators})?\s*(#{Version::VERSION_PATTERN})\s*\z/ - DefaultRequirement = ['>=', Version.new(0)] # rubocop:disable Style/ConstantName + DefaultRequirement = ['>=', Version.new(0)] # rubocop:disable Naming/ConstantName #-------------------------------------------------------------------------# diff --git a/lib/cocoapods-core/specification.rb b/lib/cocoapods-core/specification.rb index 498a3c382..5eae5a3f3 100644 --- a/lib/cocoapods-core/specification.rb +++ b/lib/cocoapods-core/specification.rb @@ -824,9 +824,9 @@ def validate_cocoapods_version # # def self._eval_podspec(string, path) - # rubocop:disable Eval + # rubocop:disable Security/Eval eval(string, nil, path.to_s) - # rubocop:enable Eval + # rubocop:enable Security/Eval # rubocop:disable Lint/RescueException rescue Exception => e From f9a5afc3ea68d359964bbf7235618462e6e55469 Mon Sep 17 00:00:00 2001 From: jasl Date: Fri, 15 Jan 2021 23:17:03 +0800 Subject: [PATCH 5/8] Do safe Rubocop auto-correct --- lib/cocoapods-core/yaml_helper.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/cocoapods-core/yaml_helper.rb b/lib/cocoapods-core/yaml_helper.rb index f690c0e6a..287f05e42 100644 --- a/lib/cocoapods-core/yaml_helper.rb +++ b/lib/cocoapods-core/yaml_helper.rb @@ -212,8 +212,6 @@ def yaml_parsing_error_msg(yaml, path = nil) #-----------------------------------------------------------------------# - private - # @!group Array Sorting # Sorts an array using another one as a sort hint. All the values of the @@ -291,21 +289,21 @@ def sorting_string(value) /0x[0-9a-fA-F]+/, # base 16 int /[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?/, # float /[-+]?\.(inf|Inf|INF)/, # infinity - /\.(nan|NaN|NAN)/, # NaN + /\.(nan|NaN|NAN)/ # NaN ) private_constant :RESOLVED_TAGS INDICATOR_START_CHARS = %w(- ? : , [ ] { } # & * ! | > ' " % @ `).freeze - INDICATOR_START = /\A#{Regexp.union(INDICATOR_START_CHARS)}/ + INDICATOR_START = /\A#{Regexp.union(INDICATOR_START_CHARS)}/.freeze private_constant :INDICATOR_START_CHARS, :INDICATOR_START - RESOLVED_TAGS_PATTERN = /\A#{Regexp.union(RESOLVED_TAGS)}\z/ + RESOLVED_TAGS_PATTERN = /\A#{Regexp.union(RESOLVED_TAGS)}\z/.freeze private_constant :RESOLVED_TAGS_PATTERN VALID_PLAIN_SCALAR_STRING = %r{\A [\w&&[^#{INDICATOR_START_CHARS}]] # valid first character [\w/\ \(\)~<>=\.:`,-]* # all characters allowed after the first one - \z}ox + \z}ox.freeze private_constant :VALID_PLAIN_SCALAR_STRING def process_string(string) From eab1b7ee5a9e187d7d3c88bc8128c22414e2f867 Mon Sep 17 00:00:00 2001 From: jasl Date: Sat, 16 Jan 2021 07:07:41 +0800 Subject: [PATCH 6/8] Loosen ActiveSupport version constraint --- Gemfile.lock | 2 +- cocoapods-core.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index be45e234d..88af8e00e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ PATH remote: . specs: cocoapods-core (1.10.1) - activesupport (~> 6.0) + activesupport (>= 5.0, < 7) addressable (~> 2.6) algoliasearch (~> 1.0) concurrent-ruby (~> 1.1) diff --git a/cocoapods-core.gemspec b/cocoapods-core.gemspec index 54f30b771..21de857ce 100644 --- a/cocoapods-core.gemspec +++ b/cocoapods-core.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.files = Dir["lib/**/*.rb"] + %w{ README.md LICENSE } s.require_paths = %w{ lib } - s.add_runtime_dependency 'activesupport', '~> 6.0' + s.add_runtime_dependency 'activesupport', '>= 5.0', '< 7' s.add_runtime_dependency 'nap', '~> 1.0' s.add_runtime_dependency 'fuzzy_match', '~> 2.0.4' s.add_runtime_dependency 'algoliasearch', '~> 1.0' From 189abc01bd42ba35a49e5261d2fd763c055a76f3 Mon Sep 17 00:00:00 2001 From: jasl Date: Mon, 18 Jan 2021 06:25:52 +0800 Subject: [PATCH 7/8] Upgrade WebMock --- Gemfile.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 88af8e00e..1f6347f95 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,7 +31,8 @@ GEM bacon (1.2.0) coderay (1.1.3) concurrent-ruby (1.1.7) - crack (0.4.4) + crack (0.4.5) + rexml ethon (0.12.0) ffi (>= 1.3.0) ffi (1.14.2) @@ -97,7 +98,7 @@ GEM concurrent-ruby (~> 1.0) unicode-display_width (2.0.0) vcr (6.0.0) - webmock (3.11.0) + webmock (3.11.1) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) From bb2386098d73913358a32e008152c9bf4650e6c4 Mon Sep 17 00:00:00 2001 From: Igor Makarov Date: Sun, 24 Jan 2021 22:05:53 +0200 Subject: [PATCH 8/8] re-add specs to RubCop config --- .rubocop_cocoapods.yml | 1 + spec/standard_error_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.rubocop_cocoapods.yml b/.rubocop_cocoapods.yml index 4dfa9b4d3..ad2af0483 100644 --- a/.rubocop_cocoapods.yml +++ b/.rubocop_cocoapods.yml @@ -4,6 +4,7 @@ require: AllCops: Include: - lib/**/*.rb + - spec/**/*.rb - Rakefile - Gemfile - "*.gemspec" diff --git a/spec/standard_error_spec.rb b/spec/standard_error_spec.rb index f9db451f1..40c5f9510 100644 --- a/spec/standard_error_spec.rb +++ b/spec/standard_error_spec.rb @@ -33,9 +33,9 @@ module Pod it 'parses syntax error messages for well-formed messages' do code = "puts 'hi'\nputs())\nputs 'bye'" - # rubocop:disable Eval + # rubocop:disable Security/Eval syntax_error = should.raise(SyntaxError) { eval(code, nil, @dsl_path.to_s) } - # rubocop:enable Eval + # rubocop:enable Security/Eval @err.stubs(:description).returns("Invalid `Three20.podspec` file: #{syntax_error.message}") @err.stubs(:underlying_exception).returns(syntax_error) File.stubs(:read).returns(code)