Problem with sonar.inclusions

dotnet
exclusions

(Sergio Rodriguez) #1

Hi,

I am trying to use sonar.inclusions to analyse only one directory of my big solution. I have this:

sonar.inclusions="**/Application.MainModule/**/*.cs"

And the log of sonar:
2018-09-12T19:17:11.7262240Z INFO: ------------- Scan Application.MainModule

2018-09-12T19:17:11.7263285Z INFO: Base dir: C:\agent\_work\13\s\Application.MainModule

2018-09-12T19:17:11.7264621Z INFO: Working dir: C:\agent\_work\13\.sonarqube\out\.sonar\Seoga_Seoga_ED328ECD-EC24-4A1C-98BB-19D4E237218F

2018-09-12T19:17:11.7282229Z INFO: Source paths: ActoManagement/IActoManagementService.cs, ActoManagement/ActoManagementService.cs, AdministradorManagement/AdministradorManagementService.cs, AdministradorManagement/IAdministradorManagementService.cs, AlertaManagement/AlertaSistemaManagementService.cs, AlertaManagement/IAlertaSistemaManagementService.cs, AutenticacionManagement/IAutenticacionManagementService.cs, AutenticacionManagement/AutenticacionManagementService.cs, BaremoManagement/BaremoManagementService.cs, BaremoManagement/IBaremoManagementService.cs, CalculoCuotaManagement/CalculoCuotaManagementService.cs, CalculoCuotaManagement/ICalculoCuotaManagementService.cs, ConciliacionManagement/IConciliacionManagementService.cs, ConciliacionManagement/ConciliacionManagementService.cs, FacturacionManagement/FacturacionManagementService.cs, FacturacionManagement/IFacturacionManagementService.cs, InfoFacturacionMutuaManagement/InfoFacturacionMutuaManagementService.cs, InfoFacturacionMutuaManagement/IInfoFacturacionMutuaManagementService.cs, FicheroManagement/FicheroManagementService.cs, FicheroManagement/IFicheroManagement.cs, GrupoEmpresarial/GrupoEmpresarialManagementService.cs, GrupoEmpresarial/IGrupoEmpresarialManagementService.cs, IncidenciaManagement/IncidenciaManagementService.cs, IncidenciaManagement/IIncidenciaManagementService.cs, InformesManagement/IInformeManagementService.cs, InformesManagement/InformeManagementService.cs, LiquidacionManagement/LiquidacionManagementService.cs, LiquidacionManagement/ILiquidacionManagementService.cs, MutuaManagement/IMutuaManagementService.cs, MutuaManagement/MutuaManagementService.cs, MutuaTraficoLaboralManagement/IMutuaTraficoLaboralManagementService.cs, MutuaTraficoLaboralManagement/MutuaTraficoLaboralManagementService.cs, NomenclatorManagement/INomenclatorManagementService.cs, NomenclatorManagement/NomenclatorManagementService.cs, PacienteManagement/IPacienteManagementService.cs, PacienteManagement/PacienteManagementService.cs, ClienteManagement/IClienteManagementService.cs, ClienteManagement/ClienteManagementService.cs, PasarelaWebManagement/IPasarelaWebManagementService.cs, PasarelaWebManagement/PasarelaWebManagementService.cs, PrescripcionManagement/IPrescripcionManagementService.cs, PrescripcionManagement/PrescripcionManagementService.cs, Properties/AssemblyInfo.cs, ReglaNegocioManagement/IReglaNegocioManagementService.cs, ReglaNegocioManagement/ReglaNegocioManagementService.cs, PlanificadorManagement/IPlanificadorManagementService.cs, PlanificadorManagement/PlanificadorManagementService.cs, SedeManagement/ISedeManagementService.cs, SedeManagement/SedeManagementService.cs, TarifaEspecificaManagement/ITarifaEspecificaMutuaManagementService.cs, TarifaEspecificaManagement/TarifaEspecificaMutuaManagementService.cs, TarjetaManagement/ITarjetaManagementService.cs, TarjetaManagement/TarjetaManagementService.cs, TerminalManagement/TerminalManagementService.cs, TerminalManagement/ITerminalManagementService.cs, VisitaManagement/IVisitaManagementService.cs, VisitaManagement/VisitaManagementService.cs

2018-09-12T19:17:11.7298817Z INFO: Source encoding: UTF-8, default locale: es_ES

2018-09-12T19:17:11.7299682Z INFO: Index files

2018-09-12T19:17:11.7300404Z INFO: Included sources:

2018-09-12T19:17:11.7301521Z INFO: **/Application.MainModule/**/*.cs

2018-09-12T19:17:11.7706794Z INFO: 0 files indexed

2018-09-12T19:17:11.8518985Z INFO: 57 files ignored because of inclusion/exclusion patterns

I dont see what I am doing wrong!

Can you help me?


(Nicolas Bontoux) #2

Hi Sergio,

Whether it’s for exclusions or inclusions, a good approach to understand what’s going in the following:

In that case, notice from your logs that the analysis base dir already is Application.MainModule, with underlying paths treated relatively from there (see Source paths), and therefore not matching your inclusion setting.

Now playing with sonar.inclusions/sonar.exclusions not always is the most effective approach, especially in cases like Scanner for MSBuild which automatically infer your project structure. In that case, you might rather consider Excluding Artifacts from the Analysis.