• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moonbitlang / core / 5652
90%

Build:
DEFAULT BRANCH: main
Ran 28 Jul 2026 12:05PM UTC
Jobs 1
Files 453
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

28 Jul 2026 12:03PM UTC coverage: 90.434%. Remained the same
5652

push

github

bobzhang
refactor: use `is_empty()` instead of comparing `length()` to zero

40 sites in 24 files: `x.length() == 0` becomes `x.is_empty()`, and
`x.length() > 0` / `x.length() != 0` become `!x.is_empty()`.

Found with moongrep:

    moongrep scan --pattern '$(x:exp).length() == 0'   # 21
    moongrep scan --pattern '$(x:exp).length() > 0'    # 25
    moongrep scan --pattern '$(x:exp).length() != 0'   #  2

**8 of the 21 `== 0` hits are the body of `is_empty` itself** and are
excluded — rewriting them would have produced infinite recursion:

    builtin/array.mbt:746          builtin/bytesview.mbt:64
    builtin/bytes.mbt:766          builtin/fixedarray.mbt:169
    builtin/arrayview.mbt:93       builtin/mutarrayview.mbt:83
    builtin/string_methods.mbt:875 immut/sorted_map/utils.mbt:68

A structural pattern cannot see this on its own: the shape of the
definition is identical to the shape of every call site. The candidates
were filtered by resolving each hit's enclosing function and dropping
those inside `fn is_empty`. Worth remembering for any "replace an
expression with the helper that wraps it" rewrite — the helper's own
body always matches.

`moon check --target all` is clean, which also confirms every remaining
receiver actually has an `is_empty` method.

Not included: `x.iter().each(f)` -> `x.each(f)`, which moongrep also
finds 18 of. Every one of those is in a `_test` or `_bench_test` file
that is deliberately exercising `.iter()` — `(Some(3) : Int?).iter()
.each(..)` in `builtin/option_test.mbt` tests `Option::iter`, and
`immut/vector/vector_iter_bench_test.mbt` measures it. Collapsing the
call would remove the thing under test. Left alone.

Tests pass on wasm-gc, js and native; `moon info` reports no `.mbti`
change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

28 of 29 new or added lines in 16 files covered. (96.55%)

15788 of 17458 relevant lines covered (90.43%)

173370.6 hits per line

Uncovered Changes

Lines Coverage ∆ File
1
83.02
0.0% argparse/parser_globals_merge.mbt
Jobs
ID Job ID Ran Files Coverage
1 5652.1 28 Jul 2026 12:05PM UTC 454
90.45
GitHub Action Run
Source Files on build 5652
  • Tree
  • List 453
  • Changed 18
  • Source Changed 18
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 8720b4b3 on github
  • Prev Build on main (#5650)
  • Next Build on main (#5666)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc