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(v3): add role slice (DEV-1010) #2099

Merged
merged 24 commits into from Jul 29, 2022
Merged

Conversation

mpro7
Copy link
Collaborator

@mpro7 mpro7 commented Jul 20, 2022

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: DEV-1010

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@mpro7 mpro7 self-assigned this Jul 26, 2022
@mpro7 mpro7 changed the title Dev 1010 dsp api add role slice refactor(v3): add role slice (DEV-1010) Jul 26, 2022
@mpro7 mpro7 marked this pull request as ready for review July 28, 2022 07:47
Copy link
Collaborator

@BalduinLandolt BalduinLandolt left a comment

Choose a reason for hiding this comment

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

LGTM, I think I have mostly cosmetics to criticise

dsp-role/core/src/main/scala/dsp/role/api/RoleRepo.scala Outdated Show resolved Hide resolved
* @param r the role to write
* @return Unit
*/
def storeRole(r: Role): UIO[RoleId]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def storeRole(r: Role): UIO[RoleId]
def storeRole(role: Role): UIO[RoleId]

I think a little more expressive variable names are nicer

Choose a reason for hiding this comment

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

I agree

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In strongly typed languages the type of param, if not omitted, speaks for itself. Therefore in most of the cases instead of repeating the type in the name it could be shortened to first letter of the type, or named: value, param, whatever, because at the end the IDE will inform one need to pass something of the defined (Role in this case) type.

dsp-role/core/src/main/scala/dsp/role/api/RoleRepo.scala Outdated Show resolved Hide resolved
dsp-role/core/src/main/scala/dsp/role/api/RoleRepo.scala Outdated Show resolved Hide resolved
dsp-shared/src/main/scala/dsp/valueobjects/Iri.scala Outdated Show resolved Hide resolved
dsp-shared/src/main/scala/dsp/valueobjects/Iri.scala Outdated Show resolved Hide resolved
Comment on lines +57 to +68
val View: String = "view"
val Create: String = "create"
val Modify: String = "modify"
val Delete: String = "delete"
val Admin: String = "admin"
val availablePermissions: Set[String] = Set(
View,
Create,
Modify,
Delete,
Admin
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should ad tome point agree how we want to model things like that, that are essentially like an enum

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What's wrong with snipped above?

dsp-shared/src/test/scala/dsp/valueobjects/IriSpec.scala Outdated Show resolved Hide resolved
Copy link

@irinaschubert irinaschubert left a comment

Choose a reason for hiding this comment

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

LGTM, I mostly mentioned things that could be cleaned up

* @param r the role to write
* @return Unit
*/
def storeRole(r: Role): UIO[RoleId]

Choose a reason for hiding this comment

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

I agree

dsp-role/core/src/main/scala/dsp/role/api/RoleRepo.scala Outdated Show resolved Hide resolved
dsp-role/core/src/main/scala/dsp/role/api/RoleRepo.scala Outdated Show resolved Hide resolved
/**
* To be implemented...
*/
object placeholder {}

Choose a reason for hiding this comment

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

Is this file needed? Are you going to implement it? I don't think we need to test the repo api (it's just an interface). I think it makes more sense to test the implementations of it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well this I'm not sure. You also have it in the user slice.

}

val roleRepoMockTests = suite("RoleRepoMock")(
roleTests

Choose a reason for hiding this comment

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

I assume this roleTest is here on purpose (as placeholder)? If not, it would be wrong and should maybe be deleted (or real tests for the mock repo added).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry I don't get this comment.

dsp-shared/src/main/scala/dsp/valueobjects/Iri.scala Outdated Show resolved Hide resolved
dsp-shared/src/main/scala/dsp/valueobjects/Role.scala Outdated Show resolved Hide resolved
* @param value the [[String]] the value to be validated
* @param isoCode thelanguage ISO code to be validated
*/
sealed abstract case class LangString private (value: String, isoCode: String)

Choose a reason for hiding this comment

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

I think it would be more intuititve to turn the paramters' order around: have the isoCode and then the value. This would be the same order as the value is represented when given by or returned to the user, e.g. {"en": "some value"}.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Subject to discuss.

@sonarcloud
Copy link

sonarcloud bot commented Jul 29, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
10.0% 10.0% Duplication

@mpro7 mpro7 merged commit 6920716 into main Jul 29, 2022
@mpro7 mpro7 deleted the DEV-1010-dsp-api-add-role-slice branch July 29, 2022 12:52
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

4 participants