/** * Anti-Pattern Rules * Enforces best practices from docs/guide-conventions.md:411-462. */ import type { ValidationRule } from '../types.js'; /** * Warns on variable reassignment patterns. * Variables lock to their first type, and reassignment suggests confusing * flow control. Prefer functional style or new variables. * * Detection: * - Capture node (=> $var) where $var already exists in validation context * - Tracks variables seen during validation pass * * Valid alternatives: * - Use new variable: $result1, $result2 * - Functional chains: value -> op1 -> op2 * * References: * - docs/guide-conventions.md:413-424 */ export declare const AVOID_REASSIGNMENT: ValidationRule; /** * Warns on complex nested boolean conditions. * Complex conditions with multiple nested operators are hard to read. * Extract to named variables for clarity. * * Detection: * - Conditional nodes with conditions containing 3+ boolean operators (&&, ||) * - Nesting depth > 2 for boolean expressions * * Valid alternatives: * - Extract sub-conditions to named variables * - Split complex checks into multiple smaller checks * * References: * - docs/guide-conventions.md:451-461 */ export declare const COMPLEX_CONDITION: ValidationRule; /** * Detects attempts to modify outer-scope variables from inside loops. * This is a common LLM-generated anti-pattern that never works in Rill. * * Rill's scoping rules mean that captures inside loop bodies create LOCAL * variables that don't affect outer scope. This is a fundamental language * constraint, not a style preference. * * WRONG - this pattern NEVER works: * 0 => $count * [1, 2, 3] -> each { $count + 1 => $count } # creates LOCAL $count * $count # still 0! * * RIGHT - use accumulators: * [1, 2, 3] -> fold(0) { $@ + 1 } # returns 3 * [1, 2, 3] -> each(0) { $@ + 1 } # returns [1, 2, 3] * * This rule catches captures inside loop/collection bodies where the * variable name matches an outer-scope variable. * * References: * - docs/ref-llm.txt (LOOP STATE PATTERNS) * - docs/topic-variables.md (Scope Rules) */ export declare const LOOP_OUTER_CAPTURE: ValidationRule; /** * Warns when a stream variable is invoked before any iteration consumes it. * Invoking a stream closure ($s()) before iterating ($s -> each { ... }) * consumes chunks internally, leaving no data for iteration. * * Detection: * - Tracks variables captured from stream closures (returnTypeTarget = stream) * or captured with explicit :stream type annotation * - Records first invocation (ClosureCall) and first iteration (each/map/filter/fold) * - Warns when invocation precedes iteration in source order * * No warning if: * - Iteration appears before invocation * - Variable is only iterated (never invoked before iteration) * - Variable is only invoked (no iteration to conflict) * * References: * - IR-15: Lint Warning for Pre-Iteration Invocation */ export declare const STREAM_PRE_ITERATION: ValidationRule;