Skip to main content

Module lint

Module lint 

Source
Expand description

SurrealQL linter — static analysis for common schema issues.

Provides lint checks for .surql files including missing types, schemaless tables, SELECT *, missing indexes, and unused functions.

§Example

use surql_parser::lint::{lint_schema, LintSeverity};
use surql_parser::SchemaGraph;
use std::path::PathBuf;

let source = "
    DEFINE TABLE user;
    DEFINE FIELD name ON user;
    SELECT * FROM user;
";
let graph = SchemaGraph::from_source(source).unwrap();
let sources = vec![(PathBuf::from("schema.surql"), source.to_string())];
let results = lint_schema(&graph, &sources);
assert!(results.iter().any(|r| r.code == "schemaless-table"));
assert!(results.iter().any(|r| r.code == "missing-type"));
assert!(results.iter().any(|r| r.code == "select-star"));

Structs§

LintResult
A single lint finding.

Enums§

LintSeverity
Severity level for a lint result.

Functions§

apply_fixes
Apply auto-fixes for fixable lints. Returns the fixed source content and the number of fixes applied.
lint_schema
Run all lint checks against a schema graph and its source files.