Skip to content

Commit

Permalink
Merge pull request #5 from andrewrdavidson/release-1.0.4
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
andrewrdavidson authored Dec 21, 2020
2 parents 0ed1136 + b87e8bb commit 543e198
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion PSQualityCheck.Functions.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RootModule = 'PSQualityCheck.Functions.psm1'

# Version number of this module.
ModuleVersion = '1.0.3'
ModuleVersion = '1.0.4'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
10 changes: 6 additions & 4 deletions PSQualityCheck.Functions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,18 @@ function Get-ParsedContent {
($ParsedModule, $ParserErrorCount) = Get-ParsedContent -Content $fileContent
#>
[CmdletBinding()]
[OutputType([System.Object[]])]
[OutputType([System.Object[]], [System.Void])]
param (
[parameter(Mandatory = $true)]
[string]$Content
)

$ParserErrors = $null
$ParsedModule = [System.Management.Automation.PSParser]::Tokenize($Content, [ref]$ParserErrors)
if (-not ([string]::IsNullOrEmpty($Content))) {
$ParserErrors = $null
$ParsedModule = [System.Management.Automation.PSParser]::Tokenize($Content, [ref]$ParserErrors)

return $ParsedModule, ($ParserErrors.Count)
return $ParsedModule, ($ParserErrors.Count)
}

}

Expand Down
2 changes: 1 addition & 1 deletion PSQualityCheck.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RootModule = 'PSQualityCheck.psm1'

# Version number of this module.
ModuleVersion = '1.0.3'
ModuleVersion = '1.0.4'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
17 changes: 9 additions & 8 deletions PSQualityCheck.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ function Invoke-PSQualityCheck {
$qualityCheckResults +=
@{
'Test' = 'Module Tests'
'Files Tested' = $ModulesToTestCount
'Files Tested' = $ModulesToTest.Count
'Total' = $moduleResults.TotalCount
'Passed' = $moduleResults.PassedCount
'Failed' = $moduleResults.FailedCount
'Skipped' = $moduleResults.SkippedCount
}
$filesTested += $ModulesToTestCount
$filesTested += $ModulesToTest.Count
$total += $moduleResults.TotalCount
$passed += $moduleResults.PassedCount
$failed += $moduleResults.FailedCount
Expand All @@ -233,7 +233,7 @@ function Invoke-PSQualityCheck {
$qualityCheckResults +=
@{
'Test' = 'Extracting functions'
'Files Tested' = $ModulesToTestCount
'Files Tested' = $ModulesToTest.Count
'Total' = $extractionResults.TotalCount
'Passed' = $extractionResults.PassedCount
'Failed' = $extractionResults.FailedCount
Expand All @@ -248,13 +248,13 @@ function Invoke-PSQualityCheck {
$qualityCheckResults +=
@{
'Test' = 'Extracted function script tests'
'Files Tested' = $extractedScriptsToTestCount
'Files Tested' = $extractedScriptsToTest.Count
'Total' = $extractedScriptResults.TotalCount
'Passed' = $extractedScriptResults.PassedCount
'Failed' = $extractedScriptResults.FailedCount
'Skipped' = $extractedScriptResults.SkippedCount
}
$filesTested += $extractedScriptsToTestCount
$filesTested += $extractedScriptsToTest.Count
$total += $extractedScriptResults.TotalCount
$passed += $extractedScriptResults.PassedCount
$failed += $extractedScriptResults.FailedCount
Expand All @@ -264,13 +264,13 @@ function Invoke-PSQualityCheck {
$qualityCheckResults +=
@{
'Test' = "Script Tests"
'Files Tested' = $scriptsToTestCount
'Files Tested' = $scriptsToTest.Count
'Total' = $scriptResults.TotalCount
'Passed' = $scriptResults.PassedCount
'Failed' = $scriptResults.FailedCount
'Skipped' = $scriptResults.SkippedCount
}
$filesTested += $scriptsToTestCount
$filesTested += $scriptsToTest.Count
$total += $scriptResults.TotalCount
$passed += $scriptResults.PassedCount
$failed += $scriptResults.FailedCount
Expand All @@ -295,7 +295,8 @@ function Invoke-PSQualityCheck {
'Passed' = $_.passed
'Failed' = $_.failed
'Skipped' = $_.skipped
} } | Format-Table -AutoSize
}
} | Format-Table -AutoSize

# This works on PS7 not on PS5
# $qualityCheckResults | Select-Object Name, 'Files Tested', Total, Passed, Failed, Skipped | Format-Table -AutoSize
Expand Down
9 changes: 8 additions & 1 deletion Tests/Script.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ Describe "Script Tests" {
# This needs to get the content of the file or the content of the function inside the file
$fileContent = Get-FileContent -File $scriptFile

($ParsedFile, $ErrorCount) = Get-ParsedContent -Content $fileContent
if (-not([string]::IsNullOrEmpty($fileContent))) {
($ParsedFile, $ErrorCount) = Get-ParsedContent -Content $fileContent
}
else {
Write-Warning "File is empty"
$ParsedFile = $null
$ErrorCount = 1
}

It "check script has valid PowerShell syntax" -TestCases @{ 'ErrorCount' = $ErrorCount } {

Expand Down

0 comments on commit 543e198

Please sign in to comment.