Since the org structure of my project doesn’t differentiate between test classes and src classes, I am unable to update it on the properties file. Also, since the project is setup locally on a different system, I dont have access to the files too. I am certain that that the sonar.source and sonar.test is left blank on the properties file.
If i use regex expressions on Test file inclusions from the UI, will it mark the matching classes as test classes? In that case, will SQ exclude certain rules from being applied to those classes?
I’ve already answered your question about rules in the separate thread where you asked it.
Regarding file differentiation, are you saying your test and source files are mingled together without a clear distinction in the file system?
sonar.sources defaults to ., which means by default all your test files are being treated as source files. To sort this out, you’ll likely need a combination of source exclusions and test inclusions. Without knowing how your files are named, or organized, this can only be a guess, but something like:
// yes, this is the default, but it avoids future confusion to make it explicit
sonar.sources=.
// there is no default. this sets it to everything
sonar.tests=.
// sonar.sources and sonar.tests now fully overlap,
// which will cause analysis errors if left as-is
sonar.exclusions=**/*test*
sonar.test.inclusions=**/*test*
Yes, there is no differentiation in the file system for test and source classes. Both test and src classes are present in the system under src/classes/. It however uses a naming convention where test classes are appended with ‘Test’
For example,
src class name: MyClass.cls
corresponding test class name: MyClassTest.cls
Given the way my organisation has set up SonarQube, I can only change it from the UI. So my question was, if I update the sonar.exclusions and test.inclusions from the UI, will that work? the sonar.sources and sonar.tests in the prop files are unchanged.
Yes, absolutely! In fact, I used to tell people to prefer the UI, but so many people insist on configuration-as-code that I’ve just given up on that one.