print-in-logicprint() or println() used inside non-main functions hides observable behaviour.
Severity: suggestion | Auto-fix: no
import fs
# Flagged
def validate(paths: List[Str]) {
for p in paths {
if not fs.exists(fs.path(p)) {
print("missing: " + p)
}
}
}
Return structured data instead so tests and mutation testing can verify it:
import fs
def validate(paths: List[Str]) -> List[Str] {
mut missing: List[Str] = []
for p in paths {
if not fs.exists(fs.path(p)) {
missing = missing + [p]
}
}
return missing
}
force-unwrap-in-logicx!! in library code. It throws when the value is None, far from where the None came from. Tests, test_* files and main are exempt. Handle the None case with ?:, let ... else, or a narrowed branch.
Severity: warning | Auto-fix: no (the right exit is a judgment). vary var treats a !! inside a changed function as a blocker.
broad-effectsFunction produces too many distinct side effect classes. Configure the threshold in vary.toml:
Severity: warning | Auto-fix: no
[check.analysis]
broad_effects_threshold = 3
A function that does IO, network, process execution, and state mutation likely has too many responsibilities. Split it into smaller functions with focused effects.
denied-effectFunction produces an effect that is denied by project policy. Configure denied effects in vary.toml:
Severity: error | Auto-fix: no
[check.effects]
deny = ["PROCESS", "NETWORK"]
This enables "pure core" architectural patterns where domain modules are guaranteed effect-free.
service-server-driftDetect drift between service declarations (client) and expose statements (server). The rule compares endpoint names, HTTP methods, URL paths, parameter types, and return types.
Severity: error | Auto-fix: no
# Server defines:
# expose ItemService via http
# → GET /item-service/item/{id}
# Client declares a mismatched path:
service ItemApi at "https://api.example.com" {
endpoint get_item(id: Int) -> Str via GET "/items/{id}"
# Error: path mismatch: server has /item-service/item/{id}
}
Warns if server methods are not declared as client endpoints.
service-host-deniedFlag service declarations targeting hosts not in the project's allowed list or explicitly denied.
Severity: error | Auto-fix: no
Configure in vary.toml:
[services]
allowed_hosts = ["api.example.com", "*.internal.example.com"]
denied_hosts = ["untrusted.com"]
Wildcard patterns (*.example.com) match any subdomain. When allowed_hosts is non-empty, unlisted hosts are blocked.
Structure rules detect project-level architectural violations that cross file boundaries. They run when vary check is given a directory and analyze the whole project.
effects-in-wrong-moduleEffectful calls (I/O, network, filesystem) in modules under src/core/ or src/logic/, which should contain pure logic.
Severity: warning | Auto-fix: no
# File: src/core/validator.vary: Flagged
import http
def validate_url(url: Str) -> Bool {
let resp = http_get(url) # effectful call in core module
return resp.status == 200
}
Move effectful calls to a handler or adapter module and pass data into the logic module instead.
fixture-in-productionTest-fixture patterns (functions named make_*, fake_*, mock_*, stub_*, setup_*; variables named FIXTURE_*, TEST_*) in production code under src/.
Severity: warning | Auto-fix: no
# File: src/services/user_service.vary: Flagged
def make_test_user() -> User {
return User("test", "test@example.com")
}
Move fixture helpers to a test/ or tests/ directory.
generated-code-locationFiles with generated-code markers (# generated or // generated in the first 5 lines) that are not inside a generated/ or gen/ directory.
Severity: warning | Auto-fix: no
# File: src/models/schema.vary: Flagged
# generated
data Schema {
name: Str
version: Int
}
Move generated files to a generated/ or gen/ directory to separate them from hand-written code.
boundary-bypassDirect HTTP calls (http_get, http_post, etc.) that bypass a declared service client boundary. Only fires when the project contains at least one service declaration.
Severity: warning | Auto-fix: no
# File: src/handlers/order_handler.vary: Flagged
# (project has a service ItemApi declaration elsewhere)
def fetch_item(id: Int) -> Str {
return http_get("https://api.example.com/items/" + str(id))
}
Use the corresponding service endpoint method instead of calling HTTP functions directly. This ensures consistent base URLs, error handling, and type-safe request/response mapping.
Great-code rules catch design smells that compile and type-check cleanly but suggest a better shape. They are enabled under the --great-code profile.
Readable-block suggestions use VCG028 for dependent adjacent bindings,
VCG029 for a temporary chain ending in one return, VCG030 for a typed
single-list selection and projection, and VCG031 for nested eager
filter/map/sorted calls. They are suggestions, with source locations and
verification commands. Comments, name shadowing, and changes in evaluation
order suppress a suggestion. See readable blocks for
the proposed forms.
vary check --great-code src/
vary var --great-code --json --no-state examples/attempt-blocks
The website checker runs standalone vary fences in one batch and reports
vary-snippet fences as needing surrounding declarations. For one fence, run
python3 scripts/readable_blocks_fences.py --check page.md:first-code-line;
its JSON diagnostics retain the page and line. A scoped vary var run on a
website page reports checked fences and any missing snippet or test coverage.
parallel-collectionTwo or more List variables indexed by the same loop variable in lockstep inside a single scope. This usually means the lists are really one list of a data class.
Severity: warning | Auto-fix: no
# Flagged
let names: List[Str] = [...]
let ages: List[Int] = [...]
for i in 0..names.len() {
print(names[i], ages[i])
}
# Better
data Person { name: Str, age: Int }
let people: List[Person] = [...]
for p in people {
print(p.name, p.age)
}
tagged-union-smellA class with a discriminator field named kind, type, or tag (Str or Int) combined with if/elif chains that dispatch on that field. This is a hand-rolled tagged union that should be a Vary enum with payloads.
Severity: warning | Auto-fix: no
The rule only fires when both the discriminator field exists and at least one method branches on its value, so legitimate flag fields are not flagged.
mixed-concern-moduleA module whose public exports cluster into two or more unrelated concern prefixes (for example, parse_* and format_*), each with at least two exports. Suggests splitting the module along concern boundaries.
Severity: warning | Auto-fix: no
manual-json-stringFlags JSON built or tested as escaped strings: manual JSON concatenation,
local escape_json helpers, inline JSON object/array literals passed to
Json.parse, and escaped JSON substring assertions.
Severity: warning | Auto-fix: no
Use structured Json values, JsonStreamWriter, typed payloads, and
Json/Decoder assertions instead.
dsl-replaceable-sqlFlags raw execute(...) and execute_query(...) calls when the SQL is a
simple single-table insert, select, count, update, or delete that the typed SQL
DSL should express.
Severity: warning | Auto-fix: no
# Flagged
db.execute("INSERT INTO issues (id, title) VALUES (?, ?)", [id, title])
let rows = db.execute_query("SELECT number FROM issues WHERE id = ?", [id])
# Better
insert db {
into PersistedIssue
values {
id = id
title = title
}
}
let rows = query db {
from PersistedIssue as issue
where issue.id == id
select {
number = issue.number
}
}
The rule allows migrations, DDL, pragmas, joins, grouped/reporting queries, subqueries, backend-specific expressions, and SQL that is not cleanly covered by the DSL.
file-too-longWarns when a hand-written .vary file exceeds the configured line budget.
Generated files are ignored when they live under generated/ or gen/, or when
they have a generated marker in the file header.
Defaults:
[check.analysis]
max_file_lines = 300
max_test_file_lines = 500
Set either value to 0 to disable that side of the rule.
Severity: warning | Auto-fix: no