class

Analyzer::Elixir::Plug

Inherits Analyzer::Elixir::ElixirEngine < FileScanEngine < Analyzer < FileHelper < Reference < Object

Constants

PLUG_ROUTE_EVIDENCE_RE = /\ \b(?:get|post|put|patch|delete|head|options|query|forward|match) \s*(?:\(\s*)?["'] /x

File-level gate: Plug.Router only registers absolute paths via the verb/match/forward macros. Files with none of those tokens cannot contribute endpoints (models, views, plain modules).

PLUG_ROUTE_MACROS = {"get" => "GET", "post" => "POST", "put" => "PUT", "patch" => "PATCH", "delete" => "DELETE", "head" => "HEAD", "options" => "OPTIONS", "forward" => "FORWARD", "query" => "QUERY"}

The route macro must start a fresh token. Without the (?:^|[^.\w]) guard the bare verb matched as a substring of any identifier — @temp_slot_options "TEMPORARY …" read as an options route, Repo.delete "x" as a delete route — flooding non-router modules with junk endpoints. The captured path is also required to start with /, because the Plug.Router DSL only ever registers absolute paths; that single constraint drops the remaining get "true"-style false positives.

PLUG_ROUTE_PATTERNS = PLUG_ROUTE_MACROS.keys.to_h do |verb| {verb, Regex.new("(?:^|[^.\\w])#{verb}\\s+[\"']([^\"']+)[\"']")} end

Precompiled per-verb route regexes. line_to_endpoint runs once per line of every .ex file, and Regex.new rebuilt these 8 PCRE2 patterns on every call — the same recompilation cost the Phoenix analyzer carried. Build them once.

Class methods

tech_name
Source

Instance methods

analyze_content(content : String, file_path : String) : Array(Endpoint)
Source
analyze_file(path : String) : Array(Endpoint)
Source
extract_params_from_block(lines : Array(String), start_index : Int32, method : String, block_end : Int32 | Nil = nil) : Array(Param)
Source
find_block_end(lines : Array(String), start_index : Int32) : Int32
Source
line_to_endpoint(line : String) : Array(Endpoint)
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