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

Refactored validation within GeneralCommands and various warnings #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mcllsti
Copy link

@mcllsti mcllsti commented Nov 13, 2023

PR contains improvements to code base and its readability:

  • Validation code wtihin GeneralCommands has been refactored to cut down on alot of repetitive checks that have been pulled out into a seperate function
  • Tackled two instances of an async method acting synchornous by default, Task.FromResult was used to keep same sync/async flow but to show intentions more clearly.
  • Disabled nullable references in various ORM classes where it made sense to do which also removed nullable warnings. There may be scope in the future to consider logic to explicitly tackle them but disabling makes more sense with their current use.
  • Small code changes that also tackle nullable warnings where it made sense to do so.

Only a single warning should be left in the solution.

…able reference warnings via appropriate suppression or logic improvement
Copy link

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
No Duplication information No Duplication information

@@ -1,5 +1,5 @@
namespace DiscordBot.Models;

#nullable disable
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't be better to add null!; for each property instead. For example:
public string Id { get; set; } = null!;

Choose a reason for hiding this comment

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

Wouldn't be better to add null!; for each property instead. For example: public string Id { get; set; } = null!;

Wouldn't declaring the types as nullable be better? So instead of:

public string Id { get; set; } = null!;

Where you're fighting the compiler to force null into a non null value, you just do:

public string? Id { get; set; };

to properly tell the compiler that the value can be null instead?

Copy link
Contributor

@pauliusdotpro pauliusdotpro left a comment

Choose a reason for hiding this comment

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

Review comment

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