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

Feature/refactor dto #16

Merged
merged 14 commits into from
Jul 18, 2022
Merged

Feature/refactor dto #16

merged 14 commits into from
Jul 18, 2022

Conversation

codecakes
Copy link
Contributor

No description provided.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jul 12, 2022

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 2.56%.

Quality metrics Before After Change
Complexity 0.63 ⭐ 1.05 ⭐ 0.42 👎
Method Length 24.09 ⭐ 28.10 ⭐ 4.01 👎
Working memory 4.71 ⭐ 5.11 ⭐ 0.40 👎
Quality 91.20% 88.64% -2.56% 👎
Other metrics Before After Change
Lines 620 806 186
Changed files Quality Before Quality After Quality Change
registrations/domain/dto.py 85.25% ⭐ 72.83% 🙂 -12.42% 👎
registrations/domain/hospital/registration.py 92.10% ⭐ 90.75% ⭐ -1.35% 👎
registrations/domain/location/location.py 90.98% ⭐ 90.98% ⭐ 0.00%
registrations/domain/repo/registration_repo.py 97.61% ⭐ 97.21% ⭐ -0.40% 👎
registrations/domain/services/application_services.py 74.16% 🙂 89.68% ⭐ 15.52% 👍
registrations/domain/services/hospital_registration_services.py 93.39% ⭐ 93.30% ⭐ -0.09% 👎
registrations/infrastructure/adapters/api/routers/register_hospital.py 76.77% ⭐ 69.34% 🙂 -7.43% 👎
registrations/utils/enum_utils.py 96.34% ⭐ 98.34% ⭐ 2.00% 👍
tests/conftest.py 94.41% ⭐ 90.24% ⭐ -4.17% 👎
tests/test_registrations.py 92.61% ⭐ 89.56% ⭐ -3.05% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
registrations/domain/dto.py validate_name 5 ⭐ 68 🙂 13 😞 63.50% 🙂 Extract out complex expressions
registrations/infrastructure/adapters/api/routers/register_hospital.py register_hospital_center 4 ⭐ 58 ⭐ 11 😞 69.34% 🙂 Extract out complex expressions
tests/conftest.py registration_entry_manual_verification 0 ⭐ 41 ⭐ 15 😞 70.07% 🙂 Extract out complex expressions
tests/conftest.py registration_entry_unclaimed 0 ⭐ 33 ⭐ 12 😞 75.62% ⭐ Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

raise ValueError(f"Invalid name: {name}. Not enough characters.")
return name

@pydantic.root_validator
Copy link

Choose a reason for hiding this comment

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

Invalid decoration: While applying decorator pydantic.root_validator

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sonatype-lift ignore

Copy link

Choose a reason for hiding this comment

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

I've recorded this as ignored for this pull request. If you change your mind, just comment @sonatype-lift unignore.

@codecakes codecakes self-assigned this Jul 13, 2022
@codecakes codecakes added the enhancement New feature or request label Jul 13, 2022
@@ -21,7 +24,7 @@ class RegisterKeyContact(
email: Optional[pydantic.EmailStr]


class HospitalRegistrationEntry(
class ToHospitalRegistrationEntry(
Copy link

Choose a reason for hiding this comment

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

Uninitialized attribute: Attribute hospital_contact_number is declared in class ToHospitalRegistrationEntry to have type str but is never initialized.

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sonatype-lift ignore

Copy link

Choose a reason for hiding this comment

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

I've recorded this as ignored for this pull request. If you change your mind, just comment @sonatype-lift unignore.

@@ -21,7 +24,7 @@ class RegisterKeyContact(
email: Optional[pydantic.EmailStr]


class HospitalRegistrationEntry(
class ToHospitalRegistrationEntry(
Copy link

Choose a reason for hiding this comment

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

Uninitialized attribute: Attribute name is declared in class ToHospitalRegistrationEntry to have type str but is never initialized.

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sonatype-lift ignore

Copy link

Choose a reason for hiding this comment

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

I've recorded this as ignored for this pull request. If you change your mind, just comment @sonatype-lift unignore.

@@ -21,7 +24,7 @@ class RegisterKeyContact(
email: Optional[pydantic.EmailStr]


class HospitalRegistrationEntry(
class ToHospitalRegistrationEntry(
Copy link

Choose a reason for hiding this comment

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

Uninitialized attribute: Attribute verified_status is declared in class ToHospitalRegistrationEntry to have type Optional[str] but is never initialized.

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sonatype-lift ignore

Copy link

Choose a reason for hiding this comment

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

I've recorded this as ignored for this pull request. If you change your mind, just comment @sonatype-lift unignore.

@@ -21,7 +24,7 @@ class RegisterKeyContact(
email: Optional[pydantic.EmailStr]


class HospitalRegistrationEntry(
class ToHospitalRegistrationEntry(
Copy link

Choose a reason for hiding this comment

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

Uninitialized attribute: Attribute address is declared in class ToHospitalRegistrationEntry to have type Address but is never initialized.

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sonatype-lift ignore

Copy link

Choose a reason for hiding this comment

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

I've recorded this as ignored for this pull request. If you change your mind, just comment @sonatype-lift unignore.

@@ -21,7 +24,7 @@ class RegisterKeyContact(
email: Optional[pydantic.EmailStr]


class HospitalRegistrationEntry(
class ToHospitalRegistrationEntry(
Copy link

Choose a reason for hiding this comment

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

Uninitialized attribute: Attribute key_contact is declared in class ToHospitalRegistrationEntry to have type Optional[RegisterKeyContact] but is never initialized.

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@@ -21,7 +24,7 @@ class RegisterKeyContact(
email: Optional[pydantic.EmailStr]


class HospitalRegistrationEntry(
class ToHospitalRegistrationEntry(
Copy link

Choose a reason for hiding this comment

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

Uninitialized attribute: Attribute ownership_type is declared in class ToHospitalRegistrationEntry to have type str but is never initialized.

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

from registrations.domain.location.location import Address
from registrations.utils import enum_utils
from registrations.utils.errors import InvalidRegistrationEntryError


class RegisterKeyContact(
Copy link

Choose a reason for hiding this comment

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

Unexpected keyword: Unexpected keyword argument extra to call object.__init_subclass__.

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sonatype-lift ignore

Copy link

Choose a reason for hiding this comment

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

I've recorded this as ignored for this pull request. If you change your mind, just comment @sonatype-lift unignore.

@@ -65,7 +54,12 @@ def _validate_number(cls, phone_number: str) -> str:


# Value Object
class ContactPerson(pydantic.BaseModel, allow_mutation=False, validate_assignment=True):
class ContactPerson(
Copy link

Choose a reason for hiding this comment

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

Unexpected keyword: Unexpected keyword argument extra to call object.__init_subclass__.

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]


@pydantic.root_validator
Copy link

Choose a reason for hiding this comment

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

Invalid decoration: While applying decorator pydantic.root_validator

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sonatype-lift ignore

Copy link

Choose a reason for hiding this comment

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

I've recorded this as ignored for this pull request. If you change your mind, just comment @sonatype-lift unignore.

@@ -12,7 +12,7 @@ class Address(pydantic.BaseModel, extra=pydantic.Extra.forbid):

@pydantic.root_validator(pre=True)
Copy link

Choose a reason for hiding this comment

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

Invalid decoration: While applying decorator pydantic.root_validator(...)

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sonatype-lift ignore

Copy link

Choose a reason for hiding this comment

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

I've recorded this as ignored for this pull request. If you change your mind, just comment @sonatype-lift unignore.

Co-authored-by: Sourcery AI <>
@codecakes codecakes marked this pull request as ready for review July 17, 2022 19:54
@codecakes codecakes requested review from anjayluh, atuljain, Matt-Murungi and a team July 17, 2022 20:04
@codecakes codecakes added help wanted Extra attention is needed dependencies Pull requests that update a dependency file labels Jul 17, 2022
Copy link

@zabuldon zabuldon 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 for me.

tests/test_registrations.py Outdated Show resolved Hide resolved
@codecakes codecakes linked an issue Jul 18, 2022 that may be closed by this pull request
Copy link

@zabuldon zabuldon 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.

@codecakes codecakes merged commit e17232b into develop Jul 18, 2022
@codecakes codecakes deleted the feature/refactor-dto branch July 18, 2022 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request help wanted Extra attention is needed
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Domain Model Design
2 participants