Expand description
The unit one-function-per-file check.
A source file holds at most one module-scope function whose body runs longer than the configured threshold. Functions at or under the threshold are trivial — an expression with a name — and share a file freely.
Detection is AST-based, one arm per language, each reading the same shape:
- Python —
def/async defat module level (rustpython_parser). - TypeScript — top-level
functiondeclarations and a top-levelconst/let/varbound to an arrow or function expression,exportor not (oxc). - Rust —
fnitems at the top level of the file (syn).
Methods, nested functions, and callbacks belong to their owner and are never counted on their own; the walk reads the same source tree the colocated-test presence rule does, so no test file is a subject.
Re-exports§
pub use crate::violation::Violation;
Functions§
- find_
violations - Scan the source files under
rootforlanguageand return a violation for every module-scope function past the first whose body runs longer thanmax_lines, sorted by(file, line).