Skip to content

Commit

Permalink
🩹 [Patch]: Update linter configurations and license year (#106)
Browse files Browse the repository at this point in the history
## Description

This pull request includes several updates to the configuration files
and PowerShell scripts to enhance code quality and maintainability. The
most important changes include updates to the JSCPD and PSScriptAnalyzer
configurations, adjustments to the module requirements in various
scripts, and suppression of specific warnings.

### Configuration Updates:
*
[`.github/linters/.jscpd.json`](diffhunk://#diff-557094e283c00b23265c1c75872f41c6b1a524a00f0d99dd68ebd22cb63bfdd6R1-R14):
Added a new configuration file for JSCPD to set the threshold to 0,
specify reporters, and ignore certain paths.
*
[`.github/linters/.powershell-psscriptanalyzer.psd1`](diffhunk://#diff-aae69c9d6774628ed181eacf53aee0f38eb6c2f53492cf3a5b7f7bdb6ef43b6aL1-L17):
Updated the PSScriptAnalyzer configuration to enable specific rules and
adjust the excluded rules.

### Module Requirement Adjustments:
* `scripts/helpers/Build-PSModule.ps1`,
`scripts/helpers/Build/Build-PSModuleBase.ps1`,
`scripts/helpers/Build/Build-PSModuleManifest.ps1`,
`scripts/helpers/Build/Get-PSModuleAliasesToExport.ps1`,
`scripts/helpers/Build/Get-PSModuleCmdletsToExport.ps1`,
`scripts/helpers/Build/Get-PSModuleFunctionsToExport.ps1`,
`scripts/helpers/Build/Get-PSModuleVariablesToExport.ps1`,
`scripts/helpers/Build/Import-PSModule.ps1`,
`scripts/helpers/Build/Resolve-PSModuleDependency.ps1`,
`scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1`,
`scripts/main.ps1`: Re-added the `#Requires -Modules` directive for
required modules and added suppression for `PSAvoidUsingWriteHost`
warnings.
[[1]](diffhunk://#diff-c688e346ad60fbe881bd05b6a5dbc1cd712fdca0bf8b8527965db583af825fd9R10-R19)
[[2]](diffhunk://#diff-1ab7417b36702be4629b208ad7dd9ec76f94998bb625c4810edda2f9b5dbddb8R14-R22)
[[3]](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9R14-R15)
[[4]](diffhunk://#diff-ae18191466ffa02c1a8429365cf96d8768f5eae03331c4a35199f8cd961e76a7R13-R17)
[[5]](diffhunk://#diff-f542f4a75d778df60fee6e176c795e133be2ed109d8212c05aa545383bd26c46R13-R17)
[[6]](diffhunk://#diff-d35d4bdcf90f10b73b3318d21c09dd5f8b9ca52fef3d2aa84ac0d0388011ee29R13-R16)
[[7]](diffhunk://#diff-e2148fcf63283d70b3d432f67fc98191e2cc712dc3f4d30914c8c0810d11a6deR13-R16)
[[8]](diffhunk://#diff-15f2301e39f56f54fa469db56cc7c487e2df36eb295bb74e8d2325aabcd164c0R15-R19)
[[9]](diffhunk://#diff-b278dc96f784d462b15a4fe67b088a5b5d9cc502dd6eba3d660da085e576652fR19-R25)
[[10]](diffhunk://#diff-faeb855accbc346b12f7a0ece1d91f67e26e8929ab8133aedca4051d179c66faR14-R19)
[[11]](diffhunk://#diff-dc2e5a659836b1b73abb03421c567f5018c2755677c4a0aa764cb26117b68011L1-R9)

### License Update:
* `LICENSE`: Updated the copyright year from 2024 to 2025. (F75789b6L1)

### Linter Workflow Adjustment:
*
[`.github/workflows/Linter.yml`](diffhunk://#diff-482e65806ed9e4a7320f14964764086b91fed4a28d12e4efde1776472e147e79L30-R30):
Changed the validation setting from `VALIDATE_JSCPD` to
`VALIDATE_JSON_PRETTIER`.

### Script Output Adjustments:
* `tests/tools/1-build.ps1`, `tests/tools/2-build.ps1`: Changed the
output from `Write-Host` to a direct string output.
[[1]](diffhunk://#diff-de6d50a7c32f536bea22dc71c6514d47d7d54d859ef5473045ac801f055ac380L1-R1)
[[2]](diffhunk://#diff-e522bb466e514d213416a3b0ab344605da146583de06b3b94fa5cce84d370109L1-R1)

## Type of change

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [ ] 📖 [Docs]
- [ ] 🪲 [Fix]
- [x] 🩹 [Patch]
- [ ] ⚠️ [Security fix]
- [ ] 🚀 [Feature]
- [ ] 🌟 [Breaking change]

## Checklist

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
  • Loading branch information
MariusStorhaug authored Feb 16, 2025
1 parent b75256c commit 8819705
Show file tree
Hide file tree
Showing 20 changed files with 682 additions and 81 deletions.
14 changes: 14 additions & 0 deletions .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"threshold": 0,
"reporters": [
"consoleFull"
],
"ignore": [
"**/tests/**",
"**/.github/workflows/Action-Test.yml",
"**/scripts/helpers/Build/Build-PSModuleManifest.ps1",
"**/scripts/helpers/Build/Build-PSModuleRootModule.ps1",
"**/scripts/helpers/Build/PSScriptAnalyzer.Tests.psd1"
],
"absolute": true
}
68 changes: 53 additions & 15 deletions .github/linters/.powershell-psscriptanalyzer.psd1
Original file line number Diff line number Diff line change
@@ -1,18 +1,56 @@
#Documentation: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/docs/Cmdlets/Invoke-ScriptAnalyzer.md#-settings
@{
#CustomRulePath='path\to\CustomRuleModule.psm1'
#RecurseCustomRulePath='path\of\customrules'
#Severity = @(
# 'Error'
# 'Warning'
#)
#IncludeDefaultRules=${true}
@{
Rules = @{
PSAlignAssignmentStatement = @{
Enable = $true
CheckHashtable = $true
}
PSAvoidLongLines = @{
Enable = $true
MaximumLineLength = 150
}
PSAvoidSemicolonsAsLineTerminators = @{
Enable = $true
}
PSPlaceCloseBrace = @{
Enable = $true
NewLineAfter = $false
IgnoreOneLineBlock = $true
NoEmptyLineBefore = $false
}
PSPlaceOpenBrace = @{
Enable = $true
OnSameLine = $true
NewLineAfter = $true
IgnoreOneLineBlock = $true
}
PSProvideCommentHelp = @{
Enable = $true
ExportedOnly = $false
BlockComment = $true
VSCodeSnippetCorrection = $false
Placement = 'begin'
}
PSUseConsistentIndentation = @{
Enable = $true
IndentationSize = 4
PipelineIndentation = 'IncreaseIndentationForFirstPipeline'
Kind = 'space'
}
PSUseConsistentWhitespace = @{
Enable = $true
CheckInnerBrace = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckPipe = $true
CheckPipeForRedundantWhitespace = $true
CheckSeparator = $true
CheckParameter = $true
IgnoreAssignmentOperatorInsideHashTable = $true
}
}
ExcludeRules = @(
'PSMissingModuleManifestField'
'PSAvoidUsingWriteHost'
'PSMissingModuleManifestField', # This rule is not applicable until the module is built.
'PSUseToExportFieldsInManifest'
)
#IncludeRules = @(
# 'PSAvoidUsingWriteHost',
# 'MyCustomRuleName'
#)
}
Loading

0 comments on commit 8819705

Please sign in to comment.