KEMBAR78
Refactor CompletionHelpers `HandleDoubleAndSingleQuote` to have less nesting logic by ArmaanMcleod · Pull Request #25179 · PowerShell/PowerShell · GitHub
Skip to content

Conversation

@ArmaanMcleod
Copy link
Contributor

@ArmaanMcleod ArmaanMcleod commented Mar 15, 2025

PR Summary

Refactor HandleDoubleAndSingleQuote method to have less nesting logic so it is easier to understand.

The current code is very hard to understand in comparison to the flatter version which has less nesting and more clearer variable names and intention.

Obviously just a preference, I am happy to close this PR if people don't find the new refactoring an improvement.

PR Context

PR Checklist

@iSazonov
Copy link
Collaborator

Have we tests covering the method?

@ArmaanMcleod
Copy link
Contributor Author

ArmaanMcleod commented Mar 15, 2025

Have we tests covering the method?

@iSazonov So currently no tests other than tests covering the command completion. I can include XUnit tests in another PR then this one can be covered.

@ArmaanMcleod
Copy link
Contributor Author

ArmaanMcleod commented Mar 15, 2025

Test will be covered in #25181 if we want to merge that in first.

@iSazonov iSazonov added the Blocked blocked on something external to this repo label Mar 15, 2025
@iSazonov
Copy link
Collaborator

Waiting tests...

@ArmaanMcleod ArmaanMcleod requested a review from iSazonov March 15, 2025 22:42
@iSazonov iSazonov added CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log and removed Blocked blocked on something external to this repo labels Mar 17, 2025
@ArmaanMcleod
Copy link
Contributor Author

I'll look into test failures for this one.

bool hasBackSingleQuote = backQuote.IsSingleQuote();
bool hasBackDoubleQuote = backQuote.IsDoubleQuote();

bool hasMatchingFrontAndBackQuote =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe hasBothFrontAndBackQuotes ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@iSazonov Thanks. Like this much better. Fixed in d0bb4f3

return quoteInUse;
}

bool hasValidFrontQuoteAndNoMatchingBackQuote =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe hasFrontQuoteAndNoBackQuote?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@iSazonov Thanks. Like this much better. Fixed in d0bb4f3

@ArmaanMcleod ArmaanMcleod requested a review from iSazonov March 17, 2025 11:48
@iSazonov

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@iSazonov
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@iSazonov

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@iSazonov

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@iSazonov iSazonov self-assigned this Mar 17, 2025
@iSazonov iSazonov merged commit 9f45f9a into PowerShell:master Mar 17, 2025
38 of 40 checks passed
@microsoft-github-policy-service
Copy link
Contributor

microsoft-github-policy-service bot commented Mar 17, 2025

📣 Hey @ArmaanMcleod, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

@iSazonov iSazonov added CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log and removed CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log labels Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants