class

Analyzer::Swift::Kitura

Inherits Analyzer::Swift::SwiftEngine < FileScanEngine < Analyzer < FileHelper < Reference < Object

Constants

FUNCTION_SIGNATURE_PATTERN = /\bfunc\s+([A-Za-z_]\w*)\s*\(/
LOOKAHEAD_LIMIT = 20

Maximum number of lines to look ahead for function parameters

ROUTE_BODY_LOOKAHEAD_LIMIT = LOOKAHEAD_LIMIT
ROUTE_CALL_RE = Regex.union(".get(", ".post(", ".put(", ".delete(", ".patch(", ".all(")

route_definition? runs on every scanned line (route detection, param lookahead, body-boundary checks). One precompiled Regex.union scan (PCRE2 JIT) replaces six naive String#includes? char scans; union auto-escapes each literal so it is provably equivalent to the OR-of-substrings it replaces.

ROUTE_PATTERN = /(\w+)\.(get|post|put|delete|patch|all)\(([^)]+)\)/

Patterns for route definitions in Kitura: router.get("path") { ... } router.post("path", handler: handler) router.all("/path") { ... }

ROUTER_ASSIGN_PATTERN = /\b(?:let|var)\s+([A-Za-z_]\w*)\s*=\s*Router\s*[(<]/

let router = Router() / func boot(router: Router) — the receivers a Kitura route is registered on. Tracking them makes detection receiver-aware, so look-alike .get/.delete/... calls on models or services (Grade.delete(id:), cache.get(...)) stop becoming phantom endpoints.

ROUTER_PARAM_PATTERN = /([A-Za-z_]\w*)\s*:\s*Router\b/

Class methods

tech_name
Source

Instance methods

analyze_file(path : String) : Array(Endpoint)
Source
extract_function_params(lines : Array(String), start_index : Int32, endpoint : Endpoint)

Extract parameters from function body

Source
extract_path_params(route : String, endpoint : Endpoint)

Extract path parameters from the route pattern (e.g., :id, :userID)

Source
parse_route_path(route_args : String) : String

Parse route path from route arguments Examples: "/hello" -> /hello "/users/:id" -> /users/:id "/api/users/:userID" -> /api/users/:userID

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