rigortype 0.4.8 → 0.4.9
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 +1 -1
- data/docs/handbook/01-getting-started.md +1 -1
- data/docs/handbook/04-tuples-and-shapes.md +6 -1
- data/docs/handbook/12-lightweight-hkt.md +1 -1
- data/docs/handbook/appendix-typescript.md +28 -17
- data/docs/manual/02-cli-reference.md +10 -0
- data/docs/manual/03-configuration.md +1 -1
- data/docs/manual/04-diagnostics.md +1 -1
- data/docs/manual/10-mcp-server.md +122 -10
- data/docs/manual/plugins/rigor-activerecord.md +7 -0
- data/lib/rigor/analysis/check_rules/always_raises.rb +95 -0
- data/lib/rigor/analysis/check_rules/always_truthy_condition_collector.rb +32 -2
- data/lib/rigor/analysis/check_rules/argument_type.rb +802 -0
- data/lib/rigor/analysis/check_rules/call_facts.rb +2 -2
- data/lib/rigor/analysis/check_rules/dead_assignment_collector.rb +30 -1
- data/lib/rigor/analysis/check_rules/declaration_sourced_guard.rb +4 -5
- data/lib/rigor/analysis/check_rules/duplicate_hash_key_collector.rb +34 -0
- data/lib/rigor/analysis/check_rules/ivar_write_collector.rb +131 -4
- data/lib/rigor/analysis/check_rules/nil_receiver.rb +195 -0
- data/lib/rigor/analysis/check_rules/override_param_narrowed.rb +111 -0
- data/lib/rigor/analysis/check_rules/override_return_widened.rb +88 -0
- data/lib/rigor/analysis/check_rules/override_support.rb +246 -0
- data/lib/rigor/analysis/check_rules/override_visibility.rb +135 -0
- data/lib/rigor/analysis/check_rules/published_constant_guard.rb +75 -31
- data/lib/rigor/analysis/check_rules/raise_non_exception.rb +198 -0
- data/lib/rigor/analysis/check_rules/receiver_predicates.rb +576 -0
- data/lib/rigor/analysis/check_rules/return_in_ensure_collector.rb +52 -4
- data/lib/rigor/analysis/check_rules/return_type.rb +225 -0
- data/lib/rigor/analysis/check_rules/rigor_testing.rb +119 -0
- data/lib/rigor/analysis/check_rules/rule_ids.rb +7 -7
- data/lib/rigor/analysis/check_rules/rule_walk.rb +4 -3
- data/lib/rigor/analysis/check_rules/self_closedness_scanner.rb +2 -0
- data/lib/rigor/analysis/check_rules/self_undefined_method.rb +165 -0
- data/lib/rigor/analysis/check_rules/shadowed_rescue_collector.rb +34 -0
- data/lib/rigor/analysis/check_rules/source_arity.rb +2 -2
- data/lib/rigor/analysis/check_rules/special_global_write.rb +256 -0
- data/lib/rigor/analysis/check_rules/suppression.rb +275 -0
- data/lib/rigor/analysis/check_rules/undefined_method.rb +882 -0
- data/lib/rigor/analysis/check_rules/unreachable_branch.rb +97 -0
- data/lib/rigor/analysis/check_rules/unreachable_clause_collector.rb +42 -0
- data/lib/rigor/analysis/check_rules/unresolved_toplevel.rb +140 -0
- data/lib/rigor/analysis/check_rules/visibility_mismatch.rb +252 -0
- data/lib/rigor/analysis/check_rules/void_value_use_collector.rb +27 -0
- data/lib/rigor/analysis/check_rules/wrong_arity.rb +303 -0
- data/lib/rigor/analysis/check_rules.rb +66 -4931
- data/lib/rigor/analysis/dependency_recorder.rb +1 -1
- data/lib/rigor/analysis/dependency_source_inference/builder.rb +2 -4
- data/lib/rigor/analysis/dependency_source_inference/gem_resolver.rb +1 -2
- data/lib/rigor/analysis/dependency_source_inference/walker.rb +15 -15
- data/lib/rigor/analysis/incremental_session.rb +4 -4
- data/lib/rigor/analysis/path_expansion.rb +1 -1
- data/lib/rigor/analysis/plugin_fact_fingerprint.rb +5 -5
- data/lib/rigor/analysis/reachability/graph.rb +2 -3
- data/lib/rigor/analysis/reachability/plugin_roots.rb +2 -2
- data/lib/rigor/analysis/reachability/scan.rb +2 -2
- data/lib/rigor/analysis/rule_catalog.rb +2 -1
- data/lib/rigor/analysis/run_cache_key.rb +9 -8
- data/lib/rigor/analysis/runner/buffer_pool_dispatcher.rb +2 -2
- data/lib/rigor/analysis/runner/dependency_rows.rb +206 -0
- data/lib/rigor/analysis/runner/diagnostic_aggregator.rb +24 -22
- data/lib/rigor/analysis/runner/effect_cache_entries.rb +69 -0
- data/lib/rigor/analysis/runner/pool_coordinator.rb +6 -8
- data/lib/rigor/analysis/runner/project_pre_passes.rb +3 -5
- data/lib/rigor/analysis/runner/scope_seed.rb +144 -0
- data/lib/rigor/analysis/runner.rb +49 -296
- data/lib/rigor/analysis/template_unit_collector.rb +1 -1
- data/lib/rigor/analysis/template_units.rb +10 -10
- data/lib/rigor/analysis/worker_session.rb +7 -7
- data/lib/rigor/bleeding_edge.rb +3 -2
- data/lib/rigor/builtins/hkt_builtins.rb +17 -17
- data/lib/rigor/builtins/imported_refinements.rb +8 -16
- data/lib/rigor/builtins/regex_refinement.rb +3 -3
- data/lib/rigor/builtins/static_return_refinements.rb +143 -19
- data/lib/rigor/cache/incremental_snapshot.rb +21 -8
- data/lib/rigor/cache/rbs_descriptor.rb +18 -1
- data/lib/rigor/cli/coverage_renderer.rb +15 -1
- data/lib/rigor/cli/coverage_report.rb +19 -1
- data/lib/rigor/cli/diagnostic_formats.rb +3 -2
- data/lib/rigor/cli/docs_command.rb +5 -5
- data/lib/rigor/cli/effects_command.rb +7 -6
- data/lib/rigor/cli/fused_protection_report.rb +7 -7
- data/lib/rigor/cli/lsp_command.rb +1 -1
- data/lib/rigor/cli/mcp_command.rb +5 -2
- data/lib/rigor/cli/options.rb +4 -0
- data/lib/rigor/cli/plugins_command.rb +1 -1
- data/lib/rigor/cli/sig_gen_command.rb +1 -1
- data/lib/rigor/cli/skill_command.rb +5 -4
- data/lib/rigor/cli/triage_renderer.rb +3 -2
- data/lib/rigor/cli/unused_command.rb +4 -4
- data/lib/rigor/cli.rb +14 -0
- data/lib/rigor/configuration/coercion.rb +418 -0
- data/lib/rigor/configuration/defaults.rb +248 -0
- data/lib/rigor/configuration/dependencies.rb +1 -1
- data/lib/rigor/configuration/loader.rb +354 -0
- data/lib/rigor/configuration/severity_profile.rb +4 -4
- data/lib/rigor/configuration.rb +51 -860
- data/lib/rigor/effects/attribution.rb +1 -1
- data/lib/rigor/effects/effect_table.rb +1 -1
- data/lib/rigor/effects/identity.rb +3 -3
- data/lib/rigor/effects/local_ownership.rb +2 -2
- data/lib/rigor/effects/snapshot.rb +1 -1
- data/lib/rigor/effects/summary.rb +5 -4
- data/lib/rigor/environment/member_consistency.rb +10 -0
- data/lib/rigor/environment/rbs_loader.rb +19 -22
- data/lib/rigor/environment/reflection.rb +1 -1
- data/lib/rigor/environment/unreadable_signature.rb +21 -0
- data/lib/rigor/environment.rb +8 -8
- data/lib/rigor/flow_contribution/merger.rb +1 -0
- data/lib/rigor/hashing/xxh3.rb +1 -1
- data/lib/rigor/inference/acceptance.rb +23 -2
- data/lib/rigor/inference/alias_mutation_floor/site_collector.rb +5 -0
- data/lib/rigor/inference/alias_mutation_floor.rb +0 -5
- data/lib/rigor/inference/anonymous_meta_class.rb +2 -2
- data/lib/rigor/inference/block_call_timing.rb +6 -0
- data/lib/rigor/inference/budget_trace.rb +3 -2
- data/lib/rigor/inference/builtins/date_catalog.rb +3 -3
- data/lib/rigor/inference/builtins/method_catalog.rb +3 -3
- data/lib/rigor/inference/builtins/time_catalog.rb +3 -3
- data/lib/rigor/inference/call_ladder/literal_send.rb +98 -0
- data/lib/rigor/inference/call_ladder/overriding_def.rb +98 -0
- data/lib/rigor/inference/call_ladder/project_singleton.rb +362 -0
- data/lib/rigor/inference/call_ladder/refined.rb +212 -0
- data/lib/rigor/inference/call_ladder/top_level_def.rb +222 -0
- data/lib/rigor/inference/call_ladder/user_method.rb +247 -0
- data/lib/rigor/inference/call_ladder.rb +219 -0
- data/lib/rigor/inference/callee_write_census.rb +2 -2
- data/lib/rigor/inference/captured_locals.rb +2 -2
- data/lib/rigor/inference/clause_widening.rb +63 -1
- data/lib/rigor/inference/declaration_walk/context.rb +12 -12
- data/lib/rigor/inference/declaration_walk/rules.rb +750 -0
- data/lib/rigor/inference/declaration_walk/traversal.rb +9 -8
- data/lib/rigor/inference/declaration_walk.rb +4 -3
- data/lib/rigor/inference/def_node_resolver.rb +2 -2
- data/lib/rigor/inference/def_return_typer.rb +14 -6
- data/lib/rigor/inference/deferred_mutation.rb +120 -0
- data/lib/rigor/inference/define_method_block_self.rb +1 -1
- data/lib/rigor/inference/definer_resolution.rb +4 -4
- data/lib/rigor/inference/error_info.rb +8 -8
- data/lib/rigor/inference/expression_typer/composites.rb +348 -0
- data/lib/rigor/inference/expression_typer/per_element_assemblers.rb +233 -0
- data/lib/rigor/inference/expression_typer/writes.rb +218 -0
- data/lib/rigor/inference/expression_typer.rb +275 -1825
- data/lib/rigor/inference/external_ancestor_resolution.rb +2 -2
- data/lib/rigor/inference/fallback.rb +1 -0
- data/lib/rigor/inference/for_yield_slots.rb +126 -0
- data/lib/rigor/inference/genuine_send.rb +92 -0
- data/lib/rigor/inference/global_write_census.rb +2 -2
- data/lib/rigor/inference/hkt_body.rb +2 -0
- data/lib/rigor/inference/in_effect_refinements/walk.rb +2 -2
- data/lib/rigor/inference/index_write_widening.rb +4 -4
- data/lib/rigor/inference/indexed_narrowing.rb +1 -1
- data/lib/rigor/inference/intervening_ivar_reset.rb +46 -9
- data/lib/rigor/inference/ivar_writer_census.rb +1 -1
- data/lib/rigor/inference/loop_store_sites.rb +239 -0
- data/lib/rigor/inference/macro_block_self_type.rb +4 -3
- data/lib/rigor/inference/method_dispatcher/block_folding.rb +3 -2
- data/lib/rigor/inference/method_dispatcher/call_context.rb +84 -14
- data/lib/rigor/inference/method_dispatcher/composite_receiver.rb +144 -0
- data/lib/rigor/inference/method_dispatcher/constant_folding.rb +7 -5
- data/lib/rigor/inference/method_dispatcher/declared_constructor.rb +1 -1
- data/lib/rigor/inference/method_dispatcher/dependency_source.rb +90 -0
- data/lib/rigor/inference/method_dispatcher/discovered_method.rb +78 -0
- data/lib/rigor/inference/method_dispatcher/file_folding.rb +2 -2
- data/lib/rigor/inference/method_dispatcher/hkt_builtin_return.rb +40 -0
- data/lib/rigor/inference/method_dispatcher/iterator_dispatch.rb +1 -6
- data/lib/rigor/inference/method_dispatcher/literal_string_folding.rb +4 -2
- data/lib/rigor/inference/method_dispatcher/match_data_folding.rb +1 -1
- data/lib/rigor/inference/method_dispatcher/meta_introspection.rb +506 -0
- data/lib/rigor/inference/method_dispatcher/overload_selector.rb +2 -0
- data/lib/rigor/inference/method_dispatcher/plugin_contribution.rb +134 -0
- data/lib/rigor/inference/method_dispatcher/project_patched.rb +134 -0
- data/lib/rigor/inference/method_dispatcher/rbs_dispatch.rb +125 -43
- data/lib/rigor/inference/method_dispatcher/reduce_folding.rb +3 -4
- data/lib/rigor/inference/method_dispatcher/regexp_folding.rb +1 -1
- data/lib/rigor/inference/method_dispatcher/set_folding.rb +1 -1
- data/lib/rigor/inference/method_dispatcher/shape_dispatch.rb +19 -6
- data/lib/rigor/inference/method_dispatcher/singleton_folding.rb +3 -3
- data/lib/rigor/inference/method_dispatcher/singleton_mixin_dispatch.rb +7 -4
- data/lib/rigor/inference/method_dispatcher/static_refinement.rb +106 -0
- data/lib/rigor/inference/method_dispatcher/synthesized_stub.rb +41 -0
- data/lib/rigor/inference/method_dispatcher/synthetic_method_dispatch.rb +133 -0
- data/lib/rigor/inference/method_dispatcher/universal_object_dispatch.rb +2 -1
- data/lib/rigor/inference/method_dispatcher/user_class_fallback.rb +216 -0
- data/lib/rigor/inference/method_dispatcher.rb +175 -1361
- data/lib/rigor/inference/method_parameter_binder.rb +18 -18
- data/lib/rigor/inference/module_function_state.rb +5 -4
- data/lib/rigor/inference/mutation_widening.rb +20 -7
- data/lib/rigor/inference/narrowing/case_literals.rb +58 -0
- data/lib/rigor/inference/narrowing/class_dispatch.rb +302 -0
- data/lib/rigor/inference/narrowing/complements.rb +322 -0
- data/lib/rigor/inference/narrowing/presence_predicates.rb +205 -0
- data/lib/rigor/inference/narrowing/regex_match.rb +499 -0
- data/lib/rigor/inference/narrowing.rb +86 -1269
- data/lib/rigor/inference/object_mixins.rb +2 -2
- data/lib/rigor/inference/opaque_mutation.rb +214 -0
- data/lib/rigor/inference/optimistic_origin.rb +52 -14
- data/lib/rigor/inference/parameter_inference_collector.rb +1 -1
- data/lib/rigor/inference/pre_eval_constants.rb +11 -9
- data/lib/rigor/inference/precision_scanner.rb +27 -2
- data/lib/rigor/inference/project_patched_methods.rb +3 -3
- data/lib/rigor/inference/range_constant.rb +3 -3
- data/lib/rigor/inference/rbs_type_translator.rb +2 -2
- data/lib/rigor/inference/refine_self.rb +8 -7
- data/lib/rigor/inference/refined_dispatch.rb +2 -2
- data/lib/rigor/inference/return_barrier.rb +24 -9
- data/lib/rigor/inference/scope_indexer/alias_def_nodes.rb +311 -0
- data/lib/rigor/inference/scope_indexer/census_scope.rb +47 -0
- data/lib/rigor/inference/scope_indexer/certainty.rb +2 -2
- data/lib/rigor/inference/scope_indexer/class_cvar_census.rb +282 -0
- data/lib/rigor/inference/scope_indexer/class_cvars_collector.rb +12 -5
- data/lib/rigor/inference/scope_indexer/class_declarations.rb +228 -0
- data/lib/rigor/inference/scope_indexer/class_ivar_index.rb +2028 -0
- data/lib/rigor/inference/scope_indexer/constant_ivar_value.rb +4 -3
- data/lib/rigor/inference/scope_indexer/constant_tables.rb +844 -0
- data/lib/rigor/inference/scope_indexer/cvar_hierarchy.rb +159 -0
- data/lib/rigor/inference/scope_indexer/declaration_artifacts.rb +219 -0
- data/lib/rigor/inference/scope_indexer/declaration_signature.rb +212 -0
- data/lib/rigor/inference/scope_indexer/def_nestings_collector.rb +2 -2
- data/lib/rigor/inference/scope_indexer/factory_call_resolver.rb +53 -0
- data/lib/rigor/inference/scope_indexer/literal_receiver_mutations.rb +266 -0
- data/lib/rigor/inference/scope_indexer/member_layouts_collector.rb +8 -7
- data/lib/rigor/inference/scope_indexer/mixin_accumulator.rb +1 -1
- data/lib/rigor/inference/scope_indexer/mixin_effects.rb +470 -0
- data/lib/rigor/inference/scope_indexer/mixin_tables.rb +388 -0
- data/lib/rigor/inference/scope_indexer/mutated_carrier_widening.rb +163 -0
- data/lib/rigor/inference/scope_indexer/mutated_element_census.rb +211 -0
- data/lib/rigor/inference/scope_indexer/node_propagation.rb +520 -0
- data/lib/rigor/inference/scope_indexer/program_globals.rb +154 -0
- data/lib/rigor/inference/scope_indexer/published_constant_cvars.rb +146 -0
- data/lib/rigor/inference/scope_indexer/published_constant_ivars.rb +181 -0
- data/lib/rigor/inference/scope_indexer/shared_walk_tables.rb +823 -0
- data/lib/rigor/inference/scope_indexer/singleton_class_sources.rb +85 -0
- data/lib/rigor/inference/scope_indexer/superclasses_collector.rb +5 -5
- data/lib/rigor/inference/scope_indexer.rb +2657 -9558
- data/lib/rigor/inference/self_call_ivar_writes.rb +22 -3
- data/lib/rigor/inference/set_mutation.rb +2 -2
- data/lib/rigor/inference/singleton_hook_definers.rb +185 -0
- data/lib/rigor/inference/statement_evaluator/def_arguments_and_assertions.rb +365 -0
- data/lib/rigor/inference/statement_evaluator/pattern_bindings.rb +581 -0
- data/lib/rigor/inference/statement_evaluator.rb +201 -1008
- data/lib/rigor/inference/synthetic_method_scanner.rb +0 -3
- data/lib/rigor/language_server/completion_provider.rb +8 -8
- data/lib/rigor/language_server/diagnostic_publisher.rb +6 -7
- data/lib/rigor/language_server/document_symbol_provider.rb +4 -6
- data/lib/rigor/language_server/folding_range_provider.rb +3 -3
- data/lib/rigor/language_server/hover_provider.rb +2 -2
- data/lib/rigor/language_server/loop.rb +2 -2
- data/lib/rigor/language_server/server.rb +3 -2
- data/lib/rigor/language_server/signature_help_provider.rb +7 -9
- data/lib/rigor/lens/document.rb +10 -1
- data/lib/rigor/lens/file_reader.rb +2 -1
- data/lib/rigor/mcp/loop.rb +48 -6
- data/lib/rigor/mcp/server.rb +248 -23
- data/lib/rigor/mcp/skill_catalog.rb +157 -0
- data/lib/rigor/plugin/base.rb +22 -4
- data/lib/rigor/plugin/effect_attribution.rb +1 -1
- data/lib/rigor/plugin/inflector.rb +2 -2
- data/lib/rigor/plugin/io_boundary.rb +1 -1
- data/lib/rigor/plugin/loader.rb +4 -4
- data/lib/rigor/plugin/macro/heredoc_template.rb +4 -3
- data/lib/rigor/plugin/optimistic_return.rb +20 -0
- data/lib/rigor/plugin/registry.rb +2 -2
- data/lib/rigor/plugin/template_unit.rb +4 -2
- data/lib/rigor/plugin/trust_policy.rb +2 -1
- data/lib/rigor/plugin.rb +1 -1
- data/lib/rigor/protection/mutator.rb +8 -9
- data/lib/rigor/rbs_extended/reporter.rb +2 -2
- data/lib/rigor/rbs_extended.rb +2 -2
- data/lib/rigor/reflection/constant_ancestors.rb +1 -1
- data/lib/rigor/reflection/project_method.rb +2 -2
- data/lib/rigor/reflection.rb +4 -4
- data/lib/rigor/scope/discovery_index.rb +15 -10
- data/lib/rigor/scope/resolution_chain.rb +29 -6
- data/lib/rigor/scope.rb +89 -32
- data/lib/rigor/sig_gen/generator.rb +5 -4
- data/lib/rigor/sig_gen/renderer.rb +3 -3
- data/lib/rigor/sig_gen/writer.rb +8 -6
- data/lib/rigor/source/parameter_envelope.rb +1 -1
- data/lib/rigor/triage/catalogue.rb +4 -4
- data/lib/rigor/type/combinator.rb +2 -2
- data/lib/rigor/type/data_instance.rb +2 -2
- data/lib/rigor/type/struct_instance.rb +3 -3
- data/lib/rigor/type_node/generic.rb +2 -1
- data/lib/rigor/type_of_memo.rb +2 -1
- data/lib/rigor/typing_state.rb +3 -2
- data/lib/rigor/version.rb +1 -1
- data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable/analyzer.rb +2 -2
- data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable/channel_discoverer.rb +1 -1
- data/plugins/rigor-actionmailer/lib/rigor/plugin/actionmailer/mailer_discoverer.rb +4 -4
- data/plugins/rigor-actionmailer/lib/rigor/plugin/actionmailer.rb +1 -1
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/controller_discoverer.rb +4 -3
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/effects.rb +7 -5
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/erb_compiler.rb +4 -2
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/render_locals.rb +1 -1
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/view_assigns.rb +3 -2
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack.rb +7 -7
- data/plugins/rigor-activejob/lib/rigor/plugin/activejob/job_discoverer.rb +1 -1
- data/plugins/rigor-activejob/lib/rigor/plugin/activejob.rb +2 -2
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/model_discoverer.rb +9 -8
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/model_index.rb +3 -2
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/schema_parser.rb +15 -7
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/schema_table.rb +10 -3
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/structure_sql_parser.rb +12 -1
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord.rb +20 -5
- data/plugins/rigor-activestorage/lib/rigor/plugin/activestorage/attachment_discoverer.rb +1 -1
- data/plugins/rigor-activestorage/lib/rigor/plugin/activestorage.rb +3 -2
- data/plugins/rigor-activesupport-core-ext/lib/rigor/plugin/activesupport_core_ext/effects.rb +1 -1
- data/plugins/rigor-activesupport-core-ext/lib/rigor/plugin/activesupport_core_ext.rb +8 -7
- data/plugins/rigor-dry-schema/lib/rigor/plugin/dry_schema.rb +1 -1
- data/plugins/rigor-dry-types/lib/rigor/plugin/dry_types/alias_scanner.rb +1 -1
- data/plugins/rigor-dry-types/lib/rigor/plugin/dry_types.rb +6 -7
- data/plugins/rigor-factorybot/lib/rigor/plugin/factorybot/factory_discoverer.rb +3 -2
- data/plugins/rigor-graphql/lib/rigor/plugin/graphql/type_scanner.rb +4 -3
- data/plugins/rigor-hanami/lib/rigor/plugin/hanami.rb +4 -2
- data/plugins/rigor-minitest/lib/rigor/plugin/minitest.rb +1 -1
- data/plugins/rigor-pundit/lib/rigor/plugin/pundit.rb +1 -1
- data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n/analyzer.rb +5 -3
- data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n.rb +1 -1
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/devise_routes.rb +4 -5
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/doorkeeper_routes.rb +2 -2
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/helper_discoverer.rb +5 -4
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/helper_table.rb +3 -2
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/routes_parser.rb +30 -31
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes.rb +13 -15
- data/plugins/rigor-rbnacl/lib/rigor/plugin/rbnacl.rb +1 -1
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec/let_scope_index.rb +4 -3
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec/matcher_analyzer.rb +16 -13
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec/scope_walker.rb +3 -2
- data/plugins/rigor-shoulda-matchers/lib/rigor/plugin/shoulda_matchers/analyzer.rb +6 -6
- data/plugins/rigor-sidekiq/lib/rigor/plugin/sidekiq/analyzer.rb +3 -3
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/assertion_recognizer.rb +2 -2
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/catalog.rb +3 -2
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/catalog_walker.rb +6 -5
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/sig_parser.rb +2 -2
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/sigil_detector.rb +4 -5
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/type_translator.rb +1 -1
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet.rb +3 -4
- data/sig/rigor/analysis/check_rules/suppression.rbs +9 -0
- data/sig/rigor/analysis/dependency_recorder.rbs +9 -0
- data/sig/rigor/inference.rbs +275 -11
- data/sig/rigor/plugin/base.rbs +14 -5
- data/sig/rigor/plugin/optimistic_return.rbs +16 -0
- data/sig/rigor/scope.rbs +7 -1
- data/sig/rigor/source.rbs +4 -0
- data/skills/rigor-mcp-setup/SKILL.md +20 -6
- data/skills/rigor-plugin-review/SKILL.md +3 -3
- data/skills/rigor-type-oracle/references/01-oracle-commands.md +1 -1
- metadata +90 -3
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "prism"
|
|
4
|
+
require_relative "../../reflection"
|
|
5
|
+
require_relative "../../rbs_extended"
|
|
6
|
+
require_relative "../../scope"
|
|
7
|
+
require_relative "../../scope/discovery_index"
|
|
8
|
+
require_relative "../../type"
|
|
9
|
+
require_relative "../diagnostic"
|
|
10
|
+
require_relative "receiver_predicates"
|
|
11
|
+
require_relative "rule_ids"
|
|
12
|
+
require_relative "source_arity"
|
|
13
|
+
|
|
14
|
+
module Rigor
|
|
15
|
+
module Analysis
|
|
16
|
+
module CheckRules
|
|
17
|
+
# ADR-116 WD1 — `call.wrong-arity` (slice 7 phase 11): an explicit-receiver call whose positional
|
|
18
|
+
# argument count falls outside the envelope of the declared signature, or (issue #992) of the project
|
|
19
|
+
# `def` when no signature declares the method.
|
|
20
|
+
#
|
|
21
|
+
# The entry point is {.diagnostic}, called by `CheckRules.call_node_diagnostics`.
|
|
22
|
+
# {.plain_positional_call?} is public because `CheckRules`' argument-type rule applies the same
|
|
23
|
+
# call-shape test. It reads {ReceiverPredicates} and {SourceArity} (the project-`def` envelope walk),
|
|
24
|
+
# and calls nothing in `CheckRules`.
|
|
25
|
+
module WrongArity
|
|
26
|
+
module_function
|
|
27
|
+
|
|
28
|
+
# Slice 7 phase 11 — wrong-arity diagnostic. Fires when
|
|
29
|
+
# an explicit-receiver `Prism::CallNode` resolves to a
|
|
30
|
+
# method whose declared overloads do not admit the
|
|
31
|
+
# supplied positional argument count (across all
|
|
32
|
+
# overloads, see {#compute_arity_envelope}). One overload
|
|
33
|
+
# with required keyword arguments or trailing positionals
|
|
34
|
+
# leaves the whole method unchecked; calls with `*splat`, keyword, or
|
|
35
|
+
# block-pass arguments are silently skipped to avoid
|
|
36
|
+
# false positives. The check piggybacks on the same
|
|
37
|
+
# scope-index lookup used by `undefined_method_diagnostic`;
|
|
38
|
+
# it returns nil when the call's receiver / RBS coverage /
|
|
39
|
+
# call shape disqualifies the rule.
|
|
40
|
+
# rubocop:disable-next Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
41
|
+
def diagnostic(path, call_node, facts, lexical_sites = nil)
|
|
42
|
+
return nil if call_node.receiver.nil?
|
|
43
|
+
return nil unless plain_positional_call?(call_node)
|
|
44
|
+
|
|
45
|
+
scope = facts.scope
|
|
46
|
+
return nil if scope.nil?
|
|
47
|
+
|
|
48
|
+
# ADR-67 WD6b — an inferred-parameter receiver's type is an open-call-site lower bound; a wrong-arity
|
|
49
|
+
# firing against it is an FP by construction. Decline.
|
|
50
|
+
return nil if ReceiverPredicates.inferred_param_receiver?(call_node, scope)
|
|
51
|
+
|
|
52
|
+
receiver_type = facts.receiver_type
|
|
53
|
+
class_name = ReceiverPredicates.concrete_class_name(receiver_type)
|
|
54
|
+
return nil if class_name.nil?
|
|
55
|
+
|
|
56
|
+
# Issue #879 — the receiver whose surface `call.undefined-method` already refuses to enumerate.
|
|
57
|
+
# Deciding an arity against a declaration this rule cannot prove the receiver actually runs is the
|
|
58
|
+
# same unsoundness in signature form: the includer may declare the name with a wider arity, and
|
|
59
|
+
# then the call is correct code.
|
|
60
|
+
return nil if ReceiverPredicates.unenumerable_receiver_shape?(receiver_type, class_name, scope)
|
|
61
|
+
|
|
62
|
+
kind = receiver_type.is_a?(Type::Singleton) ? :singleton : :instance
|
|
63
|
+
# `Struct.new(:a, :b).new(...)` chained: the inner
|
|
64
|
+
# `Struct.new(...)` is an anonymous Struct *subclass* whose
|
|
65
|
+
# `.new` accepts any positional arity (one slot per member,
|
|
66
|
+
# all defaulting to nil) — including zero. The receiver types
|
|
67
|
+
# as `Singleton[Struct]` (so the call-site `.new` dispatches,
|
|
68
|
+
# per the dispatcher's `struct_new_lift`), but validating that
|
|
69
|
+
# `.new` against the real `Struct.new(*Symbol)` signature is a
|
|
70
|
+
# false positive. Skip arity-checking the chained position.
|
|
71
|
+
return nil if anonymous_struct_new_call?(call_node, class_name, kind)
|
|
72
|
+
|
|
73
|
+
arity_envelope = arity_envelope_for(facts, class_name, kind)
|
|
74
|
+
return nil if arity_envelope.nil?
|
|
75
|
+
|
|
76
|
+
actual = (call_node.arguments&.arguments || []).size
|
|
77
|
+
min, max, source_arity = arity_envelope
|
|
78
|
+
if actual.between?(min, max)
|
|
79
|
+
source_arity&.settle_by_definitions
|
|
80
|
+
return nil
|
|
81
|
+
end
|
|
82
|
+
return nil if arity_report_withheld?(source_arity, class_name, call_node, scope, kind, lexical_sites)
|
|
83
|
+
|
|
84
|
+
build_arity_diagnostic(path, call_node, class_name, min, max, actual)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# The declines `call.wrong-arity` asks only once the arity is out of the envelope.
|
|
88
|
+
def arity_report_withheld?(source_arity, class_name, call_node, scope, kind, lexical_sites)
|
|
89
|
+
# Issue #992 — a source envelope's remaining declines can only withhold, so they run only now.
|
|
90
|
+
source_arity&.settle_by_walk
|
|
91
|
+
return true if source_arity && !source_arity.authoritative?(class_name)
|
|
92
|
+
|
|
93
|
+
ReceiverPredicates.refined_redefinition_in_effect?(class_name, call_node, scope, kind, lexical_sites)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# The `[min, max]` the call is checked against — a declared signature's, or (issue #992) the project
|
|
97
|
+
# `def`'s own when no signature declares the method, with the {SourceArity} that found it as a third
|
|
98
|
+
# element — or nil when neither may be trusted.
|
|
99
|
+
#
|
|
100
|
+
# Issue #991 — `discovered_method?` used to exempt the call outright before ever asking for a
|
|
101
|
+
# declaration. `trustworthy_signature` is the same lookup `ArgumentType.diagnostic` treats as
|
|
102
|
+
# authoritative over a source `def` (see its own comment beside that call), and the two rules must agree
|
|
103
|
+
# on whose contract binds, so a declared method is checked against its declaration.
|
|
104
|
+
def arity_envelope_for(facts, class_name, kind)
|
|
105
|
+
receiver_type = facts.receiver_type
|
|
106
|
+
call_node = facts.call_node
|
|
107
|
+
scope = facts.scope
|
|
108
|
+
if Rigor::Reflection.rbs_class_known?(class_name, scope: scope)
|
|
109
|
+
return nil unless ReceiverPredicates.definition_available?(receiver_type, class_name, scope)
|
|
110
|
+
|
|
111
|
+
method_def = ReceiverPredicates.receiver_signature(facts)
|
|
112
|
+
if method_def && !Rigor::RbsExtended.inferred_signature?(method_def)
|
|
113
|
+
return nil if undeclared_constructor?(class_name, call_node, kind, method_def)
|
|
114
|
+
|
|
115
|
+
return compute_arity_envelope(method_def)
|
|
116
|
+
end
|
|
117
|
+
return nil unless source_lane_open?(method_def, receiver_type, class_name, call_node, scope)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
source_arity_envelope(class_name, call_node, scope, kind)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Issue #992 — whether a class RBS knows may still be checked against its project `def`. Two lanes:
|
|
124
|
+
#
|
|
125
|
+
# - the member resolved and carries `%a{rigor:v1:inferred-signature}`: under ADR-93 the bundled
|
|
126
|
+
# `rigor-rbs-inline` plugin emits a full skeleton for EVERY `def` in a file carrying at least one
|
|
127
|
+
# annotation (#823), with every type slot defaulted, so nobody asserted anything about it. Its arity
|
|
128
|
+
# is NOT read here — the `def`'s envelope is, through the same {SourceArity} walk as a method with no
|
|
129
|
+
# member at all, so one `def` is never judged by two readings of its parameter list;
|
|
130
|
+
# - no member resolved, and the class's declaration is the project's own `sig/`
|
|
131
|
+
# (`project_declared_class?`): a partial sidecar of a project class whose `def` lives in source.
|
|
132
|
+
#
|
|
133
|
+
# Everything else declines. A bundled declaration (core / stdlib / gem) describes a class the project
|
|
134
|
+
# does not own, so a project `def` on it is an ADR-17 monkey-patch that another library may patch too;
|
|
135
|
+
# a lookup that raised, or a name an open receiver only inherited (`trustworthy_signature` answered
|
|
136
|
+
# nil for those while a raw lookup does not), is not "no member".
|
|
137
|
+
def source_lane_open?(method_def, receiver_type, class_name, call_node, scope)
|
|
138
|
+
return true if method_def
|
|
139
|
+
|
|
140
|
+
ReceiverPredicates.lookup_method(receiver_type, class_name, call_node.name, scope).nil? &&
|
|
141
|
+
Rigor::Reflection.project_declared_class?(class_name, scope: scope)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Issue #992 — stage 1 of {SourceArity}: the nearest project definition's envelope, after the
|
|
145
|
+
# receiver-level declines that need no walk. Stage 2 (`SourceArity#authoritative?`) runs only once the
|
|
146
|
+
# count is known to fall outside it.
|
|
147
|
+
def source_arity_envelope(class_name, call_node, scope, kind)
|
|
148
|
+
return nil unless scope.discovered_parameter_envelopes.key?(Scope::DiscoveryIndex::ENVELOPE_PROJECT_WIDE)
|
|
149
|
+
return nil if ReceiverPredicates.unbounded_receiver_surface?(class_name, scope)
|
|
150
|
+
return nil if ReceiverPredicates.plugin_typed_call?(call_node, scope)
|
|
151
|
+
# An instance of a project module is an instance of whatever includes it (#739's reasoning, which
|
|
152
|
+
# `module_mixin_receiver?` can only apply to a module RBS declares).
|
|
153
|
+
return nil if kind == :instance && project_module?(class_name, scope)
|
|
154
|
+
return nil if project_module_class_receiver?(call_node, scope)
|
|
155
|
+
|
|
156
|
+
arity = SourceArity.new(scope, call_node.name, kind)
|
|
157
|
+
envelope = arity.owner_envelope(class_name)
|
|
158
|
+
if envelope.nil? || envelope[2]
|
|
159
|
+
envelope.nil? && arity.ambiguous? ? arity.settle_by_walk : arity.settle_by_definitions
|
|
160
|
+
return nil
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
[envelope[0], envelope[1] || Float::INFINITY, arity]
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# `self.class.f(1)` inside a project module's instance method: the engine types `self.class` as the
|
|
167
|
+
# module's singleton, but at runtime it is the includer's class, whose class methods are its own. The
|
|
168
|
+
# source-lane twin of {#mixin_self_class_receiver?}, which can only see a module RBS declares.
|
|
169
|
+
def project_module_class_receiver?(call_node, scope)
|
|
170
|
+
receiver = call_node.receiver
|
|
171
|
+
return false unless receiver.is_a?(Prism::CallNode) && receiver.name == :class && receiver.arguments.nil?
|
|
172
|
+
return false if receiver.receiver.nil?
|
|
173
|
+
|
|
174
|
+
inner = ReceiverPredicates.concrete_class_name(scope.type_of(receiver.receiver))
|
|
175
|
+
!inner.nil? && project_module?(inner, scope)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Read off the table directly rather than through `Scope#parameter_envelopes_of`: a class does not turn
|
|
179
|
+
# into a module without its declaration (and so the receiver's own typing) changing, so this answer
|
|
180
|
+
# needs no ADR-46 class edge of its own.
|
|
181
|
+
def project_module?(class_name, scope)
|
|
182
|
+
bucket = scope.discovered_parameter_envelopes[class_name.to_s]
|
|
183
|
+
!bucket.nil? && bucket.key?(Scope::DiscoveryIndex::ENVELOPE_MODULE_MARK)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Issue #917 — no loaded RBS declares a constructor for this class. The definition builder
|
|
187
|
+
# synthesizes `.new` from the nearest `initialize` in the ancestry, and when nothing declares
|
|
188
|
+
# one that is `BasicObject#initialize: () -> void`, so `.new` derives a nullary envelope that
|
|
189
|
+
# is an artifact of the fallback rather than a statement about the class. `Gem::Specification`
|
|
190
|
+
# is declared in full by the vendored rubygems sigs except for its constructor, and every
|
|
191
|
+
# argument at the real one was reported. The rule needs "this class declares a nullary
|
|
192
|
+
# constructor", and only a `defined_in` naming a class other than `BasicObject` is that
|
|
193
|
+
# evidence — except on `BasicObject` and `Object` themselves, where the declaration is their
|
|
194
|
+
# own and `.new` really does take no arguments.
|
|
195
|
+
def undeclared_constructor?(class_name, call_node, kind, method_def)
|
|
196
|
+
return false unless kind == :singleton && call_node.name == :new
|
|
197
|
+
return false unless method_def.respond_to?(:defined_in)
|
|
198
|
+
|
|
199
|
+
defined_in = method_def.defined_in
|
|
200
|
+
return false unless defined_in.nil? || ReceiverPredicates.strip_root(defined_in.to_s) == "BasicObject"
|
|
201
|
+
|
|
202
|
+
!%w[BasicObject Object].include?(ReceiverPredicates.strip_root(class_name))
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# True for the outer `.new` of a chained `Struct.new(...).new`:
|
|
206
|
+
# `class_name`/`kind` already pin the receiver to
|
|
207
|
+
# `Singleton[Struct]`, and the receiver node is itself a
|
|
208
|
+
# `Struct.new` (or `::Struct.new`) call — the anonymous subclass.
|
|
209
|
+
def anonymous_struct_new_call?(call_node, class_name, kind)
|
|
210
|
+
return false unless class_name == "Struct" && kind == :singleton
|
|
211
|
+
return false unless call_node.name == :new
|
|
212
|
+
|
|
213
|
+
receiver = call_node.receiver
|
|
214
|
+
return false unless receiver.is_a?(Prism::CallNode) && receiver.name == :new
|
|
215
|
+
|
|
216
|
+
inner = receiver.receiver
|
|
217
|
+
return true if inner.is_a?(Prism::ConstantReadNode) && inner.name == :Struct
|
|
218
|
+
|
|
219
|
+
# `::Struct.new(...).new` — a top-level constant path.
|
|
220
|
+
inner.is_a?(Prism::ConstantPathNode) && inner.parent.nil? && inner.name == :Struct
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def plain_positional_call?(call_node)
|
|
224
|
+
arguments = call_node.arguments
|
|
225
|
+
return true if arguments.nil?
|
|
226
|
+
|
|
227
|
+
arguments.arguments.all? { |arg| simple_positional?(arg) }
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def simple_positional?(arg)
|
|
231
|
+
return false if arg.is_a?(Prism::SplatNode)
|
|
232
|
+
return false if arg.is_a?(Prism::KeywordHashNode)
|
|
233
|
+
return false if arg.is_a?(Prism::BlockArgumentNode)
|
|
234
|
+
return false if arg.is_a?(Prism::ForwardingArgumentsNode)
|
|
235
|
+
|
|
236
|
+
true
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# Returns `[min, max]` positional-argument arity for the
|
|
240
|
+
# method (across all overloads), or nil when the rule
|
|
241
|
+
# does not apply. We disqualify only when the method
|
|
242
|
+
# uses required keyword arguments (which the caller MUST
|
|
243
|
+
# pass at the call site, and our plain-positional check
|
|
244
|
+
# would not have caught) or trailing positionals (rare,
|
|
245
|
+
# complex). `optional_keywords` and `rest_keywords` do
|
|
246
|
+
# NOT affect positional arity. `rest_positionals` raises
|
|
247
|
+
# `max` to `Float::INFINITY`.
|
|
248
|
+
def compute_arity_envelope(method_def)
|
|
249
|
+
mins = []
|
|
250
|
+
maxes = []
|
|
251
|
+
method_def.method_types.each do |mt|
|
|
252
|
+
function = mt.type
|
|
253
|
+
return nil unless arity_eligible?(function)
|
|
254
|
+
|
|
255
|
+
min_arity = function.required_positionals.size
|
|
256
|
+
max_arity =
|
|
257
|
+
if function.rest_positionals
|
|
258
|
+
Float::INFINITY
|
|
259
|
+
else
|
|
260
|
+
min_arity + function.optional_positionals.size
|
|
261
|
+
end
|
|
262
|
+
mins << min_arity
|
|
263
|
+
maxes << max_arity
|
|
264
|
+
end
|
|
265
|
+
return nil if mins.empty?
|
|
266
|
+
|
|
267
|
+
[mins.min, maxes.max]
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def arity_eligible?(function)
|
|
271
|
+
# `RBS::Types::UntypedFunction` (used for `(?) ->`
|
|
272
|
+
# untyped sigs) does not expose the per-arity
|
|
273
|
+
# accessors. Treating it as ineligible is the
|
|
274
|
+
# correct conservative move: an untyped function
|
|
275
|
+
# has no static arity to enforce.
|
|
276
|
+
return false unless function.respond_to?(:required_keywords)
|
|
277
|
+
|
|
278
|
+
function.required_keywords.empty? && function.trailing_positionals.empty?
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
def build_arity_diagnostic(path, call_node, class_name, min, max, actual)
|
|
282
|
+
range = min == max ? min.to_s : "#{min}..#{max}"
|
|
283
|
+
method_label = "`#{call_node.name}' on #{class_name}"
|
|
284
|
+
message = "wrong number of arguments to #{method_label} (given #{actual}, expected #{range})"
|
|
285
|
+
Diagnostic.from_message_loc(
|
|
286
|
+
call_node,
|
|
287
|
+
rule: RULE_WRONG_ARITY,
|
|
288
|
+
path: path,
|
|
289
|
+
message: message,
|
|
290
|
+
severity: :error,
|
|
291
|
+
receiver_type: class_name,
|
|
292
|
+
method_name: call_node.name.to_s
|
|
293
|
+
)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
private_class_method :arity_report_withheld?, :arity_envelope_for, :source_lane_open?, :source_arity_envelope,
|
|
297
|
+
:project_module_class_receiver?, :project_module?, :undeclared_constructor?,
|
|
298
|
+
:anonymous_struct_new_call?, :simple_positional?, :compute_arity_envelope,
|
|
299
|
+
:arity_eligible?, :build_arity_diagnostic
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
end
|