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

Add Pester Test to Check for Duplicate Function Definitions #1404

Merged
merged 4 commits into from
Oct 20, 2024

Conversation

mdaneri
Copy link
Contributor

@mdaneri mdaneri commented Oct 1, 2024

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:

The following functions have multiple definitions:
Function: MyDuplicateFunction
 - File: C:\path\to\file1.ps1, Line: 45
 - File: C:\path\to\file2.ps1, Line: 67

Copy link
Owner

@Badgerati Badgerati left a comment

Choose a reason for hiding this comment

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

LGTM

@Badgerati Badgerati merged commit f7c30a1 into Badgerati:develop Oct 20, 2024
12 checks passed
@mdaneri mdaneri deleted the Duplicate-Function-test branch October 21, 2024 14:12
@Badgerati Badgerati mentioned this pull request Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants