-
Notifications
You must be signed in to change notification settings - Fork 502
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
Make all values in config classes optional #3515
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3515 +/- ##
==========================================
- Coverage 89.64% 89.63% -0.02%
==========================================
Files 171 171
Lines 3525 3540 +15
Branches 315 331 +16
==========================================
+ Hits 3160 3173 +13
- Misses 365 367 +2 ☔ View full report in Codecov by Sentry. |
pullRequests: PullRequestsConfig = PullRequestsConfig(), | ||
scalafmt: ScalafmtConfig = ScalafmtConfig(), | ||
updates: UpdatesConfig = UpdatesConfig(), | ||
commits: Option[CommitsConfig] = None, |
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.
question (non-blocking): Do we still need the None
here? Is it just for tests?
This comment follows the conventionalcomments.org standard
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.
Yes, that is just for the tests. RepoConfigAlgTest
would be cluttered with None
s for example.
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.
Makes total sense. Thanks!
This change maybe also enables us to remove nonExistingUpdatePattern since we now can differentiate between the default value and an empty list that was set by a user. |
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.
This looks like a very systematic change 👍
Do you think converting the fields of the the case classes into private val
would be a good idea to prevent accidental accessing them and forgetting the default value ?
Sounds like a good idea to me. I've done that in fc71579. |
This concludes the work started in #3514 and #3515 to remove the dependency on circe-generic-extras. Here are some notes about the changes: - `Resolver` cases had non-optional fields with defaults that needed to be made optional so that the derived decoder does not fail if those are not provided - `ArtifactChange` and `ArtifactChanges` could have always used `deriveDecoder` since the case classes have no defaults - `ScalafixMigrations` had a default value but a `scalafix-migrations.conf` without a `migrations` fields makes no sense to me and it should be the same as `ArtifactChanges` anyway
I forgot to update this reference in #3515. This is a subtle change in semantics. If `allow == Some(Nil)` `allow.isEmpty` is `false` and `allowOrDefault.isEmpty` is `true`.
This changes
RepoConfig
and the other*Config
classes such that all values are optional and there are no default parameter values exceptNone
s. This allows us to get rid of circe-generic-extras'Configuration.default.withDefaults
andderiveConfiguredCodec
since missingOption
values do not cause an error during decoding. So{}
can still be decoded into aRepoConfig
, and there are a lot of tests inRepoConfigAlgTest
that ensure that sparse configurations with a lot of missing values can still be decoded.Another benefit of this change is that
RepoConfig.show
can now usedeepDropNullValues
so that loggedRepoConfig
s only include stuff which was actually set by a user. For example, before this change, logging aRepoConfig
was similar to this:The same
RepoConfig
is now logged as:Before merging this PR, I'll squash the commits and provide a better commit message, but for potential reviewers, it should be easier to look at each commit individually.
This continues the work started in #3514 of getting rid of circe-generic-extras so that Scala Steward can be built with Scala 3.