Expand description
Harn’s lint crate. The public surface is intentionally narrow: a
handful of lint_* entry points, the diagnostic and options types,
and a couple of small utility functions reused by other crates. All
walk state, rule dispatch, and source-aware rule implementations
live in sibling modules.
Modules§
- native
- C-compatible ABI for native lint rule libraries.
Structs§
- Lint
Diagnostic - A lint diagnostic reported by the linter.
- Lint
Options - Extra options for source-aware lint rules (path-aware rules, opt-in
rules like
require-file-header).
Enums§
- Lint
Severity - Severity level for lint diagnostics.
Constants§
- DEFAULT_
COMPLEXITY_ THRESHOLD - Default cyclomatic-complexity threshold. Callers can override via
LintOptions::complexity_threshold(wired to[lint].complexity_thresholdinharn.toml). Chosen to match Clippy’scognitive_complexitydefault and sit between ESLint (20) and gocyclo (30); Harn’s scorer counts&&/||per operator, so real-world Harn functions score a notch higher than in tools that only count control-flow nodes. - DEFAULT_
TEMPLATE_ VARIANT_ BRANCH_ THRESHOLD - Default threshold; see [
template_variant_branch_threshold] inharn_cli::config::LintConfig. Picked to match the issue’s stated default (#1669). - GENERATED_
HARN_ SUFFIX - The filename suffix that marks a machine-generated Harn source file:
<name>.generated.harn.
Functions§
- collect_
selective_ import_ names - Extract all function names that appear in selective import statements
(
import { foo, bar } from "module"). - derive_
file_ header_ title - Derive the title shown inside the autofix’s file-header block. Falls back to a generic “Module.” when no path is available. Only the first letter is capitalized — not every word — per the header style.
- is_
generated_ path - True if
pathnames a machine-generated Harn file (*.generated.harn). - lint
- Lint an AST program and return all diagnostics.
- lint_
diagnostics_ from_ type_ diagnostics - Convert type-checker diagnostics tagged as lint rules into ordinary lint diagnostics so CLI/editor callers can share rule filtering, rendering, and autofix plumbing.
- lint_
prompt_ template - Lint a single
.harn.prompttemplate source. Returns the diagnostics produced by the template-specific lint rules (template-provider-identity-branch,template-variant-explosion). - lint_
with_ config - Lint an AST program, filtering out diagnostics for disabled rules.
- lint_
with_ config_ and_ source - Lint an AST program, optionally using the original source for source-aware rules.
- lint_
with_ cross_ file_ imports - Lint with cross-file import awareness. Functions named in
externally_imported_namesare exempt from the unused-function lint even without local references. - lint_
with_ module_ graph - Lint with cross-file import awareness driven by
harn_modules::ModuleGraph. - lint_
with_ options - Lint with cross-file import awareness plus extra
LintOptions. - lint_
with_ source - Lint an AST program with source-aware rules enabled.
- simplify_
bool_ comparison - Simplify a boolean comparison expression like
x == true→x. - type_
diagnostic_ lint_ disabled - Returns true when a type diagnostic is a lint diagnostic disabled by the caller’s lint configuration.