gjd6640 / sonar-text-plugin

A free and open-source plugin for SonarSource's Sonarqube product that lets you create rules to flag issues in text files.
Apache License 2.0
23 stars 4 forks source link

Add a tip to the documentation: Scanning extensionless files #3

Open gjd6640 opened 8 years ago

gjd6640 commented 8 years ago

Sometimes projects contain shell script files that have no extension. If you want to scan those with a plugin such as this one you have to give them an extension. Here's a way to do that via a shell command run prior to the Sonar scan.

# Takes any extensionless files and makes copies with '.txtcopy' extensions. This makes us able to run Sonar Text Plugin rules against their content.

find . -type f ! -path '*/.svn/*' ! -path '*/target/*' ! -name "*.*" -exec cp {} {}.txtcopy \;

This copies the extensionless files to create a version that does have an extension. Here I chose a unique extension to make it more obvious that the file name was created by my scan automation.

You also have to add the ".txtcopy" extension to the list that are assigned to the plugin via the Sonar UI's Settings page.