spoom 1.7.10 → 1.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82dc04cf069a738410f097150bff4d94af38dc6f7eefca31c368596eaf138da0
4
- data.tar.gz: ea4046ff175a5c05eb85dc8cc22b6cb88f294d63b378b88a790f6bd4d92bfaff
3
+ metadata.gz: e5cf816e6ecd86209b75a94d71474288762d94b97da6e6637f2b67bb80c5fcf0
4
+ data.tar.gz: fafeb36ec7993a9632dfa0e7c1b47b7e671122e2e0a89358b1c1ab86dd611aca
5
5
  SHA512:
6
- metadata.gz: a6c72f54e3398d0d599b92d5c266bdea3db2ee78b10151bf9a5644f2679d0778ecef4cfce105bb8dd284947e6c737ff194599c2e72ab7894dd0122466034c553
7
- data.tar.gz: ed0df1194a93939bbb4117efbc3218d9f18d079cd2dd6b704579ba8e4c78f6f5f8a58b02072dc99bd19870eeaed0bc449ee70ea5c965e152685239b801d97c99
6
+ metadata.gz: a28c07c9f9ddbd22a754d6f4619696d6a82caa6f8b355dd99fc90b27c42c14b8bbb4377e433ad593b7133fffe8397fa929c75e9d309dd9499a7aa105b2126fcb
7
+ data.tar.gz: a098d8d9fba5cef4988d5e3e5fdc01493beec8c3ddd3a75e1b78353570872d447ab82f47a83d2cc3192b6f3699a7409f45b848e29d373eee03d273647e0afacf
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "minitest"
9
+ gem "minitest-mock"
9
10
 
10
11
  group :development do
11
12
  gem "debug"
data/README.md CHANGED
@@ -375,7 +375,25 @@ $ spoom deadcode remove path/to/file.rb:42:18-47:23
375
375
 
376
376
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Don't forget to run `bin/sanity` before pushing your changes.
377
377
 
378
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
378
+ To install this gem onto your local machine, run `bundle exec rake install`.
379
+
380
+ ## Releasing
381
+
382
+ ### Bump the gem version
383
+
384
+ - [ ] Locally, update the version number in [`version.rb`](https://github.com/Shopify/spoom/blob/main/lib/spoom/version.rb)
385
+ - [ ] Run `bundle install` to update the version number in `Gemfile.lock`
386
+ - [ ] Commit this change with the message `Bump version to vx.y.z`
387
+ - [ ] Push this change directly to main or open a PR
388
+
389
+ ### Create a new tag
390
+
391
+ - [ ] Locally, create a new tag with the new version number: `git tag vx.y.z`
392
+ - [ ] Push this tag up to the remote `git push origin vx.y.z`
393
+
394
+ ### Release workflow will run automatically
395
+
396
+ We have a [release workflow](https://github.com/Shopify/spoom/actions/workflows/release.yml) that will publish your new gem version to rubygems.org via [Trusted Publishing](https://guides.rubygems.org/trusted-publishing/). This workflow must be approved by a member of the Ruby and Rails Infrastructure team at Shopify before it will run. Once it is approved, it will automatically publish a new gem version to rubygems.org and create a new GitHub release.
379
397
 
380
398
  ## Contributing
381
399
 
@@ -3,8 +3,6 @@
3
3
 
4
4
  module Spoom
5
5
  module BundlerHelper
6
- extend T::Sig
7
-
8
6
  class << self
9
7
  # Generate a gem requirement for the given gem name, using that gem's version in the "real" current bundle.
10
8
  #
@@ -59,7 +59,7 @@ module Spoom
59
59
  .select { |key, _value| key.start_with?("rbs_") }
60
60
  .sort_by { |_key, value| -value }
61
61
  .each do |key, value|
62
- say(" * #{key}: `#{value}`")
62
+ say(" * #{key}: `#{value}`")
63
63
  end
64
64
  end
65
65
  end
@@ -1,6 +1,8 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "shellwords"
5
+
4
6
  module Spoom
5
7
  class ExecResult < T::Struct
6
8
  const :out, String
@@ -30,11 +32,21 @@ module Spoom
30
32
  Bundler.with_unbundled_env do
31
33
  opts = { chdir: absolute_path } #: Hash[Symbol, untyped]
32
34
 
35
+ # When Ruby is wrapped in another dev environment (e.g. Nix), that environment might set
36
+ # env variables that cause Sorbet (or other tools) to link to incorrect versions of
37
+ # dependencies.
38
+ #
39
+ # In the case of Sorbet, this can lead to corrupted JSON output.
40
+ #
41
+ # Executing the command directly through the shell bypasses any Ruby wrappers and
42
+ # ensures that we are using the versions of tools that are default on the system.
43
+ command_with_shell = "/bin/sh -c #{command.shellescape}"
44
+
33
45
  if capture_err
34
- out, err, status = Open3.capture3(command, opts)
46
+ out, err, status = Open3.capture3(command_with_shell, opts)
35
47
  ExecResult.new(out: out, err: err, status: T.must(status.success?), exit_code: T.must(status.exitstatus))
36
48
  else
37
- out, status = Open3.capture2(command, opts)
49
+ out, status = Open3.capture2(command_with_shell, opts)
38
50
  ExecResult.new(out: out, err: nil, status: T.must(status.success?), exit_code: T.must(status.exitstatus))
39
51
  end
40
52
  end
@@ -4,14 +4,14 @@
4
4
  module Spoom
5
5
  # Build a file hierarchy from a set of file paths.
6
6
  class FileTree
7
- #: (?T::Enumerable[String] paths) -> void
7
+ #: (?Enumerable[String] paths) -> void
8
8
  def initialize(paths = [])
9
9
  @roots = {} #: Hash[String, Node]
10
10
  add_paths(paths)
11
11
  end
12
12
 
13
13
  # Add all `paths` to the tree
14
- #: (T::Enumerable[String] paths) -> void
14
+ #: (Enumerable[String] paths) -> void
15
15
  def add_paths(paths)
16
16
  paths.each { |path| add_path(path) }
17
17
  end
@@ -139,6 +139,12 @@ module Spoom
139
139
 
140
140
  apply_member_annotations(comments.method_annotations, sig)
141
141
 
142
+ # Sorbet runtime doesn't support `sig` on `method_added` or
143
+ # `singleton_method_added`, so we always use `without_runtime` for them.
144
+ if def_node.name == :method_added || def_node.name == :singleton_method_added
145
+ sig.without_runtime = true
146
+ end
147
+
142
148
  @rewriter << Source::Replace.new(
143
149
  signature.location.start_offset,
144
150
  signature.location.end_offset,
@@ -202,6 +208,9 @@ module Spoom
202
208
  signatures = comments.signatures
203
209
  if signatures.any?
204
210
  signatures.each do |signature|
211
+ # Only type param signatures (e.g. `#: [A, B]`) are valid on class/module nodes
212
+ next unless signature.string.start_with?("[")
213
+
205
214
  type_params = ::RBS::Parser.parse_type_params(signature.string)
206
215
  next if type_params.empty?
207
216
 
data/lib/spoom/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Spoom
5
- VERSION = "1.7.10"
5
+ VERSION = "1.7.12"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spoom
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.10
4
+ version: 1.7.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Terrasa
@@ -99,14 +99,14 @@ dependencies:
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: 4.0.0.dev.4
102
+ version: 4.0.0.dev.5
103
103
  type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: 4.0.0.dev.4
109
+ version: 4.0.0.dev.5
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: rexml
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -275,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
275
  - !ruby/object:Gem::Version
276
276
  version: '0'
277
277
  requirements: []
278
- rubygems_version: 3.7.2
278
+ rubygems_version: 4.0.3
279
279
  specification_version: 4
280
280
  summary: Useful tools for Sorbet enthusiasts.
281
281
  test_files: []