rigortype 0.2.1 → 0.2.2
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 +41 -14
- data/docs/handbook/01-getting-started.md +311 -0
- data/docs/handbook/02-everyday-types.md +337 -0
- data/docs/handbook/03-narrowing.md +359 -0
- data/docs/handbook/04-tuples-and-shapes.md +321 -0
- data/docs/handbook/05-methods-and-blocks.md +339 -0
- data/docs/handbook/06-classes.md +305 -0
- data/docs/handbook/07-rbs-and-extended.md +427 -0
- data/docs/handbook/08-understanding-errors.md +373 -0
- data/docs/handbook/09-plugins.md +241 -0
- data/docs/handbook/10-sorbet.md +347 -0
- data/docs/handbook/11-sig-gen.md +312 -0
- data/docs/handbook/12-lightweight-hkt.md +333 -0
- data/docs/handbook/README.md +275 -0
- data/docs/handbook/appendix-elixir.md +370 -0
- data/docs/handbook/appendix-go.md +399 -0
- data/docs/handbook/appendix-java-csharp.md +470 -0
- data/docs/handbook/appendix-liskov.md +580 -0
- data/docs/handbook/appendix-mypy.md +370 -0
- data/docs/handbook/appendix-phpstan.md +338 -0
- data/docs/handbook/appendix-protocols-and-structural-typing.md +292 -0
- data/docs/handbook/appendix-rust.md +446 -0
- data/docs/handbook/appendix-steep.md +336 -0
- data/docs/handbook/appendix-type-theory.md +1662 -0
- data/docs/handbook/appendix-typeprof.md +416 -0
- data/docs/handbook/appendix-typescript.md +332 -0
- data/docs/install.md +189 -0
- data/docs/llms.txt +72 -0
- data/docs/manual/01-installation.md +342 -0
- data/docs/manual/02-cli-reference.md +557 -0
- data/docs/manual/03-configuration.md +152 -0
- data/docs/manual/04-diagnostics.md +206 -0
- data/docs/manual/05-inspecting-types.md +109 -0
- data/docs/manual/06-baseline.md +104 -0
- data/docs/manual/07-plugins.md +92 -0
- data/docs/manual/08-skills.md +143 -0
- data/docs/manual/09-editor-integration.md +245 -0
- data/docs/manual/10-mcp-server.md +532 -0
- data/docs/manual/11-ci.md +274 -0
- data/docs/manual/12-caching.md +116 -0
- data/docs/manual/13-troubleshooting.md +120 -0
- data/docs/manual/14-rails-quickstart.md +332 -0
- data/docs/manual/15-type-protection-coverage.md +204 -0
- data/docs/manual/16-rbs-extended-annotations.md +190 -0
- data/docs/manual/17-driving-improvement.md +160 -0
- data/docs/manual/README.md +87 -0
- data/docs/manual/ci-templates/README.md +58 -0
- data/docs/manual/plugins/README.md +86 -0
- data/docs/manual/plugins/rigor-actioncable.md +78 -0
- data/docs/manual/plugins/rigor-actionmailer.md +74 -0
- data/docs/manual/plugins/rigor-actionpack.md +80 -0
- data/docs/manual/plugins/rigor-activejob.md +58 -0
- data/docs/manual/plugins/rigor-activerecord.md +102 -0
- data/docs/manual/plugins/rigor-activestorage.md +74 -0
- data/docs/manual/plugins/rigor-activesupport-core-ext.md +86 -0
- data/docs/manual/plugins/rigor-devise.md +70 -0
- data/docs/manual/plugins/rigor-dry-schema.md +56 -0
- data/docs/manual/plugins/rigor-dry-struct.md +60 -0
- data/docs/manual/plugins/rigor-dry-types.md +59 -0
- data/docs/manual/plugins/rigor-dry-validation.md +62 -0
- data/docs/manual/plugins/rigor-factorybot.md +76 -0
- data/docs/manual/plugins/rigor-graphql.md +89 -0
- data/docs/manual/plugins/rigor-hanami.md +83 -0
- data/docs/manual/plugins/rigor-mangrove.md +73 -0
- data/docs/manual/plugins/rigor-minitest.md +86 -0
- data/docs/manual/plugins/rigor-pundit.md +72 -0
- data/docs/manual/plugins/rigor-rails-i18n.md +92 -0
- data/docs/manual/plugins/rigor-rails-routes.md +94 -0
- data/docs/manual/plugins/rigor-rails.md +44 -0
- data/docs/manual/plugins/rigor-rbs-inline.md +83 -0
- data/docs/manual/plugins/rigor-rspec-rails.md +72 -0
- data/docs/manual/plugins/rigor-rspec.md +86 -0
- data/docs/manual/plugins/rigor-shoulda-matchers.md +78 -0
- data/docs/manual/plugins/rigor-sidekiq.md +78 -0
- data/docs/manual/plugins/rigor-sinatra.md +61 -0
- data/docs/manual/plugins/rigor-sorbet.md +63 -0
- data/docs/manual/plugins/rigor-statesman.md +75 -0
- data/docs/manual/plugins/rigor-typescript-utility-types.md +71 -0
- data/exe/rigor +1 -1
- data/lib/rigor/analysis/incremental_session.rb +4 -2
- data/lib/rigor/analysis/run_stats.rb +13 -1
- data/lib/rigor/analysis/runner.rb +54 -12
- data/lib/rigor/cli/check_command.rb +1 -1
- data/lib/rigor/cli/docs_command.rb +248 -0
- data/lib/rigor/cli/skill_command.rb +103 -41
- data/lib/rigor/cli/skill_describe.rb +346 -0
- data/lib/rigor/cli.rb +25 -3
- data/lib/rigor/inference/method_dispatcher/constant_folding.rb +124 -32
- data/lib/rigor/inference/method_dispatcher/shape_dispatch.rb +37 -6
- data/lib/rigor/inference/scope_indexer.rb +87 -89
- data/lib/rigor/plugin/isolation.rb +5 -5
- data/lib/rigor/plugin/loader.rb +4 -2
- data/lib/rigor/version.rb +1 -1
- data/skills/rigor-ask/SKILL.md +172 -0
- data/skills/rigor-doctor/SKILL.md +87 -0
- data/skills/rigor-editor-setup/SKILL.md +114 -0
- data/skills/rigor-mcp-setup/SKILL.md +117 -0
- data/skills/rigor-monkeypatch-resolve/SKILL.md +79 -0
- data/skills/rigor-next-steps/SKILL.md +113 -0
- data/skills/rigor-plugin-tune/SKILL.md +79 -0
- data/skills/rigor-protection-uplift/SKILL.md +133 -0
- data/skills/rigor-rbs-setup/SKILL.md +128 -0
- data/skills/rigor-upgrade/SKILL.md +79 -0
- metadata +90 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a23952ba800fa7d807c8b8acc4d1cfbb3489024d91c3c30d687ebfdb75c7d1f5
|
|
4
|
+
data.tar.gz: 1a301a820c1c0bd3c2946695ae59f8e00906d1ecebedc0fbfb1fa93da3f6a72a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6574512ee06d1eb87e42f697d7261eac8ecf9bba9ae4a8a4be6263fba188de5b9786babdcef7e9b2cf41ac4877010726d60f66b741af7b5295d6d3e98e5937cb
|
|
7
|
+
data.tar.gz: d1bcccf23cac521597657aadd2f1c35d7a860998dd3fc8e02a7802c2dc0e9bf23ca3c0e6c368cdb9574cc1ac1e5ff2395f9dd5f164beae13541874d617886b19
|
data/README.md
CHANGED
|
@@ -4,20 +4,25 @@
|
|
|
4
4
|
[](https://github.com/rigortype/rigor/blob/master/LICENSE)
|
|
5
5
|
[](https://deepwiki.com/rigortype/rigor)
|
|
6
6
|
|
|
7
|
-
**Type-aware bug finding for Ruby —
|
|
8
|
-
zero-false-positive bar enforced against real codebases.**
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
**Type-aware bug finding for Ruby — no annotations required, and a
|
|
8
|
+
zero-false-positive bar enforced against real codebases.** Built on
|
|
9
|
+
RBS: Rigor infers types from the values your code produces, reads any
|
|
10
|
+
RBS you write as an authoritative source, and generates more — but
|
|
11
|
+
needs none to start. Run one command over the code you already have,
|
|
12
|
+
and trust every line of output.
|
|
11
13
|
|
|
12
14
|
```sh
|
|
13
|
-
gem install
|
|
15
|
+
mise use -g ruby@4.0 gem:rigortype # install the tool, globally, on Ruby 4.0
|
|
16
|
+
rigor check app lib # find bugs in the code you already have
|
|
14
17
|
```
|
|
15
18
|
|
|
16
|
-
(The tool
|
|
17
|
-
|
|
19
|
+
(The tool runs on Ruby 4.0 while your project keeps its own Ruby; the
|
|
20
|
+
global `-g` install keeps it off your project's pins. See
|
|
21
|
+
[Get started](#get-started-in-one-prompt).)
|
|
18
22
|
|
|
19
|
-
No
|
|
20
|
-
|
|
23
|
+
No annotations required, no runtime dependency, no changes to your
|
|
24
|
+
code — and any RBS you do add, Rigor reads and uses. Rigor parses Ruby
|
|
25
|
+
with
|
|
21
26
|
[Prism](https://github.com/ruby/prism) and runs a flow-sensitive
|
|
22
27
|
inference engine that reasons about the *values* your expressions
|
|
23
28
|
produce — not just their classes. It catches undefined methods (and
|
|
@@ -106,13 +111,14 @@ Bahasa Indonesia, Polski, Українська, Русский, Română, Türk
|
|
|
106
111
|
the [installation guide](https://rigor.typedduck.fail/reference/manual/01-installation/#set-up-in-your-language).
|
|
107
112
|
|
|
108
113
|
**Manual install** — Rigor is a tool, not a library: install it
|
|
109
|
-
independently, **not** in your project's `Gemfile`.
|
|
110
|
-
|
|
111
|
-
|
|
114
|
+
independently, **not** in your project's `Gemfile`. Install it
|
|
115
|
+
**globally** so `rigor` is on your `PATH` everywhere, running on Ruby
|
|
116
|
+
4.0 while each project keeps its own Ruby — the `-g` install lives in
|
|
117
|
+
your global [`mise`](https://mise.jdx.dev/) config and never touches a
|
|
118
|
+
project's pins:
|
|
112
119
|
|
|
113
120
|
```sh
|
|
114
|
-
mise use ruby@4.0
|
|
115
|
-
mise use gem:rigortype # or: gem install rigortype
|
|
121
|
+
mise use -g ruby@4.0 gem:rigortype # or: gem install rigortype
|
|
116
122
|
```
|
|
117
123
|
|
|
118
124
|
The gem is named `rigortype` (the name `rigor` was taken on RubyGems);
|
|
@@ -202,6 +208,27 @@ walks the whole type model; the
|
|
|
202
208
|
and [user manual](https://rigor.typedduck.fail/reference/manual/) are
|
|
203
209
|
the reference companions.
|
|
204
210
|
|
|
211
|
+
**Stuck on Rigor — or just curious how it works? Ask your agent in
|
|
212
|
+
plain language.** The whole skill surface collapses to two an agent (and
|
|
213
|
+
you) need to remember: **`rigor-next-steps`** ("what should we do
|
|
214
|
+
next?") and **`rigor-ask`** ("answer this about Rigor"). Rigor is niche
|
|
215
|
+
and fast-moving, so a model's *remembered* answer is often stale —
|
|
216
|
+
`rigor-ask` **investigates instead**: it reads Rigor's own handbook and
|
|
217
|
+
manual (bundled in the gem, served **offline** by `rigor docs`, always
|
|
218
|
+
matching your installed version) *and* runs Rigor over your actual code
|
|
219
|
+
(`rigor check` / `annotate` / `type-of`), then answers from what it
|
|
220
|
+
found — citing the page, or the inferred type. Ask *"why is this
|
|
221
|
+
flagged?"*, *"how does narrowing work?"*, *"how is it different from
|
|
222
|
+
Sorbet?"*, *"does it handle Sidekiq?"*, or *"how do I type this
|
|
223
|
+
method?"* — you only have to remember the question, never the command.
|
|
224
|
+
To browse the docs yourself:
|
|
225
|
+
|
|
226
|
+
```sh
|
|
227
|
+
rigor docs # the offline doc index
|
|
228
|
+
rigor docs handbook/03-narrowing # any handbook or manual page by name
|
|
229
|
+
rigor docs --list # list every bundled page
|
|
230
|
+
```
|
|
231
|
+
|
|
205
232
|
## Status
|
|
206
233
|
|
|
207
234
|
Current release: **`v0.2.0`** (2026-06-17) — the first
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# Getting started
|
|
2
|
+
|
|
3
|
+
By the end of this chapter you will be able to:
|
|
4
|
+
|
|
5
|
+
- get `rigor` onto your `PATH` (the fast AI-assisted way, or
|
|
6
|
+
by hand);
|
|
7
|
+
- run `rigor check` and read the diagnostics it prints;
|
|
8
|
+
- understand the "no annotations needed" stance that sets
|
|
9
|
+
Rigor apart from most checkers, and the escape hatches for
|
|
10
|
+
when inference falls short.
|
|
11
|
+
|
|
12
|
+
It is the only chapter you must read top to bottom. The rest
|
|
13
|
+
of the handbook is reference you can dip into later.
|
|
14
|
+
|
|
15
|
+
## Installing Rigor
|
|
16
|
+
|
|
17
|
+
Rigor is a tool, not a library — like a linter or a compiler, it
|
|
18
|
+
analyses your project but is not part of its runtime. **Do not add
|
|
19
|
+
it to your application's `Gemfile`.** Install it on its own and
|
|
20
|
+
point it at your project.
|
|
21
|
+
|
|
22
|
+
Rigor itself runs on Ruby 4.0, independently of the Ruby your own
|
|
23
|
+
code targets. The [`target_ruby:` config key](#the-config-file)
|
|
24
|
+
tells Rigor which Ruby *your* project runs.
|
|
25
|
+
|
|
26
|
+
### The fast path: let an AI agent set it up
|
|
27
|
+
|
|
28
|
+
If you work with an AI coding agent (Claude Code or any assistant
|
|
29
|
+
that supports [Agent Skills](https://agentskills.io/)), hand it
|
|
30
|
+
this prompt:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
Install Rigor in this project by following the instructions at
|
|
34
|
+
https://raw.githubusercontent.com/rigortype/rigor/refs/heads/master/docs/install.md
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The agent detects your environment, installs Rigor, then runs the
|
|
38
|
+
**`rigor-project-init` skill** — which walks your `Gemfile`,
|
|
39
|
+
proposes a plugin set matched to your framework, picks an adoption
|
|
40
|
+
mode, and writes `.rigor.dist.yml` for you. No manual YAML editing.
|
|
41
|
+
This is the recommended path; the [config file](#the-config-file)
|
|
42
|
+
section below shows what the skill produces so you can read and
|
|
43
|
+
tweak it afterwards.
|
|
44
|
+
|
|
45
|
+
The same prompt is available in sixteen languages in the
|
|
46
|
+
[Rails quickstart](../manual/14-rails-quickstart.md#step-1--install-ruby-40-and-rigor-common-to-both-paths).
|
|
47
|
+
|
|
48
|
+
### The manual path: mise
|
|
49
|
+
|
|
50
|
+
If you prefer to drive the setup yourself, the recommended runtime
|
|
51
|
+
version manager is [`mise`](https://mise.jdx.dev/), which
|
|
52
|
+
provisions both Ruby 4.0 and Rigor:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
mise use ruby@4.0
|
|
56
|
+
mise use gem:rigortype
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
With mise activated in your shell, `rigor` is on your `PATH`. The
|
|
60
|
+
gem is named `rigortype` (the name `rigor` was taken on RubyGems);
|
|
61
|
+
the executable it installs is `rigor`. If you already have Ruby
|
|
62
|
+
4.0, `gem install rigortype` works too.
|
|
63
|
+
|
|
64
|
+
For shell activation and shims, `asdf`, and developing inside a
|
|
65
|
+
container, see [Installing Rigor](../manual/01-installation.md);
|
|
66
|
+
for continuous integration, see
|
|
67
|
+
[Running Rigor in CI](../manual/11-ci.md).
|
|
68
|
+
|
|
69
|
+
## What does `rigor check` look at?
|
|
70
|
+
|
|
71
|
+
Rigor reads your `.rb` files, runs a flow-sensitive type
|
|
72
|
+
inference engine over each one, consults any `sig/*.rbs`
|
|
73
|
+
declarations available to your project, and reports a small
|
|
74
|
+
catalogue of bugs:
|
|
75
|
+
|
|
76
|
+
- methods called on the wrong receiver class;
|
|
77
|
+
- methods called with the wrong number of arguments;
|
|
78
|
+
- arithmetic that can be proved to raise (`5 / 0`);
|
|
79
|
+
- arguments whose type does not satisfy a refined parameter
|
|
80
|
+
contract;
|
|
81
|
+
- a few more, all listed in
|
|
82
|
+
[Chapter 8 — Understanding errors](08-understanding-errors.md).
|
|
83
|
+
|
|
84
|
+
Rigor does **not** ask you to write type annotations in
|
|
85
|
+
your Ruby source. It infers as much as it can, and stays
|
|
86
|
+
silent everywhere it cannot prove a narrower type.
|
|
87
|
+
A diagnostic only fires when Rigor has enough static
|
|
88
|
+
information to be confident.
|
|
89
|
+
|
|
90
|
+
## The smallest working session
|
|
91
|
+
|
|
92
|
+
Drop into your project root and run:
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
rigor check lib
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
That walks every `.rb` under `lib/`. When the analyzer finds
|
|
99
|
+
nothing to complain about, it prints `No diagnostics` and
|
|
100
|
+
exits `0`:
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
No diagnostics
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
When it does find something, each diagnostic is one line. Given
|
|
107
|
+
this file:
|
|
108
|
+
|
|
109
|
+
```ruby
|
|
110
|
+
# lib/demo.rb
|
|
111
|
+
"hello".no_such_method # typo'd method name
|
|
112
|
+
[1, 2, 3].rotate(1, 2) # too many arguments
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`rigor check lib/demo.rb` prints:
|
|
116
|
+
|
|
117
|
+
```text
|
|
118
|
+
lib/demo.rb:1:9: error: undefined method `no_such_method' for "hello" [call.undefined-method]
|
|
119
|
+
lib/demo.rb:2:11: error: wrong number of arguments to `rotate' on Array (given 2, expected 0..1) [call.wrong-arity]
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
To run on a single file, pass the file instead of a directory:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
rigor check path/to/file.rb
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
And to ask what Rigor inferred at one precise position:
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
rigor type-of lib/foo.rb:10:5
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
That prints both the rich Rigor type and the conservative
|
|
135
|
+
RBS erasure (the type a non-Rigor RBS tool would see). It is
|
|
136
|
+
the fastest way to ask "what does Rigor think this expression
|
|
137
|
+
produces?"
|
|
138
|
+
|
|
139
|
+
## Reading a diagnostic
|
|
140
|
+
|
|
141
|
+
Take the first line from the run above:
|
|
142
|
+
|
|
143
|
+
```text
|
|
144
|
+
lib/demo.rb:1:9: error: undefined method `no_such_method' for "hello" [call.undefined-method]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
| Slice | Meaning |
|
|
148
|
+
| --- | --- |
|
|
149
|
+
| `lib/demo.rb:1:9` | File, 1-indexed line, 1-indexed column |
|
|
150
|
+
| `error` | Severity (`error` / `warning` / `info`) |
|
|
151
|
+
| `undefined method ...` | Human-readable message |
|
|
152
|
+
| `[call.undefined-method]` | The qualified rule identifier |
|
|
153
|
+
|
|
154
|
+
The qualified rule identifier is the handle you use to silence,
|
|
155
|
+
demote, or look up a rule. The quickest is an in-source comment
|
|
156
|
+
on the offending line:
|
|
157
|
+
|
|
158
|
+
```ruby
|
|
159
|
+
"hello".no_such_method # rigor:disable call.undefined-method
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The same identifier also drives the `disable:` and
|
|
163
|
+
`severity_overrides:` config keys, and family wildcards work
|
|
164
|
+
(`# rigor:disable call` suppresses every `call.*` rule on that
|
|
165
|
+
line). The full list of families and rules, and when to reach
|
|
166
|
+
for each suppression mechanism, is in
|
|
167
|
+
[Chapter 8 — Understanding errors](08-understanding-errors.md).
|
|
168
|
+
|
|
169
|
+
## The "no annotations" stance
|
|
170
|
+
|
|
171
|
+
Most static checkers ask the user to annotate types. Rigor
|
|
172
|
+
does the opposite: it looks at what your Ruby code does and
|
|
173
|
+
**proves** types from the values themselves. Three quick
|
|
174
|
+
examples:
|
|
175
|
+
|
|
176
|
+
```ruby
|
|
177
|
+
n = 100
|
|
178
|
+
m = n + 1
|
|
179
|
+
assert_type("101", m) # arithmetic folds
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
```ruby
|
|
183
|
+
def kind(x)
|
|
184
|
+
case x
|
|
185
|
+
when Integer then :int
|
|
186
|
+
when String then :str
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
assert_type(":int | :str | nil", kind(7)) # union of all case branches
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
```ruby
|
|
193
|
+
greeting = "Hello, " # Constant<"Hello, ">
|
|
194
|
+
name = ARGV.first # String? (RBS-declared)
|
|
195
|
+
hello = "#{greeting}#{name}!" # literal-string carrier:
|
|
196
|
+
# every interpolated part
|
|
197
|
+
# is itself literal-string-
|
|
198
|
+
# compatible, so the result
|
|
199
|
+
# is "provably source-derived"
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
You did not write a single annotation. Rigor reasons about the
|
|
203
|
+
values directly.
|
|
204
|
+
|
|
205
|
+
> The `assert_type(...)` line is Rigor's introspection helper,
|
|
206
|
+
> not a runtime check — it pins the inferred type at that point
|
|
207
|
+
> so you can compare the prose to the analyzer's actual output.
|
|
208
|
+
> See [How to read this handbook](README.md#how-to-read-this-handbook)
|
|
209
|
+
> for the full snippet convention.
|
|
210
|
+
|
|
211
|
+
When inference cannot prove a narrower type, the engine
|
|
212
|
+
returns `Dynamic[top]` (the gradual carrier — "could be any
|
|
213
|
+
Ruby value") and stays silent. Rigor never invents
|
|
214
|
+
diagnostics it cannot prove.
|
|
215
|
+
|
|
216
|
+
## When inference is not enough
|
|
217
|
+
|
|
218
|
+
*First read? Skip this section.* Out of the box, inference plus
|
|
219
|
+
any RBS your gems already ship covers most code, and the next
|
|
220
|
+
chapters teach you to read what it produces. Come back here when
|
|
221
|
+
Rigor resolves something to `Dynamic[top]` that you wish it knew
|
|
222
|
+
more about. For most projects only escape hatches (1) and (2)
|
|
223
|
+
ever come up.
|
|
224
|
+
|
|
225
|
+
There are five escape hatches, in rough order of how often you
|
|
226
|
+
will need them:
|
|
227
|
+
|
|
228
|
+
1. **Add an `.rbs` file.** Drop a signature into `sig/` and
|
|
229
|
+
Rigor picks it up automatically. This is the most common
|
|
230
|
+
reason inference does not see further than the local
|
|
231
|
+
`def` — by default the analyzer treats every external gem
|
|
232
|
+
as `Dynamic[top]` unless the gem ships RBS or you
|
|
233
|
+
opt in to gem-source inference per (4) below.
|
|
234
|
+
2. **Tighten an existing RBS sig with `RBS::Extended`.** Add
|
|
235
|
+
a `%a{rigor:v1:return: non-empty-string}` annotation
|
|
236
|
+
above the method's `def ... -> ::String` line. Rigor
|
|
237
|
+
sees the refinement; ordinary RBS tools see a comment.
|
|
238
|
+
3. **Write a plugin.** When your project has a domain DSL
|
|
239
|
+
(`Lisp.eval`, `100.kilometers`, `transition_to(:foo)`)
|
|
240
|
+
that no general-purpose analyzer can know about, a
|
|
241
|
+
plugin teaches Rigor about it.
|
|
242
|
+
4. **Opt in to gem-source inference.** When a no-RBS gem's
|
|
243
|
+
methods would otherwise resolve to `Dynamic[top]`, list
|
|
244
|
+
the gem under `dependencies.source_inference:` in
|
|
245
|
+
`.rigor.dist.yml` and Rigor will walk its `lib/` the same way
|
|
246
|
+
it walks project source. Returns are wrapped in
|
|
247
|
+
`Dynamic[T]` so the call site retains the provenance.
|
|
248
|
+
See [ADR-10](../adr/10-dependency-source-inference.md)
|
|
249
|
+
for the trade-offs (per-gem opt-in by design — broad
|
|
250
|
+
defaults would inflate budgets and make `bundle update`
|
|
251
|
+
noisy).
|
|
252
|
+
5. **Use the `rigor-sorbet` adapter.** If your project
|
|
253
|
+
already uses [Sorbet](https://sorbet.org/), Rigor can
|
|
254
|
+
read your existing `sig { ... }` blocks, RBI files, and
|
|
255
|
+
`T.let` / `T.cast` / `T.must` / `T.unsafe` assertions
|
|
256
|
+
as type sources without rewriting anything. See
|
|
257
|
+
[Chapter 10](10-sorbet.md) for the migration patterns
|
|
258
|
+
and the translation table.
|
|
259
|
+
|
|
260
|
+
Chapters 7 and 9 cover (1)–(3) in detail; chapter 10 covers
|
|
261
|
+
(5).
|
|
262
|
+
|
|
263
|
+
## The config file
|
|
264
|
+
|
|
265
|
+
The minimum useful run needs no config file at all —
|
|
266
|
+
`rigor check lib` works out of the box. A config file is for
|
|
267
|
+
non-default behaviours: extra `paths`, an alternative
|
|
268
|
+
`severity_profile`, project-wide rule disables, plugins.
|
|
269
|
+
|
|
270
|
+
If you used the [AI-assisted setup](#the-fast-path-let-an-ai-agent-set-it-up),
|
|
271
|
+
the `rigor-project-init` skill already wrote one for you. To
|
|
272
|
+
write a starter by hand, `rigor init` emits `.rigor.dist.yml`
|
|
273
|
+
— the project default that gets committed:
|
|
274
|
+
|
|
275
|
+
```yaml
|
|
276
|
+
target_ruby: "3.4" # your project's Ruby — not Rigor's own 4.0
|
|
277
|
+
|
|
278
|
+
paths:
|
|
279
|
+
- lib
|
|
280
|
+
|
|
281
|
+
# signature_paths: [sig] # auto-detected when omitted
|
|
282
|
+
|
|
283
|
+
severity_profile: balanced
|
|
284
|
+
|
|
285
|
+
# severity_overrides:
|
|
286
|
+
# call.argument-type-mismatch: warning
|
|
287
|
+
|
|
288
|
+
# disable: []
|
|
289
|
+
|
|
290
|
+
# plugins: []
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
That is all most projects need. The remaining mechanics —
|
|
294
|
+
editor autocomplete from the bundled JSON schema, the
|
|
295
|
+
`.rigor.yml` vs `.rigor.dist.yml` precedence rule, `includes:`
|
|
296
|
+
composition, and how path-bearing keys resolve relative to the
|
|
297
|
+
declaring file — are covered in
|
|
298
|
+
[Configuration](../manual/03-configuration.md). The one rule
|
|
299
|
+
worth knowing up front: when a developer keeps a local
|
|
300
|
+
`.rigor.yml`, it is the *sole* source of config for their runs
|
|
301
|
+
(the two files are never merged automatically), so to extend
|
|
302
|
+
the shared default it must list it under `includes:`.
|
|
303
|
+
|
|
304
|
+
## What's next
|
|
305
|
+
|
|
306
|
+
Chapter 2 introduces the carriers Rigor uses to represent
|
|
307
|
+
types — the part of the model that distinguishes Rigor from
|
|
308
|
+
ordinary RBS. After that, Chapter 3 (narrowing) makes the
|
|
309
|
+
carriers come alive: the carriers describe values, and
|
|
310
|
+
narrowing describes how those carriers change as control
|
|
311
|
+
flow passes through `if` / `case` / predicate methods.
|