-
Notifications
You must be signed in to change notification settings - Fork 10
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
♻️ Lot of analyser fixes #399
base: develop
Are you sure you want to change the base?
Conversation
input = Regex.Replace(input ?? "", @"\p{C}+", string.Empty); | ||
return input.Trim().Length == 0 ? defaultValue : input.Substring(0, Math.Min(input.Length, 30)); | ||
return input.Trim().Length == 0 ? defaultValue : input[..Math.Min(input.Length, 30)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really cool. Feels like python :D
@@ -17,7 +17,7 @@ protected ActionResult Page(string message, int code) | |||
{ | |||
Response.StatusCode = code; | |||
|
|||
bool success = code >= 200 && code < 300; | |||
bool success = code is >= 200 and < 300; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wtf :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perosnaly have no issues with changes, apart from that Mention removal method which is already hard to read, idk if it's a good idea to listen to IDE there. Otherwise very nice 👍
var text = new StringBuilder("I picked: "); | ||
var winNumber = random.Next(answers.Length); | ||
var winner = answers[winNumber]; | ||
int winNumber = random.Next(answers.Length); | ||
string winner = answers[winNumber]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
var response = new DiscordInteractionResponseBuilder() | ||
.WithTitle($"New Warning for {ctx.TargetMember.DisplayName}") | ||
.WithCustomId(modalId) | ||
.AddComponents(new TextInputComponent("Reason:", reasonId, required: true)); | ||
await ctx.CreateResponseAsync(InteractionResponseType.Modal, response); | ||
|
||
var numberOfWarnings = await _warningService.GetNumberOfWarnings(ctx.TargetUser.Id); | ||
int numberOfWarnings = await _warningService.GetNumberOfWarnings(ctx.TargetUser.Id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same goes here link
} | ||
catch (NotFoundException) | ||
{} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this change increases readability. There is also duplicite code now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github changed it... This review was for the changes in the whole file StringExtensions.cs
return null; | ||
|
||
return GetDto(reminder); | ||
return reminder == null ? null : GetDto(reminder); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return reminder == null ? null : GetDto(reminder); | |
return reminder is null ? null : GetDto(reminder); |
int encLen = (input.Length + 1) * 3; | ||
var enc = encLen <= 1024 ? stackalloc byte[encLen] : new byte[encLen]; | ||
Span<byte> bytes = stackalloc byte[256 / 8]; | ||
|
||
var len = Encoding.UTF8.GetBytes(input, enc); | ||
int len = Encoding.UTF8.GetBytes(input, enc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixing diferent declaration types 😄
return null; | ||
|
||
return GetDto(warning); | ||
return warning == null ? null : GetDto(warning); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return warning == null ? null : GetDto(warning); | |
return warning is null ? null : GetDto(warning); |
Quite a lot of fixes from the analyzer. I have only used the most relevant ones. There was also one nullable warning (in Poll.cs).