A simple CLI tool to provide feedback on programming assignments using tree-sitter queries composed in a YAML file.
cargo run -- <path_to_code_file> --ruleset <path_to_ruleset_directory>cargo run -- examples/hello.c --ruleset rulesets/exampleA ruleset consists of a directory containing:
rules.yaml- Main configuration file- Query files (
.scm) - Tree-sitter queries for each rule
language: c
rules:
no-goto:
file: queries/no-goto.scm
description: "Disallow use of goto statements"
severity: error
weight: 5
fail_if_matches: true
max-function-length:
file: queries/max-function-length.scm
description: "Warn if function body exceeds 50 lines"
severity: warn
weight: 2
params:
max: 50file: Path to the tree-sitter query file (relative to ruleset directory)description: Human-readable description of the ruleseverity:error,warn, orinfoweight: Numeric weight for scoring (default: 1.0)fail_if_matches: If true, rule fails when query matches (default: false)params: Additional parameters (e.g.,maxfor threshold-based rules)
queries/no-goto.scm (matches goto statements):
(goto_statement) @gotoqueries/max-function-length.scm (matches function bodies):
(function_definition
body: (compound_statement) @body)- Error rules: Pass (1.0) or fail (0.0) based on
fail_if_matches - Warn rules:
- With
maxparameter: Score decreases proportionally when matches exceed threshold - Without
max: Pass (1.0) for no matches, partial credit (0.5) for any matches
- With
- Info rules: Always pass (1.0)
Final score is weighted average across all rules.