SonarQube is taking java and javascript files

807 views
Skip to first unread message

swethap...@gmail.com

unread,
Sep 6, 2017, 7:21:15 AM9/6/17
to SonarQube
Hi,

I have project with java,javascript and xml. By defaulf it is taking java and xml but not js file. If, I add -Dsonar.language=js while running analysis in command(mvn sonar:sonar -Dsonar.language=....) its taking only .js files but not others. 

Could you please suggest me how to add all types of code files in analysis

Thanks,
Swetha

G. Ann Campbell

unread,
Sep 6, 2017, 9:08:22 AM9/6/17
to SonarQube
Hi Swetha,

Where in your project are the .js files located? By default, a Maven analysis is only going to look at files under `main`.


Ann

swethap...@gmail.com

unread,
Sep 7, 2017, 4:00:27 AM9/7/17
to SonarQube
Hi Ann,

If files are not located under main, How to load them in analysis?. Is there any way to provide their path??

Can we set multiple language -to "Dsonar.language="?( like if we have one language we gave -Dsonar.language=js. if we have js,java,python,how to give them in command )
If yes, could you share me the syntax.

Thanks,
Swetha

G. Ann Campbell

unread,
Sep 7, 2017, 7:37:57 AM9/7/17
to swethap...@gmail.com, SonarQube
Hi Swetha,

If you want to override the `sonar.sources` path that's automatically set for a Maven analysis, you can set a property in the pom, or pass -Dsonar.sources=... on the analysis command line.

You cannot set multiple languages using `sonar.language`, which is one reason that property is deprecated. Analyses are multi-language by default now, so it's merely a question of making sure all your files are actually included in the analysis.


Ann



---
G. Ann Campbell | SonarSource
Product Manager
@GAnnCampbell

--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/AC3GVxwnrGI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/f29d78cf-4db5-4bb7-9dea-13a217f39b5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

swethap...@gmail.com

unread,
Sep 8, 2017, 5:56:06 AM9/8/17
to SonarQube
Hi Ann,

Please find the project structure.

java files
---------test-->testsuite-->int--->comm-->src-->main-->java

JS files are in 2 different folders
js files
-------------test--->pmed-->src--->pmed
-------------test--->pmm-->src---->pmm

Could you please let me know how to add these different sources .

Thanks,
Swetha
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.

G. Ann Campbell

unread,
Sep 8, 2017, 7:39:14 AM9/8/17
to swethap...@gmail.com, SonarQube
Hi Swetha,

Why do all of these paths start with "test"?


Ann



---
G. Ann Campbell | SonarSource
Product Manager
@GAnnCampbell

To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/0c51cd32-8f68-4f9c-8d2d-d81cfecbb9cf%40googlegroups.com.

swethap...@gmail.com

unread,
Sep 8, 2017, 8:31:29 AM9/8/17
to SonarQube
Hi Ann,

Just for everyones understanding and a commonly used word, but the name has no significance here.

Best regards,
Swetha

Duarte Meneses

unread,
Sep 8, 2017, 9:12:57 AM9/8/17
to SonarQube
Hi Swetha,

Have you tried to follow Ann's advice to manually configure the sources?

The Scanner for maven will pick up, by default, the java source files (typically src/main/java and src/test/java).

In the <properties> of the pom file of the module where you want to add the JS files, you can add something like:
<sonar.sources>src/main/java, dir2, dir3</sonar.sources>

swethap...@gmail.com

unread,
Sep 13, 2017, 5:32:34 AM9/13/17
to SonarQube
Hi,

Yes, I have tried adding <sonar.source>. But,still sonarqube is not pickingbup the java script files.

Thanks,
Swetha

G. Ann Campbell

unread,
Sep 13, 2017, 7:10:44 AM9/13/17
to SonarQube
Hi Swetha,

Did you add sonar.source or sonar.sources?


Ann

swethap...@gmail.com

unread,
Sep 13, 2017, 8:04:25 AM9/13/17
to SonarQube
Hi Ann,

I added <sonar.sources>dir</sonar.sources>

Thanks,
Swetha

G. Ann Campbell

unread,
Sep 14, 2017, 4:56:07 AM9/14/17
to swethap...@gmail.com, SonarQube
Hi,

In your analysis log there should be a line something like

INFO: Source paths: sources

What does yours say?


Ann



---
G. Ann Campbell | SonarSource
Product Manager
@GAnnCampbell

To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/94e0d2f2-de72-4d00-8918-516f3f97c1c0%40googlegroups.com.

swethap...@gmail.com

unread,
Sep 14, 2017, 8:27:26 AM9/14/17
to SonarQube
Hi Ann,

It is reffering to pom.xml which was defined for java. This repo has 2 pom.xmls.
one is defined for java and grrovy.Other once is main pom.xml includes javascript
In analysis SonarQube is taking java related pom.xml.

Analysis we were running is from main pom.xml location only.Could you please help how to make sonarqube to point to main.xml

Thanks,
Swetha

Julien HENRY

unread,
Sep 14, 2017, 9:59:12 AM9/14/17
to SonarQube
Hi Swetha,

Please share your full scanner logs (in debug mode) so that we can help.

Thanks

Julien
Reply all
Reply to author
Forward
0 new messages