class
Analyzer::Ruby::Sinatra
- Analyzer::Ruby::Sinatra
- Analyzer::Ruby::RubyEngine
- Analyzer
- Reference
- Object
Defined in:
analyzer/analyzers/ruby/sinatra.crConstant Summary
-
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
{/doopen vs}/endclose 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.
- blanks string interiors first, so
-
SINATRA_RESERVED_PARAMS =
Set {"splat", "captures"} -
params[:splat](the*wildcard matches) andparams[: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.