feat(cli): add lint error types to problem output - #125
feat(cli): add lint error types to problem output#125devin-ai-integration[bot] wants to merge 2 commits into
Conversation
Co-Authored-By: malteherrmann.mail@gmail.com <malteherrmann.mail@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: malteherrmann.mail@gmail.com <malteherrmann.mail@gmail.com>
| pub fn match_problem(problem: &str) -> LintErrorType { | ||
| let lowercase = problem.to_lowercase(); | ||
|
|
||
| if lowercase.starts_with("duplicate ") { | ||
| return LintErrorType::Duplicate; | ||
| } | ||
|
|
||
| if lowercase.contains("filename") || lowercase.contains("found in file") { | ||
| return LintErrorType::File; | ||
| } | ||
|
|
||
| if lowercase.contains("directory") { | ||
| return LintErrorType::Dir; | ||
| } | ||
|
|
||
| if lowercase.contains("whitespace") || lowercase.contains(" space ") { | ||
| return LintErrorType::Whitespace; | ||
| } | ||
|
|
||
| if lowercase.contains("pr link") || lowercase.contains("pr number") { | ||
| return LintErrorType::PullRequest; | ||
| } | ||
|
|
||
| if lowercase.contains("change type") { | ||
| return LintErrorType::ChangeType; | ||
| } | ||
|
|
||
| if lowercase.contains("category") { | ||
| return LintErrorType::Category; | ||
| } | ||
|
|
||
| if lowercase.contains("description") | ||
| || lowercase.contains("should be used instead of") | ||
| || lowercase.contains("malformed entry") | ||
| { | ||
| return LintErrorType::Description; | ||
| } | ||
|
|
||
| if lowercase.contains("version string") | ||
| || lowercase.contains("release link") | ||
| || lowercase.contains("unreleased header") | ||
| { | ||
| return LintErrorType::Release; | ||
| } | ||
|
|
||
| LintErrorType::Other | ||
| } |
There was a problem hiding this comment.
🟡 Lint problems can be labelled with the wrong problem type when the changelog text happens to contain certain words
The problem type is guessed by searching the whole problem sentence, including the user's own changelog text that is quoted inside it (LintErrorType::match_problem at src/common/problem.rs:34-80), so an entry whose text mentions words like "directory", "whitespace" or "filename" is reported under a completely unrelated problem type.
Impact: Users see wrong labels next to some lint problems and misleading counts in the new per-type summary.
How the whole-message keyword search picks up quoted entry text
Messages such as "PR description should end with a dot: '{}'" (src/common/entry.rs:67) and "malformed entry: '{}'" (src/single_file/entry.rs:47) embed the raw changelog line. match_problem checks contains("directory"), contains("filename"), contains("whitespace"), contains(" space "), contains("pr link"), contains("change type") and contains("category") before the description branch, so e.g. PR description should end with a dot: 'Move directory handling' is classified as Dir, and ... 'Add category filters' as Category.
Separately, the change-type spelling problem "'{}' should be used instead of '{}'" produced at src/single_file/change_type.rs:70-73 is a change-type issue but matches the should be used instead of rule and is reported as description.
A more robust fix is the follow-up the description mentions: have each leaf check pass its own LintErrorType instead of deriving it from the rendered message, or at least match only on the fixed prefix of the message before the quoted user content.
Prompt for agents
LintErrorType::match_problem in src/common/problem.rs derives the lint error type by keyword-searching the entire rendered problem message. Many problem messages embed arbitrary user content (the offending changelog line or description), e.g. "PR description should end with a dot: '<desc>'" in src/common/entry.rs and "malformed entry: '<line>'" in src/single_file/entry.rs. Because keyword checks for directory/filename/whitespace/space/pr link/change type/category run before the description check, an entry whose text contains those words gets classified under the wrong type, corrupting both the per-problem label and the per-type summary printed by src/cli/lint.rs. Additionally, the change-type spelling message produced in src/single_file/change_type.rs ("'X' should be used instead of 'Y'") is classified as Description rather than ChangeType. Consider having the individual checks supply their LintErrorType explicitly (the follow-up mentioned in the PR description), or match only against the portion of the message preceding quoted user content.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
This is mentioned as a potential follow-up on this PR -- to push the problem type down to the leaves and avoid the pattern matching. I want this to be done on this PR because this pattern matching is not only ugly code but it's error-prone as well.
Summary
Closes #106: linter problems now carry a type instead of being plain strings, so
clu lintoutput explains what kind of problem was found.New
common::problemmodule:LintErrorType::match_problem(&str)is the matcher deriving the type from the problem description (e.g."PR link is not matching PR number ..."->PullRequest,"duplicate release: ..."->Duplicate,"'ABI' should be used instead of 'ABi'"->Description).Problem::newcalls it, so all existing check functions keep producingStringdescriptions and only the aggregation layer changes:SingleFileChangelog.problems,MultiFileChangelog.problemsandChangelog::get_problems()areVec<Problem>/&[Problem]now.Output format gained the type and a per-type summary:
Follow-up option (not done here to keep the diff focused): push
Problemdown into the leaf checks so each check states its type explicitly instead of relying on the string matcher.Link to Devin session: https://app.devin.ai/sessions/155810153b9847b79dcff5c9d330cc97
Requested by: @MalteHerrmann