-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add extraFields to Result.Issue (OD-41) #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,12 +22,18 @@ object Result { | |
| override def toString: String = value | ||
| } | ||
|
|
||
| /** @param extraFields | ||
| * Tool-specific structured metadata as a raw JSON string (e.g. Trivy dependency chains). | ||
| * Kept as a String to preserve this module's dependency-free, Scala-Native-friendly design; | ||
| * JSON (de)serialization of the embedded value is handled by the codecs in codacy-plugins. | ||
| */ | ||
| case class Issue(filename: Source.File, | ||
| message: Result.Message, | ||
| patternId: Pattern.Id, | ||
| line: Source.Line, | ||
| suggestion: Option[Suggestion], | ||
| sourceId: Option[String]) | ||
| sourceId: Option[String], | ||
| extraFields: Option[String] = None) | ||
| extends Result | ||
|
Comment on lines
30
to
37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding a new field to a case class, even with a default value, breaks binary compatibility in Scala. The JVM signature of the constructor, To mitigate this and maintain binary compatibility for direct instantiations (via case class Issue(filename: Source.File,
message: Result.Message,
patternId: Pattern.Id,
line: Source.Line,
suggestion: Option[Suggestion],
sourceId: Option[String],
extraFields: Option[String] = None)
extends Result
object Issue {
def apply(filename: Source.File,
message: Result.Message,
patternId: Pattern.Id,
line: Source.Line,
suggestion: Option[Suggestion],
sourceId: Option[String]): Issue = {
Issue(filename, message, patternId, line, suggestion, sourceId, None)
}
} |
||
|
|
||
| case class FileError(filename: Source.File, message: Option[ErrorMessage]) extends Result | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 HIGH RISK
Adding extraFields to the Issue case class is a binary and source-breaking change. It breaks binary compatibility for existing plugins and source compatibility for code using pattern matching on Issue. If binary stability is required, consider using a regular class with custom apply and unapply methods or ensure this change is part of a major version release. Try running the following prompt in your coding agent: > Provide a compatibility layer for the Issue case class to support existing 6-parameter calls and pattern matches after adding a 7th parameter.