Skip to content

Conversation

@dan-hughes
Copy link
Contributor

@dan-hughes dan-hughes commented Aug 4, 2025

Pull Request (PR) description

Remove use of addition operation on arrays.
Also single use variables have been inlined.

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).
  • Documentation added/updated in README.md.
  • 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 Community Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Community Testing Guidelines.
  • New/changed code adheres to DSC Community Style Guidelines.

This change is Reviewable

@coderabbitai
Copy link

coderabbitai bot commented Aug 4, 2025

Walkthrough

This change set primarily introduces suppression of the 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule across multiple PowerShell test scripts, with an additional suppression for 'PSAvoidUsingConvertToSecureStringWithPlainText' in one script. Several scripts refactor array construction and collection logic for test cases, replacing array concatenation with strongly-typed lists or direct foreach expressions. The Azure pipeline YAML is updated to remove a patching step and standardize quoting and formatting.

Changes

Cohort / File(s) Change Summary
Changelog Documentation
CHANGELOG.md
Added a "Changed" subsection under "Unreleased" to document suppression of ScriptAnalyzer rules and refactoring of array usage in multiple *.common.v5.Tests scripts.
Pipeline Configuration
azure-pipelines.yml
Removed PowerShell task for ModuleBuilder patching in Windows test job. Standardized indentation, replaced double with single quotes in tag patterns and task arguments, and reformatted dependency lists. No logic or control flow changes.
Suppression Only (No Logic Change)
source/Tests/QA/Changelog.common.v5.Tests.ps1,
source/Tests/QA/ResourceSchema.common.v5.Tests.ps1
Added suppression attribute for 'PSUseDeclaredVarsMoreThanAssignments' at the script parameter block. Minor string quoting adjustment in Changelog script. No logic or control flow changes.
Suppression and Refactor: Example Files
source/Tests/QA/ExampleFiles.common.v5.Tests.ps1
Added suppressions for both 'PSUseDeclaredVarsMoreThanAssignments' and 'PSAvoidUsingConvertToSecureStringWithPlainText'. Refactored collection construction from array initialization and appending to direct foreach expression. Minor whitespace adjustment.
Suppression and Refactor: File Formatting
source/Tests/QA/FileFormatting.common.v5.Tests.ps1
Added suppression attribute. Replaced array accumulation with strongly-typed generic list and AddRange. Refactored test case collection to use direct foreach output of hashtables.
Suppression and Refactor: Markdown Links
source/Tests/QA/MarkdownLinks.common.v5.Tests.ps1
Added suppression attribute. Changed markdown file collection from array with += to strongly-typed list with AddRange. Refactored test case collection to direct foreach. Adjusted formatting of broken links report.
Suppression and Refactor: Module Manifest
source/Tests/QA/ModuleManifest.common.v5.Tests.ps1
Added suppression attribute. Refactored array construction to direct foreach expression for class-based resources. Standardized string quoting.
Suppression and Refactor: Module Script Files
source/Tests/QA/ModuleScriptFiles.common.v5.Tests.ps1
Added suppression attribute. Changed module file collection from array with += to strongly-typed list with AddRange. Refactored test case collection to direct foreach.
Refactor Only: PSSAResource
source/Tests/QA/PSSAResource.common.v5.Tests.ps1
Refactored test case array construction from explicit loop and array accumulation to concise foreach expression. Standardized string quoting in filter.
Suppression and Refactor: Publish Example Files
source/Tests/QA/PublishExampleFiles.common.v5.Tests.ps1
Added suppression attribute. Refactored example collection and metadata enumeration from array and pipeline constructs to direct foreach and assignment. Simplified retrieval of metadata GUID.
Suppression and Refactor: Relative Path Length
source/Tests/QA/RelativePathLength.common.v5.Tests.ps1
Added suppression attribute. Changed module file collection from array with appending in pipeline to direct foreach expression for hashtable output.

Sequence Diagram(s)

Not applicable—changes are limited to code style, suppression attributes, and collection construction refactoring without affecting control flow or introducing new features.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
source/Tests/QA/RelativePathLength.common.v5.Tests.ps1 (1)

86-86: Fix variable reference bug.

The variable $fullPathHardLimit is referenced but should be $relativePathHardLimit based on the variable defined on line 82.

-            $RelativePath.Length | Should -Not -BeGreaterThan $relativePathHardLimit -Because ('for the module to be able to be downloaded and used in Azure Automation the max lengths of the relative paths of the modules files much not be greater than {0} characters including path separators' -f $fullPathHardLimit)
+            $RelativePath.Length | Should -Not -BeGreaterThan $relativePathHardLimit -Because ('for the module to be able to be downloaded and used in Azure Automation the max lengths of the relative paths of the modules files much not be greater than {0} characters including path separators' -f $relativePathHardLimit)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e9a046 and cdd8713.

📒 Files selected for processing (12)
  • CHANGELOG.md (1 hunks)
  • azure-pipelines.yml (6 hunks)
  • source/Tests/QA/Changelog.common.v5.Tests.ps1 (2 hunks)
  • source/Tests/QA/ExampleFiles.common.v5.Tests.ps1 (2 hunks)
  • source/Tests/QA/FileFormatting.common.v5.Tests.ps1 (3 hunks)
  • source/Tests/QA/MarkdownLinks.common.v5.Tests.ps1 (3 hunks)
  • source/Tests/QA/ModuleManifest.common.v5.Tests.ps1 (5 hunks)
  • source/Tests/QA/ModuleScriptFiles.common.v5.Tests.ps1 (3 hunks)
  • source/Tests/QA/PSSAResource.common.v5.Tests.ps1 (2 hunks)
  • source/Tests/QA/PublishExampleFiles.common.v5.Tests.ps1 (4 hunks)
  • source/Tests/QA/RelativePathLength.common.v5.Tests.ps1 (2 hunks)
  • source/Tests/QA/ResourceSchema.common.v5.Tests.ps1 (1 hunks)
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[style] ~16-~16: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...anAssignments' ScriptAnalyzer rule. - Suppress 'PSAvoidUsingConvertToSecureStringWithP...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: dsccommunity.DscResource.Test (Test Publish Code Coverage)
  • GitHub Check: dsccommunity.DscResource.Test (Test Test Windows (WPS))
  • GitHub Check: dsccommunity.DscResource.Test (Test Test Windows (PS))
  • GitHub Check: dsccommunity.DscResource.Test (Test Test Linux)
  • GitHub Check: dsccommunity.DscResource.Test (Test Test macOS)
  • GitHub Check: dsccommunity.DscResource.Test (Test Integration)
  • GitHub Check: dsccommunity.DscResource.Test (Build Package Module)
🔇 Additional comments (31)
azure-pipelines.yml (4)

4-4: LGTM! Improved indentation consistency.

The indentation fixes in the trigger section improve YAML readability and consistency.

Also applies to: 7-7


10-10: LGTM! Consistent quote usage.

Converting to single quotes for tag patterns improves consistency across the YAML configuration.

Also applies to: 12-12


75-75: LGTM! Consistent quote usage in PowerShell arguments.

The change from double quotes to single quotes in PowerShell task arguments improves consistency throughout the pipeline configuration.

Also applies to: 107-107, 139-139, 171-171


223-226: LGTM! Improved dependency list formatting.

The increased indentation for the dependency list enhances readability while maintaining the same semantic meaning.

source/Tests/QA/ResourceSchema.common.v5.Tests.ps1 (1)

15-15: LGTM! Appropriate static analysis suppression.

The suppression of PSUseDeclaredVarsMoreThanAssignments is appropriate here, as this test script likely has variables that are used by the Pester framework in ways that static analysis cannot detect.

source/Tests/QA/Changelog.common.v5.Tests.ps1 (2)

15-15: LGTM! Consistent static analysis suppression.

The suppression attribute follows the same pattern applied across other test files in this PR to reduce static analysis noise.


57-57: LGTM! Consistent quote usage.

The change from double quotes to single quotes in the Write-Debug statement improves consistency with PowerShell best practices.

source/Tests/QA/ExampleFiles.common.v5.Tests.ps1 (2)

14-15: LGTM! Appropriate static analysis suppressions.

Both suppression attributes are justified:

  • PSUseDeclaredVarsMoreThanAssignments for variables used by Pester framework
  • PSAvoidUsingConvertToSecureStringWithPlainText for test scenarios where mock credentials are needed

67-73: Excellent performance improvement!

Replacing the array concatenation loop with a foreach expression eliminates the performance penalty of PowerShell's immutable array += operations. This approach builds the collection efficiently in a single operation rather than creating new arrays on each iteration.

source/Tests/QA/FileFormatting.common.v5.Tests.ps1 (3)

18-18: LGTM! Consistent static analysis suppression.

The suppression attribute follows the same pattern applied across other test files to reduce static analysis noise.


67-67: Excellent performance improvement with strongly-typed collections!

Replacing PowerShell arrays with System.Collections.Generic.List[System.Object] and using AddRange methods provides significant performance benefits:

  • Avoids the overhead of PowerShell's immutable array operations
  • AddRange is more efficient than repeated array concatenation
  • Strongly-typed collections offer better performance characteristics

This change directly addresses the PR objective of avoiding array addition operations.

Also applies to: 69-69, 73-73


87-94: Outstanding performance optimization!

The refactor from array concatenation loop to a foreach expression that directly outputs hashtables eliminates the performance penalty of PowerShell's += operator on arrays. This approach:

  • Builds the collection in a single efficient operation
  • Avoids creating new arrays on each iteration
  • Results in cleaner, more readable code

Perfect alignment with the PR's performance improvement objectives.

source/Tests/QA/MarkdownLinks.common.v5.Tests.ps1 (4)

18-18: LGTM: Valid suppression for Pester test context.

The suppression attribute correctly addresses the static analysis warning for variables that appear unused but are actually utilized by Pester's test framework.


86-90: Excellent performance optimization!

Replacing array concatenation (+=) with System.Collections.Generic.List[System.Object] and AddRange eliminates the overhead of array copying that occurs with each += operation. This is a significant performance improvement when processing multiple markdown files.


96-103: LGTM: Cleaner collection construction.

The direct foreach expression that outputs hashtables is more idiomatic PowerShell and eliminates the overhead of intermediate array operations. This improves both performance and readability.


126-126: LGTM: Streamlined pipeline operation.

Specifying properties directly in Format-Table eliminates the unnecessary Select-Object pipeline stage, resulting in cleaner and slightly more efficient code.

source/Tests/QA/PSSAResource.common.v5.Tests.ps1 (2)

94-101: LGTM: Consistent performance optimization.

The direct foreach expression eliminates intermediate array operations and aligns with the performance improvements applied consistently across the test suite.


149-149: LGTM: PowerShell best practice.

Using single quotes for string literals that don't require variable expansion follows PowerShell best practices and maintains consistency with the codebase.

source/Tests/QA/ModuleManifest.common.v5.Tests.ps1 (3)

15-15: LGTM: Consistent suppression pattern.

The suppression attribute follows the same pattern applied across all test files in this PR to address static analysis warnings in Pester test contexts.


60-65: LGTM: Performance improvement applied consistently.

The direct foreach expression eliminates intermediate array operations, following the same optimization pattern used throughout this PR.


117-119: Good practice: Documenting future improvements.

The TODO comments properly document potential future enhancements to the test suite, which helps with maintenance and evolution of the codebase.

source/Tests/QA/RelativePathLength.common.v5.Tests.ps1 (2)

14-14: LGTM: Consistent suppression application.

The suppression attribute follows the established pattern for addressing static analysis warnings in Pester test files.


61-67: LGTM: Effective performance optimization.

Replacing the ForEach-Object pipeline with a direct foreach expression eliminates pipeline overhead and improves performance when processing module files.

source/Tests/QA/ModuleScriptFiles.common.v5.Tests.ps1 (4)

18-18: LGTM! Valid suppression for test script variables.

The suppression attribute appropriately addresses PSScriptAnalyzer warnings about variables that are assigned in discovery blocks but used in test contexts, which is a common pattern in Pester test files.


67-67: Excellent performance improvement!

Converting from an array to System.Collections.Generic.List[System.Object] eliminates the overhead of array recreation during addition operations, which is a significant performance benefit when building collections dynamically.


69-69: Well-implemented array addition replacement.

Using AddRange with the array subexpression operator @() efficiently adds multiple items while ensuring correct behavior even when the pipeline returns a single item. This eliminates the performance penalty of array recreation.

Also applies to: 73-73


86-93: Perfect refactoring that achieves both PR objectives!

This change eliminates array addition operations by leveraging PowerShell's natural collection output from foreach statements, while also inlining the collection building. The code is now more performant and idiomatic.

source/Tests/QA/PublishExampleFiles.common.v5.Tests.ps1 (4)

15-15: LGTM! Consistent suppression pattern.

The suppression attribute matches the pattern used across other test files in this PR and appropriately addresses PSScriptAnalyzer warnings for test script variables.


68-74: Excellent consistency with performance improvements.

This refactoring follows the same pattern as other files in the PR, eliminating array addition operations by using PowerShell's natural collection output from foreach statements.


93-112: Well-executed pipeline to foreach refactoring.

The conversion from pipeline operations to explicit foreach with inline hashtable creation improves performance while preserving all error handling logic. The try-catch structure ensures robust handling of files with missing metadata.


127-127: Good simplification of variable assignment.

Removing the unnecessary Select-Object operation and directly assigning the result of Test-ScriptFileInfo eliminates pipeline overhead while maintaining the same functionality.

@johlju johlju added the needs review The pull request needs a code review. label Aug 7, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
CHANGELOG.md (1)

18-52: Reduce repetition and fix hyphenation for clarity.

Reword bullets to avoid repeated “Suppress …” openings and hyphenate “single-use”. Keeps content intact while improving readability.

-### Changed
-- `Changelog.common.v5.Tests`
-  - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-- `ExampleFiles.common.v5.Tests`
-  - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-  - Suppress 'PSAvoidUsingConvertToSecureStringWithPlainText' ScriptAnalyzer rule.
-  - Remove array addition.
-- `FileFormatting.common.v5.Tests`
-  - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-  - Remove array addition.
-  - Remove single use variable.
-- `MarkdownLinks.common.v5.Tests`
-  - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-  - Remove array addition.
-  - Remove single use variable.
-- `ModuleScriptFiles.common.v5.Tests`
-  - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-  - Remove array addition.
-  - Remove single use variable.
-- `PSSAResource.common.v5.Tests`
-  - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-  - Remove array addition.
-  - Remove single use variable.
-- `PublishExampleFiles.common.v5.Tests`
-  - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-  - Remove array addition.
-  - Remove single use variable.
-- `RelativePathLength.common.v5.Tests`
-  - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-  - Remove array addition.
-  - Remove single use variable.
-- `ResourceSchema.common.v5.Tests`
-  - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
+### Changed
+- `Changelog.common.v5.Tests`
+  - Added suppression for 'PSUseDeclaredVarsMoreThanAssignments'.
+- `ExampleFiles.common.v5.Tests`
+  - Added suppressions for 'PSUseDeclaredVarsMoreThanAssignments' and 'PSAvoidUsingConvertToSecureStringWithPlainText'.
+  - Replaced array addition with foreach/list-based construction.
+  - Inlined single-use variables.
+- `FileFormatting.common.v5.Tests`
+  - Added suppression for 'PSUseDeclaredVarsMoreThanAssignments'.
+  - Replaced array addition with foreach/list-based construction.
+  - Inlined single-use variables.
+- `MarkdownLinks.common.v5.Tests`
+  - Added suppression for 'PSUseDeclaredVarsMoreThanAssignments'.
+  - Replaced array addition with foreach/list-based construction.
+  - Inlined single-use variables.
+- `ModuleScriptFiles.common.v5.Tests`
+  - Added suppression for 'PSUseDeclaredVarsMoreThanAssignments'.
+  - Replaced array addition with foreach/list-based construction.
+  - Inlined single-use variables.
+- `PSSAResource.common.v5.Tests`
+  - Added suppression for 'PSUseDeclaredVarsMoreThanAssignments'.
+  - Replaced array addition with foreach/list-based construction.
+  - Inlined single-use variables.
+- `PublishExampleFiles.common.v5.Tests`
+  - Added suppression for 'PSUseDeclaredVarsMoreThanAssignments'.
+  - Replaced array addition with foreach/list-based construction.
+  - Inlined single-use variables.
+- `RelativePathLength.common.v5.Tests`
+  - Added suppression for 'PSUseDeclaredVarsMoreThanAssignments'.
+  - Replaced array addition with foreach/list-based construction.
+  - Inlined single-use variables.
+- `ResourceSchema.common.v5.Tests`
+  - Added suppression for 'PSUseDeclaredVarsMoreThanAssignments'.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cdd8713 and 198be7a.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • source/DscResource.Test.psm1 (1 hunks)
  • source/Tests/QA/ExampleFiles.common.v4.Tests.ps1 (1 hunks)
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[grammar] ~10-~10: Use correct spacing
Context: ...pec/v2.0.0.html). ## [Unreleased] ### Fixed - Add ability to filter out files in `Exam...

(QB_NEW_EN_OTHER_ERROR_IDS_5)


[grammar] ~12-~12: Use correct spacing
Context: ... files in ExampleFiles.common.v4 #120. ### Removed - Remove ModuleBuilder patch. ...

(QB_NEW_EN_OTHER_ERROR_IDS_5)


[grammar] ~16-~16: Use correct spacing
Context: ...). ### Removed - Remove ModuleBuilder patch. ### Changed - Changelog.common.v5.Tests ...

(QB_NEW_EN_OTHER_ERROR_IDS_5)


[grammar] ~21-~21: Use articles correctly
Context: ...nged - Changelog.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_OTHER_ERROR_IDS_11)


[grammar] ~21-~21: There might be a problem here.
Context: ...VarsMoreThanAssignments' ScriptAnalyzer rule. - ExampleFiles.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[style] ~24-~24: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...anAssignments' ScriptAnalyzer rule. - Suppress 'PSAvoidUsingConvertToSecureStringWithP...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[grammar] ~25-~25: There might be a problem here.
Context: ...' ScriptAnalyzer rule. - Remove array addition. - FileFormatting.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~29-~29: Use hyphens correctly
Context: .... - Remove array addition. - Remove single use variable. - `MarkdownLinks.common.v5...

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~29-~29: There might be a problem here.
Context: ...e array addition. - Remove single use variable. - MarkdownLinks.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~33-~33: Use hyphens correctly
Context: .... - Remove array addition. - Remove single use variable. - `ModuleScriptFiles.commo...

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~33-~33: There might be a problem here.
Context: ...e array addition. - Remove single use variable. - ModuleScriptFiles.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~37-~37: Use hyphens correctly
Context: .... - Remove array addition. - Remove single use variable. - `PSSAResource.common.v5....

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~37-~37: There might be a problem here.
Context: ...e array addition. - Remove single use variable. - PSSAResource.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~41-~41: Use hyphens correctly
Context: .... - Remove array addition. - Remove single use variable. - `PublishExampleFiles.com...

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~41-~41: There might be a problem here.
Context: ...e array addition. - Remove single use variable. - PublishExampleFiles.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~45-~45: Use hyphens correctly
Context: .... - Remove array addition. - Remove single use variable. - `RelativePathLength.comm...

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~45-~45: There might be a problem here.
Context: ...e array addition. - Remove single use variable. - RelativePathLength.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~49-~49: Use hyphens correctly
Context: .... - Remove array addition. - Remove single use variable. - `ResourceSchema.common.v...

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~49-~49: There might be a problem here.
Context: ...e array addition. - Remove single use variable. - ResourceSchema.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~51-~51: Use correct spacing
Context: ...VarsMoreThanAssignments' ScriptAnalyzer rule. ## [0.17.2] - 2025-02-28 ### Fixed - Now ...

(QB_NEW_EN_OTHER_ERROR_IDS_5)

🔇 Additional comments (1)
source/Tests/QA/ExampleFiles.common.v4.Tests.ps1 (1)

31-31: Add –File and deterministic sorting to the pipeline

To ensure the test only returns files (not directories) and runs in a stable order, update line 31 as follows and please verify that WhereSourceFileNotExcluded gracefully handles a null/empty $ExcludeSourceFile:

-        $examples = Get-ChildItem -Path $examplesPath -Filter '*.ps1' -Recurse | WhereSourceFileNotExcluded -ExcludeSourceFile $ExcludeSourceFile
+        $examples = Get-ChildItem -Path $examplesPath -Filter '*.ps1' -Recurse -File |
+            WhereSourceFileNotExcluded -ExcludeSourceFile $ExcludeSourceFile |
+            Sort-Object -Property FullName

• Use -File to exclude directories up front.
• Pipe to Sort-Object FullName for a deterministic ordering in your tests.
• Manually confirm that WhereSourceFileNotExcluded accepts an empty or $null -ExcludeSourceFile; if not, wrap the call in an if ($ExcludeSourceFile) { … } check.

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 11 of 12 files at r1, 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @dan-hughes)


source/Tests/QA/ModuleManifest.common.v5.Tests.ps1 line 117 at r2 (raw file):

    }

    #TODO: Add checks for public functions and aliases.

Create an issue for this and remove comment?

Code quote:

#TODO: Add checks for public functions and aliases.

source/Tests/QA/ModuleManifest.common.v5.Tests.ps1 line 119 at r2 (raw file):

    #TODO: Add checks for public functions and aliases.

    #TODO: Should cmdlets be exported be set to '*'?

Suggested in PR #165, we can remove comment.

Code quote:

#TODO: Should cmdlets be exported be set to '*'?

@johlju johlju added waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. and removed needs review The pull request needs a code review. labels Aug 10, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
CHANGELOG.md (1)

24-56: Reduce repetition, fix hyphenation, and align tone with Keep a Changelog style

Reword sub-bullets to past-tense “Added/Removed,” hyphenate “single-use,” and avoid repeated “Suppress …” phrasing. This also addresses the LanguageTool flags and improves readability.

- - `Changelog.common.v5.Tests`
-   - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
+ - `Changelog.common.v5.Tests`
+   - Added suppression for ScriptAnalyzer rule 'PSUseDeclaredVarsMoreThanAssignments'.

- - `ExampleFiles.common.v5.Tests`
-   - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-   - Suppress 'PSAvoidUsingConvertToSecureStringWithPlainText' ScriptAnalyzer rule.
-   - Remove array addition.
+ - `ExampleFiles.common.v5.Tests`
+   - Added suppressions for ScriptAnalyzer rules 'PSUseDeclaredVarsMoreThanAssignments' and 'PSAvoidUsingConvertToSecureStringWithPlainText'.
+   - Replaced array additions (+=) with strongly-typed lists or pipeline output for performance.
-   - Remove single use variable.
+   - Inlined single-use variables.

- - `FileFormatting.common.v5.Tests`
-   - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-   - Remove array addition.
-   - Remove single use variable.
+ - `FileFormatting.common.v5.Tests`
+   - Added suppression for ScriptAnalyzer rule 'PSUseDeclaredVarsMoreThanAssignments'.
+   - Replaced array additions (+=) with strongly-typed lists or pipeline output for performance.
+   - Inlined single-use variables.

- - `MarkdownLinks.common.v5.Tests`
-   - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-   - Remove array addition.
-   - Remove single use variable.
+ - `MarkdownLinks.common.v5.Tests`
+   - Added suppression for ScriptAnalyzer rule 'PSUseDeclaredVarsMoreThanAssignments'.
+   - Replaced array additions (+=) with strongly-typed lists or pipeline output for performance.
+   - Inlined single-use variables.

- - `ModuleScriptFiles.common.v5.Tests`
-   - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-   - Remove array addition.
-   - Remove single use variable.
+ - `ModuleScriptFiles.common.v5.Tests`
+   - Added suppression for ScriptAnalyzer rule 'PSUseDeclaredVarsMoreThanAssignments'.
+   - Replaced array additions (+=) with strongly-typed lists or pipeline output for performance.
+   - Inlined single-use variables.

- - `PSSAResource.common.v5.Tests`
-   - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-   - Remove array addition.
-   - Remove single use variable.
+ - `PSSAResource.common.v5.Tests`
+   - Added suppression for ScriptAnalyzer rule 'PSUseDeclaredVarsMoreThanAssignments'.
+   - Replaced array additions (+=) with strongly-typed lists or pipeline output for performance.
+   - Inlined single-use variables.

- - `PublishExampleFiles.common.v5.Tests`
-   - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-   - Remove array addition.
-   - Remove single use variable.
+ - `PublishExampleFiles.common.v5.Tests`
+   - Added suppression for ScriptAnalyzer rule 'PSUseDeclaredVarsMoreThanAssignments'.
+   - Replaced array additions (+=) with strongly-typed lists or pipeline output for performance.
+   - Inlined single-use variables.

- - `RelativePathLength.common.v5.Tests`
-   - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
-   - Remove array addition.
-   - Remove single use variable.
+ - `RelativePathLength.common.v5.Tests`
+   - Added suppression for ScriptAnalyzer rule 'PSUseDeclaredVarsMoreThanAssignments'.
+   - Replaced array additions (+=) with strongly-typed lists or pipeline output for performance.
+   - Inlined single-use variables.

- - `ResourceSchema.common.v5.Tests`
-   - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ScriptAnalyzer rule.
+ - `ResourceSchema.common.v5.Tests`
+   - Added suppression for ScriptAnalyzer rule 'PSUseDeclaredVarsMoreThanAssignments'.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 198be7a and 2554510.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[grammar] ~25-~25: Use articles correctly
Context: ...nged - Changelog.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_OTHER_ERROR_IDS_11)


[grammar] ~25-~25: There might be a problem here.
Context: ...VarsMoreThanAssignments' ScriptAnalyzer rule. - ExampleFiles.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[style] ~28-~28: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...anAssignments' ScriptAnalyzer rule. - Suppress 'PSAvoidUsingConvertToSecureStringWithP...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[grammar] ~29-~29: There might be a problem here.
Context: ...' ScriptAnalyzer rule. - Remove array addition. - FileFormatting.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~33-~33: Use hyphens correctly
Context: .... - Remove array addition. - Remove single use variable. - `MarkdownLinks.common.v5...

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~33-~33: There might be a problem here.
Context: ...e array addition. - Remove single use variable. - MarkdownLinks.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~37-~37: Use hyphens correctly
Context: .... - Remove array addition. - Remove single use variable. - `ModuleScriptFiles.commo...

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~37-~37: There might be a problem here.
Context: ...e array addition. - Remove single use variable. - ModuleScriptFiles.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~41-~41: Use hyphens correctly
Context: .... - Remove array addition. - Remove single use variable. - `PSSAResource.common.v5....

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~41-~41: There might be a problem here.
Context: ...e array addition. - Remove single use variable. - PSSAResource.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~45-~45: Use hyphens correctly
Context: .... - Remove array addition. - Remove single use variable. - `PublishExampleFiles.com...

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~45-~45: There might be a problem here.
Context: ...e array addition. - Remove single use variable. - PublishExampleFiles.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~49-~49: Use hyphens correctly
Context: .... - Remove array addition. - Remove single use variable. - `RelativePathLength.comm...

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~49-~49: There might be a problem here.
Context: ...e array addition. - Remove single use variable. - RelativePathLength.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~53-~53: Use hyphens correctly
Context: .... - Remove array addition. - Remove single use variable. - `ResourceSchema.common.v...

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~53-~53: There might be a problem here.
Context: ...e array addition. - Remove single use variable. - ResourceSchema.common.v5.Tests - Suppress 'PSUseDeclaredVarsMoreThanAssignments' ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~55-~55: Use correct spacing
Context: ...VarsMoreThanAssignments' ScriptAnalyzer rule. ## [0.17.2] - 2025-02-28 ### Fixed - Now ...

(QB_NEW_EN_OTHER_ERROR_IDS_5)

@codecov
Copy link

codecov bot commented Aug 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80%. Comparing base (9e255ee) to head (5113b0f).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@         Coverage Diff         @@
##           main   #162   +/-   ##
===================================
  Coverage    80%    80%           
===================================
  Files        42     42           
  Lines       554    554           
===================================
  Hits        447    447           
  Misses      107    107           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor Author

@dan-hughes dan-hughes 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: 10 of 14 files reviewed, 4 unresolved discussions (waiting on @johlju)


source/Tests/QA/ModuleManifest.common.v5.Tests.ps1 line 117 at r2 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Create an issue for this and remove comment?

Done.


source/Tests/QA/ModuleManifest.common.v5.Tests.ps1 line 119 at r2 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Suggested in PR #165, we can remove comment.

Done.

@dan-hughes
Copy link
Contributor Author

@johlju, issue raised and TODOs removed.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2554510 and 5113b0f.

📒 Files selected for processing (1)
  • source/Tests/QA/ModuleManifest.common.v5.Tests.ps1 (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-09T19:29:36.323Z
Learnt from: johlju
PR: dsccommunity/DscResource.Test#167
File: source/Private/Test-FileContainsClassResource.ps1:44-56
Timestamp: 2025-08-09T19:29:36.323Z
Learning: In the DscResource.Test repository, DSC resource attributes are consistently written as `[DscResource(...)]` rather than using variations like `[DscResourceAttribute()]` or fully qualified names like `[Microsoft.PowerShell.DesiredStateConfiguration.DscResource()]`. The Test-FileContainsClassResource function should focus on detecting the standard `[DscResource(...)]` pattern that is actually used in the codebase.

Applied to files:

  • source/Tests/QA/ModuleManifest.common.v5.Tests.ps1
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: dsccommunity.DscResource.Test (Build Package Module)
🔇 Additional comments (2)
source/Tests/QA/ModuleManifest.common.v5.Tests.ps1 (2)

91-91: LGTM: Style consistency

Switch to single quotes in the It name is consistent with the repo’s style updates. No issues.


107-107: LGTM: Per-test description consistency

Single-quoted It string aligns with the style changes. The assertion remains clear and correct.

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 2 of 2 files at r3, 1 of 1 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @dan-hughes)

@johlju johlju merged commit ee4d708 into dsccommunity:main Aug 11, 2025
11 of 12 checks passed
@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 Aug 11, 2025
@dan-hughes dan-hughes deleted the optimize-functions branch August 19, 2025 19:09
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.

2 participants