Skip to content
This repository was archived by the owner on Feb 24, 2021. It is now read-only.

Refactor DscResource.DocumentationHelper/PowerShellHelp.psm1/New-DscResourcePowerShellHelp #328

Open
PlagueHO opened this issue Jun 30, 2019 · 0 comments
Labels
enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community.

Comments

@PlagueHO
Copy link
Contributor

PlagueHO commented Jun 30, 2019

Function DscResource.DocumentationHelper/PowerShellHelp.psm1/New-DscResourcePowerShellHelp has some code smells that require refactoring:

  1. A lot of string concatenation which should be converted to a stringbuilder.
  2. Indents being defined by a block of spaces in quotes - difficult to determine if the right number is used - should be assigned to a variable $indent = [System.String]::new(' ',4)
  3. This entire block:
 $output += "    Allowed values: "
                    $property.ValueMap | ForEach-Object {
                        $output += $_ + ", "
                    }
                    $output = $output.TrimEnd(" ")
                    $output = $output.TrimEnd(",")
                    $output +=  [Environment]::NewLine

Should be replaced with:

$stringbuilder.AppendLine($indent + 'Allowed values: ' + ($property.ValueMap -join ', '))

I'm sure there are more as this code could definitely use some TLC.

@PlagueHO PlagueHO added enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community. high priority The issue or PR should be resolved first. It is of less priority than the label 'Blocking Release'. and removed high priority The issue or PR should be resolved first. It is of less priority than the label 'Blocking Release'. labels Jun 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
Development

No branches or pull requests

1 participant