From f4a188068f1301f554ab7ce737d52936862db1fe Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Fri, 8 May 2026 20:34:29 +0200 Subject: [PATCH] fix: remove dead code in unplayable_reason; add coverage for playable path --- .../evidence/protondb-coverage-fix.json | 28 +++++++++++++++++++ python_pkg/steam_backlog_enforcer/protondb.py | 6 ++-- .../tests/test_protondb.py | 4 +++ 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 docs/superpowers/evidence/protondb-coverage-fix.json diff --git a/docs/superpowers/evidence/protondb-coverage-fix.json b/docs/superpowers/evidence/protondb-coverage-fix.json new file mode 100644 index 0000000..1a38b4f --- /dev/null +++ b/docs/superpowers/evidence/protondb-coverage-fix.json @@ -0,0 +1,28 @@ +{ + "intent": "Remove unreachable dead code in unplayable_reason and add coverage for the is_playable=True path.", + "scope": [ + "python_pkg/steam_backlog_enforcer/protondb.py", + "python_pkg/steam_backlog_enforcer/tests/test_protondb.py" + ], + "changes": [ + "Replaced conditional 'if tier_rank > min_rank and trend_rank > min_rank: return ...' + dead fallback 'return fails ProtonDB rule' with a direct return, since the condition is always True in that branch", + "Added test_unplayable_reason_empty_when_playable to cover the return '' path" + ], + "verification": [ + { + "command": "pre-commit run --files protondb.py tests/test_protondb.py", + "result": "pass", + "evidence": "All hooks passed on second run (ruff auto-fixed unused variable on first run)" + }, + { + "command": "pytest python_pkg/steam_backlog_enforcer/tests/test_protondb.py", + "result": "pass", + "evidence": "31 passed, 0 failed" + } + ], + "risks": ["None — dead code removal only, no logic change"], + "rollback": [ + "Revert protondb.py to restore the if-condition and fallback return", + "Remove the new test" + ] +} diff --git a/python_pkg/steam_backlog_enforcer/protondb.py b/python_pkg/steam_backlog_enforcer/protondb.py index 10d4c6a..cdb29a7 100644 --- a/python_pkg/steam_backlog_enforcer/protondb.py +++ b/python_pkg/steam_backlog_enforcer/protondb.py @@ -90,7 +90,7 @@ class ProtonDBRating: return "" tier_rank = TIER_ORDER.get(self.tier, 99) - min_rank = TIER_ORDER[MIN_PLAYABLE_TIER] + TIER_ORDER[MIN_PLAYABLE_TIER] silver_rank = TIER_ORDER["silver"] if not self.trending_tier: @@ -99,9 +99,7 @@ class ProtonDBRating: trend_rank = TIER_ORDER.get(self.trending_tier, 99) if tier_rank > silver_rank or trend_rank > silver_rank: return f"below silver ({self.tier}/{self.trending_tier})" - if tier_rank > min_rank and trend_rank > min_rank: - return f"no gold tier ({self.tier}/{self.trending_tier})" - return "fails ProtonDB rule" + return f"no gold tier ({self.tier}/{self.trending_tier})" def _load_cache() -> dict[str, Any]: diff --git a/python_pkg/steam_backlog_enforcer/tests/test_protondb.py b/python_pkg/steam_backlog_enforcer/tests/test_protondb.py index bd581e1..2a0caa1 100644 --- a/python_pkg/steam_backlog_enforcer/tests/test_protondb.py +++ b/python_pkg/steam_backlog_enforcer/tests/test_protondb.py @@ -100,6 +100,10 @@ class TestProtonDBRating: r = ProtonDBRating(app_id=1, tier="gold", trending_tier="bronze") assert "below silver" in r.unplayable_reason + def test_unplayable_reason_empty_when_playable(self) -> None: + r = ProtonDBRating(app_id=1, tier="gold") + assert r.unplayable_reason == "" + class TestProtonDBCache: """Tests for cache I/O."""