mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
feat(conventions): modularity checks + scan-derived, language-aware rules
The standard was architectural LINTING (placement + hygiene) — things ruff/eslint already do — and it forced backend rules onto frontend projects. This makes it enforce MODULARIZATION, the separation-of-concerns a senior demands that linters are blind to: - modular_cohesion: a file that mixes architectural concerns (a model defined in a router, a schema in a component) is a monolith — split it. One concern per file. - thin_routes (Python): a route handler that runs its own DB access instead of delegating to a service. - thin_components (TypeScript/React): a component that fetches data in its body instead of using a hook. - god_class: a class past a method-count threshold (single responsibility). The checks inspect a definition's BODY and a file's COMPOSITION via tree-sitter, precision-over-recall (fire only on a confident structural signal). Rules are now scan-derived and language-aware: hygiene seeds universally, placement only for modules that exist, and modularity per stack — so a frontend project carries no_models_in_components + thin_components, never a backend no_models_in_routers. BUILTIN_RULES is reduced to language-agnostic hygiene.
This commit is contained in:
@@ -14,8 +14,10 @@ from roboco.foundation.policy.conventions.models import (
|
||||
|
||||
def test_effective_map_applies_builtin_rules_when_file_absent() -> None:
|
||||
eff = effective_map(ConventionsStandard(), None)
|
||||
assert eff.rules["no_models_in_routers"].level == "block"
|
||||
assert eff.rules["no_lint_suppressions"].level == "block"
|
||||
assert eff.rules["no_inline_comments"].level == "warn"
|
||||
# Placement / modularity rules are derived per project, not universal.
|
||||
assert "no_models_in_routers" not in eff.rules
|
||||
|
||||
|
||||
def test_file_module_overrides_derived_by_path() -> None:
|
||||
|
||||
Reference in New Issue
Block a user