gretard / sonar-ps-plugin

Powershell language plugin for SonarQube
GNU Lesser General Public License v3.0
36 stars 7 forks source link

Always getting 0% problems and Passed #7

Closed Kungfoowiz closed 5 years ago

Kungfoowiz commented 5 years ago

Hi, I've installed:

PS > Get-InstalledModule

Version Name Repository Description


1.17.1 PSScriptAnalyzer PSGallery PSScriptAnalyzer provides script analysis and checks for potential code defect...

I believe I'vet setup everything correctly, I run sonar-scanner with the key options as copied from the tutorial wizard which comes with SonarQube. I clicked Copy on the wizard and pasted the sonar-scanner command directly into my Terminal and within the Powershell project folder to perform the code analysis.

I keep getting no actual issues or count of any lines of code. As you can see below, it doesn't find any issue within my PS files, even though I intentionally changed a line like this:

if($something = "anything"){

This should've triggered the code smell: '=' is not an assignment operator. Did you mean the equality operator '-eq'?

But as you can see, it doesn't appeared to have done anything?

always passing result sonar ps plugin

I ran sonar-scanner in debug mode (sonar-scanner -X) and there is an error here: 20:00:39.583 WARN: Unexpected exception while running analysis java.io.IOException: Cannot run program "powershell.exe": error=2, No such file or directory

Is it possible to point it to use "pwsh" which is the Mac equivalent? Thanks

gretard commented 5 years ago

Hi,

You can specify powershell executable in the UI's administration section globally or in project properties file by specifying sonar.ps.executable property, i.e.

sonar.ps.executable=/usr/bin/pwsh

Please let me know if this helps :)

Kungfoowiz commented 5 years ago

Thanks, ok its hitting the pwsh binary now, except I think the tokenizer has an issue creating the command. The error output from debug command is below, my pwsh is located in /usr/local/bin, which I've pointed correctly. I think it is appending commas (,) into the command, not sure if those should be there?

Command that was executed: /usr/local/bin/pwsh, -File, "/Users/kungfoowiz/Proto/.scannerwork/.sonartmp/ps4073323867324576719parser.ps1", -inputFile, "/Users/kungfoowiz/Proto/Prototype/import/time/date.ps1", -output, "/Users/kungfoowiz/Proto/.scannerwork/.sonartmp/8464155838017904475.tmp"

Error: 11:07:51.226 DEBUG: Running [/usr/local/bin/pwsh, -File, "/Users/kungfoowiz/Proto/.scannerwork/.sonartmp/ps4073323867324576719parser.ps1", -inputFile, "/Users/kungfoowiz/Proto/import/time/date.ps1", -output, "/Users/kungfoowiz/Proto/.scannerwork/.sonartmp/8464155838017904475.tmp"] command 11:07:51.455 INFO: Something went wrong while running tokenizer. Return code was: 64. File was: /Users/kungfoowiz/Proto/.scannerwork/.sonartmp/8464155838017904475.tmp. Error output was: The argument '"/Users/kungfoowiz/Proto/.scannerwork/.sonartmp/ps4073323867324576719parser.ps1"' is not recognized as the name of a script file. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. . Actual output was: Usage: pwsh[.exe] [[-File] [args]] [-Command { - | [-args ] | [] } ] [-ConfigurationName ] [-EncodedCommand ] [-ExecutionPolicy ] [-InputFormat {Text | XML}] [-Interactive] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile] [-OutputFormat {Text | XML}] [-Version] [-WindowStyle