-
Notifications
You must be signed in to change notification settings - Fork 382
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
Add the AvoidSemicolonsAsLineTerminators rule to warn about lines ending with a semicolon. Fix (#824) #1806
Conversation
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.
Looks great to me, I will give it a test drive but I think otherwise it looks ready to me :-) Just going to re-open this PR to trigger the build since it was temporarily disabled at the time you opened the PR,
@michaeltlombardi Please review. And we need a docs issue opened for this. |
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.
Just a few small docs-related items. Thanks so much for this contribution, @tempora-mutantur!
namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules | ||
{ | ||
/// <summary> | ||
/// AvoidSemicolonsAsLineTerminators: Checks for lines to don't end with semicolons |
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.
Minor suggestion for grammar and to bring synopsis into same structure as other rules.
/// AvoidSemicolonsAsLineTerminators: Checks for lines to don't end with semicolons | |
/// AvoidSemicolonsAsLineTerminators: Checks for lines that end with a semicolon. |
} | ||
|
||
/// <summary> | ||
/// Analyzes the given ast to find violations. |
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.
Suggest clarifying specific behavior and standardizing to other rules.
/// Analyzes the given ast to find violations. | |
/// Checks for lines that end with a semicolon. |
/// </summary> | ||
/// <param name="ast">AST to be analyzed. This should be non-null</param> | ||
/// <param name="fileName">Name of file that corresponds to the input AST.</param> | ||
/// <returns>A an enumerable type containing the violations</returns> |
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.
Minor update to standardize to language used by other rules.
/// <returns>A an enumerable type containing the violations</returns> | |
/// <returns>The diagnostic results of this rule</returns> |
} | ||
|
||
/// <summary> | ||
/// Retrieves the type of the rule, Builtin, Managed or Module. |
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.
Minor fix to standardize casing for valid keys with other items in this doc and to match docs for other rules.
/// Retrieves the type of the rule, Builtin, Managed or Module. | |
/// Retrieves the type of the rule: builtin, managed, or module. |
Rules/Strings.Designer.cs
Outdated
@@ -465,6 +465,42 @@ internal class Strings { | |||
} | |||
} | |||
|
|||
/// <summary> | |||
/// Looks up a localized string similar to Avoid long lines. |
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.
/// Looks up a localized string similar to Avoid long lines. | |
/// Looks up a localized string similar to Avoid semicolons as line terminators. | |
It's a rule to warn about lines ending with a semicolon
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.
LGTM! 💜
I filed a docs issue for tracking this on the other side once this PR is merged. 😊
Thank you all. Could you please advise what I should better do with the PSScriptAnalyzer-CI build failure, got a test failure for WS2022: Test Directed Graph.Runspaces should be disposed. Running analyzer 100 times should only create a limited number of runspaces Expected the actual value to be less than or equal to 14, because Number of Runspaces should be bound (size of runspace pool cache is 10), but got 15. I could be wrong, but it looks like flakiness. |
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 looks great - thanks for the contribution
It's a rule to warn about lines ending with a semicolon
PR Summary
Add the PSAvoidSemicolonsAsLineTerminators rule to warn about lines ending with a semicolon. Covered with tests. The rule is disabled by default as it's more of a styling preference. #824
PR Checklist
.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
to the beginning of the title and remove the prefix when the PR is ready.