Add Pester Test to Check for Duplicate Function Definitions #1404
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This pull request introduces a new Pester test that verifies if any function in the Pode codebase has more than one definition. Duplicate function definitions can cause unexpected behavior and make maintenance difficult. This test aims to detect and prevent such issues.
Changes:
New Pester Test Script:
Created a new test script named DuplicateFunctionCheck.Tests.ps1 under the tests directory.
The script recursively scans all .ps1 and .psm1 files in the Pode module for function definitions.
Groups all function names and identifies any duplicate definitions based on the function names.
Reports the file path and line numbers for any duplicates found.
Purpose:
Adding this test helps maintain code quality and ensures that all function names are unique within the module. If a duplicate is found, the test fails and outputs the offending function names along with their respective file paths and line numbers for easy identification and resolution.
Example Output:
If duplicate function definitions are detected, the following message will be displayed: