[hermes] atlasbot: python:S1871 #137

Open
opened 2026-09-25 04:23:28 +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 coroutine inside MatrixBot._answer_with_heartbeat, the if branch on line 168 and the elif branch on line 170 have identical bodies (both just set should_send = True), so the if/elif split adds no information and Sonar flags the duplicate implementations. The two conditions express one decision — send a heartbeat when the note changed or when enough time has passed — and should be combined into a single boolean expression.

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 should_send = False initializer plus the if/elif pair (each assigning should_send = True) with a single assignment that ORs the two conditions. Evaluation order is preserved: the note-change check runs first and short-circuits, and the time-based fallback only applies otherwise, exactly as the elif did. The falsy-snippet case is unchanged too — an empty snippet still falls through to the time check. No rule suppression needed.

snippet = note[:64]
                now = time.monotonic()
                should_send = (snippet and snippet != last_note) or (
                    now - last_sent >= max(60.0, self._settings.thinking_interval_sec * 2)
                )
                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_b9021ca14ba8408f9f7aedff52e25df1). 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 coroutine inside MatrixBot._answer_with_heartbeat, the if branch on line 168 and the elif branch on line 170 have identical bodies (both just set should_send = True), so the if/elif split adds no information and Sonar flags the duplicate implementations. The two conditions express one decision — send a heartbeat when the note changed or when enough time has passed — and should be combined into a single boolean expression. 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 should_send = False initializer plus the if/elif pair (each assigning should_send = True) with a single assignment that ORs the two conditions. Evaluation order is preserved: the note-change check runs first and short-circuits, and the time-based fallback only applies otherwise, exactly as the elif did. The falsy-snippet case is unchanged too — an empty snippet still falls through to the time check. No rule suppression needed. ``` snippet = note[:64] now = time.monotonic() should_send = (snippet and snippet != last_note) or ( now - last_sent >= max(60.0, self._settings.thinking_interval_sec * 2) ) 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_b9021ca14ba8408f9f7aedff52e25df1](https://triage.bstein.dev/chat?resume=run_b9021ca14ba8408f9f7aedff52e25df1)). 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#137
No description provided.