Skip to content
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

xActiveDirectory: Cleanup code #326

Merged
merged 29 commits into from
Jun 16, 2019
Merged

Conversation

johlju
Copy link
Member

@johlju johlju commented Jun 7, 2019

Pull Request (PR) description

  • Changes to xActiveDirectory
    • Cleanup of code
      • Removed semicolon throughout where it is not needed.
      • Migrate tests to Pester syntax v4.x (issue #322).
  • Changes to xADRecycleBin
    • Code cleanup.
    • It now set back the $ErrorActionPreference that was set prior to
      setting it to 'Stop'.
  • Changes to xADDomainDefaultPasswordPolicy
    • Code cleanup.
  • Changes to xADDomainTrust
    • Code cleanup.
  • Changes to xADForestProperties
    • Minor style cleanup.
  • Changes to xADOrganizationalUnit
    • Code cleanup.
  • Changes to xADReplicationSiteLink
    • Code cleanup.
  • Changes to xADReplicationSubnet
    • Code cleanup.
  • Changes to xADKDSKey
    • Code cleanup.
  • Changes to xADManagedServiceAccount
    • Code cleanup.
  • Changes to xADServicePrincipalName
    • Code cleanup.
  • Changes to xWaitForADDomain
    • Code cleanup.
  • Changes to xADDomainController
    • Code cleanup.
  • Changes to xADObjectPermissionEntry
    • Code cleanup.

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry under the Unreleased section in the CHANGELOG.md.
    Entry should say what was changed, and how that affects users (if applicable).
  • Resource documentation added/updated in README.md.
  • Resource parameter descriptions added/updated in README.md, schema.mof
    and comment-based help.
  • Comment-based help added/updated.
  • Localization strings added/updated in all localization files as appropriate.
  • Examples appropriately added/updated.
  • Unit tests added/updated. See DSC Resource Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Resource Testing Guidelines.
  • New/changed code adheres to DSC Resource Style Guidelines and Best Practices.

This change is Reviewable

@johlju johlju changed the title xActiveDirectory: Removed semicolon throughout where it is not needed xActiveDirectory: Removed semicolon Jun 7, 2019
@johlju johlju changed the title xActiveDirectory: Removed semicolon xActiveDirectory: Cleanup code Jun 7, 2019
@codecov-io
Copy link

codecov-io commented Jun 7, 2019

Codecov Report

Merging #326 into dev will increase coverage by <1%.
The diff coverage is 88%.

Impacted file tree graph

@@         Coverage Diff          @@
##            dev   #326    +/-   ##
====================================
+ Coverage    91%    92%   +<1%     
====================================
  Files        20     20            
  Lines      2383   2511   +128     
  Branches     10     10            
====================================
+ Hits       2190   2312   +122     
- Misses      183    189     +6     
  Partials     10     10

@johlju johlju added the waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. label Jun 7, 2019
@johlju
Copy link
Member Author

johlju commented Jun 7, 2019

@PlagueHO When you have an hour left over, would you mind reviewing this? 😉 It should not be to much to review I think, Please comment on additional this that need to be done if you see them, either I fix them or I will submit issue for that so other contributors can help. I already submitted a bunch of issues.

@johlju johlju added needs review The pull request needs a code review. and removed waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. labels Jun 7, 2019
@johlju johlju force-pushed the cleanup-semicolon branch from 1fa1e4a to ce52ca7 Compare June 8, 2019 19:17
@johlju johlju force-pushed the cleanup-semicolon branch from ce52ca7 to 4e505bc Compare June 13, 2019 16:46
@PlagueHO
Copy link
Member

On this now!

Copy link
Member

@PlagueHO PlagueHO left a comment

Choose a reason for hiding this comment

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

Wonderful job @johlju - this code is looking so much better. Just some minor bits. I know there is other stuff to be done, but definitely leave for another PR.

Reviewed 33 of 33 files at r1.
Reviewable status: all files reviewed, 17 unresolved discussions (waiting on @johlju)


CHANGELOG.md, line 59 at r1 (raw file):

- Changes to xADObjectPermissionEntry
  - Change the description of the property IdentityReference.
  - Fix failure when applied in the same configuration as xADDomain

Nitpick - end with full stop. And the next line.


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 121 at r1 (raw file):

            if ($isDomainMember)
            {
                ## We're already a domain member, so take the credentials out of the equation

Should be a single #


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 132 at r1 (raw file):

            }

            ## No need to check whether the node is actually a domain controller. If we don't throw an exception,

Should be comment block


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 175 at r1 (raw file):

            else
            {
                ## Not sure what's gone on here!

Should be a single #


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 253 at r1 (raw file):

    $isCompliant = $true

    ## The Get-Target resource returns .DomainName as the domain's FQDN. Therefore, we

Should be comment block.


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 362 at r1 (raw file):

    # Debug can pause Install-ADDSForest/Install-ADDSDomain, so we remove it.
    [ref] $null = $PSBoundParameters.Remove('Debug')
    ## Not entirely necessary, but run Get-TargetResouece to ensure we raise any pre-flight errors.

Should be a single #


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 376 at r1 (raw file):

        $installADDSParams['CreateDnsDelegation'] = $true
    }
    if ($PSBoundParameters.ContainsKey('DatabasePath'))

Should be blank lines around these if blocks.


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 413 at r1 (raw file):

        Write-Verbose -Message ($script:localizedData.CreatingForest -f $DomainName)
        $installADDSParams['DomainName'] = $DomainName
        if ($PSBoundParameters.ContainsKey('DomainNetbiosName'))

Should be blank lines around these if blocks.


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 429 at r1 (raw file):

    'Finished' | Out-File -FilePath (Get-TrackingFilename -DomainName $DomainName) -Force

    # Signal to the LCM to reboot the node to compensate for the one we

Should be comment block.


DSCResources/MSFT_xADDomainTrust/MSFT_xADDomainTrust.psm1, line 269 at r1 (raw file):

        # Create the target object
        $trgDirectoryContext = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext($DomainOrForest, $TargetDomainName, $TargetDomainAdministratorCredential.UserName, $TargetDomainAdministratorCredential.GetNetworkCredential().Password)

This should be using named parameters


DSCResources/MSFT_xADDomainTrust/MSFT_xADDomainTrust.psm1, line 273 at r1 (raw file):

        # Create the source object
        $srcDirectoryContext = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext($DomainOrForest, $SourceDomainName)

This should be using named parameters


DSCResources/MSFT_xADKDSKey/MSFT_xADKDSKey.psm1, line 510 at r1 (raw file):

    [OutputType([System.String])]
    param
    (

param () is allowed here I think in our Styleguidelines: https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md#correct-format-for-parameter-block


DSCResources/MSFT_xADManagedServiceAccount/MSFT_xADManagedServiceAccount.psm1, line 252 at r1 (raw file):

    $compareTargetResourceNonCompliant = Compare-TargetResourceState @PSBoundParameters |
        Where-Object { $_.Pass -eq $false }

Needs -FilterScript - and through out in all Where-Object blocks.


DSCResources/MSFT_xADManagedServiceAccount/MSFT_xADManagedServiceAccount.psm1, line 415 at r1 (raw file):

        if ($Ensure -eq 'Present')
        {
            $isEnsureNonCompliant = $false

Needs blank line after this one.


DSCResources/MSFT_xADObjectPermissionEntry/MSFT_xADObjectPermissionEntry.psm1, line 334 at r1 (raw file):

    {
        # Convert to array to a string for easy compare
        [String] $currentActiveDirectoryRights = ($currentState.ActiveDirectoryRights |

S/b [System.String] or [string]- and next line too.


DSCResources/MSFT_xADUser/MSFT_xADUser.psm1, line 1324 at r1 (raw file):

                    # Find the associated AD property
                    $adProperty = $adPropertyMap |
                        Where-Object { $_.Parameter -eq $parameter }

Should have -FilterScript


Tests/Unit/MSFT_xADGroup.Tests.ps1, line 104 at r1 (raw file):

            It 'Calls "Assert-Module" to check AD module is installed' {
                Mock -CommandName Get-ADGroup { return $fakeADGroup; }

Remove ; at end of lines in this file.

@johlju johlju force-pushed the cleanup-semicolon branch 2 times, most recently from af32e42 to f9ccbb0 Compare June 15, 2019 12:28
Copy link
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

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

Ready for review again! 😄

Reviewable status: 13 of 34 files reviewed, 17 unresolved discussions (waiting on @PlagueHO)


CHANGELOG.md, line 59 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Nitpick - end with full stop. And the next line.

Done. Did a bunch.


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 121 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Should be a single #

Done. Throughout the repo.


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 132 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Should be comment block

Done. Throughout the repo.


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 175 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Should be a single #

Done.


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 253 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Should be comment block.

Done.


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 362 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Should be a single #

Done.


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 376 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Should be blank lines around these if blocks.

Done.


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 413 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Should be blank lines around these if blocks.

Done.


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 429 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Should be comment block.

Done.


DSCResources/MSFT_xADDomainTrust/MSFT_xADDomainTrust.psm1, line 269 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

This should be using named parameters

Done. Throughout the repo.


DSCResources/MSFT_xADDomainTrust/MSFT_xADDomainTrust.psm1, line 273 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

This should be using named parameters

Done.


DSCResources/MSFT_xADKDSKey/MSFT_xADKDSKey.psm1, line 510 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

param () is allowed here I think in our Styleguidelines: https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md#correct-format-for-parameter-block

Done. Missed that, thanks!


DSCResources/MSFT_xADManagedServiceAccount/MSFT_xADManagedServiceAccount.psm1, line 252 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Needs -FilterScript - and through out in all Where-Object blocks.

Done. Throughout the repo.


DSCResources/MSFT_xADManagedServiceAccount/MSFT_xADManagedServiceAccount.psm1, line 415 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Needs blank line after this one.

Done.


DSCResources/MSFT_xADObjectPermissionEntry/MSFT_xADObjectPermissionEntry.psm1, line 334 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

S/b [System.String] or [string]- and next line too.

Done. I submitted an issue to track this. I didn't fix this on purpose, I thought the PR was large enough. 😄


DSCResources/MSFT_xADUser/MSFT_xADUser.psm1, line 1324 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Should have -FilterScript

Done.


Tests/Unit/MSFT_xADGroup.Tests.ps1, line 104 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Remove ; at end of lines in this file.

Done. Strange that I missed this file. :/

Copy link
Member

@PlagueHO PlagueHO left a comment

Choose a reason for hiding this comment

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

Doh! Just two minor tweaks left. Great job though @johlju.

Reviewed 21 of 21 files at r2, 1 of 1 files at r3.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @johlju)


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 126 at r2 (raw file):

                $forest = Get-ADForest -Identity $domain.Forest -ErrorAction Stop
            }
            else {

Doh! Missed this one - { needs to be on the next line.


DSCResources/MSFT_xADUser/MSFT_xADUser.psm1, line 152 at r2 (raw file):

    }
    @{

I don't think this blank line should be here.

Copy link
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

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

Ready for review for a last time ( I hope) 😄

Reviewable status: 32 of 34 files reviewed, 2 unresolved discussions (waiting on @PlagueHO)


DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1, line 126 at r2 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Doh! Missed this one - { needs to be on the next line.

Done. I missed that too when I went through all code :)


DSCResources/MSFT_xADUser/MSFT_xADUser.psm1, line 152 at r2 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

I don't think this blank line should be here.

Done. Ah, my bad :)

@johlju johlju force-pushed the cleanup-semicolon branch from aabb55e to b638593 Compare June 15, 2019 13:16
Copy link
Member

@PlagueHO PlagueHO left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 30 of 34 files reviewed, all discussions resolved (waiting on @PlagueHO)

@johlju johlju added ready for merge The pull request was approved by the community and is ready to be merged by a maintainer. and removed needs review The pull request needs a code review. labels Jun 16, 2019
@johlju
Copy link
Member Author

johlju commented Jun 16, 2019

Thanks for the review @PlagueHO, much appreciated! I will merge this as soon as the tests pass. Added some entries to the change log that I saw that I missed when changing code during the review. No need to review that.

@johlju johlju merged commit 82d6076 into dsccommunity:dev Jun 16, 2019
@johlju johlju deleted the cleanup-semicolon branch June 16, 2019 09:36
@johlju johlju removed the ready for merge The pull request was approved by the community and is ready to be merged by a maintainer. label Jun 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants