Pode icon indicating copy to clipboard operation
Pode copied to clipboard

Rename any internal function with a plural noun to a singular one

Open mdaneri opened this issue 9 months ago • 2 comments

Rename any internal function with a plural noun to a singular one feature: #1271

Addressed the following ScriptAnalyzer warnings

  • PSAvoidUsingCmdletAliases
  • PSAvoidUsingWriteHost
  • PSAvoidUsingInvokeExpression

Suppress PSPossibleIncorrectComparisonWithNull for function New-PodeAutoRestartServer

Renamed the following internal functions:

  • Read-PodeWebExceptionDetails -> Read-PodeWebExceptionDetail
  • Test-PodeAuthUserGroups -> Test-PodeAuthUserGroup
  • Get-PodeAuthADGroups -> Get-PodeAuthADGroup
  • Get-PodeModuleDependencies -> Get-PodeModuleDependency
  • Get-PodeModuleDetails -> Get-PodeModuleInfo
  • Get-PodeDefaultSslProtocols -> Get-PodeDefaultSslProtocol
  • New-PodeRunspacePools -> New-PodeRunspacePool
  • Test-PodeEndpoints -> Test-PodeEndpoint`
  • Close-PodeRunspacePools -> Close-PodeRunspacePool
  • Set-PodeOutputVariables -> Set-PodeOutputVariable
  • Get-PodeCronFields -> Get-PodeCronField
  • Get-PodeCronFieldConstraints -> Get-PodeCronFieldConstraint
  • Get-PodeCronFieldAliases -> Get-PodeCronFieldAlias
  • ConvertFrom-PodeCronExpressions -> ConvertFrom-PodeCronExpression
  • Get-PodeRandomBytes -> Get-PodeRandomByte
  • Find-PodeEndpoints -> Find-PodeEndpointInternal
  • Test-PodeEndpoints -> Test-PodeEndpoint
  • Get-PodeErrorLoggingLevels -> Get-PodeErrorLoggingLevel
  • Test-PodeLoggerBatches -> Test-PodeLoggerBatch
  • Update-PodeServerRequestMetrics -> Update-PodeServerRequestMetric
  • Update-PodeServerSignalMetrics -> Update-PodeServerSignalMetric
  • Update-PodeRouteSlashes -> Update-PodeRouteSlash
  • Resolve-PodePlaceholders -> Resolve-PodePlaceholder
  • Complete-PodeInternalSchedules -> Complete-PodeInternalSchedule
  • Find-PodeScopedVariableUsingVariableValues -> Find-PodeScopedVariableUsingVariableValue
  • Get-PodeScopedVariableUsingVariables -> Get-PodeScopedVariableUsingVariable
  • Convert-PodeScopedVariableUsingVariables -> Convert-PodeScopedVariableUsingVariable
  • Find-PodeScopedVariableUsingVariableValues -> Find-PodeScopedVariableUsingVariableValue
  • Unregister-PodeSecretVaults -> Unregister-PodeSecretVaultsInternal
  • Clear-PodeHashtableInnerKeys -> Clear-PodeHashtableInnerKey

Exceptions

Added body to any Execptions without any code

catch [<_exception_>] {
     $_ | Write-PodeErrorLog -Level Debug
}

mdaneri avatar May 10 '24 22:05 mdaneri

The function Add-PodeSecurityHeader is not name compliant and should be named Set-PodeSecurityHeader but I know that it's a tricky change. Maybe we can create a Set-PodeSecurityHeader alias in the meantime

mdaneri avatar May 13 '24 22:05 mdaneri

We need to be careful we're not making too many aliases here for pubic functions, otherwise it will start to cause confusion when people ask for help. For any public functions that need a rename, I'd say it would be better targeted at a v3.0 where we can write a migration guide for them. (I already have ideas for a v3, so might start shortlisting them soon - a lot of them are fixes for better best practices)

I was OK with OpenAPI as there were 1 or 2 functions that didn't conform to the "PodeOA" tag. But for some that might have a slightly wrong verb, or be plural, in the public functions, I'd say leave them for now - otherwise we'll have a flood of aliases, which borders on bad practice.

Badgerati avatar May 19 '24 20:05 Badgerati

Good to go I'm going to open another bug for the removal of the global variable. You showed me how to do it😏

mdaneri avatar Jun 02 '24 20:06 mdaneri