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

SqlServerDsc: Add Script Analyzer rule to help detect if resource do not load SMO #1684

Conversation

johlju
Copy link
Member

@johlju johlju commented Jan 30, 2021

Pull Request (PR) description

  • SqlServerDsc
    • Added a new script analyzer rule to verify that Import-SQLPSModule or Connect-SQL
      (that implicitly calls Import-SQLPSModule) is present in each Get-, Test-,
      and Set-TargetResource function. If neither command is not needed then the
      analyzer rule should be overridden (issue #1683).
    • Added a new pipeline job that runs Script Analyzer on all PowerShell scripts
      in the source folder. The rules are defined by the Script Analyzer settings
      file .vscode\analyzersettings.psd1 (which also the Visual Studio Code
      PowerShell extension uses).
    • Added unit tests and integration tests for SQL Server 2019
      (issue #1310).
    • Suppressed new custom Script Analyzer rule SqlServerDsc.AnalyzerRules\Measure-CommandsNeededToLoadSMO
      for Get-, Test-, and Set-TargetResource functions in the resources.
    • Minor lint errors throughout the repository.
  • SqlSetup
    • Minor refactor due to source code lint errors. The loop what evaluates
      the configuration parameters *FailoverCluster was change to a foreach().

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation updated in the resource's README.md.
  • Resource parameter descriptions updated in schema.mof.
  • Comment-based help updated, including parameter descriptions.
  • Localization strings updated.
  • Examples updated.
  • Unit tests updated. See DSC Community Testing Guidelines.
  • Integration tests updated (where possible). See DSC Community Testing Guidelines.
  • Code changes adheres to DSC Community Style Guidelines.

This change is Reviewable

@johlju johlju added the needs review The pull request needs a code review. label Jan 30, 2021
@codecov
Copy link

codecov bot commented Jan 31, 2021

Codecov Report

Merging #1684 (40b5af6) into main (511b365) will decrease coverage by 0%.
The diff coverage is 100%.

Impacted file tree graph

@@         Coverage Diff          @@
##           main   #1684   +/-   ##
====================================
- Coverage    97%     97%   -1%     
====================================
  Files        38      38           
  Lines      6261    6260    -1     
====================================
- Hits       6104    6103    -1     
  Misses      157     157           
Flag Coverage Δ
unit 97% <100%> (-1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
source/DSCResources/DSC_SqlAG/DSC_SqlAG.psm1 100% <ø> (ø)
...Resources/DSC_SqlAGListener/DSC_SqlAGListener.psm1 100% <ø> (ø)
...SCResources/DSC_SqlAGReplica/DSC_SqlAGReplica.psm1 100% <ø> (ø)
...Resources/DSC_SqlAgentAlert/DSC_SqlAgentAlert.psm1 96% <ø> (ø)
...ces/DSC_SqlAgentFailsafe/DSC_SqlAgentFailsafe.psm1 95% <ø> (ø)
...ces/DSC_SqlAgentOperator/DSC_SqlAgentOperator.psm1 82% <ø> (ø)
source/DSCResources/DSC_SqlAlias/DSC_SqlAlias.psm1 98% <ø> (ø)
...DSC_SqlAlwaysOnService/DSC_SqlAlwaysOnService.psm1 94% <ø> (ø)
...ces/DSC_SqlConfiguration/DSC_SqlConfiguration.psm1 94% <ø> (ø)
.../DSCResources/DSC_SqlDatabase/DSC_SqlDatabase.psm1 96% <ø> (ø)
... and 25 more

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.

:lgtm:

Reviewed 49 of 49 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @johlju)

@johlju johlju merged commit db3c76f into dsccommunity:main Jan 31, 2021
@johlju johlju deleted the f/add-script-analyzer-rule-for-Import-SQLPSMOdule branch January 31, 2021 15:49
@johlju johlju removed the needs review The pull request needs a code review. label Jan 31, 2021
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.

SqlServerDsc: Add ScriptAnalyzer rule to validate that resource loads SMO
1 participant