feat(languages): parse shell to AST (functions, source edges, complexity)#768
Open
RaghavChamadiya wants to merge 1 commit into
Open
feat(languages): parse shell to AST (functions, source edges, complexity)#768RaghavChamadiya wants to merge 1 commit into
RaghavChamadiya wants to merge 1 commit into
Conversation
…ity) Promote shell from the config/data passthrough tier to a parsed language. tree-sitter-bash now yields function symbols, `source` / `.` import edges, command call edges, and function-level code-health complexity. - specs/shell.py: grammar + scm + builtin call filter; drop passthrough - queries/shell.scm: function_definition symbols, source/. imports, calls - resolvers/shell.py: literal-relative paths, the $SCRIPT_DIR / dirname idioms, and a unique path-suffix match for project-root anchors (`$BATS_ROOT/$LIBDIR/lib/x.sh`); genuinely dynamic paths stay external - complexity map: CCN / nesting with `&&` / `||` command lists counted - dead code: never-flag *.sh / *.bash / *.zsh (invoked by name, not imported) Smoke on bats-core (54 files): 100% parse rate, 151 function symbols, statically-resolvable source edges resolve, external binaries mint no call edges, and the gnarliest function (CCN 23) surfaces in health.
|
✅ Health: 7.7 (unchanged) 📋 At a glance Files & modules (2)
🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)
🔎 More signals (2)🔥 Hotspots touched (4)
1 more
🔗 Hidden coupling (2 files)
📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-10 18:42 UTC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Promotes shell (
.sh/.bash/.zsh) from the config/data passthrough tier to a parsed language. Every repo has shell (CI glue, build scripts, dev tooling); tree-sitter-bash is a mature grammar, so this makes wiki pages and the graph honest for DevOps-heavy repos at low cost.What ships
foo() { ... }andfunction foo { ... }forms.source/.statements. The resolver handles literal relative paths, the script-directory idioms ($SCRIPT_DIR/x.sh,$(dirname "$0")/x.sh,${BASH_SOURCE%/*}/x.sh), and project-root anchors ($BATS_ROOT/$LIBDIR/lib/x.sh) via a unique multi-segment path-suffix match. Genuinely dynamic paths (source "$1") stay external rather than guessing.grep,awk) mint no edge because no function symbol matches.&&/||command lists counted (cmd || exit 1is +1, which is honest: shell branching is chained command lists). No class metrics, heritage, bindings, perf, or dataflow.Parse errors degrade per-file to the previous passthrough behavior, never a crash. tree-sitter-bash parses the bash/POSIX subset, so zsh mostly works and fish is out of scope.
Scope notes
bin/foo) depend on the traverser assigning them the shell language from their shebang; that is a traverser capability, left out of scope here..sh/.bash/.zshfiles are the 90% case.Testing
bats-core(54 shell files): 100% parse rate, 151 function symbols, statically-resolvablesourceedges resolve, external binaries mint no call edges, and the gnarliest function (CCN 23) surfaces in health.LANGUAGE_SUPPORT.md,README.md) updated.