rigortype 0.1.8 → 0.1.10
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 +4 -4
- data/README.md +186 -513
- data/lib/rigor/analysis/check_rules.rb +20 -0
- data/lib/rigor/analysis/runner.rb +67 -9
- data/lib/rigor/analysis/worker_session.rb +13 -4
- data/lib/rigor/cache/rbs_descriptor.rb +21 -2
- data/lib/rigor/cache/rbs_environment.rb +2 -1
- data/lib/rigor/cli/annotate_command.rb +274 -0
- data/lib/rigor/cli/baseline_command.rb +36 -16
- data/lib/rigor/cli/coverage_command.rb +126 -0
- data/lib/rigor/cli/coverage_renderer.rb +162 -0
- data/lib/rigor/cli/coverage_report.rb +75 -0
- data/lib/rigor/cli/mcp_command.rb +70 -0
- data/lib/rigor/cli/prism_colorizer.rb +111 -0
- data/lib/rigor/cli.rb +134 -6
- data/lib/rigor/environment/rbs_loader.rb +46 -5
- data/lib/rigor/environment/reporters.rb +3 -2
- data/lib/rigor/environment.rb +168 -5
- data/lib/rigor/inference/builtins/method_catalog.rb +17 -1
- data/lib/rigor/inference/builtins/time_catalog.rb +10 -1
- data/lib/rigor/inference/def_return_typer.rb +98 -0
- data/lib/rigor/inference/expression_typer.rb +308 -18
- data/lib/rigor/inference/method_dispatcher/cgi_folding.rb +109 -0
- data/lib/rigor/inference/method_dispatcher/constant_folding.rb +178 -10
- data/lib/rigor/inference/method_dispatcher/kernel_dispatch.rb +53 -1
- data/lib/rigor/inference/method_dispatcher/literal_string_folding.rb +62 -15
- data/lib/rigor/inference/method_dispatcher/math_folding.rb +149 -0
- data/lib/rigor/inference/method_dispatcher/overload_selector.rb +20 -1
- data/lib/rigor/inference/method_dispatcher/regexp_folding.rb +81 -0
- data/lib/rigor/inference/method_dispatcher/set_folding.rb +81 -0
- data/lib/rigor/inference/method_dispatcher/shape_dispatch.rb +431 -9
- data/lib/rigor/inference/method_dispatcher/shellwords_folding.rb +126 -0
- data/lib/rigor/inference/method_dispatcher/time_folding.rb +56 -0
- data/lib/rigor/inference/method_dispatcher/uri_folding.rb +67 -0
- data/lib/rigor/inference/method_dispatcher.rb +148 -1
- data/lib/rigor/inference/method_parameter_binder.rb +67 -10
- data/lib/rigor/inference/narrowing.rb +29 -10
- data/lib/rigor/inference/precision_scanner.rb +131 -0
- data/lib/rigor/inference/statement_evaluator.rb +29 -3
- data/lib/rigor/mcp/loop.rb +43 -0
- data/lib/rigor/mcp/server.rb +263 -0
- data/lib/rigor/mcp.rb +16 -0
- data/lib/rigor/plugin/base.rb +67 -5
- data/lib/rigor/plugin/loader.rb +22 -1
- data/lib/rigor/plugin/manifest.rb +101 -10
- data/lib/rigor/plugin/protocol_contract.rb +185 -0
- data/lib/rigor/plugin/registry.rb +87 -0
- data/lib/rigor/plugin/source_rbs_synthesis_reporter.rb +51 -0
- data/lib/rigor/sig_gen/generator.rb +150 -75
- data/lib/rigor/triage/catalogue.rb +2 -2
- data/lib/rigor/type/combinator.rb +57 -0
- data/lib/rigor/type/constant.rb +29 -2
- data/lib/rigor/version.rb +1 -1
- data/sig/rigor/analysis/baseline.rbs +39 -0
- data/sig/rigor/environment.rbs +3 -2
- data/sig/rigor/type.rbs +4 -0
- data/sig/rigor.rbs +2 -0
- metadata +42 -1
data/lib/rigor/type/constant.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "date"
|
|
3
4
|
require_relative "../trinary"
|
|
4
5
|
|
|
5
6
|
module Rigor
|
|
@@ -24,6 +25,13 @@ module Rigor
|
|
|
24
25
|
Complex,
|
|
25
26
|
Regexp,
|
|
26
27
|
Pathname,
|
|
28
|
+
::Set,
|
|
29
|
+
# `Date` covers `DateTime` (a subclass). `Time` is core.
|
|
30
|
+
# Both arise only from deterministic constructor folding
|
|
31
|
+
# (`Date.new` / `Time.utc`) — there is no Date / Time
|
|
32
|
+
# literal node — so a `Constant` carrier is always sound.
|
|
33
|
+
Date,
|
|
34
|
+
Time,
|
|
27
35
|
TrueClass,
|
|
28
36
|
FalseClass,
|
|
29
37
|
NilClass
|
|
@@ -42,12 +50,31 @@ module Rigor
|
|
|
42
50
|
raise ArgumentError, "Rigor::Type::Constant only carries scalar literals; got #{value.class}"
|
|
43
51
|
end
|
|
44
52
|
|
|
45
|
-
@value =
|
|
53
|
+
@value = freezable_carrier?(value) ? value.dup.freeze : value
|
|
46
54
|
freeze
|
|
47
55
|
end
|
|
48
56
|
|
|
57
|
+
# Mutable-ish carriers are stored as a frozen copy so a later
|
|
58
|
+
# in-place mutation cannot rewrite the literal under us. `Time`
|
|
59
|
+
# joins `String` / `Set` here: `Time#localtime` mutates the
|
|
60
|
+
# receiver's zone in place, so the carrier holds a frozen copy
|
|
61
|
+
# (the catalog also blocklists the mutators). `Date` is already
|
|
62
|
+
# immutable, but is duped-and-frozen for symmetry.
|
|
63
|
+
def freezable_carrier?(value)
|
|
64
|
+
value.is_a?(String) || value.is_a?(::Set) ||
|
|
65
|
+
value.is_a?(Date) || value.is_a?(Time)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# `Date#inspect` / `DateTime#inspect` spell out the internal
|
|
69
|
+
# astronomical-Julian-day representation, which is unreadable
|
|
70
|
+
# in a diagnostic. ISO-8601 is the compact, deterministic
|
|
71
|
+
# form. `Time#inspect` is already compact (`2026-01-01
|
|
72
|
+
# 00:00:00 UTC`), so it keeps the default.
|
|
49
73
|
def describe(_verbosity = :short)
|
|
50
|
-
value
|
|
74
|
+
case value
|
|
75
|
+
when Date then value.iso8601
|
|
76
|
+
else value.inspect
|
|
77
|
+
end
|
|
51
78
|
end
|
|
52
79
|
|
|
53
80
|
# RBS supports `Literal` types for booleans, nil, integer
|
data/lib/rigor/version.rb
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Rigor
|
|
2
|
+
module Analysis
|
|
3
|
+
# ADR-22 Slice 1 — per-project baseline filter.
|
|
4
|
+
# See lib/rigor/analysis/baseline.rb for the full contract.
|
|
5
|
+
class Baseline
|
|
6
|
+
class LoadError < ::StandardError
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Load a baseline file from disk.
|
|
10
|
+
# Returns `nil` when `path` is nil (no baseline configured).
|
|
11
|
+
# Raises {LoadError} on malformed or unsupported content.
|
|
12
|
+
def self.load: (::String? path) -> Baseline?
|
|
13
|
+
|
|
14
|
+
# Build a baseline from a current run's diagnostic stream.
|
|
15
|
+
def self.from_diagnostics: (untyped diagnostics, ?match_mode: :rule | :message) -> Baseline
|
|
16
|
+
|
|
17
|
+
attr_reader buckets: untyped
|
|
18
|
+
|
|
19
|
+
def initialize: (untyped buckets) -> void
|
|
20
|
+
|
|
21
|
+
# Apply the baseline filter. Returns [surfaced_diagnostics, silenced_count].
|
|
22
|
+
def filter: (untyped diagnostics) -> [untyped, ::Integer]
|
|
23
|
+
|
|
24
|
+
# Report bucket-level drift for each recorded baseline bucket.
|
|
25
|
+
def audit: (untyped diagnostics) -> untyped
|
|
26
|
+
|
|
27
|
+
# Return a new Baseline with the given buckets removed.
|
|
28
|
+
def without: (untyped buckets_to_drop) -> Baseline
|
|
29
|
+
|
|
30
|
+
# Serialise to a YAML string.
|
|
31
|
+
def to_yaml: () -> ::String
|
|
32
|
+
|
|
33
|
+
# Number of recorded buckets.
|
|
34
|
+
def size: () -> ::Integer
|
|
35
|
+
|
|
36
|
+
def empty?: () -> bool
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
data/sig/rigor/environment.rbs
CHANGED
|
@@ -15,11 +15,12 @@ module Rigor
|
|
|
15
15
|
attr_reader hkt_registry: untyped?
|
|
16
16
|
|
|
17
17
|
def self.default: () -> Environment
|
|
18
|
-
def self.for_project: (?root: String, ?libraries: Array[String], ?signature_paths: Array[String | _ToPath]?, ?cache_store: untyped?, ?plugin_registry: untyped?, ?dependency_source_index: untyped?, ?rbs_extended_reporter: untyped?, ?boundary_cross_reporter: untyped?, ?bundler_bundle_path: String?, ?bundler_auto_detect: bool, ?synthetic_method_index: untyped?, ?project_patched_methods: untyped?) -> Environment
|
|
18
|
+
def self.for_project: (?root: String, ?libraries: Array[String], ?signature_paths: Array[String | _ToPath]?, ?cache_store: untyped?, ?plugin_registry: untyped?, ?dependency_source_index: untyped?, ?rbs_extended_reporter: untyped?, ?boundary_cross_reporter: untyped?, ?source_rbs_synthesis_reporter: untyped?, ?bundler_bundle_path: String?, ?bundler_auto_detect: bool, ?synthetic_method_index: untyped?, ?project_patched_methods: untyped?) -> Environment
|
|
19
19
|
|
|
20
|
-
def initialize: (?class_registry: ClassRegistry, ?rbs_loader: RbsLoader?, ?plugin_registry: untyped?, ?dependency_source_index: untyped?, ?rbs_extended_reporter: untyped?, ?boundary_cross_reporter: untyped?, ?synthetic_method_index: untyped?, ?project_patched_methods: untyped?) -> void
|
|
20
|
+
def initialize: (?class_registry: ClassRegistry, ?rbs_loader: RbsLoader?, ?plugin_registry: untyped?, ?dependency_source_index: untyped?, ?rbs_extended_reporter: untyped?, ?boundary_cross_reporter: untyped?, ?source_rbs_synthesis_reporter: untyped?, ?synthetic_method_index: untyped?, ?project_patched_methods: untyped?) -> void
|
|
21
21
|
def rbs_extended_reporter: () -> untyped?
|
|
22
22
|
def boundary_cross_reporter: () -> untyped?
|
|
23
|
+
def source_rbs_synthesis_reporter: () -> untyped?
|
|
23
24
|
def attach_reporters!: (rbs_extended_reporter: untyped?, boundary_cross_reporter: untyped?) -> nil
|
|
24
25
|
def nominal_for_name: (String | Symbol name) -> Type::Nominal?
|
|
25
26
|
def singleton_for_name: (String | Symbol name) -> Type::Singleton?
|
data/sig/rigor/type.rbs
CHANGED
|
@@ -266,6 +266,10 @@ module Rigor
|
|
|
266
266
|
def self?.non_numeric_string: () -> Refined
|
|
267
267
|
def self?.literal_string_carrier?: (Type::t refined) -> bool
|
|
268
268
|
def self?.literal_string_compatible?: (Type::t type) -> bool
|
|
269
|
+
def self?.non_empty_string_compatible?: (Type::t type) -> bool
|
|
270
|
+
def self?.non_empty_string_difference?: (Type::t diff) -> bool
|
|
271
|
+
def self?.non_zero_int_compatible?: (Type::t type) -> bool
|
|
272
|
+
def self?.non_zero_int_difference?: (Type::t diff) -> bool
|
|
269
273
|
def self?.intersection: (*Type::t members) -> Type::t
|
|
270
274
|
def self?.non_empty_lowercase_string: () -> Type::t
|
|
271
275
|
def self?.non_empty_uppercase_string: () -> Type::t
|
data/sig/rigor.rbs
CHANGED
|
@@ -12,6 +12,8 @@ module Rigor
|
|
|
12
12
|
attr_reader baseline_path: String?
|
|
13
13
|
|
|
14
14
|
def self.load: (?String path) -> Configuration
|
|
15
|
+
def self.discover: () -> String?
|
|
16
|
+
def self.load_with_includes: (String path, ?visited: Set[String]) -> Hash[String, untyped]
|
|
15
17
|
def initialize: (?Hash[String, untyped] data) -> void
|
|
16
18
|
def to_h: () -> Hash[String, untyped]
|
|
17
19
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rigortype
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rigor contributors
|
|
@@ -109,6 +109,26 @@ dependencies:
|
|
|
109
109
|
- - "<"
|
|
110
110
|
- !ruby/object:Gem::Version
|
|
111
111
|
version: '15.0'
|
|
112
|
+
- !ruby/object:Gem::Dependency
|
|
113
|
+
name: rbs-inline
|
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - ">="
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '0.5'
|
|
119
|
+
- - "<"
|
|
120
|
+
- !ruby/object:Gem::Version
|
|
121
|
+
version: '1.0'
|
|
122
|
+
type: :development
|
|
123
|
+
prerelease: false
|
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
125
|
+
requirements:
|
|
126
|
+
- - ">="
|
|
127
|
+
- !ruby/object:Gem::Version
|
|
128
|
+
version: '0.5'
|
|
129
|
+
- - "<"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '1.0'
|
|
112
132
|
- !ruby/object:Gem::Dependency
|
|
113
133
|
name: rspec
|
|
114
134
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -261,10 +281,16 @@ files:
|
|
|
261
281
|
- lib/rigor/cache/rbs_known_class_names.rb
|
|
262
282
|
- lib/rigor/cache/store.rb
|
|
263
283
|
- lib/rigor/cli.rb
|
|
284
|
+
- lib/rigor/cli/annotate_command.rb
|
|
264
285
|
- lib/rigor/cli/baseline_command.rb
|
|
286
|
+
- lib/rigor/cli/coverage_command.rb
|
|
287
|
+
- lib/rigor/cli/coverage_renderer.rb
|
|
288
|
+
- lib/rigor/cli/coverage_report.rb
|
|
265
289
|
- lib/rigor/cli/diff_command.rb
|
|
266
290
|
- lib/rigor/cli/explain_command.rb
|
|
267
291
|
- lib/rigor/cli/lsp_command.rb
|
|
292
|
+
- lib/rigor/cli/mcp_command.rb
|
|
293
|
+
- lib/rigor/cli/prism_colorizer.rb
|
|
268
294
|
- lib/rigor/cli/sig_gen_command.rb
|
|
269
295
|
- lib/rigor/cli/triage_command.rb
|
|
270
296
|
- lib/rigor/cli/triage_renderer.rb
|
|
@@ -317,6 +343,7 @@ files:
|
|
|
317
343
|
- lib/rigor/inference/builtins/time_catalog.rb
|
|
318
344
|
- lib/rigor/inference/closure_escape_analyzer.rb
|
|
319
345
|
- lib/rigor/inference/coverage_scanner.rb
|
|
346
|
+
- lib/rigor/inference/def_return_typer.rb
|
|
320
347
|
- lib/rigor/inference/expression_typer.rb
|
|
321
348
|
- lib/rigor/inference/fallback.rb
|
|
322
349
|
- lib/rigor/inference/fallback_tracer.rb
|
|
@@ -327,19 +354,27 @@ files:
|
|
|
327
354
|
- lib/rigor/inference/macro_block_self_type.rb
|
|
328
355
|
- lib/rigor/inference/method_dispatcher.rb
|
|
329
356
|
- lib/rigor/inference/method_dispatcher/block_folding.rb
|
|
357
|
+
- lib/rigor/inference/method_dispatcher/cgi_folding.rb
|
|
330
358
|
- lib/rigor/inference/method_dispatcher/constant_folding.rb
|
|
331
359
|
- lib/rigor/inference/method_dispatcher/file_folding.rb
|
|
332
360
|
- lib/rigor/inference/method_dispatcher/iterator_dispatch.rb
|
|
333
361
|
- lib/rigor/inference/method_dispatcher/kernel_dispatch.rb
|
|
334
362
|
- lib/rigor/inference/method_dispatcher/literal_string_folding.rb
|
|
363
|
+
- lib/rigor/inference/method_dispatcher/math_folding.rb
|
|
335
364
|
- lib/rigor/inference/method_dispatcher/method_folding.rb
|
|
336
365
|
- lib/rigor/inference/method_dispatcher/overload_selector.rb
|
|
337
366
|
- lib/rigor/inference/method_dispatcher/rbs_dispatch.rb
|
|
338
367
|
- lib/rigor/inference/method_dispatcher/receiver_affinity.rb
|
|
368
|
+
- lib/rigor/inference/method_dispatcher/regexp_folding.rb
|
|
369
|
+
- lib/rigor/inference/method_dispatcher/set_folding.rb
|
|
339
370
|
- lib/rigor/inference/method_dispatcher/shape_dispatch.rb
|
|
371
|
+
- lib/rigor/inference/method_dispatcher/shellwords_folding.rb
|
|
372
|
+
- lib/rigor/inference/method_dispatcher/time_folding.rb
|
|
373
|
+
- lib/rigor/inference/method_dispatcher/uri_folding.rb
|
|
340
374
|
- lib/rigor/inference/method_parameter_binder.rb
|
|
341
375
|
- lib/rigor/inference/multi_target_binder.rb
|
|
342
376
|
- lib/rigor/inference/narrowing.rb
|
|
377
|
+
- lib/rigor/inference/precision_scanner.rb
|
|
343
378
|
- lib/rigor/inference/project_patched_methods.rb
|
|
344
379
|
- lib/rigor/inference/project_patched_scanner.rb
|
|
345
380
|
- lib/rigor/inference/rbs_type_translator.rb
|
|
@@ -364,6 +399,9 @@ files:
|
|
|
364
399
|
- lib/rigor/language_server/signature_help_provider.rb
|
|
365
400
|
- lib/rigor/language_server/synchronized_writer.rb
|
|
366
401
|
- lib/rigor/language_server/uri.rb
|
|
402
|
+
- lib/rigor/mcp.rb
|
|
403
|
+
- lib/rigor/mcp/loop.rb
|
|
404
|
+
- lib/rigor/mcp/server.rb
|
|
367
405
|
- lib/rigor/plugin.rb
|
|
368
406
|
- lib/rigor/plugin/access_denied_error.rb
|
|
369
407
|
- lib/rigor/plugin/base.rb
|
|
@@ -378,8 +416,10 @@ files:
|
|
|
378
416
|
- lib/rigor/plugin/macro/heredoc_template.rb
|
|
379
417
|
- lib/rigor/plugin/macro/trait_registry.rb
|
|
380
418
|
- lib/rigor/plugin/manifest.rb
|
|
419
|
+
- lib/rigor/plugin/protocol_contract.rb
|
|
381
420
|
- lib/rigor/plugin/registry.rb
|
|
382
421
|
- lib/rigor/plugin/services.rb
|
|
422
|
+
- lib/rigor/plugin/source_rbs_synthesis_reporter.rb
|
|
383
423
|
- lib/rigor/plugin/trust_policy.rb
|
|
384
424
|
- lib/rigor/plugin/type_node_resolver.rb
|
|
385
425
|
- lib/rigor/rbs_extended.rb
|
|
@@ -437,6 +477,7 @@ files:
|
|
|
437
477
|
- lib/rigor/type_node/union.rb
|
|
438
478
|
- lib/rigor/version.rb
|
|
439
479
|
- sig/rigor.rbs
|
|
480
|
+
- sig/rigor/analysis/baseline.rbs
|
|
440
481
|
- sig/rigor/analysis/check_rules/always_truthy_condition_collector.rbs
|
|
441
482
|
- sig/rigor/analysis/check_rules/dead_assignment_collector.rbs
|
|
442
483
|
- sig/rigor/analysis/dependency_source_inference/gem_resolver.rbs
|