May 15, 2025
Project Goal: Chasten enables scalable and structure-aware feedback that effectively supports both instructors and students
# O(n) is acceptable seen = set() for item in items: if item in seen: return True seen.add(item)
# O(n²) is not okay for i in range(len(items)): for j in range(len(items)): if i != j and items[i] == items[j]: return True
Goal: Automatically scan the source code that students submit to confirm that there are no inefficient looping constructs
Challenge: Linters like Ruff and Pylint don’t have rules to detect nested control structures that either are or are not acceptable
Build: An extensible tool allowing instructors to scan for arbitrary code patterns without detailed AST knowledge
Uses XPath to search Python’s AST
Rules written in simple YAML
Structure-first, not just style
Outputs to JSON, CSV, or SQLite
Result: Instructors define checks once and use Chasten to easily apply them at scale across all student submissions
- name: "nested-loops" code: "PERF001" pattern: "//For[descendant::For]" description: "Detects doubly nested for-loops (e.g., O(n²))"
pipx install chasten # Install Chasten in venv pipx list # Confirm installation chasten --help # View available commands
chasten analyze time-complexity-lab \ --config chasten-configuration \ --search-path time-complexity-lab \ --save-directory time-complexity-results \ --save
Check ID → A unique short rule code (e.g., PERF001)
PERF001
Check Name → The rule name that matched (e.g., nested-loops)
nested-loops
File → The Python file that the tool scanned (e.g., analyze.py)
analyze.py
Matches → Number of times the pattern was detected in that file (e.g., 1 match)
1
Write declarative rules for AST-based code checks
Focus on bespoke code structure patterns in Python
Automated grading aligned with learning outcomes
Generate data-rich insights into student code patterns