[hermes] atlasbot: python:S1871 #9

Open
opened 2026-08-19 14:19:54 +00:00 by hermes-automation · 0 comments

SonarQube reports python:S1871 in atlasbot/matrix/bot.py. The build is green; this is a standing finding, not a failure.

What is wrong

In the heartbeat loop of MatrixBot._answer_with_heartbeat, the if/elif chain has two branches whose bodies are both the identical statement should_send = True, so the branching adds no information and Sonar flags it as duplicated. The two conditions are genuinely different tests (new note text vs. stale-resend interval) that happen to lead to the same outcome, so the correct fix is to combine them into one boolean expression rather than to differentiate the bodies.

Ariadne opened no pull request for it: no automated patch was possible for this finding.

Facts

  • gitea — Either merge this branch with the identical one on line "168" or change one of the implementations. (MAJOR, 10min estimated) (atlasbot/matrix/bot.py:170)

Suggested fix (not applied)

Hermes could not open a pull request for this, so the change below was not written, validated, or pushed anywhere. It is a starting point for whoever picks this up, not a reviewed patch.

atlasbot/matrix/bot.py — Replace the if/elif chain (whose two branches both assign should_send = True) with a single short-circuiting boolean assignment. or preserves the original evaluation order exactly: the elapsed-time comparison is only evaluated when the note-changed test is falsy, matching elif semantics. The snippet and guard is kept verbatim so the empty-snippet case still falls through to the time check instead of comparing against last_note, and bool(...) keeps the value a plain bool when snippet is the empty string. The max(...) threshold is lifted into a named local purely so the expression fits on
... (truncated)

snippet = note[:64]
                now = time.monotonic()
                resend_after = max(60.0, self._settings.thinking_interval_sec * 2)
                should_send = bool(snippet and snippet != last_note) or (
                    now - last_sent >= resend_after
                )
                if should_send:
                    msg = f"Still thinking — {snippet}…"
                    await self._client.send_message(token, room_id, msg)
                    last_note = snippet
                    last_sent = now

Filed automatically by Ariadne from a Hermes Agent diagnosis (run run_5516b3d1ec9045d3ae19f40c98b0878d). Hermes has no write access to this repository; no files or infrastructure were changed.

SonarQube reports **python:S1871** in `atlasbot/matrix/bot.py`. The build is green; this is a standing finding, not a failure. ## What is wrong In the heartbeat loop of MatrixBot._answer_with_heartbeat, the if/elif chain has two branches whose bodies are both the identical statement `should_send = True`, so the branching adds no information and Sonar flags it as duplicated. The two conditions are genuinely different tests (new note text vs. stale-resend interval) that happen to lead to the same outcome, so the correct fix is to combine them into one boolean expression rather than to differentiate the bodies. Ariadne opened no pull request for it: no automated patch was possible for this finding. ## Facts - **gitea** — Either merge this branch with the identical one on line "168" or change one of the implementations. (MAJOR, 10min estimated) (`atlasbot/matrix/bot.py:170`) ## Suggested fix (not applied) Hermes could not open a pull request for this, so the change below was not written, validated, or pushed anywhere. It is a starting point for whoever picks this up, not a reviewed patch. **`atlasbot/matrix/bot.py`** — Replace the if/elif chain (whose two branches both assign should_send = True) with a single short-circuiting boolean assignment. `or` preserves the original evaluation order exactly: the elapsed-time comparison is only evaluated when the note-changed test is falsy, matching elif semantics. The `snippet and` guard is kept verbatim so the empty-snippet case still falls through to the time check instead of comparing against last_note, and bool(...) keeps the value a plain bool when `snippet` is the empty string. The max(...) threshold is lifted into a named local purely so the expression fits on ... (truncated) ``` snippet = note[:64] now = time.monotonic() resend_after = max(60.0, self._settings.thinking_interval_sec * 2) should_send = bool(snippet and snippet != last_note) or ( now - last_sent >= resend_after ) if should_send: msg = f"Still thinking — {snippet}…" await self._client.send_message(token, room_id, msg) last_note = snippet last_sent = now ``` ## Links - SonarQube finding: https://quality.bstein.dev/project/issues?resolved=false&id=atlasbot&open=AZ2y3T24Ky9i4pkIpSiI - Full evidence bundle and audit trail live in Ariadne at `/api/admin/audit/events`, event types `hermes_autotriage_incident` and `hermes_autotriage_diagnosis`. Filed automatically by Ariadne from a Hermes Agent diagnosis (run [run_5516b3d1ec9045d3ae19f40c98b0878d](https://triage.hermes.bstein.dev/chat?resume=run_5516b3d1ec9045d3ae19f40c98b0878d)). Hermes has no write access to this repository; no files or infrastructure were changed. <!-- hermes-triage job=atlasbot classification=python:S1871 incident=sonar/atlasbot/python:S1871/AZ2y3T24Ky9i4pkIpSiI -->
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bstein/atlasbot#9
No description provided.