class

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 +1 their matching end will later subtract. The previous open/close split counted every end as a close while ignoring the if/case/… that opened it. A single multi-line if inside a route body therefore popped the surrounding namespace prefix early — gollum dropped /gollum from ~17 real routes (/gollum/last_commit_info surfaced 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. One end (-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\b alternatives 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
Source

Instance methods

analyze
Source
line_to_param(content : String) : Param
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