Skip to content

Commit 9c906f3

Browse files
lowlydbaAppveyorJohn McCall
authored
Linter updates (#168)
* suppress ps lint errors * fixes #78 * fix lint error * CI produced files * Update super-linter.yml * Update .markdown-lint.yml * Update .markdown-lint.yml * turn on posh lint * fix posh lint errors * fix lint errors * Update codecov.yml * Update run_pester_tests.ps1 * Update run_pester_tests.ps1 Co-authored-by: Appveyor <[email protected]> Co-authored-by: John McCall <[email protected]>
1 parent fc9cf97 commit 9c906f3

21 files changed

+672
-608
lines changed

.github/CONTRIBUTING.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ for your commits to be automatically linted using Github Actions.
4343

4444
### PowerShell
4545

46-
PowerShell is only used in the automation piece of this project, but could probably
47-
benefit from being better documented and standardized. Right now no particular
48-
style is enforced,
49-
but [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) is recommended.
46+
PowerShell is only used in the automation piece of this project,
47+
but [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer)
48+
is used to lint it for general best practice adherement.
5049

5150
[mdconfig]: https://github.com/LowlyDBA/dba-multitool/blob/master/.github/linters/.markdown-lint.yml
5251
[mdlint]: https://github.com/DavidAnson/markdownlint

.github/codecov.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ coverage:
33
round: down
44
precision: 2
55
status:
6+
project:
7+
default:
8+
# basic
9+
target: auto
10+
threshold: 1%
611
patch: off
712

813
fixes:
9-
- "::"
14+
- "::"

.github/linters/.markdown-lint.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
###############
1919
# Rules by id #
2020
###############
21-
MD033:
22-
allowed_elements: ["details", "summary", "img", "sub"]
21+
MD009: false
22+
MD010:
23+
code_blocks: false
2324
MD013:
2425
code_blocks: false
2526
tables: false
2627
MD024: false
27-
MD010:
28-
code_blocks: false
29-
MD009: false
28+
MD033:
29+
allowed_elements: ["details", "summary", "img", "sub"]
30+
31+
32+

.github/workflows/super-linter.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ jobs:
4545
- name: Lint Code Base
4646
uses: docker://github/super-linter:v3.13.5
4747
env:
48-
VALIDATE_ALL_CODEBASE: false
49-
VALIDATE_POWERSHELL: false
50-
VALIDATE_SQL: false
48+
VALIDATE_MARKDOWN: true
49+
VALIDATE_POWERSHELL: true
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

appveyor/generate_sample_markdown.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
param(
2-
[Parameter()]
1+
#PSScriptAnalyzer rule excludes
2+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')]
3+
4+
param(
5+
[Parameter()]
36
[string]$SqlInstance = $env:DB_INSTANCE,
47
[string]$UtilityDatabase = $env:TARGET_DB,
5-
[bool]$IsAzureSQL = [System.Convert]::ToBoolean($env:AzureSQL),
6-
[string]$User = $env:AZURE_SQL_USER,
7-
[string]$Pass = $env:AZURE_SQL_PASS,
88
[string]$Color = "Green"
99
)
1010

appveyor/install_dependencies.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
param(
2-
[Parameter()]
1+
#PSScriptAnalyzer rule excludes
2+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')]
3+
4+
param(
5+
[Parameter()]
36
[switch]$CodeCoverage,
47
$Color = "Green"
58
)

appveyor/install_tsqlt.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#PSScriptAnalyzer rule excludes
2+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')]
3+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
4+
15
param(
26
[Parameter()]
37
[String]$SqlInstance = $env:DB_INSTANCE,
@@ -10,7 +14,7 @@ param(
1014

1115
Write-Host "Downloading and installing tSQLt..." -ForegroundColor $Color
1216

13-
# BaseUrl gets the latest version by default - blocked by https://github.com/LowlyDBA/dba-multitool/issues/165
17+
# BaseUrl gets the latest version by default - blocked by https://github.com/LowlyDBA/dba-multitool/issues/165
1418
$Version = "1-0-5873-27393"
1519
$DownloadUrl = "http://tsqlt.org/download/tsqlt/?version=" + $Version
1620
$TempPath = [System.IO.Path]::GetTempPath()
@@ -26,7 +30,7 @@ IF EXISTS (SELECT 1 FROM sys.configurations WHERE name = 'clr strict security')
2630
BEGIN
2731
EXEC sp_configure 'show advanced options', 1;
2832
RECONFIGURE;
29-
33+
3034
EXEC sp_configure 'clr strict security', 0;
3135
RECONFIGURE;
3236
END

appveyor/push_git_changes.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ $StagedFiles = git diff --staged
66

77
# Commit & push if stated
88
If ($StagedFiles) {
9-
git commit -a -m "CI produced files" -q
9+
git commit -a -m "CI produced files" -q
1010
git push origin $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH -f -q
1111
}

appveyor/run_pester_tests.ps1

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
11
using namespace System.IO.Path
22

3-
param(
4-
[Parameter()]
3+
#PSScriptAnalyzer rule excludes
4+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')]
5+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
6+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '')]
7+
param(
8+
[Parameter()]
59
[switch]$LocalTest,
610
[string]$CoverageXMLPath = $env:COV_REPORT,
711
[string]$SqlInstance = $env:DB_INSTANCE,
812
[string]$Database = $env:TARGET_DB,
913
[bool]$IsAzureSQL = [System.Convert]::ToBoolean($env:AzureSQL),
1014
[string]$User = $env:AZURE_SQL_USER,
1115
[string]$Pass = $env:AZURE_SQL_PASS,
12-
[string]$Color = "Green",
16+
[System.ConsoleColor]$Color = "Green",
1317
[switch]$CodeCoverage
1418
)
19+
1520
. ".\tests\constants.ps1"
1621
$ErrorActionPreference = "Stop"
1722
$TestFiles = Get-ChildItem -Path .\tests\*.Tests.ps1
1823
$FailedTests = 0
1924

2025
function Start-CodeCoverage {
26+
param(
27+
[string]$SqlInstance,
28+
[string]$Database,
29+
[string]$User,
30+
[string]$Pass,
31+
[bool]$IsAzureSQL,
32+
[System.ConsoleColor]$Color
33+
)
2134
# Setup vars
35+
$ConnString = "server=$SqlInstance;initial catalog=$Database;Trusted_Connection=yes"
2236
If ($IsAzureSQL) {
2337
$ConnString = "server=$SqlInstance;initial catalog=$Database;User Id=$User;pwd=$Pass"
2438
}
2539

26-
Else {
27-
$ConnString = "server=$SqlInstance;initial catalog=$Database;Trusted_Connection=yes"
28-
}
29-
3040
$NugetPath = (Get-Package GOEddie.SQLCover).Source | Convert-Path
3141
$SQLCoverRoot = Split-Path $NugetPath
3242
$SQLCoverPath = Join-Path $SQLCoverRoot "lib"
@@ -42,7 +52,11 @@ function Start-CodeCoverage {
4252
}
4353

4454
function Complete-CodeCoverage {
45-
# Stop covering
55+
param (
56+
[string]$CoverageXMLPath,
57+
[string]$Color
58+
)
59+
# Stop covering
4660
Write-Host "Stopping SQLCover..." -ForegroundColor $Color
4761
$coverageResults = $global:SQLCover.Stop()
4862

@@ -51,10 +65,10 @@ function Complete-CodeCoverage {
5165
If (!($LocalTest.IsPresent)) {
5266
$SavePath = Join-Path -Path $PSScriptRoot -ChildPath "sqlcover"
5367
$coverageResults.OpenCoverXml() | Out-File $CoverageXMLPath -Encoding utf8
54-
$coverageResults.SaveSourceFiles($SavePath)
68+
$coverageResults.SaveSourceFiles($SavePath)
5569
}
5670

57-
Else {
71+
Else {
5872
# Don't save any files and bring up html report for review
5973
$tmpFile = Join-Path $env:TEMP "Coverage.html"
6074
Set-Content -Path $tmpFile -Value $coverageResults.Html2() -Force
@@ -66,7 +80,15 @@ function Complete-CodeCoverage {
6680

6781
# Start Coverage
6882
If ($CodeCoverage.IsPresent) {
69-
Start-CodeCoverage
83+
$Hash = @{
84+
SqlInstance = $SqlInstance
85+
Database = $Database
86+
User = $User
87+
Pass = $Pass
88+
IsAzureSQL = $IsAzureSQL
89+
Color = $Color
90+
}
91+
Start-CodeCoverage @Hash
7092
}
7193

7294
# Generate all-in-one installer script
@@ -88,7 +110,7 @@ ForEach ($file in $TestFiles) {
88110

89111
# End Coverage
90112
If ($CodeCoverage.IsPresent) {
91-
Complete-CodeCoverage
113+
Complete-CodeCoverage -CoverageXMLPath $CoverageXMLPath -Color $Color
92114
}
93115

94116
# Check for failures

appveyor/sqlcover/Coverage.opencoverxml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
<SequencePoint vc="8" uspid="31" ordinal="31" offset="6146" sl="198" sc="3" el="198" ec="36" />
4444
<SequencePoint vc="1" uspid="32" ordinal="32" offset="6197" sl="200" sc="5" el="204" ec="56" />
4545
<SequencePoint vc="7" uspid="33" ordinal="33" offset="6511" sl="208" sc="4" el="212" ec="50" />
46-
<SequencePoint vc="8" uspid="34" ordinal="34" offset="6798" sl="216" sc="3" el="273" ec="14" />
47-
<SequencePoint vc="8" uspid="35" ordinal="35" offset="9411" sl="274" sc="5" el="274" ec="38" />
48-
<SequencePoint vc="1" uspid="36" ordinal="36" offset="9466" sl="276" sc="7" el="282" ec="15" />
46+
<SequencePoint vc="8" uspid="34" ordinal="34" offset="6798" sl="216" sc="3" el="273" ec="13" />
47+
<SequencePoint vc="8" uspid="35" ordinal="35" offset="9410" sl="274" sc="5" el="274" ec="38" />
48+
<SequencePoint vc="1" uspid="36" ordinal="36" offset="9465" sl="276" sc="7" el="282" ec="15" />
4949
<SequencePoint vc="8" uspid="37" ordinal="37" offset="9809" sl="284" sc="5" el="284" ec="27" />
5050
<SequencePoint vc="8" uspid="38" ordinal="38" offset="9837" sl="285" sc="3" el="301" ec="44" />
5151
<SequencePoint vc="8" uspid="39" ordinal="39" offset="10804" sl="303" sc="3" el="303" ec="36" />

0 commit comments

Comments
 (0)