class

Analyzer::Go::Beego

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

Constants

CONTEXT_GETTER_PATTERNS = ["GetString", "GetStrings", "GetInt", "GetInt8", "GetUint8", "GetInt16", "GetUint16", "GetInt32", "GetUint32", "GetInt64", "GetUint64", "GetBool", "GetFloat"].map do |pattern| {pattern, /#{pattern}\(\s*"([^"]*)"\s*[,)]/} end

Crystal recompiles an interpolated regex literal on every evaluation (a full PCRE2 JIT compile), and this fixed accessor set used to be rebuilt for every line — precompile it once at load time.

CONTROLLER_ARG = /Router\s*\(\s*[^,]+,\s*([a-z_]\w*)\s*[,)]/
CONTROLLER_LITERAL = /&\s*(?:(\w+)\s*\.\s*)?([A-Z]\w*)\s*\{/

&controllers.ApiController{} on a web.Router line: the controller's package qualifier (if any) and type.

EMBEDDED_FIELD = /\A\*?(?:(\w+)\s*\.\s*)?([A-Z]\w*)\s*(?:\/\/.*)?\z/
IMPORT_MARKER = "github.com/beego/beego"
IMPORT_MARKER_RE = Regex.union(IMPORT_MARKER)

One precompiled matcher instead of a String#includes? scan per .go file: includes? runs Rabin-Karp over the whole buffer and the marker is absent in the overwhelming majority of files in a polyglot repo, so every one of them pays the full scan. See Analyzer#content_matches?.

INPUT_ACCESSORS = {/\.Input\s*\.\s*Query\s*\(\s*"([^"]+)"/ => "query", /\.Input\s*\(\s*\)\s*\.\s*Get\s*\(\s*"([^"]+)"/ => "query", /\.Input\s*\.\s*Header\s*\(\s*"([^"]+)"/ => "header", /\.Input\s*\.\s*Cookie\s*\(\s*"([^"]+)"/ => "cookie"}

Beego's Context.Input accessors (c.Ctx.Input.Query("owner")) and c.Input().Get("id"), with the param type each reads.

METHOD_RECEIVER = /\Afunc\s*\(\s*\w*\s*\*?\s*(\w+)\s*\)/
STRUCT_HEAD = /^type\s+(\w+)\s+struct\s*\{/

type T struct {, and a field that is a bare (embedded) type.

Class methods

tech_name
Source

Instance methods

analyze
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