Skip to content

Style: Add period in summary doc tags - #8577

Merged
Dongbo Wang (daxian-dbw) merged 15 commits into
PowerShell:masterfrom
iSazonov:style-summary-comments-point
Jan 5, 2019
Merged

Style: Add period in summary doc tags#8577
Dongbo Wang (daxian-dbw) merged 15 commits into
PowerShell:masterfrom
iSazonov:style-summary-comments-point

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Jan 1, 2019

Copy link
Copy Markdown
Collaborator

PR Summary

Style fix: Add period in summary doc tags.

PR Checklist

@RDIL Reece Dunham (RDIL) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me!

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

Copy link
Copy Markdown
Member

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, and all look good :D Thanks Ilya (@iSazonov)!


CheckAddingPeriod.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)
                $Script:ScanResult["OriginalStrs"] += $old
            }
        }

    "+*"
        {
            if ($state -eq [DiffState]::DiffContent)
            {
                $new = $_.Substring(1)
                $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]

        $afterReplace = $oldString.Trim() + "."
        $afterProcess = $newString.TrimStart()

        if (!$afterProcess.StartsWith("///") -or $afterReplace -cne $afterProcess)
        {
            Write-Error -Message @"
$($result['FileName']) - mismatch
Old: $oldString
New: $newString
"@
        }
    }
}

if ($PassThru) { return $Log }

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 1be3f4c into PowerShell:master Jan 5, 2019
@iSazonov
Ilya (iSazonov) deleted the style-summary-comments-point branch January 6, 2019 05:53
@iSazonov

Copy link
Copy Markdown
Collaborator Author

Dongbo Wang (@daxian-dbw) You could publish the script in gist.
Or do you hope never see so large PRs? :-)

@daxian-dbw

Dongbo Wang (daxian-dbw) commented Jan 7, 2019

Copy link
Copy Markdown
Member

The very first version of this script was published in gist years ago, at https://gist.github.com/daxian-dbw/3df8f9236a73a1d9b8c5cc913476d618
The scripts I used to validate this PR and the other one were slightly updated on top of the original one.

Or do you hope never see so large PRs? :-)

Well, I do wish we don't have huge PRs like this one, but it's inevitable for style changes 😄

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.

3 participants