diff options
56 files changed, 1015 insertions, 589 deletions
diff --git a/azure-pipelines/rbreadline.diff b/.azure-pipelines/rbreadline.diff index c139577610..c139577610 100644 --- a/azure-pipelines/rbreadline.diff +++ b/.azure-pipelines/rbreadline.diff diff --git a/azure-pipelines/steps.yml b/.azure-pipelines/steps.yml index 548847c910..733ca0998e 100644 --- a/azure-pipelines/steps.yml +++ b/.azure-pipelines/steps.yml @@ -16,7 +16,7 @@ steps: displayName: 'work around readline crash (for https://github.com/bundler/bundler/issues/6902)' - script: | - git apply --ignore-space-change --ignore-whitespace azure-pipelines\rbreadline.diff --directory=C:/hostedtoolcache/windows/Ruby/2.4.3/x64/lib/ruby/site_ruby --unsafe-paths + git apply --ignore-space-change --ignore-whitespace .azure-pipelines\rbreadline.diff --directory=C:/hostedtoolcache/windows/Ruby/2.4.3/x64/lib/ruby/site_ruby --unsafe-paths displayName: 'patch local readline implementation (for https://github.com/bundler/bundler/issues/6907)' - script: | diff --git a/.rubocop.yml b/.rubocop.yml index a6412ecb13..8fd8c2c588 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,140 +1,811 @@ -inherit_from: - - .rubocop_todo.yml - AllCops: - TargetRubyVersion: 1.9 + DisabledByDefault: true + TargetRubyVersion: 2.3 Exclude: - tmp/**/* - lib/bundler/vendor/**/* DisplayCopNames: true +# Bundler + +Bundler/DuplicatedGem: + Enabled: true + +Bundler/InsecureProtocolSource: + Enabled: true + +Bundler/OrderedGems: + Enabled: true + +# Gemspec + +Gemspec/OrderedDependencies: + Enabled: true + +Gemspec/RequiredRubyVersion: + Enabled: true + # Lint -# They are idiomatic -Lint/AssignmentInCondition: - Enabled: false +Lint/AmbiguousOperator: + Enabled: true -Lint/EndAlignment: - EnforcedStyleAlignWith: variable - AutoCorrect: true +Lint/AmbiguousRegexpLiteral: + Enabled: true + +Lint/BigDecimalNew: + Enabled: true + +Lint/BooleanSymbol: + Enabled: true + +Lint/Debugger: + Enabled: true + +Lint/DeprecatedClassMethods: + Enabled: true + +Lint/DuplicateCaseCondition: + Enabled: true + +Lint/DuplicateMethods: + Enabled: true + +Lint/DuplicatedKey: + Enabled: true + +Lint/EachWithObjectArgument: + Enabled: true + +Lint/ElseLayout: + Enabled: true + +Lint/EmptyEnsure: + Enabled: true + +Lint/EmptyExpression: + Enabled: true + +Lint/EmptyInterpolation: + Enabled: true + +Lint/EndInMethod: + Enabled: true + +Lint/EnsureReturn: + Enabled: true + +Lint/ErbNewArguments: + Enabled: true + +Lint/FlipFlop: + Enabled: true + +Lint/FloatOutOfRange: + Enabled: true + +Lint/FormatParameterMismatch: + Enabled: true + +Lint/ImplicitStringConcatenation: + Enabled: true + +Lint/InheritException: + Enabled: true + +Lint/LiteralAsCondition: + Enabled: true + +Lint/LiteralInInterpolation: + Enabled: true -Lint/UnusedMethodArgument: - Enabled: false +Lint/Loop: + Enabled: true + +Lint/MultipleCompare: + Enabled: true + +Lint/NestedPercentLiteral: + Enabled: true + +Lint/NextWithoutAccumulator: + Enabled: true + +Lint/NonLocalExitFromIterator: + Enabled: true + +Lint/OrderedMagicComments: + Enabled: true + +Lint/ParenthesesAsGroupedExpression: + Enabled: true + +Lint/PercentStringArray: + Enabled: true + +Lint/PercentSymbolArray: + Enabled: true + +Lint/RandOne: + Enabled: true + +Lint/RedundantWithIndex: + Enabled: true + +Lint/RedundantWithObject: + Enabled: true + +Lint/RegexpAsCondition: + Enabled: true + +Lint/RequireParentheses: + Enabled: true + +Lint/RescueException: + Enabled: true + +Lint/RescueType: + Enabled: true + +Lint/ReturnInVoidContext: + Enabled: true + +Lint/SafeNavigationChain: + Enabled: true + +Lint/SafeNavigationConsistency: + Enabled: true Lint/ScriptPermission: + Enabled: true Exclude: - 'lib/bundler/templates/Executable' +Lint/ShadowedArgument: + Enabled: true + +Lint/ShadowingOuterLocalVariable: + Enabled: true + +Lint/StringConversionInInterpolation: + Enabled: true + +Lint/Syntax: + Enabled: true + +Lint/UnderscorePrefixedVariableName: + Enabled: true + +Lint/UnifiedInteger: + Enabled: true + +Lint/UnneededCopDisableDirective: + Enabled: true + +Lint/UnneededCopEnableDirective: + Enabled: true + +Lint/UnneededSplatExpansion: + Enabled: true + +Lint/UnreachableCode: + Enabled: true + +Lint/UnusedBlockArgument: + Enabled: true + +Lint/UriEscapeUnescape: + Enabled: true + +Lint/UriRegexp: + Enabled: true + +Lint/UselessComparison: + Enabled: true + +Lint/UselessElseWithoutRescue: + Enabled: true + +Lint/UselessSetterCall: + Enabled: true + +Lint/Void: + Enabled: true + # Layout Layout/AccessModifierIndentation: + Enabled: true EnforcedStyle: outdent + Exclude: + - 'lib/bundler/cli.rb' + - 'lib/bundler/definition.rb' + - 'lib/bundler/feature_flag.rb' + - 'lib/bundler/gem_helpers.rb' + - 'lib/bundler/index.rb' + - 'lib/bundler/remote_specification.rb' + - 'lib/bundler/shared_helpers.rb' + - 'lib/bundler/source/path.rb' + - 'spec/realworld/gemfile_source_header_spec.rb' + +Layout/AlignArray: + Enabled: true Layout/AlignParameters: + Enabled: true EnforcedStyle: with_fixed_indentation +Layout/BlockAlignment: + Enabled: true + +Layout/CaseIndentation: + Enabled: true + +Layout/ClosingParenthesisIndentation: + Enabled: true + +Layout/CommentIndentation: + Enabled: true + +Layout/ConditionPosition: + Enabled: true + +Layout/DefEndAlignment: + Enabled: true + +Layout/DotPosition: + Enabled: true + EnforcedStyle: trailing + +Layout/ElseAlignment: + Enabled: true + +Layout/EmptyComment: + Enabled: true + +Layout/EmptyLineAfterMagicComment: + Enabled: true + +Layout/EmptyLineBetweenDefs: + Enabled: true + +Layout/EmptyLines: + Enabled: true + +Layout/EmptyLinesAroundAccessModifier: + Enabled: true + +Layout/EmptyLinesAroundArguments: + Enabled: true + +Layout/EmptyLinesAroundBeginBody: + Enabled: true + +Layout/EmptyLinesAroundBlockBody: + Enabled: true + +Layout/EmptyLinesAroundClassBody: + Enabled: true + +Layout/EmptyLinesAroundExceptionHandlingKeywords: + Enabled: true + +Layout/EmptyLinesAroundMethodBody: + Enabled: true + +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +Layout/EndAlignment: + Enabled: true + EnforcedStyleAlignWith: variable + AutoCorrect: true + +Layout/EndOfLine: + Enabled: true + +Layout/ExtraSpacing: + Enabled: true + +Layout/FirstParameterIndentation: + Enabled: true + +Layout/IndentArray: + Enabled: true + EnforcedStyle: consistent + +Layout/IndentAssignment: + Enabled: true + +Layout/IndentHash: + Enabled: true + EnforcedStyle: special_inside_parentheses + +Layout/IndentationConsistency: + Enabled: true + +Layout/IndentationWidth: + Enabled: true + +Layout/InitialIndentation: + Enabled: true + +Layout/LeadingBlankLines: + Enabled: true + +Layout/LeadingCommentSpace: + Enabled: true + +Layout/MultilineArrayBraceLayout: + Enabled: true + +Layout/MultilineBlockLayout: + Enabled: true + +Layout/MultilineHashBraceLayout: + Enabled: true + +Layout/MultilineMethodCallBraceLayout: + Enabled: true + +Layout/MultilineMethodDefinitionBraceLayout: + Enabled: true + Layout/MultilineOperationIndentation: + Enabled: true EnforcedStyle: indented +Layout/SpaceBeforeComma: + Enabled: true + +Layout/SpaceBeforeComment: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +Layout/SpaceBeforeSemicolon: + Enabled: true + +Layout/SpaceInLambdaLiteral: + Enabled: true + +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: true + +Layout/SpaceInsideArrayPercentLiteral: + Enabled: true + Layout/SpaceInsideBlockBraces: + Enabled: true SpaceBeforeBlockParameters: false -Layout/DotPosition: - EnforcedStyle: trailing +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + +Layout/SpaceInsideParens: + Enabled: true + +Layout/SpaceInsidePercentLiteralDelimiters: + Enabled: true + +Layout/SpaceInsideRangeLiteral: + Enabled: true + +Layout/SpaceInsideReferenceBrackets: + Enabled: true + +Layout/SpaceInsideStringInterpolation: + Enabled: true + +Layout/Tab: + Enabled: true + +Layout/TrailingBlankLines: + Enabled: true + +Layout/TrailingWhitespace: + Enabled: true + +# Naming + +Naming/AsciiIdentifiers: + Enabled: true + +Naming/BinaryOperatorParameterName: + Enabled: true + +Naming/ClassAndModuleCamelCase: + Enabled: true + +Naming/ConstantName: + Enabled: true + +Naming/FileName: + Enabled: true + +Naming/HeredocDelimiterCase: + Enabled: true + +Naming/MethodName: + Enabled: true + +Naming/UncommunicativeBlockParamName: + Enabled: true + +Naming/VariableName: + Enabled: true + +Naming/VariableNumber: + Enabled: true + +# Performance + +Performance/Casecmp: + Enabled: true + +Performance/CompareWithBlock: + Enabled: true + +Performance/Count: + Enabled: true + +Performance/Detect: + Enabled: true + +Performance/DoubleStartEndWith: + Enabled: true + +Performance/EndWith: + Enabled: true + +Performance/FixedSize: + Enabled: true + +Performance/LstripRstrip: + Enabled: true + +Performance/RedundantSortBy: + Enabled: true + +Performance/RegexpMatch: + Enabled: true + +Performance/ReverseEach: + Enabled: true + +Performance/Sample: + Enabled: true + +Performance/Size: + Enabled: true + +Performance/StartWith: + Enabled: true + +Performance/StringReplacement: + Enabled: true + +Performance/TimesMap: + Enabled: true + +Performance/UriDefaultParser: + Enabled: true + +# Security + +Security/JSONLoad: + Enabled: true # Style Style/Alias: + Enabled: true EnforcedStyle: prefer_alias_method -Style/FrozenStringLiteralComment: +Style/AndOr: + Enabled: true EnforcedStyle: always -Style/MultilineBlockChain: - Enabled: false +Style/ArrayJoin: + Enabled: true -Style/PerlBackrefs: - Enabled: false +Style/AsciiComments: + Enabled: true -Style/SingleLineBlockParams: - Enabled: false +Style/Attr: + Enabled: true -Style/TrivialAccessors: - Enabled: false +Style/BarePercentLiterals: + Enabled: true -# We adopted raise instead of fail. -Style/SignalException: - EnforcedStyle: only_raise +Style/BeginBlock: + Enabled: true -Style/StringLiterals: - EnforcedStyle: double_quotes +Style/BlockComments: + Enabled: true -Style/StringLiteralsInInterpolation: - EnforcedStyle: double_quotes +Style/BlockDelimiters: + Enabled: true -# Having these make it easier to *not* forget to add one when adding a new -# value and you can simply copy the previous line. -Style/TrailingCommaInLiteral: - EnforcedStyleForMultiline: comma +Style/BracesAroundHashParameters: + Enabled: true -Style/TrailingUnderscoreVariable: - Enabled: false +Style/CharacterLiteral: + Enabled: true -# `String.new` is preferred style with enabled frozen string literal -Style/EmptyLiteral: - Enabled: false +Style/ClassCheck: + Enabled: true -# 1.8.7 support +Style/ClassMethods: + Enabled: true + +Style/ClassVars: + Enabled: true + +Style/ColonMethodCall: + Enabled: true + +Style/ColonMethodDefinition: + Enabled: true + +Style/CommandLiteral: + Enabled: true + +Style/CommentAnnotation: + Enabled: true + +Style/DefWithParentheses: + Enabled: true + +Style/Dir: + Enabled: true + +Style/DoubleNegation: + Enabled: true + +Style/EachForSimpleLoop: + Enabled: true + +Style/EmptyBlockParameter: + Enabled: true + +Style/EmptyCaseCondition: + Enabled: true + +Style/EmptyElse: + Enabled: true + +Style/EmptyLambdaParameter: + Enabled: true + +Style/Encoding: + Enabled: true + +Style/EndBlock: + Enabled: true + +Style/EvenOdd: + Enabled: true + +Style/For: + Enabled: true + +Style/FormatString: + Enabled: true + +Style/FrozenStringLiteralComment: + Enabled: true + EnforcedStyle: always +# 1.8.7 support Style/HashSyntax: + Enabled: true EnforcedStyle: hash_rockets -Style/Lambda: - Enabled: false +Style/IdenticalConditionalBranches: + Enabled: true + +Style/IfInsideElse: + Enabled: true + +Style/IfUnlessModifierOfIfUnless: + Enabled: true + +Style/IfWithSemicolon: + Enabled: true + +Style/InfiniteLoop: + Enabled: true + +Style/LambdaCall: + Enabled: true + +Style/LineEndConcatenation: + Enabled: true + +Style/MethodCallWithoutArgsParentheses: + Enabled: true + +Style/MethodDefParentheses: + Enabled: true + +Style/MinMax: + Enabled: true + +Style/MixinGrouping: + Enabled: true + +Style/MultilineIfThen: + Enabled: true + +Style/MultilineMemoization: + Enabled: true + +Style/MultilineTernaryOperator: + Enabled: true + +Style/MultipleComparison: + Enabled: true + +Style/MutableConstant: + Enabled: true + +Style/NegatedIf: + Enabled: true + +Style/NegatedWhile: + Enabled: true + +Style/NestedModifier: + Enabled: true + +Style/NestedParenthesizedCalls: + Enabled: true + +Style/NestedTernaryOperator: + Enabled: true + +Style/Next: + Enabled: true + +Style/NilComparison: + Enabled: true + +Style/NonNilCheck: + Enabled: true + +Style/Not: + Enabled: true + +Style/NumericLiteralPrefix: + Enabled: true + +Style/NumericLiterals: + Enabled: true + +Style/OneLineConditional: + Enabled: true + +Style/OptionalArguments: + Enabled: true + +Style/OrAssignment: + Enabled: true + +Style/ParallelAssignment: + Enabled: true -Style/EachWithObject: - Enabled: false +Style/ParenthesesAroundCondition: + Enabled: true -Style/SpecialGlobalVars: - Enabled: false +Style/PercentLiteralDelimiters: + Enabled: true -Style/TrailingCommaInArguments: - Enabled: false +Style/PercentQLiterals: + Enabled: true -Performance/FlatMap: - Enabled: false +Style/PreferredHashMethods: + Enabled: true -Security/YAMLLoad: - Enabled: false +Style/Proc: + Enabled: true -# Metrics +Style/RandomWithOffset: + Enabled: true -# We've chosen to use Rubocop only for style, and not for complexity or quality checks. -Metrics/ClassLength: - Enabled: false +Style/RedundantBegin: + Enabled: true -Metrics/ModuleLength: - Enabled: false +Style/RedundantConditional: + Enabled: true -Metrics/MethodLength: - Enabled: false +Style/RedundantException: + Enabled: true -Metrics/BlockNesting: - Enabled: false +Style/RedundantParentheses: + Enabled: true -Metrics/AbcSize: - Enabled: false +Style/RedundantSelf: + Enabled: true -Metrics/CyclomaticComplexity: - Enabled: false +Style/RegexpLiteral: + Enabled: true + +Style/RescueModifier: + Enabled: true + +Style/RescueStandardError: + Enabled: true + +Style/SelfAssignment: + Enabled: true + +Style/Semicolon: + Enabled: true + +# We adopted raise instead of fail. +Style/SignalException: + Enabled: true + EnforcedStyle: only_raise + +Style/SingleLineMethods: + Enabled: true + +Style/StabbyLambdaParentheses: + Enabled: true + +Style/StderrPuts: + Enabled: true + +Style/StringLiterals: + Enabled: true + EnforcedStyle: double_quotes + +Style/StringLiteralsInInterpolation: + Enabled: true + EnforcedStyle: double_quotes + +Style/StructInheritance: + Enabled: true + +Style/SymbolArray: + Enabled: true + EnforcedStyle: brackets + +Style/SymbolLiteral: + Enabled: true + +Style/SymbolProc: + Enabled: true + +Style/TernaryParentheses: + Enabled: true + +Style/TrailingBodyOnClass: + Enabled: true + +Style/TrailingBodyOnMethodDefinition: + Enabled: true + +Style/TrailingBodyOnModule: + Enabled: true + +# Having these make it easier to *not* forget to add one when adding a new +# value and you can simply copy the previous line. +Style/TrailingCommaInArrayLiteral: + Enabled: true + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInHashLiteral: + Enabled: true + EnforcedStyleForMultiline: comma -Metrics/ParameterLists: - Enabled: false +Style/TrailingMethodEndStatement: + Enabled: true -Metrics/BlockLength: - Enabled: false +Style/UnlessElse: + Enabled: true -# It will be obvious which code is complex, Rubocop should only lint simple -# rules for us. -Metrics/PerceivedComplexity: - Enabled: false +Style/YodaCondition: + Enabled: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml deleted file mode 100644 index e8c49c05c4..0000000000 --- a/.rubocop_todo.yml +++ /dev/null @@ -1,385 +0,0 @@ -# This configuration was generated by -# `rubocop --auto-gen-config` -# on 2017-09-17 16:46:43 +0900 using RuboCop version 0.50.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 -# versions of RuboCop, may require this file to be generated again. - -# Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/IndentArray: - EnforcedStyle: consistent - -# Offense count: 40 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent -Layout/IndentHeredoc: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Exclude: - - 'lib/bundler/cli/common.rb' - - 'spec/bundler/plugin/source_list_spec.rb' - -# Offense count: 31 -Lint/AmbiguousBlockAssociation: - Exclude: - - 'lib/bundler/definition.rb' - - 'lib/bundler/resolver.rb' - - 'spec/bundler/compact_index_client/updater_spec.rb' - - 'spec/commands/init_spec.rb' - - 'spec/commands/install_spec.rb' - - 'spec/install/gems/flex_spec.rb' - - 'spec/lock/lockfile_bundler_1_spec.rb' - - 'spec/lock/lockfile_spec.rb' - - 'spec/other/major_deprecation_spec.rb' - - 'spec/runtime/setup_spec.rb' - - 'spec/support/helpers.rb' - - 'spec/support/indexes.rb' - -# Offense count: 2 -Lint/EmptyWhen: - Exclude: - - 'lib/bundler/friendly_errors.rb' - - 'spec/support/builders.rb' - -# Offense count: 3 -Lint/HandleExceptions: - Exclude: - - 'lib/bundler/psyched_yaml.rb' - - 'lib/bundler/vendored_persistent.rb' - -# Offense count: 1 -Lint/IneffectiveAccessModifier: - Exclude: - - 'lib/bundler/settings.rb' - -# Offense count: 6 -Lint/InterpolationCheck: - Exclude: - - 'lib/bundler/dsl.rb' - - 'lib/bundler/installer/standalone.rb' - - 'spec/commands/binstubs_spec.rb' - - 'spec/install/gems/standalone_spec.rb' - - 'spec/other/major_deprecation_spec.rb' - -# Offense count: 3 -Lint/NestedMethodDefinition: - Exclude: - - 'lib/bundler/inline.rb' - - 'spec/support/builders.rb' - -# Offense count: 5 -Lint/RescueException: - Exclude: - - 'lib/bundler/cli.rb' - - 'lib/bundler/dsl.rb' - - 'lib/bundler/friendly_errors.rb' - - 'lib/bundler/rubygems_integration.rb' - - 'lib/bundler/worker.rb' - -# Offense count: 29 -Lint/RescueWithoutErrorClass: - Enabled: false - -# Offense count: 2 -Lint/ShadowedException: - Exclude: - - 'lib/bundler.rb' - - 'lib/bundler/rubygems_integration.rb' - -# Offense count: 1 -# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. -Lint/UselessAccessModifier: - Exclude: - - 'lib/bundler/fetcher.rb' - -# Offense count: 6 -Lint/UselessAssignment: - Exclude: - - 'lib/bundler/index.rb' - - 'lib/bundler/installer.rb' - -# Offense count: 2564 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Metrics/LineLength: - Max: 207 - -# Offense count: 1 -Naming/AccessorMethodName: - Exclude: - - 'lib/bundler/source/git.rb' - -# Offense count: 31 -# Configuration parameters: Blacklist. -# Blacklist: END, (?-mix:EO[A-Z]{1}) -Naming/HeredocDelimiterNaming: - Enabled: false - -# Offense count: 9 -# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. -# NamePrefix: is_, has_, have_ -# NamePrefixBlacklist: is_, has_, have_ -# NameWhitelist: is_a? -Naming/PredicateName: - Exclude: - - 'spec/**/*' - - 'lib/bundler/definition.rb' - - 'lib/bundler/installer/parallel_installer.rb' - - 'lib/bundler/settings.rb' - - 'lib/bundler/source/git.rb' - - 'lib/bundler/source/git/git_proxy.rb' - - 'lib/bundler/source/path.rb' - -# Offense count: 2 -Performance/Caller: - Exclude: - - 'lib/bundler/rubygems_integration.rb' - - 'spec/support/builders.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect. -Performance/HashEachMethods: - Exclude: - - 'lib/bundler/definition.rb' - - 'lib/bundler/dependency.rb' - - 'lib/bundler/dsl.rb' - - 'lib/bundler/index.rb' - - 'lib/bundler/plugin.rb' - - 'spec/install/gems/standalone_spec.rb' - - 'spec/support/builders.rb' - - 'spec/support/helpers.rb' - -# Offense count: 7 -# Cop supports --auto-correct. -Performance/RedundantBlockCall: - Exclude: - - 'lib/bundler/gem_helper.rb' - - 'lib/bundler/retry.rb' - - 'lib/bundler/shared_helpers.rb' - - 'spec/support/helpers.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Performance/RedundantMatch: - Exclude: - - 'lib/bundler/definition.rb' - - 'lib/bundler/lockfile_parser.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: MaxKeyValuePairs. -Performance/RedundantMerge: - Exclude: - - 'lib/bundler/cli/gem.rb' - -# Offense count: 4 -Security/Eval: - Exclude: - - 'lib/bundler.rb' - - 'lib/bundler/endpoint_specification.rb' - - 'spec/support/streams.rb' - -# Offense count: 6 -Security/MarshalLoad: - Exclude: - - 'lib/bundler.rb' - - 'spec/install/gems/resolving_spec.rb' - - 'spec/support/artifice/compact_index.rb' - - 'spec/support/artifice/endpoint.rb' - -# Offense count: 3 -Style/CaseEquality: - Exclude: - - 'lib/bundler/match_platform.rb' - - 'lib/bundler/rubygems_ext.rb' - -# Offense count: 27 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: nested, compact -Style/ClassAndModuleChildren: - Enabled: false - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions. -# SupportedStyles: assign_to_condition, assign_inside_condition -Style/ConditionalAssignment: - Exclude: - - 'lib/bundler/cli.rb' - - 'lib/bundler/cli/gem.rb' - - 'lib/bundler/cli/platform.rb' - - 'lib/bundler/dsl.rb' - - 'lib/bundler/lazy_specification.rb' - - 'lib/bundler/psyched_yaml.rb' - - 'lib/bundler/rubygems_integration.rb' - - 'lib/bundler/source/git.rb' - - 'lib/bundler/source/rubygems.rb' - -# Offense count: 167 -Style/Documentation: - Enabled: false - -# Offense count: 17 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: compact, expanded -Style/EmptyMethod: - Exclude: - - 'exe/bundle_ruby' - - 'lib/bundler/cli.rb' - - 'lib/bundler/plugin/api/source.rb' - - 'lib/bundler/rubygems_integration.rb' - - 'lib/bundler/ui/silent.rb' - - 'spec/support/artifice/fail.rb' - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, AutoCorrectEncodingComment. -# SupportedStyles: when_needed, always, never -Style/Encoding: - Exclude: - - 'Rakefile' - - 'bundler.gemspec' - - 'lib/bundler/friendly_errors.rb' - - 'spec/bundler/bundler_spec.rb' - - 'spec/install/gemfile_spec.rb' - - 'spec/install/gemspecs_spec.rb' - - 'spec/quality_es_spec.rb' - -# Offense count: 1 -# Configuration parameters: SupportedStyles. -# SupportedStyles: annotated, template -Style/FormatStringToken: - EnforcedStyle: template - -# Offense count: 2 -# Configuration parameters: AllowedVariables. -Style/GlobalVars: - Exclude: - - 'lib/bundler/cli.rb' - - 'spec/spec_helper.rb' - -# Offense count: 12 -# Configuration parameters: MinBodyLength. -Style/GuardClause: - Exclude: - - 'lib/bundler/cli/cache.rb' - - 'lib/bundler/cli/install.rb' - - 'lib/bundler/cli/outdated.rb' - - 'lib/bundler/cli/package.rb' - - 'lib/bundler/definition.rb' - - 'lib/bundler/installer.rb' - - 'lib/bundler/runtime.rb' - - 'lib/bundler/source/path/installer.rb' - - 'lib/bundler/source_list.rb' - - 'spec/commands/newgem_spec.rb' - - 'spec/support/sometimes.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: InverseMethods, InverseBlocks. -Style/InverseMethods: - Exclude: - - 'lib/bundler/cli/doctor.rb' - - 'lib/bundler/definition.rb' - - 'lib/bundler/dsl.rb' - - 'lib/bundler/index.rb' - - 'lib/bundler/resolver.rb' - - 'lib/bundler/resolver/spec_group.rb' - -# Offense count: 6 -Style/MethodMissing: - Exclude: - - 'lib/bundler/dep_proxy.rb' - - 'lib/bundler/dsl.rb' - - 'lib/bundler/lazy_specification.rb' - - 'lib/bundler/plugin/dsl.rb' - - 'lib/bundler/remote_specification.rb' - - 'spec/support/builders.rb' - -# Offense count: 2 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: module_function, extend_self -Style/ModuleFunction: - Exclude: - - 'lib/bundler/shared_helpers.rb' - - 'spec/support/path.rb' - -# Offense count: 10 -# Cop supports --auto-correct. -Style/MultilineIfModifier: - Exclude: - - 'bin/with_rubygems' - - 'lib/bundler/installer.rb' - - 'lib/bundler/psyched_yaml.rb' - - 'lib/bundler/rubygems_ext.rb' - - 'lib/bundler/runtime.rb' - - 'lib/bundler/source/rubygems.rb' - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles. -# SupportedStyles: predicate, comparison -Style/NumericPredicate: - Exclude: - - 'spec/**/*' - - 'lib/bundler/gem_helper.rb' - - 'lib/bundler/mirror.rb' - - 'lib/bundler/source/path.rb' - -# Offense count: 24 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: compact, exploded -Style/RaiseArgs: - Exclude: - - 'lib/bundler/cli/install.rb' - - 'lib/bundler/deployment.rb' - - 'lib/bundler/fetcher/downloader.rb' - - 'lib/bundler/fetcher/index.rb' - - 'lib/bundler/installer/standalone.rb' - - 'lib/bundler/rubygems_integration.rb' - - 'lib/bundler/shared_helpers.rb' - - 'lib/bundler/source/git/git_proxy.rb' - - 'lib/bundler/source/rubygems/remote.rb' - - 'spec/bundler/endpoint_specification_spec.rb' - - 'spec/bundler/fetcher/dependency_spec.rb' - - 'spec/bundler/fetcher/downloader_spec.rb' - - 'spec/bundler/fetcher/index_spec.rb' - - 'spec/bundler/rubygems_integration_spec.rb' - - 'spec/bundler/shared_helpers_spec.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInLiteral: - Exclude: - - 'lib/bundler/cli/gem.rb' - - 'lib/bundler/fetcher.rb' - - 'lib/bundler/gem_helpers.rb' - - 'lib/bundler/graph.rb' - - 'lib/bundler/ruby_version.rb' - - 'lib/bundler/similarity_detector.rb' - - 'spec/support/artifice/endpoint.rb' - -# Offense count: 14 -# Cop supports --auto-correct. -Style/UnneededInterpolation: - Exclude: - - 'lib/bundler/cli/config.rb' - - 'lib/bundler/env.rb' - - 'spec/bundler/shared_helpers_spec.rb' - - 'spec/cache/git_spec.rb' - - 'spec/commands/exec_spec.rb' diff --git a/.travis.yml b/.travis.yml index e0c6c2b07a..2e90164fe8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ env: # We need to know if changes to rubygems will break bundler on release - RGV=master # Test the latest rubygems release with all of our supported rubies - - RGV=v3.0.2 + - RGV=v3.0.3 jobs: include: @@ -52,7 +52,7 @@ jobs: stage: linting # Ruby 2.5, Rubygems 2.7 - rvm: 2.5.3 - env: RGV=v2.7.8 + env: RGV=v2.7.9 stage: test # Ruby 2.4, Rubygems 2.6 - rvm: 2.4.5 @@ -68,7 +68,7 @@ jobs: stage: test # 1.x mode (we want to keep stuff passing in 1.x mode for now) - rvm: 2.6.1 - env: RGV=v3.0.2 BUNDLER_SPEC_SUB_VERSION=1.98 + env: RGV=v3.0.3 BUNDLER_SPEC_SUB_VERSION=1.98 stage: test allow_failures: @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # frozen_string_literal: true $:.unshift File.expand_path("../lib", __FILE__) @@ -19,7 +18,7 @@ end def safe_task(&block) yield true -rescue +rescue StandardError false end @@ -70,7 +69,7 @@ namespace :spec do sh "sudo apt-get install graphviz -y 2>&1 | tail -n 2" # Install the gems with a consistent version of RubyGems - sh "gem update --system 3.0.2" + sh "gem update --system 3.0.3" # Fix incorrect default gem specifications on ruby 2.6.1. Can be removed # when 2.6.2 is released and we start testing against it @@ -140,7 +139,7 @@ begin rubyopt = ENV["RUBYOPT"] # When editing this list, also edit .travis.yml! branches = %w[master] - releases = %w[v2.5.2 v2.6.14 v2.7.8 v3.0.2] + releases = %w[v2.5.2 v2.6.14 v2.7.9 v3.0.3] (branches + releases).each do |rg| desc "Run specs with RubyGems #{rg}" RSpec::Core::RakeTask.new(rg) do |t| diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9d1535f8cd..3aa8f82d3d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,4 +3,4 @@ jobs: pool: vmImage: 'vs2017-win2016' steps: - - template: azure-pipelines/steps.yml + - template: .azure-pipelines/steps.yml @@ -11,7 +11,7 @@ unless ARGV[0] == "spec:deps" begin gem dep.name, dep.requirement rescue Gem::LoadError => e - $stderr.puts "#{e.message} (#{e.class})" + warn "#{e.message} (#{e.class})" end end diff --git a/bin/rubocop b/bin/rubocop index 81f4679fb8..8014aff639 100755 --- a/bin/rubocop +++ b/bin/rubocop @@ -10,7 +10,7 @@ bundler_spec.dependencies.each do |dep| gem dep.name, dep.requirement end -gem "rubocop", "= 0.50.0" +gem "rubocop", "= 0.65.0" Gem.finish_resolve if Gem.respond_to?(:finish_resolve) diff --git a/bundler.gemspec b/bundler.gemspec index 56cb8e3ae1..d58b1d3d0c 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true begin @@ -45,10 +44,9 @@ Gem::Specification.new do |s| s.add_development_dependency "rake", "~> 12.0" s.add_development_dependency "ronn", "~> 0.7.3" s.add_development_dependency "rspec", "~> 3.6" - s.add_development_dependency "rubocop", "= 0.50.0" + s.add_development_dependency "rubocop", "= 0.65.0" - base_dir = File.dirname(__FILE__).gsub(%r{([^A-Za-z0-9_\-.,:\/@\n])}, "\\\\\\1") - s.files = IO.popen("git -C #{base_dir} ls-files -z", &:read).split("\x0").select {|f| f.match(%r{^(lib|exe)/}) } + s.files = Dir.glob("{lib,exe}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) } # we don't check in man pages, but we need to ship them because # we use them to generate the long-form help for each command. diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 916ae9bf78..affd7a78c1 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -16,7 +16,7 @@ module Bundler def self.start(*) super - rescue Exception => e + rescue Exception => e # rubocop:disable Lint/RescueException Bundler.ui = UI::Shell.new raise e ensure diff --git a/lib/bundler/cli/doctor.rb b/lib/bundler/cli/doctor.rb index 3e0898ff8a..6d038937c0 100644 --- a/lib/bundler/cli/doctor.rb +++ b/lib/bundler/cli/doctor.rb @@ -4,8 +4,8 @@ require "rbconfig" module Bundler class CLI::Doctor - DARWIN_REGEX = /\s+(.+) \(compatibility / - LDD_REGEX = /\t\S+ => (\S+) \(\S+\)/ + DARWIN_REGEX = /\s+(.+) \(compatibility /.freeze + LDD_REGEX = /\t\S+ => (\S+) \(\S+\)/.freeze attr_reader :options diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index 58e2f8a3fd..3db1ec7843 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -11,7 +11,7 @@ module Bundler class CLI::Gem TEST_FRAMEWORK_VERSIONS = { "rspec" => "3.0", - "minitest" => "5.0" + "minitest" => "5.0", }.freeze attr_reader :options, :gem_name, :thor, :name, :target @@ -57,7 +57,7 @@ module Bundler :ext => options[:ext], :exe => options[:exe], :bundler_version => bundler_dependency_version, - :github_username => github_username.empty? ? "[USERNAME]" : github_username + :github_username => github_username.empty? ? "[USERNAME]" : github_username, } ensure_safe_gem_name(name, constant_array) @@ -69,7 +69,7 @@ module Bundler "Rakefile.tt" => "Rakefile", "README.md.tt" => "README.md", "bin/console.tt" => "bin/console", - "bin/setup.tt" => "bin/setup" + "bin/setup.tt" => "bin/setup", } executables = %w[ diff --git a/lib/bundler/compact_index_client.rb b/lib/bundler/compact_index_client.rb index 6c241ca07a..2f713041c8 100644 --- a/lib/bundler/compact_index_client.rb +++ b/lib/bundler/compact_index_client.rb @@ -18,11 +18,6 @@ module Bundler attr_reader :directory - # @return [Lambda] A lambda that takes an array of inputs and a block, and - # maps the inputs with the block in parallel. - # - attr_accessor :in_parallel - def initialize(directory, fetcher) @directory = Pathname.new(directory) @updater = Updater.new(fetcher) @@ -31,7 +26,28 @@ module Bundler @info_checksums_by_name = {} @parsed_checksums = false @mutex = Mutex.new - @in_parallel = lambda do |inputs, &blk| + end + + def execution_mode=(block) + Bundler::CompactIndexClient.debug { "execution_mode=" } + @endpoints = Set.new + + @execution_mode = block + end + + # @return [Lambda] A lambda that takes an array of inputs and a block, and + # maps the inputs with the block in parallel. + # + def execution_mode + @execution_mode || sequentially + end + + def sequential_execution_mode! + self.execution_mode = sequentially + end + + def sequentially + @sequentially ||= lambda do |inputs, &blk| inputs.map(&blk) end end @@ -51,7 +67,7 @@ module Bundler def dependencies(names) Bundler::CompactIndexClient.debug { "dependencies(#{names})" } - in_parallel.call(names) do |name| + execution_mode.call(names) do |name| update_info(name) @cache.dependencies(name).map {|d| d.unshift(name) } end.flatten(1) diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 6f0d361160..c736fc9730 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -45,7 +45,7 @@ module Bundler @gemfiles << expanded_gemfile_path contents ||= Bundler.read_file(@gemfile.to_s) instance_eval(contents.dup.untaint, gemfile.to_s, 1) - rescue Exception => e + rescue Exception => e # rubocop:disable Lint/RescueException message = "There was an error " \ "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \ "`#{File.basename gemfile.to_s}`: #{e.message}" @@ -441,10 +441,10 @@ repo_name ||= user_name message = String.new message << "You passed #{invalid_keys.map {|k| ":" + k }.join(", ")} " message << if invalid_keys.size > 1 - "as options for #{command}, but they are invalid." - else - "as an option for #{command}, but it is invalid." - end + "as options for #{command}, but they are invalid." + else + "as an option for #{command}, but it is invalid." + end message << " Valid options are: #{valid_keys.join(", ")}." message << " You may be able to resolve this by upgrading Bundler to the newest version." diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 7ab71d99a8..272aac6882 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -15,6 +15,8 @@ module Bundler # This error is raised when it looks like the network is down class NetworkDownError < HTTPError; end + # This error is raised if we should rate limit our requests to the API + class TooManyRequestsError < HTTPError; end # This error is raised if the API returns a 413 (only printed in verbose) class FallbackError < HTTPError; end # This is the error raised if OpenSSL fails the cert verification @@ -226,7 +228,7 @@ module Bundler "GO_SERVER_URL" => "go", "SNAP_CI" => "snap", "CI_NAME" => ENV["CI_NAME"], - "CI" => "ci" + "CI" => "ci", } env_cis.find_all {|env, _| ENV[env] }.map {|_, ci| ci } end diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb index cfc74d642c..a117af72fa 100644 --- a/lib/bundler/fetcher/compact_index.rb +++ b/lib/bundler/fetcher/compact_index.rb @@ -39,7 +39,13 @@ module Bundler until remaining_gems.empty? log_specs "Looking up gems #{remaining_gems.inspect}" - deps = compact_index_client.dependencies(remaining_gems) + deps = begin + parallel_compact_index_client.dependencies(remaining_gems) + rescue TooManyRequestsError + @bundle_worker.stop if @bundle_worker + @bundle_worker = nil # reset it. Not sure if necessary + serial_compact_index_client.dependencies(remaining_gems) + end next_gems = deps.map {|d| d[3].map(&:first).flatten(1) }.flatten(1).uniq deps.each {|dep| gem_info << dep } complete_gems.concat(deps.map(&:first)).uniq! @@ -80,18 +86,26 @@ module Bundler private def compact_index_client - @compact_index_client ||= begin + @compact_index_client ||= SharedHelpers.filesystem_access(cache_path) do CompactIndexClient.new(cache_path, client_fetcher) - end.tap do |client| - client.in_parallel = lambda do |inputs, &blk| - func = lambda {|object, _index| blk.call(object) } - worker = bundle_worker(func) - inputs.each {|input| worker.enq(input) } - inputs.map { worker.deq } - end end + end + + def parallel_compact_index_client + compact_index_client.execution_mode = lambda do |inputs, &blk| + func = lambda {|object, _index| blk.call(object) } + worker = bundle_worker(func) + inputs.each {|input| worker.enq(input) } + inputs.map { worker.deq } end + + compact_index_client + end + + def serial_compact_index_client + compact_index_client.sequential_execution_mode! + compact_index_client end def bundle_worker(func = nil) diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb index 87ad4140fd..2aeb9962c4 100644 --- a/lib/bundler/fetcher/downloader.rb +++ b/lib/bundler/fetcher/downloader.rb @@ -34,6 +34,8 @@ module Bundler fetch(uri, new_headers) when Net::HTTPRequestEntityTooLarge raise FallbackError, response.body + when Net::HTTPTooManyRequests + raise TooManyRequestsError, response.body when Net::HTTPUnauthorized raise AuthenticationRequiredError, uri.host when Net::HTTPNotFound diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index ae3299a7c8..dd9b847f10 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 # frozen_string_literal: true require "cgi" @@ -45,7 +44,7 @@ module Bundler "Alternatively, you can increase the amount of memory the JVM is able to use by running Bundler with jruby -J-Xmx1024m -S bundle (JRuby defaults to 500MB)." else request_issue_report_for(error) end - rescue + rescue StandardError raise error end @@ -124,7 +123,7 @@ module Bundler yield rescue SignalException raise - rescue Exception => e + rescue Exception => e # rubocop:disable Lint/RescueException FriendlyErrors.log_error(e) exit FriendlyErrors.exit_status(e) end diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb index 019ae10c66..9d35169b99 100644 --- a/lib/bundler/gem_helpers.rb +++ b/lib/bundler/gem_helpers.rb @@ -10,7 +10,7 @@ module Bundler [Gem::Platform.new("universal-mingw32"), Gem::Platform.new("universal-mingw32")], [Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw32")], [Gem::Platform.new("x86_64-mingw32"), Gem::Platform.new("x64-mingw32")], - [Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")] + [Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")], ].freeze def generic(p) diff --git a/lib/bundler/graph.rb b/lib/bundler/graph.rb index de6bba0214..5644e41079 100644 --- a/lib/bundler/graph.rb +++ b/lib/bundler/graph.rb @@ -117,7 +117,7 @@ module Bundler :style => "filled", :fillcolor => "#B9B9D5", :shape => "box3d", - :fontsize => 16 + :fontsize => 16, }.merge(@node_options[group]) ) end @@ -142,7 +142,7 @@ module Bundler g.output @output_format.to_sym => "#{@output_file}.#{@output_format}" Bundler.ui.info "#{@output_file}.#{@output_format}" rescue ArgumentError => e - $stderr.puts "Unsupported output format. See Ruby-Graphviz/lib/graphviz/constants.rb" + warn "Unsupported output format. See Ruby-Graphviz/lib/graphviz/constants.rb" raise e end end diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index cd42919da2..19084f12b9 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -23,7 +23,7 @@ module Bundler PATH = "PATH".freeze PLUGIN = "PLUGIN SOURCE".freeze SPECS = " specs:".freeze - OPTIONS = /^ ([a-z]+): (.*)$/i + OPTIONS = /^ ([a-z]+): (.*)$/i.freeze SOURCE = [GIT, GEM, PATH, PLUGIN].freeze SECTIONS_BY_VERSION_INTRODUCED = { @@ -183,7 +183,7 @@ module Bundler (?:-(.*))?\))? # Optional platform (!)? # Optional pinned marker $ # Line end - /xo + /xo.freeze def parse_dependency(line) return unless line =~ NAME_VERSION diff --git a/lib/bundler/plugin/api/source.rb b/lib/bundler/plugin/api/source.rb index 586477efb5..b33926a181 100644 --- a/lib/bundler/plugin/api/source.rb +++ b/lib/bundler/plugin/api/source.rb @@ -37,7 +37,7 @@ module Bundler # # @!attribute [rw] dependency_names # @return [Array<String>] Names of dependencies that the source should - # try to resolve. It is not necessary to use this list intenally. This + # try to resolve. It is not necessary to use this list internally. This # is present to be compatible with `Definition` and is used by # rubygems source. module Source diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb index 713d679f12..a2ec0c1d65 100644 --- a/lib/bundler/plugin/installer.rb +++ b/lib/bundler/plugin/installer.rb @@ -43,16 +43,11 @@ module Bundler private - # Rubocop misunderstands the semantics of this method, assuming an `else` code block - # that doesn't exist. See https://github.com/bbatsov/rubocop/issues/5702. - # - # rubocop:disable Style/GuardClause def check_sources_consistency!(options) if options.key?(:git) && options.key?(:local_git) raise InvalidOption, "Remote and local plugin git sources can't be both specified" end end - # rubocop:enable Style/GuardClause def install_git(names, version, options) uri = options.delete(:git) diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index aaa7bb7583..266a77e220 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -172,13 +172,13 @@ module Bundler def name_for_explicit_dependency_source Bundler.default_gemfile.basename.to_s - rescue + rescue StandardError "Gemfile" end def name_for_locking_dependency_source Bundler.default_lockfile.basename.to_s - rescue + rescue StandardError "Gemfile.lock" end @@ -279,10 +279,10 @@ module Bundler versions_with_platforms = specs.map {|s| [s.version, s.platform] } message = String.new("Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in #{source}#{cache_message}.\n") message << if versions_with_platforms.any? - "The source contains '#{name}' at: #{formatted_versions_with_platforms(versions_with_platforms)}" - else - "The source does not contain any versions of '#{name}'" - end + "The source contains '#{name}' at: #{formatted_versions_with_platforms(versions_with_platforms)}" + else + "The source does not contain any versions of '#{name}'" + end else message = "Could not find gem '#{requirement}' in any of the gem sources " \ "listed in your Gemfile#{cache_message}." @@ -375,12 +375,12 @@ module Bundler o << " " o << if relevant_sources.empty? - "in any of the sources.\n" - elsif metadata_requirement - "is not available in #{relevant_sources.join(" or ")}" - else - "in any of the relevant sources:\n #{relevant_sources * "\n "}\n" - end + "in any of the sources.\n" + elsif metadata_requirement + "is not available in #{relevant_sources.join(" or ")}" + else + "in any of the relevant sources:\n #{relevant_sources * "\n "}\n" + end end end, :version_for_spec => lambda {|spec| spec.version }, diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb index 5e4f0c502d..d64958ba70 100644 --- a/lib/bundler/retry.rb +++ b/lib/bundler/retry.rb @@ -38,7 +38,7 @@ module Bundler @failed = false @current_run += 1 @result = block.call - rescue => e + rescue StandardError => e fail_attempt(e) end diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb index e6c31a94c9..80dc444f93 100644 --- a/lib/bundler/ruby_version.rb +++ b/lib/bundler/ruby_version.rb @@ -49,7 +49,7 @@ module Bundler ([\d.]+) # ruby version (?:p(-?\d+))? # optional patchlevel (?:\s\((\S+)\s(.+)\))? # optional engine info - /xo + /xo.freeze # Returns a RubyVersion from the given string. # @param [String] the version string to match. @@ -74,7 +74,7 @@ module Bundler @host ||= [ RbConfig::CONFIG["host_cpu"], RbConfig::CONFIG["host_vendor"], - RbConfig::CONFIG["host_os"] + RbConfig::CONFIG["host_os"], ].join("-") end diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 783d106e7b..ee2964dab7 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -307,7 +307,7 @@ module Bundler gem_from_path(path, security_policies[policy]).spec rescue Gem::Package::FormatError raise GemspecError, "Could not read gem at #{path}. It may be corrupted." - rescue Exception, Gem::Exception, Gem::Security::Exception => e + rescue Exception, Gem::Exception, Gem::Security::Exception => e # rubocop:disable Lint/RescueException if e.is_a?(Gem::Security::Exception) || e.message =~ /unknown trust policy|unsigned gem/i || e.message =~ /couldn't verify (meta)?data signature/i diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index ff9a5f57af..c9294ca801 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -421,7 +421,7 @@ module Bundler ) \2 # matching closing quote $ - }xo + }xo.freeze def load_config(config_file) return {} if !config_file || ignore_config? @@ -444,7 +444,7 @@ module Bundler (https?.*?) # URI (\.#{Regexp.union(PER_URI_OPTIONS)})? # optional suffix key \z - /ix + /ix.freeze # TODO: duplicates Rubygems#normalize_uri # TODO: is this the correct place to validate mirror URIs? diff --git a/lib/bundler/similarity_detector.rb b/lib/bundler/similarity_detector.rb index b7f3ee7afa..f698f46a4c 100644 --- a/lib/bundler/similarity_detector.rb +++ b/lib/bundler/similarity_detector.rb @@ -51,7 +51,7 @@ module Bundler dm[i][j] = [ dm[i - 1][j - 1] + (this[j - 1] == that[i - 1] ? 0 : sub), dm[i][j - 1] + ins, - dm[i - 1][j] + del + dm[i - 1][j] + del, ].min end end diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index ed734bf549..5f3f1bc2e4 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -191,10 +191,10 @@ module Bundler else message = String.new("The path `#{expanded_path}` ") message << if File.exist?(expanded_path) - "is not a directory." - else - "does not exist." - end + "is not a directory." + else + "does not exist." + end raise PathError, message end diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 9e5032c079..54758c9443 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -106,7 +106,7 @@ module Bundler end end - if installed?(spec) && !force + if (installed?(spec) || Plugin.installed?(spec.name)) && !force print_using_message "Using #{version_message(spec)}" return nil # no post-install message end @@ -124,7 +124,7 @@ module Bundler begin s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"]) spec.__swap__(s) - rescue + rescue StandardError Bundler.rm_rf(path) raise end diff --git a/lib/bundler/worker.rb b/lib/bundler/worker.rb index e91cfa7805..1c7c1ccf6c 100644 --- a/lib/bundler/worker.rb +++ b/lib/bundler/worker.rb @@ -62,7 +62,7 @@ module Bundler def apply_func(obj, i) @func.call(obj, i) - rescue Exception => e + rescue Exception => e # rubocop:disable Lint/RescueException WrappedException.new(e) end diff --git a/lib/bundler/yaml_serializer.rb b/lib/bundler/yaml_serializer.rb index 0fd81c40ef..c9ab5a4907 100644 --- a/lib/bundler/yaml_serializer.rb +++ b/lib/bundler/yaml_serializer.rb @@ -32,7 +32,7 @@ module Bundler (.*) # value \1 # matching closing quote $ - /xo + /xo.freeze HASH_REGEX = / ^ @@ -45,7 +45,7 @@ module Bundler (.*) # value \3 # matching closing quote $ - /xo + /xo.freeze def load(str) res = {} diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb index 194d6752b2..e33c8dc606 100644 --- a/spec/bundler/bundler_spec.rb +++ b/spec/bundler/bundler_spec.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 # frozen_string_literal: true require "bundler" @@ -313,10 +312,9 @@ EOF let(:bundle_path) { Pathname("#{tmpdir}/bundle") } def clear_cached_requires_sudo - # Private in ruby 1.8.7 return unless Bundler.instance_variable_defined?(:@requires_sudo_ran) - Bundler.send(:remove_instance_variable, :@requires_sudo_ran) - Bundler.send(:remove_instance_variable, :@requires_sudo) + Bundler.remove_instance_variable(:@requires_sudo_ran) + Bundler.remove_instance_variable(:@requires_sudo) end before do @@ -383,14 +381,8 @@ EOF after do FileUtils.rm_rf("tmp/vendor/bundle") FileUtils.rm_rf("tmp/vendor/bin_dir") - if Bundler.respond_to?(:remove_instance_variable) - Bundler.remove_instance_variable(:@requires_sudo_ran) - Bundler.remove_instance_variable(:@requires_sudo) - else - # TODO: Remove these code when Bundler drops Ruby 1.8.7 support - Bundler.send(:remove_instance_variable, :@requires_sudo_ran) - Bundler.send(:remove_instance_variable, :@requires_sudo) - end + Bundler.remove_instance_variable(:@requires_sudo_ran) + Bundler.remove_instance_variable(:@requires_sudo) end context "writable paths" do it "should return false and display nothing" do diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb index 1d4085d209..445bc18265 100644 --- a/spec/bundler/shared_helpers_spec.rb +++ b/spec/bundler/shared_helpers_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Bundler::SharedHelpers do before { ENV["BUNDLE_GEMFILE"] = "/path/Gemfile" } context "Gemfile is present" do - let(:expected_gemfile_path) { Pathname.new("/path/Gemfile") } + let(:expected_gemfile_path) { Pathname.new("/path/Gemfile").expand_path } it "returns the Gemfile path" do expect(subject.default_gemfile).to eq(expected_gemfile_path) diff --git a/spec/bundler/source_spec.rb b/spec/bundler/source_spec.rb index 9ef8e7e50f..d70fd7e549 100644 --- a/spec/bundler/source_spec.rb +++ b/spec/bundler/source_spec.rb @@ -60,6 +60,10 @@ RSpec.describe Bundler::Source do before { Bundler.ui = Bundler::UI::Shell.new } it "should return a string with the spec name and version and locked spec version" do + if Bundler.ui.instance_variable_get(:@shell).is_a?(Bundler::Thor::Shell::Basic) + skip "tty color is not supported with Thor::Shell::Basic environment." + end + expect(subject.version_message(spec)).to eq("nokogiri >= 1.6\e[32m (was < 1.5)\e[0m") end end @@ -79,6 +83,10 @@ RSpec.describe Bundler::Source do before { Bundler.ui = Bundler::UI::Shell.new } it "should return a string with the locked spec version in yellow" do + if Bundler.ui.instance_variable_get(:@shell).is_a?(Bundler::Thor::Shell::Basic) + skip "tty color is not supported with Thor::Shell::Basic environment." + end + expect(subject.version_message(spec)).to eq("nokogiri 1.6.1\e[33m (was 1.7.0)\e[0m") end end @@ -92,6 +100,10 @@ RSpec.describe Bundler::Source do before { Bundler.ui = Bundler::UI::Shell.new } it "should return a string with the locked spec version in green" do + if Bundler.ui.instance_variable_get(:@shell).is_a?(Bundler::Thor::Shell::Basic) + skip "tty color is not supported with Thor::Shell::Basic environment." + end + expect(subject.version_message(spec)).to eq("nokogiri 1.7.1\e[32m (was 1.7.0)\e[0m") end end diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index b958677876..9126b29592 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -133,7 +133,7 @@ RSpec.describe "bundle binstubs <gem>" do context "when BUNDLER_VERSION is set" do it "runs the correct version of bundler" do - sys_exec "BUNDLER_VERSION='999.999.999' #{bundled_app("bin/bundle")} install" + sys_exec "#{bundled_app("bin/bundle")} install", "BUNDLER_VERSION" => "999.999.999" expect(exitstatus).to eq(42) if exitstatus expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`") diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb index c7cc5e594a..0d1058ad11 100644 --- a/spec/commands/newgem_spec.rb +++ b/spec/commands/newgem_spec.rb @@ -162,7 +162,7 @@ RSpec.describe "bundle gem" do load_paths = [lib, spec] load_path_str = "-I#{load_paths.join(File::PATH_SEPARATOR)}" - sys_exec "PATH=\"\" #{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}" + sys_exec "#{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}", "PATH" => "" end it "creates the gem without the need for git" do diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index aa19fa1ce0..cac571754c 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -221,7 +221,7 @@ RSpec.describe "bundle install with git sources" do end Dir.chdir(lib_path("foo-1.0")) do - `git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1` + `git update-ref -m "Bundler Spec!" refs/bundler/1 master~1` end # want to ensure we don't fallback to HEAD @@ -257,7 +257,7 @@ RSpec.describe "bundle install with git sources" do end Dir.chdir(lib_path("foo-1.0")) do - `git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1` + `git update-ref -m "Bundler Spec!" refs/bundler/1 master~1` end # want to ensure we don't fallback to HEAD @@ -282,7 +282,7 @@ RSpec.describe "bundle install with git sources" do it "does not download random non-head refs" do Dir.chdir(lib_path("foo-1.0")) do - sys_exec!("git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1") + sys_exec!('git update-ref -m "Bundler Spec!" refs/bundler/1 master~1') end bundle! "config global_gem_cache true" @@ -1163,7 +1163,7 @@ RSpec.describe "bundle install with git sources" do void Init_foo() { rb_define_global_function("foo", &foo, 0); } C end - `git commit -m 'commit for iteration #{i}' ext/foo.c` + `git commit -m "commit for iteration #{i}" ext/foo.c` end git_commit_sha = git_reader.ref_for("HEAD") diff --git a/spec/install/gemfile_spec.rb b/spec/install/gemfile_spec.rb index 9306b625db..1e59695163 100644 --- a/spec/install/gemfile_spec.rb +++ b/spec/install/gemfile_spec.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 # frozen_string_literal: true RSpec.describe "bundle install" do diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb index 0be7a56606..cf3aaa719e 100644 --- a/spec/install/gems/resolving_spec.rb +++ b/spec/install/gems/resolving_spec.rb @@ -117,6 +117,26 @@ RSpec.describe "bundle install with install-time dependencies" do expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000") expect(the_bundle).to include_gems("rack 1.2") end + + it "installs the older version under rate limiting conditions" do + build_repo4 do + build_gem "rack", "9001.0.0" do |s| + s.required_ruby_version = "> 9000" + end + build_gem "rack", "1.2" + build_gem "foo1", "1.0" + end + + install_gemfile <<-G, :artifice => "compact_index_rate_limited", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4 } + ruby "#{RUBY_VERSION}" + source "http://localgemserver.test/" + gem 'rack' + gem 'foo1' + G + + expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000") + expect(the_bundle).to include_gems("rack 1.2") + end end context "allows no gems" do diff --git a/spec/install/gemspecs_spec.rb b/spec/install/gemspecs_spec.rb index c4cceeefb6..a90d2fea4e 100644 --- a/spec/install/gemspecs_spec.rb +++ b/spec/install/gemspecs_spec.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 # frozen_string_literal: true RSpec.describe "bundle install" do diff --git a/spec/plugins/install_spec.rb b/spec/plugins/install_spec.rb index 3d13278d9c..afc6087c1b 100644 --- a/spec/plugins/install_spec.rb +++ b/spec/plugins/install_spec.rb @@ -22,6 +22,18 @@ RSpec.describe "bundler plugin install" do plugin_should_be_installed("foo") end + context "plugin is already installed" do + before do + bundle "plugin install foo --source file://#{gem_repo2}" + end + + it "doesn't install plugin again" do + bundle "plugin install foo --source file://#{gem_repo2}" + expect(out).not_to include("Installing plugin foo") + expect(out).not_to include("Installed plugin foo") + end + end + it "installs multiple plugins" do bundle "plugin install foo kung-foo --source file://#{gem_repo2}" @@ -165,7 +177,7 @@ RSpec.describe "bundler plugin install" do build_plugin "foo", "1.1.0" end - install_gemfile <<-G + gemfile <<-G source 'file://#{gem_repo2}' plugin 'foo', "1.0" G diff --git a/spec/quality_es_spec.rb b/spec/quality_es_spec.rb index d837b88f78..8fc653c45a 100644 --- a/spec/quality_es_spec.rb +++ b/spec/quality_es_spec.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 # frozen_string_literal: true if defined?(Encoding) && Encoding.default_external.name != "UTF-8" diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index 8bdef33a79..6477a03fe4 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -237,6 +237,18 @@ RSpec.describe "The library itself" do end end + it "ships the correct set of files" do + Dir.chdir(root) do + git_list = IO.popen("git ls-files -z", &:read).split("\x0").select {|f| f.match(%r{^(lib|exe)/}) } + git_list += %w[CHANGELOG.md LICENSE.md README.md bundler.gemspec] + git_list += Dir.glob("man/**/*") + + gem_list = Gem::Specification.load(gemspec.to_s).files + + expect(git_list.to_set).to eq(gem_list.to_set) + end + end + it "does not contain any warnings" do Dir.chdir(root) do exclusions = %w[ diff --git a/spec/support/artifice/compact_index.rb b/spec/support/artifice/compact_index.rb index 38559e2e23..f97c2b3fbc 100644 --- a/spec/support/artifice/compact_index.rb +++ b/spec/support/artifice/compact_index.rb @@ -21,7 +21,7 @@ class CompactIndexAPI < Endpoint headers "Surrogate-Control" => "max-age=2592000, stale-while-revalidate=60" content_type "text/plain" requested_range_for(response_body) - rescue => e + rescue StandardError => e puts e puts e.backtrace raise @@ -83,7 +83,7 @@ class CompactIndexAPI < Endpoint end checksum = begin Digest(:SHA256).file("#{GEM_REPO}/gems/#{spec.original_name}.gem").base64digest - rescue + rescue StandardError nil end CompactIndex::GemVersion.new(spec.version.version, spec.platform.to_s, checksum, nil, diff --git a/spec/support/artifice/compact_index_api_missing.rb b/spec/support/artifice/compact_index_api_missing.rb index d4e68c38e8..94e6b73000 100644 --- a/spec/support/artifice/compact_index_api_missing.rb +++ b/spec/support/artifice/compact_index_api_missing.rb @@ -6,7 +6,7 @@ Artifice.deactivate class CompactIndexApiMissing < CompactIndexAPI get "/fetch/actual/gem/:id" do - $stderr.puts params[:id] + warn params[:id] if params[:id] == "rack-1.0.gemspec.rz" halt 404 else diff --git a/spec/support/artifice/compact_index_rate_limited.rb b/spec/support/artifice/compact_index_rate_limited.rb new file mode 100644 index 0000000000..d8f4fc941c --- /dev/null +++ b/spec/support/artifice/compact_index_rate_limited.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require File.expand_path("../compact_index", __FILE__) + +Artifice.deactivate + +class CompactIndexRateLimited < CompactIndexAPI + class RequestCounter + def self.queue + @queue ||= Queue.new + end + + def self.size + @queue.size + end + + def self.enq(name) + @queue.enq(name) + end + + def self.deq + @queue.deq + end + end + + configure do + RequestCounter.queue + end + + get "/info/:name" do + RequestCounter.enq(params[:name]) + + begin + if RequestCounter.size == 1 + etag_response do + gem = gems.find {|g| g.name == params[:name] } + CompactIndex.info(gem ? gem.versions : []) + end + else + status 429 + end + ensure + RequestCounter.deq + end + end +end + +Artifice.activate_with(CompactIndexRateLimited) diff --git a/spec/support/artifice/endpoint.rb b/spec/support/artifice/endpoint.rb index 9a0cfae8a2..fcced6ea35 100644 --- a/spec/support/artifice/endpoint.rb +++ b/spec/support/artifice/endpoint.rb @@ -59,7 +59,7 @@ class Endpoint < Sinatra::Base :platform => spec.platform.to_s, :dependencies => spec.dependencies.select {|dep| dep.type == :runtime }.map do |dep| [dep.name, dep.requirement.requirements.map {|a| a.join(" ") }.join(", ")] - end + end, } end.compact end diff --git a/spec/support/artifice/endpoint_api_missing.rb b/spec/support/artifice/endpoint_api_missing.rb index 95db8e2a7e..2ada0dc553 100644 --- a/spec/support/artifice/endpoint_api_missing.rb +++ b/spec/support/artifice/endpoint_api_missing.rb @@ -6,7 +6,7 @@ Artifice.deactivate class EndpointApiMissing < Endpoint get "/fetch/actual/gem/:id" do - $stderr.puts params[:id] + warn params[:id] if params[:id] == "rack-1.0.gemspec.rz" halt 404 else diff --git a/spec/support/builders.rb b/spec/support/builders.rb index 442623a415..33a81f6f65 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -649,7 +649,7 @@ module Spec `git config user.email "lol@wut.com"` `git config user.name "lolwut"` `git config commit.gpgsign false` - `git commit -m 'OMG INITIAL COMMIT'` + `git commit -m "OMG INITIAL COMMIT"` end end end diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 9be5955ac3..a222957c10 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -131,8 +131,6 @@ module Spec load_path << spec load_path_str = "-I#{load_path.join(File::PATH_SEPARATOR)}" - env = env.map {|k, v| "#{k}='#{v}'" }.join(" ") - args = options.map do |k, v| case v when nil @@ -146,8 +144,8 @@ module Spec end end.join - cmd = "#{env} #{sudo} #{Gem.ruby} #{load_path_str} #{requires_str} #{bundle_bin} #{cmd}#{args}" - sys_exec(cmd) {|i, o, thr| yield i, o, thr if block_given? } + cmd = "#{sudo} #{Gem.ruby} #{load_path_str} #{requires_str} #{bundle_bin} #{cmd}#{args}" + sys_exec(cmd, env) {|i, o, thr| yield i, o, thr if block_given? } end bang :bundle @@ -216,10 +214,12 @@ module Spec "#{Gem.ruby} -S #{ENV["GEM_PATH"]}/bin/rake" end - def sys_exec(cmd) + def sys_exec(cmd, env = {}) command_execution = CommandExecution.new(cmd.to_s, Dir.pwd) - Open3.popen3(cmd.to_s) do |stdin, stdout, stderr, wait_thr| + env = env.map {|k, v| [k.to_s, v.to_s] }.to_h # convert env keys and values to string + + Open3.popen3(env, cmd.to_s) do |stdin, stdout, stderr, wait_thr| yield stdin, stdout, wait_thr if block_given? stdin.close @@ -318,7 +318,7 @@ module Spec Dir.chdir(root) { gem_command! :build, gemspec.to_s } end bundler_path = root + "bundler-#{Bundler::VERSION}.gem" - elsif g.to_s =~ %r{\A/.*\.gem\z} + elsif g.to_s =~ %r{\A(?:[A-Z]:)?/.*\.gem\z} g else "#{gem_repo}/gems/#{g}.gem" @@ -569,7 +569,7 @@ module Spec tries = 0 sleep 0.5 TCPSocket.new(host, port) - rescue => e + rescue StandardError => e raise(e) if tries > (seconds * 2) tries += 1 retry @@ -579,7 +579,7 @@ module Spec port = 21_453 begin port += 1 while TCPSocket.new("127.0.0.1", port) - rescue + rescue StandardError false end port diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 8f0c1e5f91..2e2c51edfa 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -60,7 +60,7 @@ module Spec end end - MAJOR_DEPRECATION = /^\[DEPRECATED\]\s*/ + MAJOR_DEPRECATION = /^\[DEPRECATED\]\s*/.freeze RSpec::Matchers.define :eq_err do |expected| diffable @@ -152,7 +152,7 @@ module Spec version_const = name == "bundler" ? "Bundler::VERSION" : Spec::Builders.constantize(name) begin run! "require '#{name}.rb'; puts #{version_const}", *groups - rescue => e + rescue StandardError => e next "#{name} is not installed:\n#{indent(e)}" end last_command.stdout.gsub!(/#{MAJOR_DEPRECATION}.*$/, "") @@ -167,7 +167,7 @@ module Spec begin source_const = "#{Spec::Builders.constantize(name)}_SOURCE" run! "require '#{name}/source'; puts #{source_const}", *groups - rescue + rescue StandardError next "#{name} does not have a source defined:\n#{indent(e)}" end last_command.stdout.gsub!(/#{MAJOR_DEPRECATION}.*$/, "") @@ -193,7 +193,7 @@ module Spec puts "WIN" end R - rescue => e + rescue StandardError => e next "checking for #{name} failed:\n#{e}" end next if last_command.stdout == "WIN" diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb index 478cd12eb5..f031570e33 100644 --- a/spec/support/rubygems_ext.rb +++ b/spec/support/rubygems_ext.rb @@ -47,8 +47,6 @@ module Spec def self.install_gems(gems) reqs, no_reqs = gems.partition {|_, req| !req.nil? && !req.split(" ").empty? } - # TODO: remove when we drop ruby 1.8.7-2.2.2 support - reqs = reqs.sort_by {|name, _| name == "rack" ? 0 : 1 }.sort_by {|name, _| name =~ /rack/ ? 0 : 1 } no_reqs.map!(&:first) reqs.map! {|name, req| "'#{name}:#{req}'" } deps = reqs.concat(no_reqs).join(" ") diff --git a/task/release.rake b/task/release.rake index 3a48c1d255..f22d1296cc 100644 --- a/task/release.rake +++ b/task/release.rake @@ -4,9 +4,33 @@ require "bundler/gem_tasks" task :build => ["build_metadata", "man:build", "generate_files"] do Rake::Task["build_metadata:clean"].tap(&:reenable).real_invoke end -task :release => ["man:require", "man:build", "release:verify_github", "build_metadata"] +task :release => ["man:require", "man:build", "release:verify_files", "release:verify_github", "build_metadata"] namespace :release do + task :verify_files do + git_list = IO.popen("git ls-files -z", &:read).split("\x0").select {|f| f.match(%r{^(lib|exe)/}) } + git_list += %w[CHANGELOG.md LICENSE.md README.md bundler.gemspec] + git_list += Dir.glob("man/**/*") + + gem_list = Gem::Specification.load("bundler.gemspec").files + + extra_files = gem_list.to_set - git_list.to_set + + error_msg = <<~MSG + + You intend to ship some files with the gem that are not generated man pages + nor source control files. Please review the extra list of files and try + again: + + #{extra_files.to_a.join("\n ")} + + MSG + + raise error_msg if extra_files.any? + + puts "The file list is correct for a release." + end + def gh_api_post(opts) gem "netrc", "~> 0.11.0" require "netrc" |