The bitrate/codec quality ladder is hand-copied into four files, and the only unit test targets the copy with no caller
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
調査の方向性
Read the four implementations in SearchResultScorer.cs, CompositeScorer.cs, SearchResultSortingService.cs, and QualityProfileService.cs, plus tests/Features/Application/Audiobooks/Quality/QualityScoringTests.cs. Start by tracing the three live callers and checking where QualityMatcher in listenarr.domain/Common/ can live without unwanted assembly dependencies. Done means one shared ladder serves the live callers, the unreachable copy is resolved, and the existing score assertions cover the surviving implementation.
索引モデルが issue の本文から書いたものです。
説明
Summary
GetQualityScore maps a quality string to a number (FLAC 100, AAX 95, M4B 90, Opus 85, the V0/V1/V2 presets, then bitrates). It is written out by hand in four separate files. Three of those drive live behaviour, and the fourth has no caller at all, which is awkward because the fourth is the one the only direct unit test of the ladder reaches.
Checked on canary d25b3e11 (1.3.3).
The four copies
| File | Declared at | Called from | What it decides |
|---|---|---|---|
listenarr.application/Search/Scoring/SearchResultScorer.cs |
:414 |
:280 |
accept/reject scoring, and the MinimumScore threshold |
listenarr.application/Search/Scoring/CompositeScorer.cs |
:132 |
:35 |
the "Smart" sort shown in the UI |
listenarr.application/Search/Scoring/SearchResultSortingService.cs |
:137 |
:97-98 |
the "Quality" column sort |
listenarr.application/Audiobooks/Quality/QualityProfileService.cs |
:223 |
nothing | nothing |
Each carries its own private ContainsVbrPreset and ContainsAnyBitrate helpers alongside it, so the duplication is the whole heuristic rather than one method.
git grep -n "GetQualityScore" -- '*.cs'
Ten lines: four declarations, four call sites spread across three of them, and two lines in QualityScoringTests. QualityProfileService is not partial and the method is private, so the absence of a call inside its own file is the whole story for that copy.
Why the test does not cover any of this
tests/Features/Application/Audiobooks/Quality/QualityScoringTests.cs:28-58 is the only test that exercises the ladder directly. It reaches QualityProfileService.GetQualityScore at :37 through BindingFlags.NonPublic | BindingFlags.Instance and puts nine tokens through it.
Those assertions are correct. They are just against the one copy that cannot affect anything. Nothing asserts that the three live copies return the same numbers, and because all four are private, nothing can assert it without reflection either.
They have already drifted once
SearchResultSortingService.cs:142 lowercases with ToLowerInvariant(). The other three use ToLower(), which follows the server's culture.
I want to be accurate about what that is worth. I could not make it change a score. None of the tokens the ladder matches on (flac, aax, m4b, opus, v0, aac, m4a, mp3, vbr, cbr, and the bitrates) contain an i, and the dotted and dotless I is the only place ToLower and ToLowerInvariant disagree for these inputs. I ran the four copies over a token corpus under en-US, de-DE, tr-TR and az-Latn-AZ and they agreed everywhere.
So this is not a live bug. It is one line of unintended difference that got in without anything noticing, in logic where the next such difference would change a ranking silently.
Suggested fix
Extract one implementation and have the three live call sites use it, the same direction as #869 for the naming-variable table. QualityMatcher in listenarr.domain/Common/ already looks like where codec and bitrate knowledge lives, so that may be the natural home, though I have not checked whether moving it there would pull anything unwanted into the domain assembly.
Deciding what happens to the QualityProfileService copy is part of it. If it is genuinely unreachable it can go, but then QualityScoringTests needs repointing at whatever survives rather than deleting, since its assertions are the only recorded statement of what the ladder is supposed to return.
Offer
I have a test that pins the four copies to each other, in case it is wanted ahead of any refactor. It reflects into all four, runs them over a corpus covering every rung plus the casing and separator variants, and asserts they agree, under each of the four cultures above.
It passes on canary as it stands, so it is a regression guard and not a reproduction. It fails the moment someone edits one copy and not the others, and it names the copy that moved. Dropping 85 to 84 in CompositeScorer alone fails it with
"OPUS": SearchResultScorer (accept/reject scoring) = 85, CompositeScorer (Smart sort) = 84,
SearchResultSortingService (Quality column sort) = 85, QualityProfileService (no production caller) = 85
Full suite with it added: 3,042 passed, 0 failed, 127 skipped, against a 3,039 baseline on d25b3e11.
It needs reflection to reach all four, which is awkward, and I would rather that were an argument for making them one method than for keeping the test. Happy to open it as a PR, or to leave it if you would rather go straight to the extraction.
Related
#582 and #549 are also about quality logic, but neither is this. #582 is the import-time comparison of candidate against existing, and #549 is DeriveQualityLabel producing labels that do not match profile keys. This is the search-side scoring ladder and it is duplicated independently of both.
- 主要言語
- C#
- スター
- 901
- フォーク
- 70
- 平均マージ
- 16時間 27分
- マージ済み PR(30日)
- 60
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Listenarrs/Listenarr のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Listenarrs/Listenarr#1173 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Listenarrs/Listenarr#1133 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Listenarrs/Listenarr#1128 ·
メンテナーはふだん 1 日以内に返信
-
Add New's search splits a title that contains "Series:", "Author:"… as if they were search keywordsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Listenarrs/Listenarr#1127 ·
メンテナーはふだん 1 日以内に返信
-
p3
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
Listenarrs/Listenarr#971 ·
メンテナーはふだん 1 日以内に返信
Listenarrs/Listenarr の issue をすべて見る
似ている issue
-
kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
unoplatform/uno#26555 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
CactuseSecurity/firewall-orchestrator#5739 ·
メンテナーはふだん 1 日以内に返信
-
chore project-system small
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
vikramlearning/blazorbootstrap#1388 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
GamaEdtech/gamatrain-back#977 ·
メンテナーはふだん 1 日以内に返信