sbaudoin / sonar-shellcheck

SonarQube plugin to analyze Shell scripts with ShellCheck
Apache License 2.0
55 stars 10 forks source link

Allow checking files without extensions #36

Closed officerNordberg closed 2 years ago

officerNordberg commented 2 years ago

I currently have to create links to all our existing shebanged shell scripts to get them analyzed. I see that empty strings get filtered from the suffix list. My work around breaks blame info. CLI Shellcheck checks files without extensions/suffixes just fine. This should be configurable.

(https://github.com/sbaudoin/sonar-shellcheck/blob/50e4684e7d936b494205096ff48ad755508f3e9f/src/main/java/com/github/sbaudoin/sonar/plugins/shellcheck/languages/ShellLanguage.java#L54-L60)

sbaudoin commented 2 years ago

Hello,

If I undestand well, you mean that your scripts are named just foo instead of foo.sh. The problem with the plugin is that it has to discover the files to be analyzed or else it scans all files, possibly leading to tons of errors. I can add a specific "token" (eg. <NONE>) to mean "files with no suffix". The configuration would then be something like <NONE> and then only files containing no dot will be analyzed: foo would be analyzed but foo.something or even foo.sh would not (obviously unless you also add something or sh along with <NONE> in the suffix list). Would this be OK?

officerNordberg commented 2 years ago

Absolutely! <None> wouldn't or shouldn't default to scanning everything.

officerNordberg commented 2 years ago

Sonarqube has made this nigh impossible on their end. Even when using sonar.lang.patterns.shell property to subvert the fileSuffix requirement, the globbing implementation results in collisions because the overlap between */.py and */ makes language decisions impossible. Thanks