Skip to content

Add Timestamp field to psscriptanalyzer-summary.json output #1002

@WilliamBerryiii

Description

@WilliamBerryiii

Summary

Invoke-PSScriptAnalyzer.ps1 writes logs/psscriptanalyzer-summary.json with keys Errors, Information, TotalFiles, TotalIssues, Warnings, HasErrors — but no Timestamp field. This is the only JSON result file in logs/ that completely lacks a timestamp, preventing correlation with other lint results.

Current Behavior

The summary JSON has no way to determine when the scan was performed. All other JSON result files in logs/ include a timestamp.

Expected Behavior

The summary JSON includes a Timestamp field using Get-StandardTimestamp from CIHelpers.psm1, consistent with all other result files.

Root Cause

The summary hashtable was built with only statistical fields and no timestamp was included in the original implementation.

Files Requiring Changes

File Change
scripts/linting/Invoke-PSScriptAnalyzer.ps1 Add Timestamp = Get-StandardTimestamp to summary hashtable
Corresponding Pester test file Update test assertions for new field

Fix Guidance

  1. Verify Get-StandardTimestamp is available (requires Issue Add Get-StandardTimestamp utility to CIHelpers module #993 merged first).
  2. Find the summary hashtable construction in Invoke-PSScriptAnalyzer.ps1.
  3. Add Timestamp = Get-StandardTimestamp to the hashtable.
  4. CIHelpers.psm1 should already be imported — verify.
  5. Update Pester tests to assert the Timestamp field exists and is a valid ISO 8601 UTC string.

Depends on: #993 (Get-StandardTimestamp utility)

RPI Framework Starter Prompts

Phase 1: Research

Select Task Researcher from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:

Research adding a Timestamp field to psscriptanalyzer-summary.json. Investigate: (1) Read scripts/linting/Invoke-PSScriptAnalyzer.ps1 and find the summary hashtable construction (exact line numbers). (2) Identify all fields currently in the summary hashtable. (3) Verify Get-StandardTimestamp is available from CIHelpers.psm1 (from Issue #993). (4) Check whether CIHelpers.psm1 is already imported. (5) Check existing Pester tests for summary JSON assertions. (6) Verify no downstream consumers (CI workflows) parse the summary JSON in a way that would break with an added field.

Phase 2: Plan

Select Task Planner from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:

Plan adding a Timestamp field to the psscriptanalyzer-summary.json output. The plan should cover: (1) Adding Timestamp = Get-StandardTimestamp to the summary hashtable. (2) Verifying CIHelpers.psm1 is imported. (3) Updating Pester tests to assert the Timestamp field exists. (4) Validation: npm run test:ps, npm run lint:ps.

Phase 3: Implement

Select Task Implementor from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:

Implement adding a Timestamp field to psscriptanalyzer-summary.json following the plan. Steps: (1) Add Timestamp = Get-StandardTimestamp to the summary hashtable at the identified location. (2) Verify CIHelpers.psm1 import is present. (3) Update Pester test assertions. (4) Run npm run lint:ps and npm run test:ps. (5) Run npm run lint:ps and verify logs/psscriptanalyzer-summary.json now contains a Timestamp field with ISO 8601 UTC format.

Phase 4: Review

Select Task Reviewer from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:

Review the Timestamp field addition to psscriptanalyzer-summary.json. Verify: (1) Timestamp = Get-StandardTimestamp is added to the summary hashtable. (2) CIHelpers.psm1 is imported. (3) The new field is a valid ISO 8601 UTC string ending in Z. (4) No other summary fields were modified. (5) Pester tests updated and passing. (6) npm run lint:ps clean. (7) The summary JSON now includes the Timestamp field alongside existing fields.

References

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomerslintingLinting rules and validationscriptsPowerShell, Bash, or Python scripts

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions