Skip to content

skycheck

A static analysis tool for Starlark files that checks for undefined names, unused variables, and parse errors without executing the code.

Terminal window
go install github.com/albertocavalcante/sky/cmd/skycheck@latest
Terminal window
# Check a single file
skycheck file.star
# Check multiple files
skycheck *.star
# Check with JSON output
skycheck --json file.star
# Quiet mode (errors only)
skycheck --quiet file.star
FlagDescription
--jsonOutput diagnostics as JSON
--quietOnly output errors, suppress warnings
--versionPrint version and exit

skycheck performs static analysis to detect:

Variables or functions that are used but never defined:

def example():
return undefined_variable # Error: undefined name

Variables that are defined but never used:

def example():
unused = 42 # Warning: unused variable
return "result"

Syntax errors that prevent the file from being parsed:

def broken(
# Missing closing parenthesis - parse error
Terminal window
$ skycheck lib.star
lib.star:10:5: error: undefined: helper_function [undefined-name]
lib.star:15:9: warning: local variable 'temp' is unused [unused-variable]
Found 1 error(s) and 1 warning(s) in 1 file(s)

The text format shows:

  • File path and line:column location
  • Severity (error or warning)
  • Description of the issue
  • Diagnostic code in brackets
Terminal window
$ skycheck --json lib.star
{
"files": 1,
"errors": 1,
"warnings": 1,
"diagnostics": [
{
"file": "lib.star",
"line": 10,
"column": 5,
"severity": "error",
"code": "undefined-name",
"message": "undefined: helper_function"
},
{
"file": "lib.star",
"line": 15,
"column": 9,
"severity": "warning",
"code": "unused-variable",
"message": "local variable 'temp' is unused"
}
]
}
CodeSeverityDescription
undefined-nameErrorReference to undefined variable or function
unused-variableWarningLocal variable defined but never used
parse-errorErrorSyntax error in the file
- name: Check Starlark files
run: |
go install github.com/albertocavalcante/sky/cmd/skycheck@latest
skycheck *.star
repos:
- repo: local
hooks:
- id: skycheck
name: skycheck
entry: skycheck
language: system
files: \.star$
.PHONY: check
check:
skycheck *.star rules/*.bzl
CodeMeaning
0No issues found
1Errors found
2Only warnings found (no errors)
Terminal window
# Check all .star files
skycheck *.star
# Check files in subdirectories (shell glob)
skycheck **/*.star
# Check specific directories
skycheck rules/*.bzl internal/*.star
Terminal window
# Run skycheck as part of a larger check pipeline
skycheck *.star && skylint . && skytest -r .
# Combine with skyfmt for a full lint pass
skyfmt --check . && skycheck *.star
Terminal window
# Only fail on errors, ignore warnings
skycheck --quiet *.star
Terminal window
# Count errors with jq
skycheck --json *.star | jq '.errors'
# Get list of files with issues
skycheck --json *.star | jq '.diagnostics[].file' | sort -u
# Filter for errors only
skycheck --json *.star | jq '.diagnostics[] | select(.severity == "error")'
Featureskycheckskylint
Undefined namesYesNo
Unused variablesYesYes
Parse errorsYesYes
Style issuesNoYes
Auto-fixNoYes
Buildtools rulesNoYes

Use skycheck for semantic analysis (undefined names, unused variables) and skylint for style/formatting issues. Both tools complement each other.