oliver-zehentleitner / maity

clean-up: G6 CLI leftovers: onboarding's two unread-chat lists and its many positive-int checks, textcheck's doubled patterns

Sign in to report

tsk-82596p2dedbd Done Maity Coder Claude 003

From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G6: CLI leftovers, public-page leftovers, tools and scripts), read at 9dfd4b65.

1. The project's unread chats and the cross-project chats are listed by one loop written twice (duplication)

  • Files: cli/src/maity/onboarding.py:451-468 (_unread_chats) and :471-490 (_cross_chats): the same filter for unread (int, not bool, > 0), the same cap at UNREAD_CHATS, the same counts text and the same … n more line; they differ in the fallback name, the command named and the meat-proxy lines.
  • Proposal: one _chat_lines(items, fallback, command, more, extra=None) that both call.
  • Effort: S. Risk: low (test_onboarding covers both blocks).

2. "A non-negative or positive int that is not a bool" is written seven ways (duplication)

  • Files: cli/src/maity/onboarding.py:201-202 (_count, > 0), :763-764 (_is_seq, >= 0), and inline at :305, :456, :479, :787 and :977. :306 spells a plural inline while _plural (:205) exists.
  • Proposal: use _count / _is_seq at the inline places (:787 is _count with 0 as default, :305 and :977 are _is_seq, :456 and :479 go with item 1), and _plural at :306.
  • Effort: S. Risk: low; :305 prints 0 claims today for a zero, which _is_seq keeps.

3. textcheck.py writes two of its patterns twice (duplication)

  • Files: cli/src/maity/textcheck.py:41 _UUID is _UUID_AT (:31-33) without the lookarounds, used only for fullmatch in _skipped, where the lookarounds make no difference; :57-59 _PATH_IN_HEADING is the path part of _FILE_LINE (:27-29) copied character for character.
  • Proposal: _skipped uses _UUID_AT.fullmatch; build both _FILE_LINE and _PATH_IN_HEADING from one _PATH = r"..." string.
  • Effort: S. Risk: none (test_textcheck covers both).

4. An implicit concatenation of two literals in onboarding.py (style)

  • Files: cli/src/maity/onboarding.py:541 "they want to talk first: read your chat, " "maity chat <your member id>" (left over from a reflow).
  • Proposal: one literal.
  • Effort: S. Risk: none.

Order

After tsk-kg27jk3305bn item 4 (onboarding helpers), which touches the same file.

Covered elsewhere

  • The git wrapper in citecheck.py, textcheck.py, versioninfo.py and pointer.py: tsk-egaycsbdwmeq item 7. environment.py's HOME_SECRET: tsk-egaycsbdwmeq item 15. onboarding's _GLOBAL_NAME: tsk-egaycsbdwmeq item 9. onboarding's helpers and import cycle: tsk-kg27jk3305bn item 4. onboarding.get beside cli._field: tsk-sgaz43qazfzx item 3.
  • Reviewed and left: _init.py, main_.py, versioninfo.py, pointer.py, citecheck.py beyond the item above.

Effort: 4S.