GeezerVison is showing github.com — Style: Add space in comments by iSazonov · Pull Request #8576 · PowerShell/PowerShell
Conversation
PR Summary
Add space in comments after //.
PR Checklist
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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 ran a script to validate the changes in this PR. All look good to me. Thanks Ilya (@iSazonov)!
CheckAddSpace-8576.ps1
param(
[Parameter(Mandatory=$true)]
[string]
$PRUrl,
[switch]
$PassThru
)
enum DiffState {
None
FileInfo
DiffContent
}
[DiffState]$state = [DiffState]::None
$Log = @{}
$diffFile = Join-Path -Path $PSScriptRoot -ChildPath "diff.txt"
if (Test-Path -Path $diffFile) { Remove-Item -Path $diffFile -Force -ErrorAction Stop }
##
## .diff and .patch can be append in the end to get some raw content
##
$PRUrl += ".diff"
Invoke-WebRequest -Uri $PRUrl -OutFile $diffFile
$Script:ScanResult = $null
switch -Wildcard -File $diffFile
{
"diff --git *"
{
$state = [DiffState]::FileInfo
$fileName = ($_ -split " ")[-1].Substring(2)
if ($Script:ScanResult -ne $null -and
$Script:ScanResult["OriginalStrs"].Count -ne $Script:ScanResult["NewStrs"].Count)
{
throw "$($Script:ScanResult['FileName']) contains mismatched + and -"
}
if ($Log.ContainsKey($fileName))
{
throw "$fileName appeared twice in diff file. Something is wrong"
}
$Script:ScanResult = @{ FileName = $fileName; OriginalStrs = @(); NewStrs = @() }
$Log[$fileName] = $Script:ScanResult
}
"@@ * @@ *"
{
$state = [DiffState]::DiffContent
}
"-*"
{
if ($state -eq [DiffState]::DiffContent)
{
$old = $_.Substring(1)
if (![string]::IsNullOrWhiteSpace($old))
{
$Script:ScanResult["OriginalStrs"] += $old
}
}
}
"+*"
{
if ($state -eq [DiffState]::DiffContent)
{
$new = $_.Substring(1)
if (![string]::IsNullOrWhiteSpace($new))
{
$Script:ScanResult["NewStrs"] += $new
}
}
}
}
Write-Host -Object "$($Log.Count) files involved in this PR`n"
foreach ($result in $Log.Values)
{
$newStrs = $result["NewStrs"]
$originalStrs = $result["OriginalStrs"]
for ($i = 0; $i -lt $originalStrs.Length; $i++)
{
$oldString = $originalStrs[$i]
$newString = $newStrs[$i]
$xOldString = $oldString.Trim()
$xNewString = $newString.TrimStart()
$failed = $false
if ($xOldString.StartsWith("}"))
{
## Attempt 1 - }//blah => }
$sub = $xOldString.Substring(1).Trim()
$failed = !$sub.StartsWith("//")
$xOldString = "}"
}
elseif ($xOldString.StartsWith("//"))
{
## Attempt 2 - //var => // var
$xOldString = "// " + $xOldString.Substring(2)
}
else
{
## Attempt 3 - //var => // var
$commentIndex = $xOldString.IndexOf("//")
$firstHalf = $xOldString.Substring(0, $commentIndex)
$lastHalf = "// " + $xOldString.Substring($commentIndex + 2)
$xOldString = $firstHalf + $lastHalf
}
if ($failed -or $xOldString -cne $xNewString)
{
Write-Host @"
$($result['FileName']) - mismatch
Old: $oldString
New: $newString
"@
}
}
}
if ($PassThru) { return $Log }
A few outstanding mismatches found by the script, which need to be reviewed manually:
PS:298> .\CheckAddSpace-8576.ps1 -PRUrl https://github.com/PowerShell/PowerShell/pull/8576
296 files involved in this PR
src/Microsoft.PowerShell.Commands.Management/commands/management/GetComputerInfoCommand.cs - mismatch
Old: public string CsName { get; internal set; } //TODO: get rid of this? Is this about CIM rather than about the computer?
New: public string CsName { get; internal set; }
src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/Reader/ProviderMetadataCachedInformation.cs - mismatch
Old: }
New: }
src/Microsoft.WSMan.Management/ConfigProvider.cs - mismatch
Old: // //sbCerts.Append(childnode.LocalName);
New: // // sbCerts.Append(childnode.LocalName);
src/Microsoft.WSMan.Management/ConfigProvider.cs - mismatch
Old: // //sbCerts.Append(WSManStringLiterals.Equalto);
New: // // sbCerts.Append(WSManStringLiterals.Equalto);
src/Microsoft.WSMan.Management/ConfigProvider.cs - mismatch
Old: // //sbCerts.Append(childnode.InnerText);
New: // // sbCerts.Append(childnode.InnerText);
src/Microsoft.WSMan.Management/ConfigProvider.cs - mismatch
Old: // //keys[0] = childnode.LocalName + WSManStringLiterals.Equalto + childnode.InnerText;
New: // // keys[0] = childnode.LocalName + WSManStringLiterals.Equalto + childnode.InnerText;
src/Microsoft.WSMan.Management/ConfigProvider.cs - mismatch
Old: // //sbCerts.Append(childnode.LocalName);
New: // // sbCerts.Append(childnode.LocalName);
src/Microsoft.WSMan.Management/ConfigProvider.cs - mismatch
Old: // //sbCerts.Append(WSManStringLiterals.Equalto);
New: // // sbCerts.Append(WSManStringLiterals.Equalto);
src/Microsoft.WSMan.Management/ConfigProvider.cs - mismatch
Old: // //sbCerts.Append(childnode.InnerText);
New: // // sbCerts.Append(childnode.InnerText);
src/Microsoft.WSMan.Management/ConfigProvider.cs - mismatch
Old: // //keys[1] = childnode.LocalName + WSManStringLiterals.Equalto + childnode.InnerText;
New: // // keys[1] = childnode.LocalName + WSManStringLiterals.Equalto + childnode.InnerText;
src/Microsoft.WSMan.Management/ConfigProvider.cs - mismatch
Old: // //sbCerts.Append(childnode.LocalName);
New: // // sbCerts.Append(childnode.LocalName);
src/Microsoft.WSMan.Management/ConfigProvider.cs - mismatch
Old: // //sbCerts.Append(WSManStringLiterals.Equalto);
New: // // sbCerts.Append(WSManStringLiterals.Equalto);
src/Microsoft.WSMan.Management/ConfigProvider.cs - mismatch
Old: // //sbCerts.Append(childnode.InnerText);
New: // // sbCerts.Append(childnode.InnerText);
src/Microsoft.WSMan.Management/ConfigProvider.cs - mismatch
Old: // //keys[2] = childnode.LocalName + WSManStringLiterals.Equalto + childnode.InnerText;
New: // // keys[2] = childnode.LocalName + WSManStringLiterals.Equalto + childnode.InnerText;
src/System.Management.Automation/engine/parser/Parser.cs - mismatch
Old: // //Diagnostics.Assert(token.Text.Equals("${}", StringComparison.OrdinalIgnoreCase),
New: // // Diagnostics.Assert(token.Text.Equals("${}", StringComparison.OrdinalIgnoreCase),
src/System.Management.Automation/engine/ExecutionContext.cs - mismatch
Old: // Reset the command origin for script commands... //BUGBUG - dotting can get around command origin checks???
New: // Reset the command origin for script commands... // BUGBUG - dotting can get around command origin checks???
src/System.Management.Automation/engine/remoting/client/Job.cs - mismatch
Old: // //ISSUE: Change this code to look in to child jobs for exception
New: // // ISSUE: Change this code to look in to child jobs for exception
src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/UnsafeNativeMethods.cs - mismatch
Old: EvtQueryNames = 0, //String; //Variant will be array of EvtVarTypeString
New: EvtQueryNames = 0, // String; // Variant will be array of EvtVarTypeString
src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/UnsafeNativeMethods.cs - mismatch
Old: EvtQueryStatuses = 1 //UInt32; //Variant will be Array of EvtVarTypeUInt32
New: EvtQueryStatuses = 1 // UInt32; // Variant will be Array of EvtVarTypeUInt32
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Labels
CL-CodeCleanup
Indicates that a PR should be marked as a Code Cleanup change in the Change Log
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|