-
Notifications
You must be signed in to change notification settings - Fork 49
Add a test for Egyptian braces Meta.tests.ps1 and a fixer to Meta.Fixers.ps1 #27
Comments
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
@PlagueHO I gave this a try to fix this one with PSSA custom rules. But can't seem to get it to report warnings in AppVeyor. 😞 I can see it being called three times as expected in Appveyor here. Would you mind take a look at the code? It must be a simple mistake somewhere that I fail to see. I have a test branch test-dscresource-tests here that should trigger each of the custom rule (all three Measue-* functions). It should trigger on MSFT_xCluster.pms1 as seen here johlju/FailoverClusterDsc@1a63b6d. And the actually new custom rule is in this branch. Tested it locally:
|
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
@PlagueHO When stripping code from the first function |
This one is making me scratch my head. 😄 So it seems that the the file locally has '\r\n' in the file, while the cloned one in AppVeyor has '\n'. Making sure the file is the same (replaced to '\n') regardless where it was run made thing to start work. Also, add check so it doesn't try to index into arrays that aren't long enough, that was one bug for other files than the one I tested on, but it was not thrown any errors. Now at the end of the day I realized that we starting Invoke-ScriptAnalyzer with BUT, for some reason https://ci.appveyor.com/project/johlju/xfailovercluster/build/1.6.216.0#L274
But ScriptAnalyzer is returning double entries in AppVeyor.
Locally, with the exact same version (latest) as AppVeyor it works
|
Finally! This was me being a newbie with Script Analyzer (and AST). The problem was that it calls the measure function for each script block. I thought that was the entire file because that is how it behaved locally. But in AppVeyor it was called first for the entire file, then for each function statement script block (why it didn't do that locally is still a mystery). |
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
- Add Script Analyzer custom rule to test functions and statements so that opening braces are set according to the style guideline (issue PowerShell#27).
There is a StyleGuideline that states that Egyptian Braces shouldn't be used - e.g. code block open braces should appear on a new line.
It would be good if Meta.Tests.ps1 could include a test identified this problem.
Ideally, an automatic fixer for this could also be provided in Meta.Fixers.ps1.
The text was updated successfully, but these errors were encountered: