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

refactor: Move project related value objects to admin.domain.model package and cleanup code #2923

Merged
merged 18 commits into from Nov 10, 2023

Conversation

seakayone
Copy link
Collaborator

@seakayone seakayone commented Nov 9, 2023

Pull Request Checklist

Task Description/Number

from 2.13.2, the sealed abstract case class private can be reduced by enabling -Xsource:3. From scala/scala#7702:

Backport from dotty:

  • If a case class constructor is private or private[foo]: the synthesized copy and apply methods will have the same access modifier.
  • If a case class constructor is protected or protected[foo]: the synthesized copy method will have the same access modifier. The synthesized apply method will remain public, because protected doesn't make sense in an object.

Obviously, if a user defines a custom copy or apply method, that one—including its access modifier—will take precedence.

see also https://tuleism.github.io/blog/2020/scala-smart-constructors/

This way it is also possible to reduce boxing for value classes which can extend AnyVal.

However this PR does not include the activation of that flag as some existing code needs to be updated as well, this is done in #2924

PR Type

  • build/chore: maintenance tasks (no production code change)
  • docs: documentation changes (no production code change)
  • feat: represents new features
  • fix: represents bug fixes
  • perf: performance improvements
  • refactor: represents production code refactoring
  • test: adding or refactoring tests (no production code change)

Basic requirements for bug fixes and features

  • Tests for the changes have been added
  • Docs have been added / updated

Does this PR introduce a breaking change?

  • Yes

Does this PR change client-test-data?

  • Yes

Copy link

codecov bot commented Nov 9, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (3e95d71) 11.68% compared to head (252be57) 88.23%.
Report is 10 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2923       +/-   ##
===========================================
+ Coverage   11.68%   88.23%   +76.54%     
===========================================
  Files         251      248        -3     
  Lines       23065    22989       -76     
===========================================
+ Hits         2695    20284    +17589     
+ Misses      20370     2705    -17665     
Files Coverage Δ
webapi/src/main/scala/dsp/errors/Errors.scala 20.00% <ø> (+15.00%) ⬆️
.../org/knora/webapi/messages/OntologyConstants.scala 99.74% <100.00%> (+1.02%) ⬆️
...sponder/projectsmessages/ProjectsMessagesADM.scala 83.75% <100.00%> (+52.50%) ⬆️
...a/webapi/responders/admin/GroupsResponderADM.scala 93.82% <100.00%> (+93.82%) ⬆️
...webapi/responders/admin/ProjectsResponderADM.scala 92.51% <100.00%> (+92.51%) ⬆️
...ra/webapi/responders/admin/UsersResponderADM.scala 89.31% <100.00%> (+89.31%) ⬆️
...ora/webapi/responders/v2/OntologyResponderV2.scala 92.89% <100.00%> (+92.89%) ⬆️
...pi/slice/admin/api/model/MaintenanceRequests.scala 100.00% <ø> (ø)
...webapi/slice/admin/domain/model/KnoraProject.scala 100.00% <100.00%> (ø)
.../slice/admin/domain/service/KnoraProjectRepo.scala 100.00% <100.00%> (ø)
... and 11 more

... and 188 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@seakayone seakayone self-assigned this Nov 9, 2023
@seakayone seakayone changed the title refactor: Make Shortcode, Shortname and Longname extend Anyval and simplify code refactor: Use Longname in Entity and make Shortcode, Shortname and Longname extend Anyval and simplify code Nov 9, 2023
@seakayone seakayone force-pushed the chore/cleanup branch 2 times, most recently from eefd8e4 to 7b0becf Compare November 9, 2023 13:50
@seakayone seakayone changed the title refactor: Use Longname in Entity and make Shortcode, Shortname and Longname extend Anyval and simplify code refactor: Move project related values to KnoraProject and cleanup code Nov 9, 2023
@seakayone seakayone force-pushed the chore/cleanup branch 3 times, most recently from 0139859 to 8338fee Compare November 9, 2023 16:57
@seakayone seakayone changed the title refactor: Move project related values to KnoraProject and cleanup code refactor: Move project related values object to admin.domain.model package and cleanup code Nov 9, 2023
@seakayone seakayone changed the title refactor: Move project related values object to admin.domain.model package and cleanup code refactor: Move project related value objects to admin.domain.model package and cleanup code Nov 9, 2023
@seakayone seakayone marked this pull request as ready for review November 10, 2023 08:38
@seakayone seakayone requested review from BalduinLandolt, subotic and mpro7 and removed request for subotic November 10, 2023 08:38
Copy link
Collaborator

@mpro7 mpro7 left a comment

Choose a reason for hiding this comment

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

Looks good, apart of places where I suggest changes.

Also general question, why to not keep store error messages in object vals instead of keep repeating them?

@seakayone
Copy link
Collaborator Author

seakayone commented Nov 10, 2023

Also general question, why to not keep store error messages in object vals instead of keep repeating them?

The error message is only used once in production code and is encapsulated in the function returning the error. This approach keeps it close to the actual usage of the code responsible for validation.

I have introduced redundancy in the test to ensure that a change in the production code will cause the test to fail if we unintentionally alter the desired return value. Previously, one could change any of the Project.ErrorMessages in the production code to anything, and the test would always pass because we did not test the actual desired return value but rather that the exact same, changed String was returned.

@seakayone seakayone merged commit 57c6ac2 into main Nov 10, 2023
14 checks passed
@seakayone seakayone deleted the chore/cleanup branch November 10, 2023 17:19
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

Successfully merging this pull request may close these issues.

None yet

3 participants