spoom 1.5.4 → 1.6.0

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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/lib/spoom/backtrace_filter/minitest.rb +2 -3
  3. data/lib/spoom/cli/deadcode.rb +1 -2
  4. data/lib/spoom/cli/helper.rb +36 -28
  5. data/lib/spoom/cli/srb/assertions.rb +48 -0
  6. data/lib/spoom/cli/srb/bump.rb +1 -2
  7. data/lib/spoom/cli/srb/sigs.rb +133 -18
  8. data/lib/spoom/cli/srb.rb +8 -4
  9. data/lib/spoom/cli.rb +1 -2
  10. data/lib/spoom/colors.rb +2 -6
  11. data/lib/spoom/context/bundle.rb +8 -9
  12. data/lib/spoom/context/exec.rb +2 -5
  13. data/lib/spoom/context/file_system.rb +12 -19
  14. data/lib/spoom/context/git.rb +14 -19
  15. data/lib/spoom/context/sorbet.rb +13 -26
  16. data/lib/spoom/context.rb +3 -7
  17. data/lib/spoom/coverage/d3/base.rb +6 -8
  18. data/lib/spoom/coverage/d3/circle_map.rb +6 -16
  19. data/lib/spoom/coverage/d3/pie.rb +14 -19
  20. data/lib/spoom/coverage/d3/timeline.rb +46 -47
  21. data/lib/spoom/coverage/d3.rb +2 -4
  22. data/lib/spoom/coverage/report.rb +38 -76
  23. data/lib/spoom/coverage/snapshot.rb +7 -13
  24. data/lib/spoom/coverage.rb +3 -5
  25. data/lib/spoom/deadcode/definition.rb +12 -14
  26. data/lib/spoom/deadcode/erb.rb +10 -8
  27. data/lib/spoom/deadcode/index.rb +19 -23
  28. data/lib/spoom/deadcode/indexer.rb +5 -6
  29. data/lib/spoom/deadcode/plugins/action_mailer.rb +2 -3
  30. data/lib/spoom/deadcode/plugins/action_mailer_preview.rb +2 -3
  31. data/lib/spoom/deadcode/plugins/actionpack.rb +4 -4
  32. data/lib/spoom/deadcode/plugins/active_model.rb +2 -3
  33. data/lib/spoom/deadcode/plugins/active_record.rb +2 -3
  34. data/lib/spoom/deadcode/plugins/active_support.rb +2 -1
  35. data/lib/spoom/deadcode/plugins/base.rb +29 -32
  36. data/lib/spoom/deadcode/plugins/graphql.rb +2 -3
  37. data/lib/spoom/deadcode/plugins/minitest.rb +4 -4
  38. data/lib/spoom/deadcode/plugins/namespaces.rb +5 -5
  39. data/lib/spoom/deadcode/plugins/rails.rb +5 -5
  40. data/lib/spoom/deadcode/plugins/rubocop.rb +4 -4
  41. data/lib/spoom/deadcode/plugins/ruby.rb +3 -4
  42. data/lib/spoom/deadcode/plugins/sorbet.rb +12 -6
  43. data/lib/spoom/deadcode/plugins/thor.rb +2 -3
  44. data/lib/spoom/deadcode/plugins.rb +2 -4
  45. data/lib/spoom/deadcode/remover.rb +37 -59
  46. data/lib/spoom/deadcode/send.rb +2 -8
  47. data/lib/spoom/file_collector.rb +10 -18
  48. data/lib/spoom/file_tree.rb +31 -46
  49. data/lib/spoom/location.rb +9 -20
  50. data/lib/spoom/model/builder.rb +60 -15
  51. data/lib/spoom/model/model.rb +65 -68
  52. data/lib/spoom/model/namespace_visitor.rb +3 -2
  53. data/lib/spoom/model/reference.rb +4 -8
  54. data/lib/spoom/model/references_visitor.rb +49 -29
  55. data/lib/spoom/parse.rb +17 -3
  56. data/lib/spoom/poset.rb +17 -19
  57. data/lib/spoom/printer.rb +10 -13
  58. data/lib/spoom/sorbet/assertions.rb +278 -0
  59. data/lib/spoom/sorbet/config.rb +8 -12
  60. data/lib/spoom/sorbet/errors.rb +16 -31
  61. data/lib/spoom/sorbet/lsp/base.rb +9 -15
  62. data/lib/spoom/sorbet/lsp/errors.rb +8 -16
  63. data/lib/spoom/sorbet/lsp/structures.rb +36 -59
  64. data/lib/spoom/sorbet/lsp.rb +15 -17
  65. data/lib/spoom/sorbet/metrics.rb +3 -5
  66. data/lib/spoom/sorbet/sigils.rb +7 -11
  67. data/lib/spoom/sorbet/sigs.rb +118 -25
  68. data/lib/spoom/sorbet.rb +3 -9
  69. data/lib/spoom/timeline.rb +4 -6
  70. data/lib/spoom/version.rb +1 -1
  71. data/lib/spoom/visitor.rb +298 -151
  72. data/lib/spoom.rb +0 -2
  73. data/rbi/spoom.rbi +3963 -0
  74. metadata +6 -3
@@ -5,32 +5,31 @@ module Spoom
5
5
  class Context
6
6
  # File System features for a context
7
7
  module FileSystem
8
- extend T::Sig
9
8
  extend T::Helpers
10
9
 
11
10
  requires_ancestor { Context }
12
11
 
13
12
  # Returns the absolute path to `relative_path` in the context's directory
14
- sig { params(relative_path: String).returns(String) }
13
+ #: (String relative_path) -> String
15
14
  def absolute_path_to(relative_path)
16
15
  File.join(absolute_path, relative_path)
17
16
  end
18
17
 
19
18
  # Does the context directory at `absolute_path` exist and is a directory?
20
- sig { returns(T::Boolean) }
19
+ #: -> bool
21
20
  def exist?
22
21
  File.directory?(absolute_path)
23
22
  end
24
23
 
25
24
  # Create the context directory at `absolute_path`
26
- sig { void }
25
+ #: -> void
27
26
  def mkdir!
28
27
  FileUtils.rm_rf(absolute_path)
29
28
  FileUtils.mkdir_p(absolute_path)
30
29
  end
31
30
 
32
31
  # List all files in this context matching `pattern`
33
- sig { params(pattern: String).returns(T::Array[String]) }
32
+ #: (?String pattern) -> Array[String]
34
33
  def glob(pattern = "**/*")
35
34
  Dir.glob(absolute_path_to(pattern)).map do |path|
36
35
  Pathname.new(path).relative_path_from(absolute_path).to_s
@@ -38,18 +37,12 @@ module Spoom
38
37
  end
39
38
 
40
39
  # List all files at the top level of this context directory
41
- sig { returns(T::Array[String]) }
40
+ #: -> Array[String]
42
41
  def list
43
42
  glob("*")
44
43
  end
45
44
 
46
- sig do
47
- params(
48
- allow_extensions: T::Array[String],
49
- allow_mime_types: T::Array[String],
50
- exclude_patterns: T::Array[String],
51
- ).returns(T::Array[String])
52
- end
45
+ #: (?allow_extensions: Array[String], ?allow_mime_types: Array[String], ?exclude_patterns: Array[String]) -> Array[String]
53
46
  def collect_files(allow_extensions: [], allow_mime_types: [], exclude_patterns: [])
54
47
  collector = FileCollector.new(
55
48
  allow_extensions: allow_extensions,
@@ -61,7 +54,7 @@ module Spoom
61
54
  end
62
55
 
63
56
  # Does `relative_path` point to an existing file in this context directory?
64
- sig { params(relative_path: String).returns(T::Boolean) }
57
+ #: (String relative_path) -> bool
65
58
  def file?(relative_path)
66
59
  File.file?(absolute_path_to(relative_path))
67
60
  end
@@ -69,7 +62,7 @@ module Spoom
69
62
  # Return the contents of the file at `relative_path` in this context directory
70
63
  #
71
64
  # Will raise if the file doesn't exist.
72
- sig { params(relative_path: String).returns(String) }
65
+ #: (String relative_path) -> String
73
66
  def read(relative_path)
74
67
  File.read(absolute_path_to(relative_path))
75
68
  end
@@ -77,7 +70,7 @@ module Spoom
77
70
  # Write `contents` in the file at `relative_path` in this context directory
78
71
  #
79
72
  # Append to the file if `append` is true.
80
- sig { params(relative_path: String, contents: String, append: T::Boolean).void }
73
+ #: (String relative_path, ?String contents, ?append: bool) -> void
81
74
  def write!(relative_path, contents = "", append: false)
82
75
  absolute_path = absolute_path_to(relative_path)
83
76
  FileUtils.mkdir_p(File.dirname(absolute_path))
@@ -85,13 +78,13 @@ module Spoom
85
78
  end
86
79
 
87
80
  # Remove the path at `relative_path` (recursive + force) in this context directory
88
- sig { params(relative_path: String).void }
81
+ #: (String relative_path) -> void
89
82
  def remove!(relative_path)
90
83
  FileUtils.rm_rf(absolute_path_to(relative_path))
91
84
  end
92
85
 
93
86
  # Move the file or directory from `from_relative_path` to `to_relative_path`
94
- sig { params(from_relative_path: String, to_relative_path: String).void }
87
+ #: (String from_relative_path, String to_relative_path) -> void
95
88
  def move!(from_relative_path, to_relative_path)
96
89
  destination_path = absolute_path_to(to_relative_path)
97
90
  FileUtils.mkdir_p(File.dirname(destination_path))
@@ -101,7 +94,7 @@ module Spoom
101
94
  # Delete this context and its content
102
95
  #
103
96
  # Warning: it will `rm -rf` the context directory on the file system.
104
- sig { void }
97
+ #: -> void
105
98
  def destroy!
106
99
  FileUtils.rm_rf(absolute_path)
107
100
  end
@@ -4,13 +4,9 @@
4
4
  module Spoom
5
5
  module Git
6
6
  class Commit < T::Struct
7
- extend T::Sig
8
-
9
7
  class << self
10
- extend T::Sig
11
-
12
8
  # Parse a line formatted as `%h %at` into a `Commit`
13
- sig { params(string: String).returns(T.nilable(Commit)) }
9
+ #: (String string) -> Commit?
14
10
  def parse_line(string)
15
11
  sha, epoch = string.split(" ", 2)
16
12
  return unless sha && epoch
@@ -23,7 +19,7 @@ module Spoom
23
19
  const :sha, String
24
20
  const :time, Time
25
21
 
26
- sig { returns(Integer) }
22
+ #: -> Integer
27
23
  def timestamp
28
24
  time.to_i
29
25
  end
@@ -33,13 +29,12 @@ module Spoom
33
29
  class Context
34
30
  # Git features for a context
35
31
  module Git
36
- extend T::Sig
37
32
  extend T::Helpers
38
33
 
39
34
  requires_ancestor { Context }
40
35
 
41
36
  # Run a command prefixed by `git` in this context directory
42
- sig { params(command: String).returns(ExecResult) }
37
+ #: (String command) -> ExecResult
43
38
  def git(command)
44
39
  exec("git #{command}")
45
40
  end
@@ -48,7 +43,7 @@ module Spoom
48
43
  #
49
44
  # Warning: passing a branch will run `git init -b <branch>` which is only available in git 2.28+.
50
45
  # In older versions, use `git_init!` followed by `git("checkout -b <branch>")`.
51
- sig { params(branch: T.nilable(String)).returns(ExecResult) }
46
+ #: (?branch: String?) -> ExecResult
52
47
  def git_init!(branch: nil)
53
48
  if branch
54
49
  git("init -b #{branch}")
@@ -58,13 +53,13 @@ module Spoom
58
53
  end
59
54
 
60
55
  # Run `git checkout` in this context directory
61
- sig { params(ref: String).returns(ExecResult) }
56
+ #: (?ref: String) -> ExecResult
62
57
  def git_checkout!(ref: "main")
63
58
  git("checkout #{ref}")
64
59
  end
65
60
 
66
61
  # Run `git checkout -b <branch-name> <ref>` in this context directory
67
- sig { params(branch_name: String, ref: T.nilable(String)).returns(ExecResult) }
62
+ #: (String branch_name, ?ref: String?) -> ExecResult
68
63
  def git_checkout_new_branch!(branch_name, ref: nil)
69
64
  if ref
70
65
  git("checkout -b #{branch_name} #{ref}")
@@ -74,7 +69,7 @@ module Spoom
74
69
  end
75
70
 
76
71
  # Run `git add . && git commit` in this context directory
77
- sig { params(message: String, time: Time, allow_empty: T::Boolean).returns(ExecResult) }
72
+ #: (?message: String, ?time: Time, ?allow_empty: bool) -> ExecResult
78
73
  def git_commit!(message: "message", time: Time.now.utc, allow_empty: false)
79
74
  git("add --all")
80
75
 
@@ -85,7 +80,7 @@ module Spoom
85
80
  end
86
81
 
87
82
  # Get the current git branch in this context directory
88
- sig { returns(T.nilable(String)) }
83
+ #: -> String?
89
84
  def git_current_branch
90
85
  res = git("branch --show-current")
91
86
  return unless res.status
@@ -94,13 +89,13 @@ module Spoom
94
89
  end
95
90
 
96
91
  # Run `git diff` in this context directory
97
- sig { params(arg: String).returns(ExecResult) }
92
+ #: (*String arg) -> ExecResult
98
93
  def git_diff(*arg)
99
94
  git("diff #{arg.join(" ")}")
100
95
  end
101
96
 
102
97
  # Get the last commit in the currently checked out branch
103
- sig { params(short_sha: T::Boolean).returns(T.nilable(Spoom::Git::Commit)) }
98
+ #: (?short_sha: bool) -> Spoom::Git::Commit?
104
99
  def git_last_commit(short_sha: true)
105
100
  res = git_log("HEAD --format='%#{short_sha ? "h" : "H"} %at' -1")
106
101
  return unless res.status
@@ -111,24 +106,24 @@ module Spoom
111
106
  Spoom::Git::Commit.parse_line(out)
112
107
  end
113
108
 
114
- sig { params(arg: String).returns(ExecResult) }
109
+ #: (*String arg) -> ExecResult
115
110
  def git_log(*arg)
116
111
  git("log #{arg.join(" ")}")
117
112
  end
118
113
 
119
114
  # Run `git push <remote> <ref>` in this context directory
120
- sig { params(remote: String, ref: String, force: T::Boolean).returns(ExecResult) }
115
+ #: (String remote, String ref, ?force: bool) -> ExecResult
121
116
  def git_push!(remote, ref, force: false)
122
117
  git("push #{force ? "-f" : ""} #{remote} #{ref}")
123
118
  end
124
119
 
125
- sig { params(arg: String).returns(ExecResult) }
120
+ #: (*String arg) -> ExecResult
126
121
  def git_show(*arg)
127
122
  git("show #{arg.join(" ")}")
128
123
  end
129
124
 
130
125
  # Is there uncommitted changes in this context directory?
131
- sig { params(path: String).returns(T::Boolean) }
126
+ #: (?path: String) -> bool
132
127
  def git_workdir_clean?(path: ".")
133
128
  git_diff("HEAD").out.empty?
134
129
  end
@@ -5,13 +5,12 @@ module Spoom
5
5
  class Context
6
6
  # Sorbet features for a context
7
7
  module Sorbet
8
- extend T::Sig
9
8
  extend T::Helpers
10
9
 
11
10
  requires_ancestor { Context }
12
11
 
13
12
  # Run `bundle exec srb` in this context directory
14
- sig { params(arg: String, sorbet_bin: T.nilable(String), capture_err: T::Boolean).returns(ExecResult) }
13
+ #: (*String arg, ?sorbet_bin: String?, ?capture_err: bool) -> ExecResult
15
14
  def srb(*arg, sorbet_bin: nil, capture_err: true)
16
15
  res = if sorbet_bin
17
16
  exec("#{sorbet_bin} #{arg.join(" ")}", capture_err: capture_err)
@@ -29,19 +28,13 @@ module Spoom
29
28
  res
30
29
  end
31
30
 
32
- sig { params(arg: String, sorbet_bin: T.nilable(String), capture_err: T::Boolean).returns(ExecResult) }
31
+ #: (*String arg, ?sorbet_bin: String?, ?capture_err: bool) -> ExecResult
33
32
  def srb_tc(*arg, sorbet_bin: nil, capture_err: true)
34
33
  arg.prepend("tc") unless sorbet_bin
35
34
  T.unsafe(self).srb(*arg, sorbet_bin: sorbet_bin, capture_err: capture_err)
36
35
  end
37
36
 
38
- sig do
39
- params(
40
- arg: String,
41
- sorbet_bin: T.nilable(String),
42
- capture_err: T::Boolean,
43
- ).returns(T.nilable(T::Hash[String, Integer]))
44
- end
37
+ #: (*String arg, ?sorbet_bin: String?, ?capture_err: bool) -> Hash[String, Integer]?
45
38
  def srb_metrics(*arg, sorbet_bin: nil, capture_err: true)
46
39
  metrics_file = "metrics.tmp"
47
40
 
@@ -61,7 +54,7 @@ module Spoom
61
54
  end
62
55
 
63
56
  # List all files typechecked by Sorbet from its `config`
64
- sig { params(with_config: T.nilable(Spoom::Sorbet::Config), include_rbis: T::Boolean).returns(T::Array[String]) }
57
+ #: (?with_config: Spoom::Sorbet::Config?, ?include_rbis: bool) -> Array[String]
65
58
  def srb_files(with_config: nil, include_rbis: true)
66
59
  config = with_config || sorbet_config
67
60
 
@@ -94,19 +87,13 @@ module Spoom
94
87
  end
95
88
 
96
89
  # List all files typechecked by Sorbet from its `config` that matches `strictness`
97
- sig do
98
- params(
99
- strictness: String,
100
- with_config: T.nilable(Spoom::Sorbet::Config),
101
- include_rbis: T::Boolean,
102
- ).returns(T::Array[String])
103
- end
90
+ #: (String strictness, ?with_config: Spoom::Sorbet::Config?, ?include_rbis: bool) -> Array[String]
104
91
  def srb_files_with_strictness(strictness, with_config: nil, include_rbis: true)
105
92
  srb_files(with_config: with_config, include_rbis: include_rbis)
106
93
  .select { |file| read_file_strictness(file) == strictness }
107
94
  end
108
95
 
109
- sig { params(arg: String, sorbet_bin: T.nilable(String), capture_err: T::Boolean).returns(T.nilable(String)) }
96
+ #: (*String arg, ?sorbet_bin: String?, ?capture_err: bool) -> String?
110
97
  def srb_version(*arg, sorbet_bin: nil, capture_err: true)
111
98
  res = T.unsafe(self).srb_tc("--no-config", "--version", *arg, sorbet_bin: sorbet_bin, capture_err: capture_err)
112
99
  return unless res.status
@@ -115,36 +102,36 @@ module Spoom
115
102
  end
116
103
 
117
104
  # Does this context has a `sorbet/config` file?
118
- sig { returns(T::Boolean) }
105
+ #: -> bool
119
106
  def has_sorbet_config?
120
107
  file?(Spoom::Sorbet::CONFIG_PATH)
121
108
  end
122
109
 
123
- sig { returns(Spoom::Sorbet::Config) }
110
+ #: -> Spoom::Sorbet::Config
124
111
  def sorbet_config
125
112
  Spoom::Sorbet::Config.parse_string(read_sorbet_config)
126
113
  end
127
114
 
128
115
  # Read the contents of `sorbet/config` in this context directory
129
- sig { returns(String) }
116
+ #: -> String
130
117
  def read_sorbet_config
131
118
  read(Spoom::Sorbet::CONFIG_PATH)
132
119
  end
133
120
 
134
121
  # Set the `contents` of `sorbet/config` in this context directory
135
- sig { params(contents: String, append: T::Boolean).void }
122
+ #: (String contents, ?append: bool) -> void
136
123
  def write_sorbet_config!(contents, append: false)
137
124
  write!(Spoom::Sorbet::CONFIG_PATH, contents, append: append)
138
125
  end
139
126
 
140
127
  # Read the strictness sigil from the file at `relative_path` (returns `nil` if no sigil)
141
- sig { params(relative_path: String).returns(T.nilable(String)) }
128
+ #: (String relative_path) -> String?
142
129
  def read_file_strictness(relative_path)
143
130
  Spoom::Sorbet::Sigils.file_strictness(absolute_path_to(relative_path))
144
131
  end
145
132
 
146
133
  # Get the commit introducing the `sorbet/config` file
147
- sig { returns(T.nilable(Spoom::Git::Commit)) }
134
+ #: -> Spoom::Git::Commit?
148
135
  def sorbet_intro_commit
149
136
  res = git_log("--diff-filter=A --format='%h %at' -1 -- sorbet/config")
150
137
  return unless res.status
@@ -156,7 +143,7 @@ module Spoom
156
143
  end
157
144
 
158
145
  # Get the commit removing the `sorbet/config` file
159
- sig { returns(T.nilable(Spoom::Git::Commit)) }
146
+ #: -> Spoom::Git::Commit?
160
147
  def sorbet_removal_commit
161
148
  res = git_log("--diff-filter=D --format='%h %at' -1 -- sorbet/config")
162
149
  return unless res.status
data/lib/spoom/context.rb CHANGED
@@ -18,8 +18,6 @@ module Spoom
18
18
  # A context maps to a directory in the file system.
19
19
  # It is used to manipulate files and run commands in the context of this directory.
20
20
  class Context
21
- extend T::Sig
22
-
23
21
  include Bundle
24
22
  include Exec
25
23
  include FileSystem
@@ -27,27 +25,25 @@ module Spoom
27
25
  include Sorbet
28
26
 
29
27
  class << self
30
- extend T::Sig
31
-
32
28
  # Create a new context in the system's temporary directory
33
29
  #
34
30
  # `name` is used as prefix to the temporary directory name.
35
31
  # The directory will be created if it doesn't exist.
36
- sig { params(name: T.nilable(String)).returns(T.attached_class) }
32
+ #: (?String? name) -> instance
37
33
  def mktmp!(name = nil)
38
34
  new(::Dir.mktmpdir(name))
39
35
  end
40
36
  end
41
37
 
42
38
  # The absolute path to the directory this context is about
43
- sig { returns(String) }
39
+ #: String
44
40
  attr_reader :absolute_path
45
41
 
46
42
  # Create a new context about `absolute_path`
47
43
  #
48
44
  # The directory will not be created if it doesn't exist.
49
45
  # Call `#make!` to create it.
50
- sig { params(absolute_path: String).void }
46
+ #: (String absolute_path) -> void
51
47
  def initialize(absolute_path)
52
48
  @absolute_path = T.let(::File.expand_path(absolute_path), String)
53
49
  end
@@ -10,30 +10,28 @@ module Spoom
10
10
 
11
11
  abstract!
12
12
 
13
- sig { returns(String) }
13
+ #: String
14
14
  attr_reader :id
15
15
 
16
- sig { params(id: String, data: T.untyped).void }
16
+ #: (String id, untyped data) -> void
17
17
  def initialize(id, data)
18
18
  @id = id
19
19
  @data = data
20
20
  end
21
21
 
22
22
  class << self
23
- extend T::Sig
24
-
25
- sig { returns(String) }
23
+ #: -> String
26
24
  def header_style
27
25
  ""
28
26
  end
29
27
 
30
- sig { returns(String) }
28
+ #: -> String
31
29
  def header_script
32
30
  ""
33
31
  end
34
32
  end
35
33
 
36
- sig { returns(String) }
34
+ #: -> String
37
35
  def html
38
36
  <<~HTML
39
37
  <svg id="#{id}"></svg>
@@ -41,7 +39,7 @@ module Spoom
41
39
  HTML
42
40
  end
43
41
 
44
- sig { returns(String) }
42
+ #: -> String
45
43
  def tooltip
46
44
  ""
47
45
  end
@@ -8,9 +8,7 @@ module Spoom
8
8
  module D3
9
9
  class CircleMap < Base
10
10
  class << self
11
- extend T::Sig
12
-
13
- sig { returns(String) }
11
+ #: -> String
14
12
  def header_style
15
13
  <<~CSS
16
14
  .node {
@@ -36,7 +34,7 @@ module Spoom
36
34
  CSS
37
35
  end
38
36
 
39
- sig { returns(String) }
37
+ #: -> String
40
38
  def header_script
41
39
  <<~JS
42
40
  function treeHeight(root, height = 0) {
@@ -55,7 +53,8 @@ module Spoom
55
53
  end
56
54
  end
57
55
 
58
- sig { override.returns(String) }
56
+ # @override
57
+ #: -> String
59
58
  def script
60
59
  <<~JS
61
60
  var root = {children: #{@data.to_json}}
@@ -146,23 +145,14 @@ module Spoom
146
145
  end
147
146
 
148
147
  class Sigils < CircleMap
149
- extend T::Sig
150
-
151
- sig do
152
- params(
153
- id: String,
154
- file_tree: FileTree,
155
- nodes_strictnesses: T::Hash[FileTree::Node, T.nilable(String)],
156
- nodes_scores: T::Hash[FileTree::Node, Float],
157
- ).void
158
- end
148
+ #: (String id, FileTree file_tree, Hash[FileTree::Node, String?] nodes_strictnesses, Hash[FileTree::Node, Float] nodes_scores) -> void
159
149
  def initialize(id, file_tree, nodes_strictnesses, nodes_scores)
160
150
  @nodes_strictnesses = nodes_strictnesses
161
151
  @nodes_scores = nodes_scores
162
152
  super(id, file_tree.roots.map { |r| tree_node_to_json(r) })
163
153
  end
164
154
 
165
- sig { params(node: FileTree::Node).returns(T::Hash[Symbol, T.untyped]) }
155
+ #: (FileTree::Node node) -> Hash[Symbol, untyped]
166
156
  def tree_node_to_json(node)
167
157
  if node.children.empty?
168
158
  {
@@ -7,21 +7,18 @@ module Spoom
7
7
  module Coverage
8
8
  module D3
9
9
  class Pie < Base
10
- extend T::Sig
11
10
  extend T::Helpers
12
11
 
13
12
  abstract!
14
13
 
15
- sig { params(id: String, title: String, data: T.untyped).void }
14
+ #: (String id, String title, untyped data) -> void
16
15
  def initialize(id, title, data)
17
16
  super(id, data)
18
17
  @title = title
19
18
  end
20
19
 
21
20
  class << self
22
- extend T::Sig
23
-
24
- sig { returns(String) }
21
+ #: -> String
25
22
  def header_style
26
23
  <<~CSS
27
24
  .pie .title {
@@ -39,7 +36,7 @@ module Spoom
39
36
  CSS
40
37
  end
41
38
 
42
- sig { returns(String) }
39
+ #: -> String
43
40
  def header_script
44
41
  <<~JS
45
42
  function tooltipPie(d, title, kind, sum) {
@@ -52,7 +49,8 @@ module Spoom
52
49
  end
53
50
  end
54
51
 
55
- sig { override.returns(String) }
52
+ # @override
53
+ #: -> String
56
54
  def script
57
55
  <<~JS
58
56
  #{tooltip}
@@ -121,14 +119,13 @@ module Spoom
121
119
  end
122
120
 
123
121
  class Sigils < Pie
124
- extend T::Sig
125
-
126
- sig { params(id: String, title: String, snapshot: Snapshot).void }
122
+ #: (String id, String title, Snapshot snapshot) -> void
127
123
  def initialize(id, title, snapshot)
128
124
  super(id, title, snapshot.sigils_excluding_rbis.select { |_k, v| v })
129
125
  end
130
126
 
131
- sig { override.returns(String) }
127
+ # @override
128
+ #: -> String
132
129
  def tooltip
133
130
  <<~JS
134
131
  function tooltip_#{id}(d) {
@@ -139,14 +136,13 @@ module Spoom
139
136
  end
140
137
 
141
138
  class Calls < Pie
142
- extend T::Sig
143
-
144
- sig { params(id: String, title: String, snapshot: Snapshot).void }
139
+ #: (String id, String title, Snapshot snapshot) -> void
145
140
  def initialize(id, title, snapshot)
146
141
  super(id, title, { true: snapshot.calls_typed, false: snapshot.calls_untyped })
147
142
  end
148
143
 
149
- sig { override.returns(String) }
144
+ # @override
145
+ #: -> String
150
146
  def tooltip
151
147
  <<~JS
152
148
  function tooltip_#{id}(d) {
@@ -157,9 +153,7 @@ module Spoom
157
153
  end
158
154
 
159
155
  class Sigs < Pie
160
- extend T::Sig
161
-
162
- sig { params(id: String, title: String, snapshot: Snapshot).void }
156
+ #: (String id, String title, Snapshot snapshot) -> void
163
157
  def initialize(id, title, snapshot)
164
158
  super(
165
159
  id,
@@ -168,7 +162,8 @@ module Spoom
168
162
  )
169
163
  end
170
164
 
171
- sig { override.returns(String) }
165
+ # @override
166
+ #: -> String
172
167
  def tooltip
173
168
  <<~JS
174
169
  function tooltip_#{id}(d) {