Skip to content

Commit

Permalink
Various other code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
TehMuffinMoo committed Jul 15, 2024
1 parent cd77381 commit 95027d7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 469 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/Analyze Code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
shell: pwsh
run : |
Install-Module PSScriptAnalyzer -Force -Confirm:$false
$Findings = Get-ChildItem -Path Modules/ibPS/Functions/*.ps1 -Recurse -File | %{ Invoke-ScriptAnalyzer $_ }
$ExcludedRules = @('PSAvoidUsingWriteHost')
$Findings = Get-ChildItem -Path Modules/ibPS/Functions/*.ps1 -Recurse -File | %{ Invoke-ScriptAnalyzer $_ -ExcludeRule $ExcludedRules}
$Findings | Select-Object ScriptName,Severity,Line,Column,RuleName,Message | ConvertTo-Csv | Set-Content ./docs/analysis.csv -Force
- name: Update Repository
Expand Down
5 changes: 0 additions & 5 deletions Modules/ibPS/Functions/BloxOne/BloxOneCloud/Get-B1DNSLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ function Get-B1DNSLog {
}
}

$Start = $Start.ToUniversalTime()
$End = $End.ToUniversalTime()
$StartTime = $Start.ToString("yyyy-MM-ddTHH:mm:ss.000")
$EndTime = $End.ToString("yyyy-MM-ddTHH:mm:ss.000")

$Dimensions = @(
"timestamp",
"qname",
Expand Down
12 changes: 6 additions & 6 deletions Modules/ibPS/Functions/BloxOne/Private/ArgCompleter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,23 @@ Register-ArgumentCompleter -CommandName Invoke-B1CubeJS,Get-B1CubeJSCubes,Get-B1

$B1CubeJSMeasures = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
(Get-B1CubeJSMeasures -Cube $fakeBoundParameters['Cube']).Name | %{
(Get-B1CubeJSMeasures -Cube $fakeBoundParameters['Cube']).Name | ForEach-Object {
$_.replace("$($fakeBoundParameters['Cube']).","")
} | Where-Object {$_ -like "$($wordToComplete)*" -and $_ -notin @($fakeBoundParameters['Measures'])}
}
Register-ArgumentCompleter -CommandName Invoke-B1CubeJS -ParameterName Measures -ScriptBlock $B1CubeJSMeasures

$B1CubeJSDimensions = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
(Get-B1CubeJSDimensions -Cube $fakeBoundParameters['Cube']).Name | %{
(Get-B1CubeJSDimensions -Cube $fakeBoundParameters['Cube']).Name | ForEach-Object {
$_.replace("$($fakeBoundParameters['Cube']).","")
} | Where-Object {$_ -like "$($wordToComplete)*" -and $_ -notin @($fakeBoundParameters['Dimensions'])}
}
Register-ArgumentCompleter -CommandName Invoke-B1CubeJS -ParameterName Dimensions -ScriptBlock $B1CubeJSDimensions

$B1CubeJSSegments = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
(Get-B1CubeJSSegments -Cube $fakeBoundParameters['Cube']).Name | %{
(Get-B1CubeJSSegments -Cube $fakeBoundParameters['Cube']).Name | ForEach-Object {
$_.replace("$($fakeBoundParameters['Cube']).","")
} | Where-Object {$_ -like "$($wordToComplete)*" -and $_ -notin @($fakeBoundParameters['Segments'])}
}
Expand All @@ -202,11 +202,11 @@ $B1CubeJSOrderBy = {
$fakeBoundParameters['Cube'] = 'NstarDnsActivity'
}
}
$Dimensions = (Get-B1CubeJSDimensions -Cube $fakeBoundParameters['Cube']).Name | %{
$Dimensions = (Get-B1CubeJSDimensions -Cube $fakeBoundParameters['Cube']).Name | ForEach-Object {
$_.replace("$($fakeBoundParameters['Cube']).","")
} | Where-Object {$_ -like "$($wordToComplete)*" -and $_ -notin @($fakeBoundParameters['OrderBy'])}

$Measures = (Get-B1CubeJSMeasures -Cube $fakeBoundParameters['Cube']).Name | %{
$Measures = (Get-B1CubeJSMeasures -Cube $fakeBoundParameters['Cube']).Name | ForEach-Object {
$_.replace("$($fakeBoundParameters['Cube']).","")
} | Where-Object {$_ -like "$($wordToComplete)*" -and $_ -notin @($fakeBoundParameters['Measures'])}

Expand All @@ -216,7 +216,7 @@ Register-ArgumentCompleter -CommandName Invoke-B1CubeJS,Get-B1DFPLog -ParameterN

$B1CubeJSTimeDimensions = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
((Get-B1CubeJSDimensions -Cube $fakeBoundParameters['Cube']) | Where-Object {$_.type -eq 'time'}).Name | %{
((Get-B1CubeJSDimensions -Cube $fakeBoundParameters['Cube']) | Where-Object {$_.type -eq 'time'}).Name | ForEach-Object {
$_.replace("$($fakeBoundParameters['Cube']).","")
} | Where-Object {$_ -like "$($wordToComplete)*" -and $_ -notin @($fakeBoundParameters['TimeDimension'])}
}
Expand Down
10 changes: 5 additions & 5 deletions Modules/ibPS/Functions/Misc/Misc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -986,11 +986,11 @@ function Write-Chart {
})]
[DateTime[]]$XAxis
)
$DateStrings = $XAxis | %{ $_.ToString('dd/MM') }
$DateStrings = $XAxis | ForEach-Object { $_.ToString('dd/MM') }
$UnderChar = [Char]9472

$C = 0
$Map = @($XAxis | %{
$Map = @($XAxis | ForEach-Object {
[PSCustomObject]@{ "Date" = $_
"_Count" = $YAxis[$C]
"Instance" = $C
Expand All @@ -999,13 +999,13 @@ function Write-Chart {
})


Write-Host "$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$(1..$($Map.Count) | %{ Write-Host -NoNewline "$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)" })"
Write-Host "$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$(1..$($Map.Count) | ForEach-Object { Write-Host -NoNewline "$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)" })"
$YAxisUnique = $Map._Count | Select-Object -Unique | Sort-Object -Desc
foreach ($YAU in $YAxisUnique) {
$Row = ""
## Get list of X-Axis which have the same count
$XAxisObjs = $Map | Where-Object {$_._Count -eq $YAU}
$(0..$($Map.Count-1) | %{
$(0..$($Map.Count-1) | ForEach-Object {
## Check if the instance exists in list to print
$Instance = $_
if ($XAxisObjs | Where-Object {$_.Instance -eq $Instance}) {
Expand All @@ -1018,7 +1018,7 @@ function Write-Chart {
}

Write-Host "$([char]9474)$(''.PadLeft(8))$([char]9474)" -NoNewline
$(1..$($Map.Count) | %{ Write-Host -NoNewline "$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$([char]9516)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)" })
$(1..$($Map.Count) | ForEach-Object { Write-Host -NoNewline "$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)$([char]9516)$($UnderChar)$($UnderChar)$($UnderChar)$($UnderChar)" })
Write-Host ""
Write-Graph -YAxisLabel ' ' -Row " $($DateStrings -join " $([char]9474) ")" -RowColor Black -LabelColor 'Blue'
}
Loading

0 comments on commit 95027d7

Please sign in to comment.