Skip to main content

Crate harn_lint

Crate harn_lint 

Source
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§

LintDiagnostic
A lint diagnostic reported by the linter.
LintOptions
Extra options for source-aware lint rules (path-aware rules, opt-in rules like require-file-header).

Enums§

LintSeverity
Severity level for lint diagnostics.

Constants§

DEFAULT_COMPLEXITY_THRESHOLD
Default cyclomatic-complexity threshold. Callers can override via LintOptions::complexity_threshold (wired to [lint].complexity_threshold in harn.toml). Chosen to match Clippy’s cognitive_complexity default 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] in harn_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 path names 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.prompt template 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_names are 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 == truex.
type_diagnostic_lint_disabled
Returns true when a type diagnostic is a lint diagnostic disabled by the caller’s lint configuration.