Skip to content

Commit

Permalink
Merge pull request #21 from andrewrdavidson/release-1.1.0
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
andrewrdavidson committed Jan 14, 2021
2 parents 0f181b1 + 7de38fe commit cbaa5ff
Show file tree
Hide file tree
Showing 25 changed files with 108 additions and 38 deletions.
6 changes: 3 additions & 3 deletions PSQualityCheck.Functions.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Andrew Davidson
#
# Generated on: 11/01/2021
# Generated on: 14/01/2021
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'PSQualityCheck.Functions.psm1'

# Version number of this module.
ModuleVersion = '1.0.10'
ModuleVersion = '1.1.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -102,7 +102,7 @@ PrivateData = @{
PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'powershell', 'powershell-module', 'tests', 'quality', 'quality-check',
Tags = 'powershell', 'powershell-module', 'quality', 'quality-check', 'tests',
'pester', 'pester-tests'

# A URL to the license for this module.
Expand Down
20 changes: 18 additions & 2 deletions PSQualityCheck.Functions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -400,16 +400,24 @@ function Get-FileList {
.PARAMETER Extension
A string containing the extension
.PARAMETER Recurse
A switch specifying whether or not to recursively search the path specified
.EXAMPLE
$files = Get-FileList -Path 'c:\folder' -Extension ".ps1"
.EXAMPLE
$files = Get-FileList -Path 'c:\folder' -Extension ".ps1" -Recurse
#>
[CmdletBinding()]
[OutputType([System.Object[]])]
param (
[parameter(Mandatory = $true)]
[string]$Path,
[parameter(Mandatory = $true)]
[string]$Extension
[string]$Extension,
[parameter(Mandatory = $false)]
[switch]$Recurse
)

$Extension = $Extension
Expand All @@ -418,8 +426,16 @@ function Get-FileList {

if (Test-Path -Path $Path) {

$gciSplat = @{
'Path' = $Path
'Exclude' = "*.Tests.*"
}
if ($PSBoundParameters.ContainsKey('Recurse')) {
$gciSplat.Add('Recurse', $true)
}

# Get the list of files
$SelectedFilesArray = Get-ChildItem -Path $Path -Recurse -Exclude "*.Tests.*" | Where-Object { $_.Extension -eq $Extension } | Select-Object -Property FullName
$SelectedFilesArray = Get-ChildItem @gciSplat | Where-Object { $_.Extension -eq $Extension } | Select-Object -Property FullName
# Convert to a string array of filenames
$SelectedFilesArray | ForEach-Object { $FileNameArray += [string]$_.FullName }

Expand Down
6 changes: 3 additions & 3 deletions PSQualityCheck.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Andrew Davidson
#
# Generated on: 11/01/2021
# Generated on: 14/01/2021
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'PSQualityCheck.psm1'

# Version number of this module.
ModuleVersion = '1.0.10'
ModuleVersion = '1.1.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -95,7 +95,7 @@ PrivateData = @{
PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'powershell', 'powershell-module', 'tests', 'quality', 'quality-check',
Tags = 'powershell', 'powershell-module', 'quality', 'quality-check', 'tests',
'pester', 'pester-tests'

# A URL to the license for this module.
Expand Down
22 changes: 20 additions & 2 deletions PSQualityCheck.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ function Invoke-PSQualityCheck {
.PARAMETER File
A string array containing testable files
.PARAMETER Recurse
A switch specifying whether or not to recursively search the path specified
.PARAMETER SonarQubeRulesPath
A path the the external PSScriptAnalyzer rules for SonarQube
Expand All @@ -23,6 +26,11 @@ function Invoke-PSQualityCheck {
This will call the quality checks on single path
.EXAMPLE
Invoke-PSQualityCheck -Path 'C:\Scripts' -Recurse
This will call the quality checks on single path and sub folders
.EXAMPLE
Invoke-PSQualityCheck -Path @('C:\Scripts', 'C:\MoreScripts')
Expand Down Expand Up @@ -81,6 +89,9 @@ function Invoke-PSQualityCheck {
[Parameter(Mandatory = $true, ParameterSetName = "File")]
[String[]]$File,

[Parameter(Mandatory = $false, ParameterSetName = "Path")]
[switch]$Recurse,

[Parameter(Mandatory = $false)]
[String]$SonarQubeRulesPath,

Expand Down Expand Up @@ -111,8 +122,15 @@ function Invoke-PSQualityCheck {
# Test whether the item is a directory (also tells us if it exists)
if (Test-Path -Path $item -PathType Container) {

$scriptsToTest += Get-FileList -Path $item -Extension '.ps1'
$modulesToTest += Get-FileList -Path $item -Extension '.psm1'
$getFileListSplat = @{
'Path' = $item
}
if ($PSBoundParameters.ContainsKey('Recurse')) {
$getFileListSplat.Add('Recurse', $true)
}

$scriptsToTest += Get-FileList @getFileListSplat -Extension '.ps1'
$modulesToTest += Get-FileList @getFileListSplat -Extension '.psm1'

}
else {
Expand Down
2 changes: 1 addition & 1 deletion Source/Build.Properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"HelpInfoURI": "https://github.com/andrewrdavidson/PSQualityCheck/wiki",
"LicenseUri": "https://github.com/andrewrdavidson/PSQualityCheck/blob/main/LICENSE",
"ModuleVersion": "1.0.10",
"ModuleVersion": "1.1.0",
"NestedModules": {
"PSQualityCheck": "PSQualityCheck.Functions.psd1",
"PSQualityCheck.Functions": null
Expand Down
20 changes: 18 additions & 2 deletions Source/PSQualityCheck.Functions/Get-FileList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,24 @@ function Get-FileList {
.PARAMETER Extension
A string containing the extension
.PARAMETER Recurse
A switch specifying whether or not to recursively search the path specified
.EXAMPLE
$files = Get-FileList -Path 'c:\folder' -Extension ".ps1"
.EXAMPLE
$files = Get-FileList -Path 'c:\folder' -Extension ".ps1" -Recurse
#>
[CmdletBinding()]
[OutputType([System.Object[]])]
param (
[parameter(Mandatory = $true)]
[string]$Path,
[parameter(Mandatory = $true)]
[string]$Extension
[string]$Extension,
[parameter(Mandatory = $false)]
[switch]$Recurse
)

$Extension = $Extension
Expand All @@ -30,8 +38,16 @@ function Get-FileList {

if (Test-Path -Path $Path) {

$gciSplat = @{
'Path' = $Path
'Exclude' = "*.Tests.*"
}
if ($PSBoundParameters.ContainsKey('Recurse')) {
$gciSplat.Add('Recurse', $true)
}

# Get the list of files
$SelectedFilesArray = Get-ChildItem -Path $Path -Recurse -Exclude "*.Tests.*" | Where-Object { $_.Extension -eq $Extension } | Select-Object -Property FullName
$SelectedFilesArray = Get-ChildItem @gciSplat | Where-Object { $_.Extension -eq $Extension } | Select-Object -Property FullName
# Convert to a string array of filenames
$SelectedFilesArray | ForEach-Object { $FileNameArray += [string]$_.FullName }

Expand Down
22 changes: 20 additions & 2 deletions Source/PSQualityCheck/Invoke-PSQualityCheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ function Invoke-PSQualityCheck {
.PARAMETER File
A string array containing testable files
.PARAMETER Recurse
A switch specifying whether or not to recursively search the path specified
.PARAMETER SonarQubeRulesPath
A path the the external PSScriptAnalyzer rules for SonarQube
Expand All @@ -23,6 +26,11 @@ function Invoke-PSQualityCheck {
This will call the quality checks on single path
.EXAMPLE
Invoke-PSQualityCheck -Path 'C:\Scripts' -Recurse
This will call the quality checks on single path and sub folders
.EXAMPLE
Invoke-PSQualityCheck -Path @('C:\Scripts', 'C:\MoreScripts')
Expand Down Expand Up @@ -81,6 +89,9 @@ function Invoke-PSQualityCheck {
[Parameter(Mandatory = $true, ParameterSetName = "File")]
[String[]]$File,

[Parameter(Mandatory = $false, ParameterSetName = "Path")]
[switch]$Recurse,

[Parameter(Mandatory = $false)]
[String]$SonarQubeRulesPath,

Expand Down Expand Up @@ -111,8 +122,15 @@ function Invoke-PSQualityCheck {
# Test whether the item is a directory (also tells us if it exists)
if (Test-Path -Path $item -PathType Container) {

$scriptsToTest += Get-FileList -Path $item -Extension '.ps1'
$modulesToTest += Get-FileList -Path $item -Extension '.psm1'
$getFileListSplat = @{
'Path' = $item
}
if ($PSBoundParameters.ContainsKey('Recurse')) {
$getFileListSplat.Add('Recurse', $true)
}

$scriptsToTest += Get-FileList @getFileListSplat -Extension '.ps1'
$modulesToTest += Get-FileList @getFileListSplat -Extension '.psm1'

}
else {
Expand Down
4 changes: 2 additions & 2 deletions Source/Tests/Unit/Convert-Help.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe "Convert-Help.Tests" {

Context "Parameter Tests" -Foreach @(
Context "Parameter Tests" -ForEach @(
@{ 'Name' = 'Help'; 'Type' = 'String' }
) {

Expand Down Expand Up @@ -63,7 +63,7 @@ Describe "Convert-Help.Tests" {

}

It "should find <token> in help" -ForEach @(
It "should find <token> in help" -Foreach @(
@{ 'Token' = '.SYNOPSIS' }
@{ 'Token' = '.DESCRIPTION' }
@{ 'Token' = '.PARAMETER' }
Expand Down
2 changes: 1 addition & 1 deletion Source/Tests/Unit/Export-FunctionsFromModule.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe "Export-FunctionsFromModule.Tests" {

Context "Parameter Tests" -Foreach @(
Context "Parameter Tests" -ForEach @(
@{ 'Name' = 'Path'; 'Type' = 'String' }
@{ 'Name' = 'ExtractPath'; 'Type' = 'String' }
) {
Expand Down
2 changes: 1 addition & 1 deletion Source/Tests/Unit/Get-FileContent.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe "Get-FileContent.Tests" {

Context "Parameter Tests" -Foreach @(
Context "Parameter Tests" -ForEach @(
@{ 'Name' = 'Path'; 'Type' = 'String' }
) {

Expand Down
7 changes: 4 additions & 3 deletions Source/Tests/Unit/Get-FileList.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Describe "Get-FileList.Tests" {

Context "Parameter Tests" -ForEach @(
@{ 'Name' = 'Path'; 'Type' = 'String' }
@{ 'Name' = 'Extension'; 'Type' = 'String' }
@{ 'Name' = 'Path'; 'Type' = 'String'; 'MandatoryFlag' = $true }
@{ 'Name' = 'Extension'; 'Type' = 'String'; 'MandatoryFlag' = $true }
@{ 'Name' = 'Recurse'; 'Type' = 'SwitchParameter'; 'MandatoryFlag' = $false }
) {

BeforeAll {
Expand All @@ -12,7 +13,7 @@ Describe "Get-FileList.Tests" {
It "should have $Name as a mandatory parameter" {

(Get-Command -Name $commandletUnderTest).Parameters[$Name].Name | Should -BeExactly $Name
(Get-Command -Name $commandletUnderTest).Parameters[$Name].Attributes.Mandatory | Should -BeTrue
(Get-Command -Name $commandletUnderTest).Parameters[$Name].Attributes.Mandatory | Should -BeExactly $MandatoryFlag

}

Expand Down
2 changes: 1 addition & 1 deletion Source/Tests/Unit/Get-FunctionCount.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe "Get-FunctionCount.Tests" {

Context "Parameter Tests" -ForEach @(
Context "Parameter Tests" -Foreach @(
@{ 'Name' = 'ModulePath'; 'Type' = 'String' }
@{ 'Name' = 'ManifestPath'; 'Type' = 'String' }
) {
Expand Down
2 changes: 1 addition & 1 deletion Source/Tests/Unit/Get-ParsedContent.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe "Get-ParsedContent.Tests" {

Context "Parameter Tests" -Foreach @(
Context "Parameter Tests" -ForEach @(
@{ 'Name' = 'Content'; 'Type' = 'String' }
) {

Expand Down
2 changes: 1 addition & 1 deletion Source/Tests/Unit/Get-ParsedFile.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe "Get-ParsedFile.Tests" {

Context "Parameter Tests" -Foreach @(
Context "Parameter Tests" -ForEach @(
@{ 'Name' = 'Path'; 'Type' = 'String' }
) {

Expand Down
4 changes: 2 additions & 2 deletions Source/Tests/Unit/Get-ScriptParameter.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Describe "Get-ScriptParameters.Tests" {
Describe "Get-ScriptParameter.Tests" {

Context "Parameter Tests" -Foreach @(
@{ 'Name' = 'Content'; 'Type' = 'String' }
) {

BeforeAll {
$commandletUnderTest = "Get-ScriptParameters"
$commandletUnderTest = "Get-ScriptParameter"
}

It "should have $Name as a mandatory parameter" {
Expand Down
2 changes: 1 addition & 1 deletion Source/Tests/Unit/Get-TokenComponent.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe "Get-TokenComponent.Tests" {

Context "Parameter Tests" -ForEach @(
Context "Parameter Tests" -Foreach @(
@{ 'Name' = 'ParsedContent'; 'Type' = 'Object[]' }
@{ 'Name' = 'StartLine'; 'Type' = 'Int32' }
) {
Expand Down
2 changes: 1 addition & 1 deletion Source/Tests/Unit/Get-TokenMarker.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe "Get-TokenMarker.Tests" {

Context "Parameter Tests" -Foreach @(
Context "Parameter Tests" -ForEach @(
@{ 'Name' = 'ParsedContent'; 'Type' = 'Object[]' }
@{ 'Name' = 'Type'; 'Type' = 'String' }
@{ 'Name' = 'Content'; 'Type' = 'String' }
Expand Down
3 changes: 2 additions & 1 deletion Source/Tests/Unit/Invoke-PSQualityCheck.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Describe "Invoke-PSQualityCheck.Tests" {
@{ 'Name' = 'File'; 'Type' = 'String[]'; 'MandatoryFlag' = $true; 'ParameterSet' = 'File' }
@{ 'Name' = 'SonarQubeRulesPath'; 'Type' = 'String'; 'MandatoryFlag' = $false; 'ParameterSet' = '__AllParameterSets' }
@{ 'Name' = 'ShowCheckResults'; 'Type' = 'SwitchParameter'; 'MandatoryFlag' = $false; 'ParameterSet' = '__AllParameterSets' }
@{ 'Name' = 'Recurse'; 'Type' = 'SwitchParameter'; 'MandatoryFlag' = $false; 'ParameterSet' = 'Path' }
) {

BeforeAll {
Expand All @@ -18,7 +19,7 @@ Describe "Invoke-PSQualityCheck.Tests" {

}

It "should $Name not belong to a parameter set" {
It "should $Name belong to a $ParameterSet parameter set" {

(Get-Command -Name $commandletUnderTest).Parameters[$Name].ParameterSets.Keys | Should -Be $ParameterSet

Expand Down
2 changes: 1 addition & 1 deletion Source/Tests/Unit/Test-HelpTokensCountIsValid.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe "Test-HelpTokensCountIsValid.Tests" {

Context "Parameter Tests" -Foreach @(
Context "Parameter Tests" -ForEach @(
@{ 'Name' = 'HelpTokens'; 'Type' = 'HashTable' }
) {

Expand Down
2 changes: 1 addition & 1 deletion Source/Tests/Unit/Test-HelpTokensParamsMatch.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe "Test-HelpTokensParamsMatch.Tests" {

Context "Parameter Tests" -ForEach @(
Context "Parameter Tests" -Foreach @(
@{ 'Name' = 'HelpTokens'; 'Type' = 'HashTable' }
@{ 'Name' = 'ParameterVariables'; 'Type' = 'PSObject' }
) {
Expand Down
2 changes: 1 addition & 1 deletion Source/Tests/Unit/Test-HelpTokensTextIsValid.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe "Test-HelpTokensTextIsValid.Tests" {

Context "Parameter Tests" -Foreach @(
Context "Parameter Tests" -ForEach @(
@{ 'Name' = 'HelpTokens'; 'Type' = 'HashTable' }
) {

Expand Down
Loading

0 comments on commit cbaa5ff

Please sign in to comment.