sbaudoin/sonar-shellcheck

Allow checking files without extensions

Closed this issue · 3 comments

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.

(

public String[] getFileSuffixes() {
String[] suffixes = filterEmptyStrings(config.getStringArray(ShellCheckSettings.FILE_SUFFIXES_KEY));
if (suffixes.length == 0) {
suffixes = StringUtils.split(ShellCheckSettings.FILE_SUFFIXES_DEFAULT_VALUE, ",");
}
return suffixes;
}
)

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?

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

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