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

moonbitlang / core / 4299
94%

Build:
DEFAULT BRANCH: main
Ran 12 May 2026 01:46AM UTC
Jobs 1
Files 365
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

12 May 2026 01:44AM UTC coverage: 94.626% (-0.002%) from 94.628%
4299

push

github

web-flow
refactor(argparse): collapse format_entries to fold + comprehension (#3550)

* refactor(argparse): collapse format_entries to fold + comprehension

`format_entries` had two stateful loops to (1) compute the maximum name
length, then (2) build the formatted entries. Replace both with a single
fold + comprehension:

```diff
 fn format_entries(display : Array[(String, String)]) -> Array[String] {
-  let entries = Array::new(capacity=display.length())
-  let max_len = for item in display; max_len = 0 {
-    let (name, _) = item
-    if name.length() > max_len {
-      continue name.length()
-    } else {
-      continue max_len
-    }
-  } nobreak {
-    max_len
-  }
-  for item in display {
-    let (name, doc) = item
-    let padding = " ".repeat(max_len - name.length() + 2)
-    entries.push("  \{name}\{padding}\{doc}")
-  }
-  entries
+  let max_len = display
+    .iter()
+    .fold(init=0, (acc, item) => acc.max(item.0.length()))
+  fn fmt(name : String, doc : String) -> String {
+    let padding = " ".repeat(max_len - name.length() + 2)
+    "  \{name}\{padding}\{doc}"
+  }
+  [for item in display => fmt(item.0, item.1)]
 }
```

The nested `fmt` helper exists because string interpolation can't contain
`"` inside `\{ }` so the `padding` `let` can't be inlined into a
comprehension body — it's a single-expression closure capturing
`max_len`.

Removes one `let mut`-style accumulator and one imperative-push loop.

Semantics-preserving: `moon test -p argparse` (225/225) passes and
`moon info` produces no `.mbti` change.

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

* refactor(argparse): drop redundant .iter() before Array::fold

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

2 of 2 new or added lines in 1 file covered. (100.0%)

14880 of 15725 relevant lines covered (94.63%)

218227.74 hits per line

Jobs
ID Job ID Ran Files Coverage
1 4299.1 12 May 2026 01:46AM UTC 366
94.64
GitHub Action Run
Source Files on build 4299
  • Tree
  • List 365
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • e3b81960 on github
  • Prev Build on main (#4296)
  • Next Build on main (#4302)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc