class

Analyzer::Go::Chi

Inherits Analyzer::Go::GoTestPath < Analyzer < FileHelper < Reference < Object

Constants

EMPTY_STRING_VALUES = Hash(String, String).new
IMPORT_MARKER = "github.com/go-chi/chi"

Go enforces per-file imports, so any file using chi's router types must mention the package path. Filter on this marker to avoid touching the bulk of files in projects whose detection matched on a single dummy/fixture file (the chi extractor is loose enough that another framework's verb calls would otherwise surface as chi routes).

IMPORT_MARKER_RE = Regex.union(IMPORT_MARKER)

Whole-file gates, run on every .go in the tree.

MAX_MOUNT_DEPTH = 8

Nested Mount calls inside a mounted router are followed to this depth; deeper trees are almost certainly a cycle through a symbol the resolver could not tell apart.

MOUNT_CALL_RE = /\.Mount\(/
ROUTER_HELPER_DECL_RE = /^func\s+([A-Za-z_]\w*)\s*\(([^)]*)\)/m

A function that takes a router parameter (func addGitRoutes(m *web.Router, ...)): candidate route helper, by name, per directory.

ROUTER_PARAM_RE = /\w\s+\*?(?:\w+\.)?(?:Router|Mux)\b/

Class methods

tech_name
Source

Instance methods

analyze
Source
expand_mounted_router(dir : String, func_name : String, recv_type : String | Nil, package_files : Hash(String, Array(String)), file_contents_cache : Hash(String, String), file_lines_cache : Hash(String, Array(String)), ancestors : Array(String)) : Array(Endpoint)

Extracts endpoints from a router function definition declared in the Go package at dir, searching every .go file there.

Uses the tree-sitter walker, scoped down to just the target function's declaration so the returned routes are relative to the function body — the caller slaps on the Mount prefix. When recv_type is given, the target is a method (func (r Type) Name()) and only the declaration on that receiver type is matched.

.Mount(...) calls inside the body are expanded recursively with their own prefix, so apiRouter() mounting usersRouter() at /users yields /users/... relative to apiRouter's root. The ancestors list guards against a router that (transitively) mounts itself.

Source
get_param(line : String, pattern : String) : Param
Source
tech

Instance-side view of the same declaration. The per-file rescues live on this base class, which has no way to name the analyzer that is running inside them, so a skipped file could not be attributed to a tech. Deriving it from analyzer_for keeps the name written exactly once.

Source

Nested types