Analyzer::Ruby::Sinatra
Inherits Analyzer::Ruby::RubyEngine < Analyzer < FileHelper < Reference < Object
Constants
SINATRA_DEPTH_TOKEN_RE = /\bend\b|\bdo\b|(?:^|;)\s*(?:if|unless|case|begin|while|until|for|class|module|def)\b/
Net change in block nesting contributed by a single line. Unlike a
naive {/do open vs }/end close tally, this:
- blanks string interiors first, so
#{...}interpolation and any DSL keyword that merely appears inside a string literal never skew the count; - credits statement-position keyword blocks (
if,unless,case,begin,while,until,for,class,module,def) with the+1their matchingendwill later subtract. The previous open/close split counted everyendas a close while ignoring theif/case/… that opened it. A single multi-lineifinside a route body therefore popped the surroundingnamespaceprefix early — gollum dropped/gollumfrom ~17 real routes (/gollum/last_commit_infosurfaced as/last_commit_info). Modifier forms (forbid unless x,return if y) sit mid-line, never at a statement boundary, so they are correctly left uncounted. Oneend(-1) is the only closer;do(+1) and any statement-position keyword block (+1) are the openers. The three matchers are folded into a single ordered-alternation scan so each line takes one regex pass instead of three — this is the hottest per-line call in the whole-tree scan. The\bend\b/\bdo\balternatives capture exactly "end"/"do"; the keyword alternative captures its;/leading-space prefix too, so the closer is identified by an exact-string test and everything else is an opener.
SINATRA_RESERVED_PARAMS = Set {"splat", "captures"}
params[:splat] (the * wildcard matches) and params[:captures]
(regex route captures) are Sinatra's framework bindings for the
route pattern itself, not user-supplied query fields — the */regex
segment is already modeled in the URL.
Class methods
tech_name
SourceInstance methods
analyze
Sourcetech
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.