altrive / pscodeanalyzer Goto Github PK
View Code? Open in Web Editor NEWPowerShell code analysis module
License: The Unlicense
PowerShell code analysis module
License: The Unlicense
Escaped space characters is not retained after code formatting operation.
Example
#Before format
"1" + ` + "1"
#After format
"1" + + "1"
PowerShell buildin tokenizer doesn't return escaped space characters(` ).
If this problem cause wrong formatting result case, it may need to fixed.
begin
{
function Func1{
Write-Host "def"
}
function Func2{
Write-Host "ghi"
}
}
Write-Host "abc"
end {
Func1
Func2
}
Need to check extensions before code formatting.
Error dialog appeared when hit break point condition on code formatting operation.
example:
Get-PSBreakpoint -Variable StackTrace | Remove-PSBreakpoint
Set-PSBreakpoint -Variable StackTrace -Mode Write -Action {
Write-Host "error!!!!"
} > $null
ISE randomly crashed when Ctrl+K,Ctrl+D formatting.
There seems to be exist some text pattern that cause this problem.
but it can't reproduce in unit test environment, only occures ISE environment.
When execute following command, ISE crashed.(Crash dialog appeared)
Need to handle remoting events?
Enter-PSSession localhost
User defined DynamicKeyword token is not recognized appropriately after code formatting.
#Requires -Version 4.0
Set-StrictMode -Version Latest
#Reset Existing Dynamic Keywords
[Management.Automation.Language.DynamicKeyword]::Reset()
#Add Dynamic Keyword
$keyword = New-Object System.Management.Automation.Language.DynamicKeyword
$keyword.Keyword = "requires"
$keyword.BodyMode = [Management.Automation.Language.DynamicKeywordBodyMode]::ScriptBlock
$keyword.NameMode = [Management.Automation.Language.DynamicKeywordNameMode]::NoName
[System.Management.Automation.Language.DynamicKeyword]::AddKeyword($keyword)
function Test
{
param (
$aaa,
$bbb
)
$ccc = "ccc"
requires
{
1 | should be 1
1 | should be 2
}
}
function requires
{
param (
[Management.Automation.Language.DynamicKeyword] $KeywordData,
$Name,
[ScriptBlock] $Value,
$SourceMetaData,
$InstanceName
)
#$PSBoundParameters
$ErrorActionPreference = "Stop"
try
{
return & $Value #Execute ScriptBlock
}
catch
{
Write-Host ("Error Line: {0}" -f $vvv.InvocationInfo.Line.Trim())
}
}
Test
Example
$result = if ($false)
{ "abc" } else #True
{ "def" } #False
Ref: https://connect.microsoft.com/PowerShell/Feedback/Details/53059
Currently, LParen placed after variable is handled as function call.
and space is removed.
Join-Path $env:TEMP([Guid]::NewGuid())
should be
Join-Path $env:TEMP ([Guid]::NewGuid())
Current implementation only indent multiline comment first line.
Need to indent other lines.
It cause corrupted strings literal (spaces inserted after double-quote start)
and can't detect token validation errors after code format.
It should not format source code when specific parse error found.
In some case, editor's IsDirty flag is marked after code formatting operation even if no effective change exists.
This problem is caused when token is replaced with same token.
If replaced token is identical. Need to be skip replace operation.
Executing formatting following statement throw errors.
$(1..100)<##>.<##>Where({ $_ % 4 -eq 0 })
Format code operation failed! Please report following error context information
---------------------------------------
Line: Before -> After
$(1..100)<##>.<##>Where({ $_ % 4 -eq 0 })
$(1..100) <##>.<##>Where({ $_ % 4 -eq 0 })
---------------------------------------
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.