GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Style: Add space in comments by iSazonov · Pull Request #8576 · PowerShell/PowerShell

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Jan 1, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

PR Summary

Add space in comments after //.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready.
  • User-facing changes
    • Not Applicable
    • OR
    • User-facing Documentation needed
      • Issue filed - Issue link:
  • Testing - New and feature
    • Not Applicable or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
      • Add [feature] if the change is significant or affects feature tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Ilya (iSazonov) added 6 commits January 1, 2019 13:09
@iSazonov
Remove unneded comments
707211f
@iSazonov
Add space 1
f766e0f
@iSazonov
Add space 2
fa2df46
@iSazonov
Add space 3
af41605
@iSazonov
Add space 4
e775b98
@iSazonov
Add space 5
8f418cf
@iSazonov Ilya (iSazonov) added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Jan 1, 2019
@iSazonov
Ilya (iSazonov) requested review from Steve Lee (SteveL-MSFT) and Dongbo Wang (daxian-dbw) January 1, 2019 08:56
@iSazonov
Ilya (iSazonov) requested review from Bruce Payette (BrucePay), Francisco Gamino (Francisco-Gamino), James Truher (JamesWTruher), Paul Higinbotham (PaulHigin), Travis Plunk (TravisEz13), Aditya Patwardhan (adityapatwardhan), Andrew (anmenaga) and Mike Richmond (mirichmo) as code owners January 1, 2019 08:56
@iSazonov
Fix new style issues
0beb089
daxian-dbw
Dongbo Wang (daxian-dbw) approved these changes Jan 6, 2019
View reviewed changes

@daxian-dbw Dongbo Wang (daxian-dbw) left a comment

Copy link
Copy Markdown
Member

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.

All reactions
@daxian-dbw Dongbo Wang (daxian-dbw) self-assigned this Jan 6, 2019
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 233b54e into PowerShell:master Jan 6, 2019
@iSazonov
Ilya (iSazonov) deleted the style-comments-space branch April 17, 2020 12:18
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@iSazonov @daxian-dbw
Style: Add a space after "//" in comments and remove unneeded comment…
46dd8ca
…s after "}" (PowerShell#8576)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@daxian-dbw Dongbo Wang (daxian-dbw) daxian-dbw approved these changes
@SteveL-MSFT Steve Lee (SteveL-MSFT) Awaiting requested review from SteveL-MSFT
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) Awaiting requested review from adityapatwardhan adityapatwardhan is a code owner
@anmenaga Andrew (anmenaga) Awaiting requested review from anmenaga
@BrucePay Bruce Payette (BrucePay) Awaiting requested review from BrucePay
@Francisco-Gamino Francisco Gamino (Francisco-Gamino) Awaiting requested review from Francisco-Gamino
@JamesWTruher James Truher (JamesWTruher) Awaiting requested review from JamesWTruher
@mirichmo Mike Richmond (mirichmo) Awaiting requested review from mirichmo
@PaulHigin Paul Higinbotham (PaulHigin) Awaiting requested review from PaulHigin
@TravisEz13 Travis Plunk (TravisEz13) Awaiting requested review from TravisEz13 TravisEz13 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@daxian-dbw Dongbo Wang (daxian-dbw)

Labels

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

Projects

None yet

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.

2 participants

@iSazonov @daxian-dbw
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.