I am not able to analyze java files present in “src/test” folder using SonarLint Plugin in intellij IDE while I am able to analyze java files those are present in “src/main” folder.
Any sonarLint plugin configuration in intellij or any workaround so that I can analyze java files present in “src/test” folders using sonarlint plugin in intellij.
Thanks in Advance for your solution or suggestions.
Usually main and test files are analyzed differently as some rules don’t apply in both cases. It would be helpful if you could create a small reproducer project for us to understand if there is really a problem.
Hello @Damien_Urruty There is no main folder and only a test folder present in my existing project and I need to use sonarlint plugin to analyze. So this is really a problem as I cannot change folder name test to main in existing folder.
As we have workaround for sonarQube to analyze test folders can we have some workaround for sonarlint also?
What workaround are you using for SonarQube ? Are you changing the
sonar.tests properties ? May I ask why your project only has test files ? As I said, not the same rules apply for main and test code, so why do you want to analyze your test files as main ?
On IntelliJ SonarLint relies on the IDE project model. Folders that are marked as test folders in the Project Structure dialog are what SonarLint considers to be tests files.
As a workaround you could try to mark your test folder as main but it could have unwanted consequences.
EDIT: And I would prefer to understand the reason why you try to achieve that, this might help us improve the products
Yes, we changed the sonar.sources and sonar.tests properties and its working similar to main for test folders in sonar-qube.
Actually, we are working for test automation scripts so existing project contains only test folder without main. Also, we cannot change test folder to main due to some dependent components.
We are using below properties for sonar-qube -
I tried the same properties with sonarlint but doesn’t work me. Please suggest if something possible to analyze test folders as main in sonarlint in intellij.
We have the same issue, for automatic tests we use selenium/cucumber, so we have only files in src/test. Is it possible to analyse this files with sonarlint (any workaround)?
Thanx in advance
It’s not possible at the moment, and I don’t see any good workaround.We always rely on the IDE project information to categorize main and test folders, and there is no way to customize that.
I moved this thread to the ‘Suggest new features’ category, so that people could vote for this idea. This way we can understand if the idea gets traction from the community.
Thanks for raising this!