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: Reduce amount of warnings from 180 to 17 #183

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

marfavi
Copy link
Member

@marfavi marfavi commented Jun 8, 2023

  • Added doc comments to all public fields (phew!)

  • Added nonempty constructors to entities where a field could be null after creation (like strings).

    • Some of these constuctors throw an error if app attempted to instantiate with empty values.
    • Entities still have 0-argument constructors to work with DbSet.
  • Some entities now have simplified constructors.

    • For example, the new Purchase constructor sets 8 fields using 3 parameters.
    • The new Ticket constructor sets 5 fields with 1 parameter.
  • Fixed tests as a result of breaking them.

    • Enable nullable in test project
    • Most should be more robust by avoiding magic strings
    • Test object getters, like a testUser getter, reduces code duplication
    • Redundant fields in test objects have been removed while ensuring the tests still pass.
  • Removed LoginAttempt entity as stated in a TODO comment

  • Removed pragma warning ignores

  • Removed unused usings

marfavi added 3 commits June 8, 2023 11:31
- Added doc comments to all public fields (phew!)

- Added nonempty constructors to entities where a field could be null after creation (like strings).
  > Some of these constuctors throw an error if app attempted to instantiate with empty values.
  > Entities still have 0-argument constructors to work with DbSet.

- Some entities now have simplified constructors.
  > For example, the new Purchase constructor sets 8 fields using 3 parameters.
  > The new Ticket constructor sets 5 fields with 1 parameter.

- Fixed tests as a result of breaking them.
  > Enable `nullable` in test project
  > Most should be more robust by avoiding magic strings
  > Test object getters, like a `testUser` getter, reduces code duplication
  > Redundant fields in test objects have been removed while ensuring the tests still pass.

- Removed `LoginAttempt` entity as stated in a TODO comment
- Removed pragma warning ignores
- Removed unused usings
@marfavi marfavi requested a review from a team June 8, 2023 09:37
@ghost
Copy link

ghost commented Jun 8, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@codecov-commenter
Copy link

codecov-commenter commented Jun 8, 2023

Codecov Report

Merging #183 (d9d3a68) into develop (22271a7) will increase coverage by 0.83%.
The diff coverage is 41.66%.

@@             Coverage Diff             @@
##           develop     #183      +/-   ##
===========================================
+ Coverage    11.55%   12.39%   +0.83%     
===========================================
  Files          142      141       -1     
  Lines         6680     6865     +185     
  Branches       455      478      +23     
===========================================
+ Hits           772      851      +79     
- Misses        5891     5983      +92     
- Partials        17       31      +14     
Impacted Files Coverage Δ
...offeeCard.Library/Persistence/CoffeecardContext.cs 100.00% <ø> (ø)
...card/CoffeeCard.Library/Services/AccountService.cs 46.63% <0.00%> (-0.04%) ⬇️
...ard/CoffeeCard.Library/Services/PurchaseService.cs 0.00% <0.00%> (ø)
...ecard/CoffeeCard.Library/Services/TicketService.cs 0.00% <0.00%> (ø)
...CoffeeCard.Library/Services/v2/StatisticService.cs 0.00% <0.00%> (ø)
...odels/DataTransferObjects/CoffeeCard/CoffeeCard.cs 0.00% <0.00%> (ø)
...taTransferObjects/v2/MobilePay/MobilePayWebhook.cs 0.00% <0.00%> (ø)
...s/DataTransferObjects/v2/Programme/ProgrammeDto.cs 0.00% <0.00%> (ø)
.../DataTransferObjects/v2/Purchase/PaymentDetails.cs 100.00% <ø> (ø)
...nsferObjects/v2/Purchase/SimplePurchaseResponse.cs 0.00% <0.00%> (ø)
... and 40 more

marfavi added 2 commits June 8, 2023 12:01
Created new simplified constructor for UserResponse
Remove commented out code
Remove an unused using
@sonarcloud
Copy link

sonarcloud bot commented Jun 8, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

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

43.8% 43.8% Coverage
1.1% 1.1% Duplication

@jonasanker
Copy link
Member

Really cool that you took the combat on this Omid. Much appreciated. 🙌
I will have a few comments to some of the refactors. Mostly I want to align on the usage of constructors C#'s vs object initialization. We have no standard but we probably should have one.

I will provide my thoughts in a few days. 🙂

@jonasanker
Copy link
Member

Instead of using constructors. we want to use the new required property introduced in C# 11. This will be available in #191. Hereafter we suggest to use this instead of constructors, this we pause this until the completion #191

@jonasanker jonasanker marked this pull request as draft September 23, 2023 19:32
Base automatically changed from develop to main December 7, 2023 18:17
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.

3 participants