Skip to main content

Crate pine_lint

Crate pine_lint 

Source
Expand description

Static analysis for Pine Script ASTs.

pine-lint walks a parsed pine_ast::Program and reports likely bugs and non-idiomatic constructs as Diagnostics. It is organized around three pieces:

  • Visitor + the walk_* functions — the reusable traversal core.
  • LintPass — one check; a visitor that collects diagnostics.
  • lint — the driver that runs every registered pass over a program.

§Example

use pine_ast::Program;
use pine_lexer::Lexer;
use pine_parser::Parser;

let src = "x = close == na\n";
let tokens = Lexer::new(src).tokenize().unwrap();
let program = Program::new(Parser::new(tokens).parse().unwrap());

let diagnostics = pine_lint::lint(&program);
assert_eq!(diagnostics.len(), 1);
assert_eq!(diagnostics[0].rule, "eq-na");

Structs§

Diagnostic
A single finding from any analysis phase.

Enums§

Severity
How serious a finding is.

Traits§

LintPass
A single check.
Visitor
A read-only traversal over the AST.

Functions§

lint
Run every built-in lint pass over program and return all findings, sorted by line for stable, readable output.
lint_with
Run a specific set of passes. Useful for tests that want to exercise one check in isolation.
walk_block
walk_expr
walk_program
walk_stmt