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

only files with extension .properties is being analyzed #9

Closed leojosefm closed 6 years ago

leojosefm commented 6 years ago

I have two files in the directory same content, one with .txt and one with .properties. I have a rule Simple Regex Match (\W\W\W\Wtab\sQDF). Ideally it should give 2 code smells 1 from each file. But only 1 bug from .properties is showing up

image

gjd6640 commented 6 years ago

Hi. This is a solvable problem as I’m doing exactly this. I’m on mobile right now so this is a preliminary response. I’ll try to follow up later by clarifying this project’s readme.md and responding to Ann’s answer in this stackoverflow question:

https://stackoverflow.com/questions/39451413/how-to-use-two-different-plugins-on-one-type-of-file-in-sonarqube

The very end of Ann’s answer has the information that you seek. Sonarqube by default ignores files whose extensions aren’t named by any of its language plugins (text counts as a language). Typically each plugin’s global configuration page let’s you adjust the list of extensions that are assigned to it. Each unique file extension can be “owned” by at most 1 plugin BUT once any plugin names an extension Sonar quits excluding it from scans and all plugins then have the opportunity to include it in scans.

So you have two options:

I prefer this one for its predictability: A) Using the configuration webpage to configure the text plugin’s extension list to include both extensions.

B) Per Ann’s comment configure Sonarqube to include all files regardless of extension.

leojosefm commented 6 years ago

Hello, Thank you for the response. When creating the rule using template, there is a a column called "File pattern" . The default value was **/*.properties which I did not notice. When I changed it to **/*.txt , it worked. Seems like the issue is solved.

Regarding list of extension in configuration webpage, .txt and .properties are already present.