File extension in mutiple plugin fail

Hello

I develop multiple plugins for several languages. I am facing a serious problem. It seams that

  • if a file extension (ex HTML) is referenced in 2 plugins, the scanner fails [1]
  • the Quality Profile set in the pom.xml or via the -Dsonar.profile=Foo Maven argument is ignored by the scanner [2]
  • tests done on SQ 7.9.3 and > under JDK11 [3]

The result is that one can’t create a new SQ plugin for either an existing language (like Java) or an existing file extension (like HTML or ASPX).

Thanks for your help

PS: I want to avoid using the native SQ source code analyzer.

Is there some way to walk arround this severe limitation ?
[1] : Caused by: org.apache.maven.plugin.MojoExecutionException: Language of file ‘xxx.aspx’ can not be decided as the file matches patterns of both sonar.lang.patterns.foo : /*.foo,/.html,**/.aspx,/*.ascx,/.css,**/.js,/*.json,/.xml,**/.pngb64,/*.jpegb64,/.gifb64,**/.icob64 and sonar.lang.patterns.web : /*.html,/.xhtml,**/.cshtml,/*.vbhtml,/.aspx,**/.ascx,/*.rhtml,/.erb,**/.shtm,**/*.shtml
[2] : <sonar.profile>Foo</sonar.profile>
[3] : SQ 7.9.3, 8.0, 8.1, SonarScanner 3.6.0.1398, 3.6.1.1688, 3.7.0.1746

Hello @qualitesys,

  • Right now SonarQube does not allow to associate a same file extension to 2 different plugins. However that can happen in legitimate situations (eg .sql can be PL/SQL or T-SQL, .h can be C, C++ or Objective-C etc…).

  • When there’s an ambiguity it should be resolved per project by “dissociating” an extension from one language plugin, and association to another. Take the case of your .aspx file you should set project level property:

    sonar.html.file.suffixes=.html,... (anything you want except the extensions used by your foo plugin like aspx) sonar.foo.file.suffixes=.aspx

This extension association is for the “primary” plugin that will analyze the file to raise issues and also produce metrics
If you look at the plugin API there’s the possibility for a “secondary” plugin, even if not associated to some given file extensions, to request to analyze these files, but only to produce issues. Please check the API

In other words: A single plugin can produce metrics for a file, but several can produce issues.

Regards, Olivier

PS: I am not quite sure of what you tried to achieve by passing the sonar.profile property to the analyzer, but this is now completely dropped and has no effect.

Hello @OlivierK
Since which SQ version this limitation has appeared ?
Thanks

This limitation has never “appeared”. It is there since the beginning, or more precisely since SonarQube can analyze multi-languages projects at once, ie since a very long time.