dependabot-bundler 0.211.0 → 0.212.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b17b4f044523e671c8d5089cd9f4e8f63ce0d03f40c2c0cf98592bbd08e328b
4
- data.tar.gz: c4c07d736246603d2ab6a2222b285f5dd4058cd9466de3ae55e4e01a6c34fe0c
3
+ metadata.gz: b08c43d9300e9e7fa9b6d5f0e3e0631638a6e9785385688079fdc91fa4ad5aaf
4
+ data.tar.gz: 4958a4a8e3a18c4b533891917c85b71f75fe94c002faac703240eef60e24cfad
5
5
  SHA512:
6
- metadata.gz: 3493c9d2028172e1f80ced2a7d80585471ea07cc298c47af088e8dcc42471c8c594aafe16e4dc376f63602f68190f0952a56ec1ef6f9b32397bfc4041659ffe0
7
- data.tar.gz: e8a1f7a0657d4bb5d6371a73a6c627d7538a480fa1e4e3d2afe5be11a3fbc5cdb88f561c84869f3e5344183cac1294b638d6f161f9a63be13a210ba6019af5b1
6
+ metadata.gz: c808f814bde969264d27a002a03839c07b7654f013154b3287b9b3259568c795bcd1b4a4fd346a3c9496aee2e8364243832baad5cdf02bfbeb2add6f844fc885
7
+ data.tar.gz: 5caf001d47e54cca9efac60192e772aafdc5038add498779d96e5f722568d260e0adbc3503c382600805d9c2ea012101bc346e1f9c62607dfc1506763e008de7
@@ -63,7 +63,7 @@ module Functions
63
63
  if spec.name == top_level.name
64
64
  "#{spec.name} (#{spec.version}) requires #{dependency_name} (#{dependency.requirement})"
65
65
  else
66
- "#{top_level.name} (#{top_level.version}) requires #{dependency_name} "\
66
+ "#{top_level.name} (#{top_level.version}) requires #{dependency_name} " \
67
67
  "(#{dependency.requirement}) via #{spec.name} (#{spec.version})"
68
68
  end
69
69
  end
@@ -14,13 +14,13 @@ module Functions
14
14
  Bundler::Definition.build(gemfile_name, nil, {}).
15
15
  dependencies.select(&:current_platform?).
16
16
  reject { |dep| dep.source.is_a?(Bundler::Source::Gemspec) }.
17
- map(&method(:serialize_bundler_dependency))
17
+ map { |dep| serialize_bundler_dependency(dep) }
18
18
  end
19
19
 
20
20
  def parsed_gemspec(gemspec_name:)
21
21
  Bundler.load_gemspec_uncached(gemspec_name).
22
22
  dependencies.
23
- map(&method(:serialize_bundler_dependency))
23
+ map { |dep| serialize_bundler_dependency(dep) }
24
24
  end
25
25
 
26
26
  private
@@ -71,15 +71,17 @@ module Functions
71
71
  }
72
72
  end
73
73
 
74
+ RUBYGEMS_HOSTS = [
75
+ "rubygems.org",
76
+ "www.rubygems.org"
77
+ ].freeze
78
+
74
79
  def default_rubygems?(source)
75
80
  return true if source.nil?
76
81
  return false unless source.is_a?(Bundler::Source::Rubygems)
77
82
 
78
83
  source.remotes.any? do |r|
79
- [
80
- "rubygems.org",
81
- "www.rubygems.org"
82
- ].include?(URI(r.to_s).host)
84
+ RUBYGEMS_HOSTS.include?(URI(r.to_s).host)
83
85
  end
84
86
  end
85
87
 
@@ -160,9 +160,9 @@ module Functions
160
160
  potentials_deps =
161
161
  error.cause.conflicts.values.
162
162
  flat_map(&:requirement_trees).
163
- map do |tree|
163
+ filter_map do |tree|
164
164
  tree.find { |req| allowed_new_unlocks.include?(req.name) }
165
- end.compact.map(&:name)
165
+ end.map(&:name)
166
166
 
167
167
  # If there are specific dependencies we can unlock, unlock them
168
168
  return dependencies_to_unlock.append(*potentials_deps) if potentials_deps.any?
@@ -11,7 +11,7 @@ module BundlerFileUtilsKeywordSplatPatch
11
11
  opts = {}
12
12
  opts[:encoding] = ::Encoding::UTF_8 if fu_windows?
13
13
  Dir.entries(path, **opts).
14
- reject { |n| [".", ".."].include?(n) }.
14
+ reject { |n| n == "." || n == ".." }.
15
15
  map { |n| self.class.new(prefix, join(rel, n.untaint)) }
16
16
  end
17
17
  end
@@ -51,7 +51,7 @@ module Bundler
51
51
 
52
52
  Bundler.rubygems.set_installed_by_version(spec)
53
53
  Bundler.rubygems.validate(spec)
54
- File.open(spec_path, "wb") { |file| file.write(spec.to_ruby) }
54
+ File.binwrite(spec_path, spec.to_ruby)
55
55
  end
56
56
  $LOAD_PATH.shift until $LOAD_PATH.empty?
57
57
  original_load_paths.each { |p| $LOAD_PATH << p }
@@ -9,7 +9,7 @@ RSpec.shared_context "in a temporary bundler directory" do
9
9
  let(:project_name) { "gemfile" }
10
10
 
11
11
  let(:tmp_path) do
12
- Dir.mkdir(TMP_DIR_PATH) unless Dir.exist?(TMP_DIR_PATH)
12
+ FileUtils.mkdir_p(TMP_DIR_PATH)
13
13
  dir = Dir.mktmpdir("native_helper_spec_", TMP_DIR_PATH)
14
14
  Pathname.new(dir).expand_path
15
15
  end
@@ -63,7 +63,7 @@ module Functions
63
63
  if spec.name == top_level.name
64
64
  "#{spec.name} (#{spec.version}) requires #{dependency_name} (#{dependency.requirement})"
65
65
  else
66
- "#{top_level.name} (#{top_level.version}) requires #{dependency_name} "\
66
+ "#{top_level.name} (#{top_level.version}) requires #{dependency_name} " \
67
67
  "(#{dependency.requirement}) via #{spec.name} (#{spec.version})"
68
68
  end
69
69
  end
@@ -14,13 +14,13 @@ module Functions
14
14
  Bundler::Definition.build(gemfile_name, nil, {}).
15
15
  dependencies.select(&:current_platform?).
16
16
  reject { |dep| dep.source.is_a?(Bundler::Source::Gemspec) }.
17
- map(&method(:serialize_bundler_dependency))
17
+ map { |dep| serialize_bundler_dependency(dep) }
18
18
  end
19
19
 
20
20
  def parsed_gemspec(gemspec_name:)
21
21
  Bundler.load_gemspec_uncached(gemspec_name).
22
22
  dependencies.
23
- map(&method(:serialize_bundler_dependency))
23
+ map { |dep| serialize_bundler_dependency(dep) }
24
24
  end
25
25
 
26
26
  private
@@ -72,15 +72,17 @@ module Functions
72
72
  }
73
73
  end
74
74
 
75
+ RUBYGEMS_HOSTS = [
76
+ "rubygems.org",
77
+ "www.rubygems.org"
78
+ ].freeze
79
+
75
80
  def default_rubygems?(source)
76
81
  return true if source.nil?
77
82
  return false unless source.is_a?(Bundler::Source::Rubygems)
78
83
 
79
84
  source.remotes.any? do |r|
80
- [
81
- "rubygems.org",
82
- "www.rubygems.org"
83
- ].include?(URI(r.to_s).host)
85
+ RUBYGEMS_HOSTS.include?(URI(r.to_s).host)
84
86
  end
85
87
  end
86
88
 
@@ -161,9 +161,9 @@ module Functions
161
161
  potentials_deps =
162
162
  error.cause.conflicts.values.
163
163
  flat_map(&:requirement_trees).
164
- map do |tree|
164
+ filter_map do |tree|
165
165
  tree.find { |req| allowed_new_unlocks.include?(req.name) }
166
- end.compact.map(&:name)
166
+ end.map(&:name)
167
167
 
168
168
  # If there are specific dependencies we can unlock, unlock them
169
169
  return dependencies_to_unlock.append(*potentials_deps) if potentials_deps.any?
@@ -13,7 +13,7 @@ module Bundler
13
13
  # Instead, we convert all `git@github.com:` URLs to use HTTPS.
14
14
  def configured_uri_for(uri)
15
15
  uri = uri.gsub(%r{git@(.*?):/?}, 'https://\1/')
16
- if /https?:/ =~ uri
16
+ if /https?:/.match?(uri)
17
17
  remote = Bundler::URI(uri)
18
18
  config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]
19
19
  remote.userinfo ||= config_auth
@@ -50,7 +50,7 @@ module Bundler
50
50
 
51
51
  Bundler.rubygems.set_installed_by_version(spec)
52
52
  Bundler.rubygems.validate(spec)
53
- File.open(spec_path, "wb") { |file| file.write(spec.to_ruby) }
53
+ File.binwrite(spec_path, spec.to_ruby)
54
54
  end
55
55
  $LOAD_PATH.shift until $LOAD_PATH.empty?
56
56
  original_load_paths.each { |p| $LOAD_PATH << p }
@@ -38,7 +38,7 @@ RSpec.describe Functions do
38
38
  expect(git_specs.size).to eq(count)
39
39
  git_specs.each do |gs|
40
40
  uri = URI.parse(gs[:auth_uri])
41
- expect(uri.scheme).to(satisfy { |s| %w(http https).include?(s) })
41
+ expect(uri.scheme).to(satisfy { |s| s.match?(/https?/o) })
42
42
  end
43
43
  end
44
44
 
@@ -10,7 +10,7 @@ RSpec.shared_context "in a temporary bundler directory" do
10
10
  let(:project_name) { "gemfile" }
11
11
 
12
12
  let(:tmp_path) do
13
- Dir.mkdir(TMP_DIR_PATH) unless Dir.exist?(TMP_DIR_PATH)
13
+ FileUtils.mkdir_p(TMP_DIR_PATH)
14
14
  dir = Dir.mktmpdir("native_helper_spec_", TMP_DIR_PATH)
15
15
  Pathname.new(dir).expand_path
16
16
  end
@@ -33,8 +33,8 @@ module Dependabot
33
33
  path_node = node.children[2]
34
34
  unless path_node.type == :str
35
35
  path = gemfile.path
36
- msg = "Dependabot only supports uninterpolated string arguments "\
37
- "to eval_gemfile. Got "\
36
+ msg = "Dependabot only supports uninterpolated string arguments " \
37
+ "to eval_gemfile. Got " \
38
38
  "`#{path_node.loc.expression.source}`"
39
39
  raise Dependabot::DependencyFileNotParseable.new(path, msg)
40
40
  end
@@ -35,8 +35,8 @@ module Dependabot
35
35
 
36
36
  unless path_node.type == :str
37
37
  path = gemfile.path
38
- msg = "Dependabot only supports uninterpolated string arguments "\
39
- "to gemspec. Got "\
38
+ msg = "Dependabot only supports uninterpolated string arguments " \
39
+ "to gemspec. Got " \
40
40
  "`#{path_node.loc.expression.source}`"
41
41
  raise Dependabot::DependencyFileNotParseable.new(path, msg)
42
42
  end
@@ -34,8 +34,8 @@ module Dependabot
34
34
 
35
35
  unless path_node.type == :str
36
36
  path = gemfile.path
37
- msg = "Dependabot only supports uninterpolated string arguments "\
38
- "for path dependencies. Got "\
37
+ msg = "Dependabot only supports uninterpolated string arguments " \
38
+ "for path dependencies. Got " \
39
39
  "`#{path_node.loc.expression.source}`"
40
40
  raise Dependabot::DependencyFileNotParseable.new(path, msg)
41
41
  end
@@ -6,6 +6,8 @@ module Dependabot
6
6
  module Bundler
7
7
  class FileUpdater
8
8
  class GemfileUpdater
9
+ GEMFILE_FILENAMES = %w(Gemfile gems.rb).freeze
10
+
9
11
  require_relative "git_pin_replacer"
10
12
  require_relative "git_source_remover"
11
13
  require_relative "requirement_replacer"
@@ -68,13 +70,13 @@ module Dependabot
68
70
  def remove_git_source?(dependency)
69
71
  old_gemfile_req =
70
72
  dependency.previous_requirements.
71
- find { |f| %w(Gemfile gems.rb).include?(f[:file]) }
73
+ find { |f| GEMFILE_FILENAMES.include?(f[:file]) }
72
74
 
73
75
  return false unless old_gemfile_req&.dig(:source, :type) == "git"
74
76
 
75
77
  new_gemfile_req =
76
78
  dependency.requirements.
77
- find { |f| %w(Gemfile gems.rb).include?(f[:file]) }
79
+ find { |f| GEMFILE_FILENAMES.include?(f[:file]) }
78
80
 
79
81
  new_gemfile_req[:source].nil?
80
82
  end
@@ -82,7 +84,7 @@ module Dependabot
82
84
  def update_git_pin?(dependency)
83
85
  new_gemfile_req =
84
86
  dependency.requirements.
85
- find { |f| %w(Gemfile gems.rb).include?(f[:file]) }
87
+ find { |f| GEMFILE_FILENAMES.include?(f[:file]) }
86
88
  return false unless new_gemfile_req&.dig(:source, :type) == "git"
87
89
 
88
90
  # If the new requirement is a git dependency with a ref then there's
@@ -90,9 +90,9 @@ module Dependabot
90
90
  def wrap_require(node)
91
91
  replace(
92
92
  node.loc.expression,
93
- "begin\n"\
94
- "#{node.loc.expression.source_line}\n"\
95
- "rescue LoadError\n"\
93
+ "begin\n" \
94
+ "#{node.loc.expression.source_line}\n" \
95
+ "rescue LoadError\n" \
96
96
  "end"
97
97
  )
98
98
  end
@@ -56,7 +56,7 @@ module Dependabot
56
56
  if length_change.positive?
57
57
  updated_line.sub(/(?<=\s)\s{#{length_change}}#/, "#")
58
58
  elsif length_change.negative?
59
- updated_line.sub(/(?<=\s{2})#/, " " * length_change.abs + "#")
59
+ updated_line.sub(/(?<=\s{2})#/, (" " * length_change.abs) + "#")
60
60
  end
61
61
 
62
62
  updated_lines[updated_line_index] = updated_line
@@ -76,7 +76,7 @@ module Dependabot
76
76
  end
77
77
 
78
78
  def find_source_from_git_url
79
- info = dependency.requirements.map { |r| r[:source] }.compact.first
79
+ info = dependency.requirements.filter_map { |r| r[:source] }.first
80
80
 
81
81
  url = info[:url] || info.fetch("url")
82
82
  Source.from_url(url)
@@ -106,8 +106,8 @@ module Dependabot
106
106
 
107
107
  rubygems_marshalled_gemspec_response.gsub("\x06;", "\n").
108
108
  scan(Dependabot::Source::SOURCE_REGEX) do
109
- github_urls << Regexp.last_match.to_s +
110
- Regexp.last_match.post_match.split("\n").first
109
+ github_urls << (Regexp.last_match.to_s +
110
+ Regexp.last_match.post_match.split("\n").first)
111
111
  end
112
112
 
113
113
  github_urls.find do |url|
@@ -124,7 +124,7 @@ module Dependabot
124
124
  return @rubygems_marshalled_gemspec_response if defined?(@rubygems_marshalled_gemspec_response)
125
125
 
126
126
  gemspec_uri =
127
- "#{registry_url}quick/Marshal.4.8/"\
127
+ "#{registry_url}quick/Marshal.4.8/" \
128
128
  "#{dependency.name}-#{dependency.version}.gemspec.rz"
129
129
 
130
130
  response =
@@ -198,7 +198,7 @@ module Dependabot
198
198
  def registry_url
199
199
  return "https://rubygems.org/" if new_source_type == "default"
200
200
 
201
- info = dependency.requirements.map { |r| r[:source] }.compact.first
201
+ info = dependency.requirements.filter_map { |r| r[:source] }.first
202
202
  info[:url] || info.fetch("url")
203
203
  end
204
204
 
@@ -63,7 +63,7 @@ module Dependabot
63
63
  end
64
64
 
65
65
  def self.native_helpers_root
66
- helpers_root = ENV["DEPENDABOT_NATIVE_HELPERS_PATH"]
66
+ helpers_root = ENV.fetch("DEPENDABOT_NATIVE_HELPERS_PATH", nil)
67
67
  return File.join(helpers_root, "bundler") unless helpers_root.nil?
68
68
 
69
69
  File.expand_path("../../../helpers", __dir__)
@@ -85,7 +85,7 @@ module Dependabot
85
85
  #
86
86
  # This is kind of a bug in Bundler, and we should try to fix it,
87
87
  # but resolving it won't necessarily be easy.
88
- updated_deps.map do |dep|
88
+ updated_deps.filter_map do |dep|
89
89
  original_dep =
90
90
  original_dependencies.find { |d| d.name == dep.fetch("name") }
91
91
  spec = specs.find { |d| d.fetch("name") == dep.fetch("name") }
@@ -93,7 +93,7 @@ module Dependabot
93
93
  next if spec.fetch("version") == original_dep.version
94
94
 
95
95
  build_dependency(original_dep, spec)
96
- end.compact
96
+ end
97
97
  end
98
98
 
99
99
  def build_dependency(original_dep, updated_spec)
@@ -28,7 +28,7 @@ module Dependabot
28
28
 
29
29
  def updated_requirements
30
30
  requirements.map do |req|
31
- if req[:file].match?(/\.gemspec/)
31
+ if req[:file].include?(".gemspec")
32
32
  update_gemspec_requirement(req)
33
33
  else
34
34
  # If a requirement doesn't come from a gemspec, it must be from
@@ -101,7 +101,7 @@ module Dependabot
101
101
  when "!="
102
102
  []
103
103
  else
104
- raise "Unexpected operation for unsatisfied Gemfile "\
104
+ raise "Unexpected operation for unsatisfied Gemfile " \
105
105
  "requirement: #{op}"
106
106
  end
107
107
  end
@@ -181,7 +181,7 @@ module Dependabot
181
181
  )
182
182
  git_specs.reject do |spec|
183
183
  uri = URI.parse(spec.fetch("auth_uri"))
184
- next false unless %w(http https).include?(uri.scheme)
184
+ next false unless uri.scheme&.match?(/https?/o)
185
185
 
186
186
  Dependabot::RegistryClient.get(
187
187
  url: uri.to_s
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.211.0
4
+ version: 0.212.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-23 00:00:00.000000000 Z
11
+ date: 2022-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.211.0
19
+ version: 0.212.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.211.0
26
+ version: 0.212.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debase
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 3.11.1
89
+ version: 3.12.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 3.11.1
96
+ version: 3.12.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +142,28 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.35.1
145
+ version: 1.36.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.35.1
152
+ version: 1.36.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-performance
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 1.14.2
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 1.14.2
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: ruby-debug-ide
155
169
  requirement: !ruby/object:Gem::Requirement