-
Notifications
You must be signed in to change notification settings - Fork 125
Labels
automationCI/CD and automation improvementsCI/CD and automation improvementsenhancementNew feature or requestNew feature or request
Description
Description
Create a PowerShell script that validates the presence of copyright and SPDX license headers in source files. This script integrates with the existing linting infrastructure and follows PSScriptAnalyzer patterns established in the codebase.
Acceptance Criteria
- Create
scripts/linting/Test-CopyrightHeaders.ps1 - Script detects missing or malformed headers
- Output follows existing JSON result format
- Results written to
logs/copyright-header-results.json - Add
npm runscript for easy execution - Include comment-based help following codebase conventions
- Pass PSScriptAnalyzer validation
- Create Pester tests in
scripts/tests/linting/
Implementation Steps
-
Create
scripts/linting/Test-CopyrightHeaders.ps1with these features:- Accept path parameter for target directory
- Support file type filtering (
.ps1,.psm1,.psd1,.sh) - Check for copyright line pattern:
# Copyright (c) Microsoft Corporation. - Check for SPDX line pattern:
# SPDX-License-Identifier: MIT - Handle shebang and
#Requiresstatement positioning
-
Output format (matching existing patterns):
{ "timestamp": "2026-01-26T12:00:00Z", "totalFiles": 38, "filesWithHeaders": 38, "filesMissingHeaders": 0, "results": [ { "file": "scripts/lib/Get-VerifiedDownload.ps1", "hasCopyright": true, "hasSpdx": true, "valid": true } ] } -
Add npm script to
package.json:"validate:copyright": "pwsh scripts/linting/Test-CopyrightHeaders.ps1"
-
Create Pester tests covering:
- Files with valid headers
- Files missing copyright line
- Files missing SPDX line
- Files with incorrect line positions
Reference Implementation
Follow patterns from:
scripts/linting/Invoke-PSScriptAnalyzer.ps1scripts/security/Test-DependencyPinning.ps1
Time Estimate
2-3 hours
Dependencies
- Issues chore: add copyright headers to shell scripts #304 and chore: add copyright headers to PowerShell scripts #305 (header addition) completed first provides test data
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
automationCI/CD and automation improvementsCI/CD and automation improvementsenhancementNew feature or requestNew feature or request