Skip to content
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

Early semver labels are wrongly added #3475

Open
dpevunov-cp opened this issue Nov 11, 2024 · 1 comment
Open

Early semver labels are wrongly added #3475

dpevunov-cp opened this issue Nov 11, 2024 · 1 comment

Comments

@dpevunov-cp
Copy link

I suppose that in some cases 'early-semver-<major/minor/patch>' are wrongly added to the PRs produced by scala-steward
Currently there is a code below to define the severity of change for early-semver. Judging by the definition I would say it should return None if major is not zero which in turn will lead to earlySemVerLabel not having 'early-semver-<major/minor/patch>' for dependency changes with major > 0

I have found that even in your test the lable is wrongly added for the following dependency changes

val update1 = ("ch.qos.logback".g % "logback-classic".a % "1.2.0" %> "1.2.3").single
val update2 = ("com.example".g % "foo".a % "1.0.0" %> "2.0.0").single
val update = Update.Grouped("my-group", None, List(update1, update2))
val earlySemVerLabel = semVerVersions.flatMap { case (curr, next) =>
        SemVer.getChangeEarly(curr, next).map(c => s"early-semver-${c.render}")
      }
@tailrec
  def getChangeEarly(from: SemVer, to: SemVer): Option[Change] = {
    val zero = "0"
    // Codacy doesn't allow using `if`s, so using `match` instead
    (from.major === zero, to.major === zero) match { // work around Codacy's "Consider using case matching instead of else if blocks"
      case (true, true)
          if from.minor =!= zero ||
            to.minor =!= zero ||
            from.patch =!= zero ||
            to.patch =!= zero =>
        getChangeEarly(
          from.copy(major = from.minor, minor = from.patch, patch = zero),
          to.copy(major = to.minor, minor = to.patch, patch = zero)
        )
      case _ =>
        getChangeSpec(from, to)
    }
  }
@dpevunov-cp
Copy link
Author

Could any maintainer review my finding and prove or reject it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant