Skip to content

xActiveDirectory: Fix Script Analyzer Rule Failures #303

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

Merged
merged 29 commits into from
Jun 1, 2019
Merged

xActiveDirectory: Fix Script Analyzer Rule Failures #303

merged 29 commits into from
Jun 1, 2019

Conversation

X-Guardian
Copy link
Contributor

@X-Guardian X-Guardian commented May 29, 2019

Pull Request (PR) description

This PR fixes all the current Script Analyzer rule failures that are occurring during the AppVeyor build and opts in to the following tests for future builds:

  • Common Tests - Custom Script Analyzer Rules
  • Common Tests - Required Script Analyzer Rules
  • Common Tests - Flagged Script Analyzer Rules

A summary of the changes that have been made are as follows:

  • xADDomainDefaultPasswordPolicy
    • Custom Script Analyzer rule fix
  • xADDomainTrust
    • Required Script Analyzer rule fix
    • Flagged Script Analyzer rule fix
    • Custom Script Analyzer rule fix
    • Move message localization to external file
    • Suppress PSDSCUseVerboseMessageInDSCResource due to verbose messages being in helper functions
  • xADOrganizationalUnit
    • Custom Script Analyzer rule fix
  • xADObjectPermissionEntry
  • xADRecycleBin
    • Flagged Script Analyzer rule fix
    • Custom Script Analyzer rule fix
    • Message localization
  • xADReplicationSite
    • Flagged Script Analyzer rule fix
    • Message localization
  • xADReplicationSubnet
    • Flagged Script Analyzer rule fix
    • Message localization
  • xADServicePrincipalName
    • Flagged Script Analyzer rule fix
    • Message localization
  • xWaitForADDomain
    • Flagged Script Analyzer rule fix
    • Custom Script Analyzer rule fix
    • Message localization

New tests have also been added for the following resources:

  • xADRecycleBin

This Pull Request (PR) fixes the following issues

None

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

X-Guardian and others added 13 commits May 29, 2019 21:53
- Script Analyzer fix
- Message localization
- Add missing verbose messages
- Message localization
- Add missing verbose messages
- Message localization
- Add missing verbose messages
- Message localization
- Add missing verbose messages
- Script Analyzer fix
- Message localization
- Add missing verbose messages
@codecov-io
Copy link

codecov-io commented May 29, 2019

Codecov Report

Merging #303 into dev will increase coverage by 2%.
The diff coverage is 76%.

Impacted file tree graph

@@         Coverage Diff          @@
##            dev   #303    +/-   ##
====================================
+ Coverage    90%    92%    +2%     
====================================
  Files        20     20            
  Lines      2241   2299    +58     
  Branches     10     10            
====================================
+ Hits       2029   2135   +106     
+ Misses      202    154    -48     
  Partials     10     10

@X-Guardian X-Guardian marked this pull request as ready for review May 29, 2019 23:16
@X-Guardian
Copy link
Contributor Author

Hi @johlju, I can't improve the codecov/patch percentage anymore, as the main culprit is the xADDomainTrust resource, which uses object method calls which can't currently be mocked.

Can you add this to your list of PRs to review? Thanks.

@johlju johlju added the needs review The pull request needs a code review. label May 31, 2019
Copy link
Member

@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.

Thank you for all this work! 😃 A few review comments.

Reviewed 9 of 15 files at r3, 9 of 9 files at r4, 1 of 1 files at r5.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @X-Guardian)


CHANGELOG.md, line 54 at r5 (raw file):

Quoted 5 lines of code…
- Changes to xActiveDirectory
  - Fix Script Analyzer rule failures
  - Opt-in to "Common Tests - Custom Script Analyzer Rules"
  - Opt-in to "Common Tests - Required Script Analyzer Rules"
  - Opt-in to "Common Tests - Flagged Script Analyzer Rules"

Let's move this entries to the Changes to xActiveDirectory at the top.


DSCResources/MSFT_xADDomainTrust/MSFT_xADDomainTrust.psm1, line 101 at r5 (raw file):

[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseVerboseMessageInDSCResource", "")]

Instead of this, please add at least one Write-Verbose message in this function. I rather we add verbose messages than overriding this. If we want to pass the common test then please add at least one verbose message.

Throughout where this override exist. Sorry, I know it will be a bit of additional work, but it helps debugging in the future.

I'm okay by removing the overrides and opt-out from that particular common test if there are more places that has this override.

I rather see verbose logging is improved than overridden. 🙂


DSCResources/MSFT_xADDomainTrust/MSFT_xADDomainTrust.psm1, line 133 at r5 (raw file):

[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseVerboseMessageInDSCResource", "")]

See previous comment.

@johlju johlju removed the needs review The pull request needs a code review. label May 31, 2019
@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 May 31, 2019
@johlju
Copy link
Member

johlju commented May 31, 2019

Awesome improvement on the coverage percentage! 😃

Copy link
Contributor Author

@X-Guardian X-Guardian left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 18 files reviewed, 3 unresolved discussions (waiting on @johlju)


CHANGELOG.md, line 54 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
- Changes to xActiveDirectory
  - Fix Script Analyzer rule failures
  - Opt-in to "Common Tests - Custom Script Analyzer Rules"
  - Opt-in to "Common Tests - Required Script Analyzer Rules"
  - Opt-in to "Common Tests - Flagged Script Analyzer Rules"

Let's move this entries to the Changes to xActiveDirectory at the top.

Done.


DSCResources/MSFT_xADDomainTrust/MSFT_xADDomainTrust.psm1, line 101 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseVerboseMessageInDSCResource", "")]

Instead of this, please add at least one Write-Verbose message in this function. I rather we add verbose messages than overriding this. If we want to pass the common test then please add at least one verbose message.

Throughout where this override exist. Sorry, I know it will be a bit of additional work, but it helps debugging in the future.

I'm okay by removing the overrides and opt-out from that particular common test if there are more places that has this override.

I rather see verbose logging is improved than overridden. 🙂

Are you sure? There is plenty of verbose logging in the Confirm-ResourceProperties helper function which is all that this function calls. Adding another verbose message here is then just noise. I can add a justification attribute saying 'Verbose messaging in helper function' if that would help.


DSCResources/MSFT_xADDomainTrust/MSFT_xADDomainTrust.psm1, line 133 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseVerboseMessageInDSCResource", "")]

See previous comment.

Same response as previous comment.

Copy link
Member

@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.

Reviewed 18 of 19 files at r7.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @X-Guardian)


DSCResources/MSFT_xADDomainTrust/MSFT_xADDomainTrust.psm1, line 101 at r5 (raw file):

Previously, X-Guardian (Simon Heather) wrote…

Are you sure? There is plenty of verbose logging in the Confirm-ResourceProperties helper function which is all that this function calls. Adding another verbose message here is then just noise. I can add a justification attribute saying 'Verbose messaging in helper function' if that would help.

Ah okay! Did not realizes that. Yes, please add a comment to the override. Thanks for questioning my comment! 🙂


DSCResources/MSFT_xADDomainTrust/MSFT_xADDomainTrust.psm1, line 133 at r5 (raw file):

Previously, X-Guardian (Simon Heather) wrote…

Same response as previous comment.

Ah okay! Did not realizes that. Yes, please add a comment to the override. Thanks for questioning my comment! 🙂

Copy link
Contributor Author

@X-Guardian X-Guardian left a comment

Choose a reason for hiding this comment

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

Reviewable status: 16 of 18 files reviewed, 2 unresolved discussions (waiting on @johlju)


DSCResources/MSFT_xADDomainTrust/MSFT_xADDomainTrust.psm1, line 101 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Ah okay! Did not realizes that. Yes, please add a comment to the override. Thanks for questioning my comment! 🙂

Done.


DSCResources/MSFT_xADDomainTrust/MSFT_xADDomainTrust.psm1, line 133 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Ah okay! Did not realizes that. Yes, please add a comment to the override. Thanks for questioning my comment! 🙂

Done.

Copy link
Member

@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.

:lgtm:

Reviewed 1 of 1 files at r8, 1 of 1 files at r9.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@johlju johlju merged commit d8d71e1 into dsccommunity:dev Jun 1, 2019
@johlju
Copy link
Member

johlju commented Jun 1, 2019

Thank you for this @X-Guardian! 🙇

@johlju johlju removed 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 1, 2019
@X-Guardian X-Guardian deleted the ScriptAnalyzerRules-Fix branch June 1, 2019 16:22
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