maintainability-agent docs
Languages

Ruby

The second language here with no braces, and the harder of the two. Fortran's closer names what it closes — a subroutine ends at end subroutine — so its end-finder looks for a word. Ruby's one bare end closes a method, a class, a module, a block, an if, a while, a case and a begin, so telling them apart means counting openers.

That counting is the whole scanner. A method containing one items.each do |item| … end ends at its own end, not the block's, and a naive def/end pairing reports half the method. The lengths and complexities drawn from that are not approximately wrong — they describe a different span of code.

Three things make the count wrong if they are not handled first:

All three are blanked or discounted before a single keyword is counted, because a miscount does not corrupt one declaration — it shifts every range after it.

A method carries its class in Ruby's own notation: Store#get for an instance method, Store.build for one defined with def self..

Two defects found by adversarial cases, not by the contract

Both were the dangerous kind, and both are now pinned by tests:

What it misses

All under-reporting rather than over:

Measured with Ruby's own keywords

unless is the idiomatic guard clause and until the negated loop; neither is in the C-family pattern, and elsif has one e so elif misses it too. Measured with C's keywords a guard-heavy Ruby method reads as branchless. and and or are word operators alongside && and ||.