Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Copy Markdown

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.

extends Result
Comment on lines 30 to 37
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Adding a new field to a case class, even with a default value, breaks binary compatibility in Scala. The JVM signature of the constructor, apply, unapply, and copy methods will change. Any downstream dependency compiled against the previous version of this library will throw a NoSuchMethodError or LinkageError at runtime if they attempt to instantiate or pattern match on Result.Issue without being recompiled.

To mitigate this and maintain binary compatibility for direct instantiations (via apply), you can define an explicit companion object with an overloaded apply method that accepts 6 arguments. Note that pattern matching (unapply) and copy will still remain binary-incompatible, so a minor/major version bump and recompilation of downstream consumers is highly recommended.

  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
Expand Down