#c# #msbuild #sonarqube #sonarqube-msbuild-runner
#c# #msbuild #sonarqube #sonarqube-msbuild-runner
Вопрос:
У меня есть два проекта в Sonarqube 6, один из них работает, как и ожидалось. Другой анализирует, но классифицирует обнаруженный код как тестовый код.
Смотрите следующую выдержку из журналов :
2016-10-17T15:30:45.9139431Z INFO: ------------- Scan XXXX.WebApp.Advisor.CrossCuttings.Constants
2016-10-17T15:30:45.9139431Z INFO: Excluded sources for coverage:
2016-10-17T15:30:45.9139431Z INFO: **/I*.cs
2016-10-17T15:30:45.9139431Z INFO: **/*DTO.cs
2016-10-17T15:30:45.9139431Z INFO: **/*ViewModel.cs
2016-10-17T15:30:45.9139431Z INFO: **/AssemblyInfo.cs
2016-10-17T15:30:45.9139431Z INFO: **/project.json
2016-10-17T15:30:45.9139431Z INFO: Base dir: C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutionsrcXXXX.WebApp.Advisor.CrossCuttings.Constants
2016-10-17T15:30:45.9139431Z INFO: Working dir: C:agent_work12.sonarqubeout.sonarDigitalDelivery-AdvisorPortal_DigitalDelivery-AdvisorPortal_9E577C4E-1343-4FC4-BC51-CA75DE04C8C7
2016-10-17T15:30:45.9139431Z INFO: Test paths: Parameter.cs, Properties/AssemblyInfo.cs, packages.config
2016-10-17T15:30:45.9139431Z INFO: Source encoding: UTF-8, default locale: en_US
2016-10-17T15:30:45.9139431Z INFO: Index files
2016-10-17T15:30:45.9139431Z INFO: Excluded sources:
2016-10-17T15:30:45.9139431Z INFO: **/Scripts/Global/**/*.*
2016-10-17T15:30:45.9139431Z INFO: 2 files indexed
2016-10-17T15:30:45.9139431Z INFO: 0 files ignored because of inclusion/exclusion patterns
2016-10-17T15:30:45.9139431Z INFO: Quality profile for cs: Sonar way
2016-10-17T15:30:45.9139431Z INFO: Sensor Lines Sensor
2016-10-17T15:30:45.9305374Z INFO: Sensor Lines Sensor (done) | time=0ms
2016-10-17T15:30:45.9305374Z INFO: Sensor Sonar-Sonargraph-Plugin [3.5]
2016-10-17T15:30:45.9305374Z INFO: ----------------------------------------------------------------
2016-10-17T15:30:45.9305374Z INFO: Sonargraph: Skipping project XXXX.WebApp.Advisor.CrossCuttings.Constants [DigitalDelivery-AdvisorPortal:DigitalDelivery-AdvisorPortal:9E577C4E-1343-4FC4-BC51-CA75DE04C8C7], since no Sonargraph rules are activated in current SonarQube quality profile.
2016-10-17T15:30:45.9305374Z INFO: ----------------------------------------------------------------
2016-10-17T15:30:45.9305374Z INFO: Sensor Sonar-Sonargraph-Plugin [3.5] (done) | time=0ms
2016-10-17T15:30:45.9305374Z INFO: Sensor org.sonar.plugins.csharp.CSharpCodeCoverageProvider$CSharpCoverageReportImportSensor
2016-10-17T15:30:45.9305374Z INFO: Parsing the Visual Studio coverage XML report C:agent_work12TestResultsLOCAL SERVICE_BUILDBOX1 2016-10-17 16_30_21InBUILDBOX1LOCAL SERVICE_BUILDBOX1 2016-10-17 16_30_06.coveragexml
2016-10-17T15:30:45.9305374Z INFO: Adding this code coverage report to the cache for later reuse: C:agent_work12TestResultsLOCAL SERVICE_BUILDBOX1 2016-10-17 16_30_21InBUILDBOX1LOCAL SERVICE_BUILDBOX1 2016-10-17 16_30_06.coveragexml
2016-10-17T15:30:45.9305374Z INFO: Sensor org.sonar.plugins.csharp.CSharpCodeCoverageProvider$CSharpCoverageReportImportSensor (done) | time=62ms
2016-10-17T15:30:45.9305374Z INFO: Sensor SCM Sensor
2016-10-17T15:30:45.9305374Z INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
2016-10-17T15:30:45.9305374Z INFO: Sensor SCM Sensor (done) | time=0ms
2016-10-17T15:30:45.9305374Z INFO: Sensor XmlFileSensor
2016-10-17T15:30:45.9305374Z INFO: Sensor XmlFileSensor (done) | time=0ms
2016-10-17T15:30:45.9305374Z INFO: Sensor Zero Coverage Sensor
2016-10-17T15:30:45.9305374Z INFO: Sensor Zero Coverage Sensor (done) | time=0ms
2016-10-17T15:30:45.9305374Z INFO: Sensor Code Colorizer Sensor
2016-10-17T15:30:45.9305374Z INFO: Sensor Code Colorizer Sensor (done) | time=0ms
2016-10-17T15:30:45.9305374Z INFO: Sensor CPD Block Indexer
2016-10-17T15:30:45.9305374Z INFO: DefaultCpdBlockIndexer is used for cs
2016-10-17T15:30:45.9305374Z INFO: Copy-paste detection exclusions:
2016-10-17T15:30:45.9305374Z **/stylecop.json
2016-10-17T15:30:45.9305374Z INFO: Sensor CPD Block Indexer (done) | time=0ms
Смотрите Раздел :
2016-10-17T15:30:45.9139431Z INFO: Test paths: Parameter.cs, Properties/AssemblyInfo.cs, packages.config
Код, который находится в этом проекте C #, был помечен как тестовый код и, следовательно, не анализировался. Что это контролирует? Как мне изменить поведение?
Что я нахожу странным, так это то, что один проект в решении анализируется правильно :
2016-10-17T15:30:46.1326703Z INFO: ------------- Scan XXXX.WebApp.Advisor.Presentation.MVC5
2016-10-17T15:30:46.1326703Z INFO: Excluded sources for coverage:
2016-10-17T15:30:46.1326703Z INFO: **/I*.cs
2016-10-17T15:30:46.1326703Z INFO: **/*DTO.cs
2016-10-17T15:30:46.1326703Z INFO: **/*ViewModel.cs
2016-10-17T15:30:46.1326703Z INFO: **/AssemblyInfo.cs
2016-10-17T15:30:46.1326703Z INFO: **/project.json
2016-10-17T15:30:46.1326703Z INFO: Base dir: C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutionsrcXXXX.WebApp.Advisor.Presentation.MVC5
2016-10-17T15:30:46.1326703Z INFO: Working dir: C:agent_work12.sonarqubeout.sonarDigitalDelivery-AdvisorPortal_DigitalDelivery-AdvisorPortal_C7028C31-65FE-4DFA-B557-6BC43CBA0B0D
2016-10-17T15:30:46.1326703Z INFO: Source paths: App_Start/BundleConfig.cs, App_Start/DependencyConfig.cs, App_Start/FilterConfig.cs, App_Start/IdentityConfig.cs, App_Start/RouteConfig.cs, App_Start/Startup.Auth.cs, BootStrapper.cs, Common/DistributorContainer.cs, Common/ExceptionHandler.cs, Common/RuleLookup.cs, Constants/PortalConstants.cs, Controllers/AccountController.cs, Controllers/ApplicationController.cs, Controllers/HomeController.cs, Controllers/ManageController.cs, Controllers/ClientDetailsController.cs, Controllers/QuotationController.cs, Controllers/UnderWritingController.cs, Extensions/CustomValidatorExtension.cs, Extensions/HtmlHelper.cs, Extensions/SessionExtension.cs, Extensions/WebViewExtension.cs, Filters/DistributorFilterAttribute.cs, Global.asax.cs, Models/AccountViewModels.cs, Models/Binder/DateTimeBinder.cs, Models/IdentityModels.cs, Models/ManageViewModels.cs, Properties/AssemblyInfo.cs, Startup.cs, Validators/BenefitParaSubmitViewModelValidator.cs, Validators/ClientViewModelValidator.cs, Validators/CustomValidator/ValidateDate.cs, Validators/ProductBenefitViewModelValidator.cs, Validators/QuotationClientViewModelValidator.cs, Validators/ValidatorFactory.cs, App_Data/RuleLookups.xml, Content/Application/Applications.css, Content/Customer/Customers.css, Content/Distributors/staysure/en-US/css/layout.css, Content/Distributors/staysure/images/DD_Gaurantee.png, Content/Distributors/staysure/images/logo.png, Content/Distributors/staysure/images/logo2.jpg, Content/Distributors/uib/en-US/css/layout.css, Content/Distributors/uib/images/DD_Gaurantee.png, Content/Distributors/uib/images/logo.png, Content/Global/Css/bootstrap/bootstrap-datepicker.css, Content/Global/Css/bootstrap/bootstrap-rtl.css, Content/Global/Css/bootstrap/bootstrap.css, Content/Global/Css/bootstrap/bootstrap.min.css, Content/Global/Css/bootstrap/font-awesome.css, Content/Global/Css/branding.css, Content/Global/Css/datatables/jquery.dataTables.css, Content/Global/Css/fonts/fontawesome-webfont.svg, Content/Global/Css/fonts/iconfont.css, Content/Global/Css/fonts/Metrize-Icons.dev.svg, Content/Global/Css/fonts/Metrize-Icons.svg, Content/Global/Css/google/font-family-droid-sans.css, Content/Global/Css/google/font-family-source-sans-pro.css, Content/Global/Css/iconfont.css, Content/Global/Css/Site.css, Content/Global/Css/style.css, Content/Global/Css/styleguide.css, Content/Global/fonts/glyphicons-halflings-regular.svg, Content/Global/images/arrow-up.jpg, Content/Global/images/arrow-up.png, Content/Global/images/bg/bottom-footer-gradient.jpg, Content/Global/images/bg/green-gradient.gif, Content/Global/images/bg/green-hover.gif, Content/Global/images/bg/header-gradient.jpg, Content/Global/images/bg/nav-gradient.jpg, Content/Global/images/bg/orange-gradient.gif, Content/Global/images/bg/top-footer-gradient.jpg, Content/Global/images/close.png, Content/Global/images/list-icon.png, Content/Global/images/list-ltr.png, Content/Global/images/loader.gif, Content/Global/images/logo.png, Content/Global/images/pdf.png, Content/Global/images/plus.png, Content/Global/images/sort_asc.png, Content/Global/images/sort_both.png, Content/Global/images/sort_desc.png, Content/Global/images/status.gif, Content/Global/images/tables/minus.png, Content/Global/images/tables/plus.png, Content/Global/images/tabs-grad.jpg, Content/Global/images/tabs-passed.jpg, Content/Home/Css/dashboard.css, Content/Quotation/Quotations.css, Content/Quotation/step.css, favicon.ico, fonts/glyphicons-halflings-regular.svg, Global.asax, Scripts/Customer/Customers.js, Scripts/Application/Applications.js, Scripts/Global/jquery.dataTables.js, Scripts/Quotation/AcceptPricingTerms.js, Scripts/Global/bootstrap.js, Scripts/Global/bootstrap.min.js, Content/Global/fonts/glyphicons-halflings-regular.eot, Content/Global/fonts/glyphicons-halflings-regular.ttf, Content/Global/fonts/glyphicons-halflings-regular.woff, Content/Global/Css/fonts/fontawesome-webfont.eot, Content/Global/Css/fonts/fontawesome-webfont.ttf, Content/Global/Css/fonts/fontawesome-webfont.woff, Content/Global/Css/fonts/FontAwesome.otf, Content/Global/Css/fonts/Metrize-Icons.eot, Content/Global/Css/fonts/Metrize-Icons.ttf, Content/Global/Css/fonts/Metrize-Icons.woff, Scripts/Global/footable.js, Scripts/Global/gauge/justgage.js, Scripts/Global/gauge/raphael.2.1.0.min.js, Scripts/Global/globalize.culture.en-US.js, Scripts/Global/globalize.culture.zh-CN.js, Scripts/Global/globalize.js, Scripts/Global/jquery-1.10.2.js, Scripts/Global/jquery-1.10.2.min.js, Scripts/Global/jquery.hcsticky.js, Scripts/Global/jquery.metadata.js, Scripts/Global/jquery.validate.js, Scripts/Global/jquery.validate.min.js, Scripts/Global/jquery.validate.unobtrusive.js, Scripts/Global/jquery.validate.unobtrusive.min.js, Scripts/Global/jquery.wizard.js, Scripts/Global/modernizr-2.6.2.js, Scripts/Global/respond.js, Scripts/Global/respond.min.js, Scripts/Home/dashboard.js, Scripts/Quotation/AcceptQuote.js, Scripts/Quotation/ClientDetails.js, Scripts/Quotation/BillingDetail.js, Scripts/Quotation/ConfirmationAndBuy.js, Scripts/Quotation/ContractAndPrice.js, Scripts/Quotation/DeclineOrRefer.js, Scripts/Quotation/FullMedicalReview.js, Scripts/Quotation/MedicalReview.js, Scripts/Quotation/ProductAndBenefit.js, Scripts/Quotation/Quotation.js, Scripts/Home/header.js, Scripts/Quotation/Quotations.js, Scripts/Quotation/SecondClientDetails.js, Scripts/Quotation/TermsAndConditions.js, Scripts/_references.js, StartUp.html, Web.config, Web.Debug.config, Web.Release.config, Views/Web.config, Views/_ViewStart.cshtml, Views/Shared/Error.cshtml, Views/Shared/_Layout.cshtml, Views/Home/About.cshtml, Views/Home/Contact.cshtml, Views/Home/Index.cshtml, Views/Account/_ExternalLoginsListPartial.cshtml, Views/Account/ConfirmEmail.cshtml, Views/Account/ExternalLoginConfirmation.cshtml, Views/Account/ExternalLoginFailure.cshtml, Views/Account/ForgotPassword.cshtml, Views/Account/ForgotPasswordConfirmation.cshtml, Views/Account/Login.cshtml, Views/Account/Register.cshtml, Views/Account/ResetPassword.cshtml, Views/Account/ResetPasswordConfirmation.cshtml, Views/Account/SendCode.cshtml, Views/Account/VerifyCode.cshtml, Views/Manage/AddPhoneNumber.cshtml, Views/Manage/ChangePassword.cshtml, Views/Manage/Index.cshtml, Views/Manage/ManageLogins.cshtml, Views/Manage/SetPassword.cshtml, Views/Manage/VerifyPhoneNumber.cshtml, Views/Shared/Lockout.cshtml, Views/Shared/_LoginPartial.cshtml, Views/Shared/_Header.cshtml, Views/Shared/_Footer.cshtml, Views/Home/Dashboard.cshtml, Views/Quotation/NewClientDetails.cshtml, Views/Quotation/NewQuotation.cshtml, Views/Quotation/ProductAndBenefit.cshtml, Views/Quotation/ContractAndPricing.cshtml, Views/Quotation/AcceptQuote.cshtml, Views/Quotation/TermsAndConditions.cshtml, Views/Quotation/QuotationBillDetail.cshtml, Views/Quotation/DeclineOrRefer.cshtml, Views/Quotation/ConfirmationAndBuy.cshtml, Views/UnderWriting/FullMedicalReview.cshtml, Views/UnderWriting/MedicalReview.cshtml, Views/Shared/_ErrorMessage.cshtml, Views/Quotation/AcceptPricingTerms.cshtml, Views/Customer/Customers.cshtml, Views/Quotation/Quotations.cshtml, Views/Application/Applications.cshtml, Views/Quotation/ContractIssue.cshtml, Views/Quotation/SecondClientDetails.cshtml, Views/Shared/_Loading.cshtml, fonts/glyphicons-halflings-regular.woff, fonts/glyphicons-halflings-regular.ttf, fonts/glyphicons-halflings-regular.eot, packages.config, Scripts/Global/jquery-1.10.2.min.map, Properties/PublishProfiles/AutomatedDeployment.pubxml, Properties/PublishProfiles/AutomatedDeploymentFileSystem.pubxml, Scripts/Global/jquery-1.10.2.intellisense.js, Scripts/Global/jquery.validate-vsdoc.js, Project_Readme.html
2016-10-17T15:30:46.1326703Z INFO: Source encoding: UTF-8, default locale: en_US
2016-10-17T15:30:46.1326703Z INFO: Index files
2016-10-17T15:30:46.1326703Z INFO: Excluded sources:
2016-10-17T15:30:46.1326703Z INFO: **/Scripts/Global/**/*.*
2016-10-17T15:30:46.1326703Z INFO: 58 files indexed
2016-10-17T15:30:46.1326703Z INFO: 24 files ignored because of inclusion/exclusion patterns
2016-10-17T15:30:46.1326703Z INFO: Quality profile for cs: Sonar way
2016-10-17T15:30:46.1326703Z INFO: Quality profile for js: Sonar way
2016-10-17T15:30:46.1326703Z INFO: Quality profile for web: Sonar way
2016-10-17T15:30:46.1326703Z INFO: Quality profile for xml: Sonar way
2016-10-17T15:30:46.1326703Z INFO: All FxCop rules are disabled, skipping its execution.
2016-10-17T15:30:46.1326703Z INFO: Sensor Lines Sensor
2016-10-17T15:30:46.1326703Z INFO: Sensor Lines Sensor (done) | time=15ms
2016-10-17T15:30:46.1326703Z INFO: Sensor Sonar-Sonargraph-Plugin [3.5]
2016-10-17T15:30:46.1326703Z INFO: ----------------------------------------------------------------
2016-10-17T15:30:46.1326703Z INFO: Sonargraph: Skipping project XXXX.WebApp.Advisor.Presentation.MVC5 [DigitalDelivery-AdvisorPortal:DigitalDelivery-AdvisorPortal:C7028C31-65FE-4DFA-B557-6BC43CBA0B0D], since no Sonargraph rules are activated in current SonarQube quality profile.
2016-10-17T15:30:46.1326703Z INFO: ----------------------------------------------------------------
2016-10-17T15:30:46.1326703Z INFO: Sensor Sonar-Sonargraph-Plugin [3.5] (done) | time=0ms
2016-10-17T15:30:46.1326703Z INFO: Sensor org.sonar.plugins.csharp.CSharpSensor
2016-10-17T15:30:46.1326703Z INFO: SonarLint for Visual Studio version 1.13.0.0
2016-10-17T15:30:46.2576727Z INFO: 0/36 files analyzed, starting to analyze: C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutionsrcXXXX.WebApp.Advisor.Presentation.MVC5App_StartBundleConfig.cs
2016-10-17T15:30:47.2420820Z INFO: 1/36 files analyzed, starting to analyze: C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutionsrcXXXX.WebApp.Advisor.Presentation.MVC5App_StartDependencyConfig.cs
2016-10-17T15:30:47.2420820Z INFO: 2/36 files analyzed, starting to analyze: C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutionsrcXXXX.WebApp.Advisor.Presentation.MVC5App_StartFilterConfig.cs
2016-10-17T15:30:47.2420820Z INFO: 3/36 files analyzed, starting to analyze: C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutionsrcXXXX.WebApp.Advisor.Presentation.MVC5App_StartIdentityConfig.cs
2016-10-17T15:30:47.2420820Z INFO: 4/36 files analyzed, starting to analyze: C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutionsrcXXXX.WebApp.Advisor.Presentation.MVC5App_StartRouteConfig.cs
2016-10-17T15:30:47.2420820Z INFO: 5/36 files analyzed, starting to analyze: C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutionsrcXXXX.WebApp.Advisor.Presentation.MVC5App_StartStartup.Auth.cs
……
Я подумал, что это может быть настройка уровня проекта, поэтому я удалил исходный проект SQ и создал новый проект. Это не имело никакого значения. Я попытался добавить
<Property Name="sonar.test.inclusions">file:**/*XXXX.WebApp*Test*/**/*.*</Property>
Но это не имело никакого значения.
Так что теперь я не понимаю, что происходит. Любая помощь приветствуется.
Комментарии:
1. Я создал новый экземпляр сервера SONAR и все еще получаю эту проблему. Я создал новый проект MVC, проанализировал его и получил аналогичный результат: в sln есть три проекта: один MVC, один тестовый и один проект класса. Ничего из этого не анализируется. Но сразу после того, как я создаю новое решение, проект класса и тестовый проект, и он анализируется, как и ожидалось. Такое ощущение, что в SQ есть ошибка при проектировании MVC ?!?
Ответ №1:
Итак, я чувствую, что файл sonar-project.properties выглядит неверным. Поскольку я использую задачу VSTS, мне нужно выяснить, что она делает.
BF14297E-4A17-4869-9612-E3CBB92E573B.sonar.stylecop.projectFilePath=C:\agent\_work\12\s\Seeds\XXXX.WebApp.Advisor\solution\src\XXXX.WebApp.Advisor.CrossCuttings.Configuration\XXXX.WebApp.Advisor.CrossCuttings.Configuration.csproj
9E577C4E-1343-4FC4-BC51-CA75DE04C8C7.sonar.projectKey=DigitalDelivery-AdvisorPortal6:9E577C4E-1343-4FC4-BC51-CA75DE04C8C7
9E577C4E-1343-4FC4-BC51-CA75DE04C8C7.sonar.projectName=XXXX.WebApp.Advisor.CrossCuttings.Constants
9E577C4E-1343-4FC4-BC51-CA75DE04C8C7.sonar.projectBaseDir=C:\agent\_work\12\s\Seeds\XXXX.WebApp.Advisor\solution\src\XXXX.WebApp.Advisor.CrossCuttings.Constants
9E577C4E-1343-4FC4-BC51-CA75DE04C8C7.sonar.cs.vscoveragexml.reportsPaths=C:\agent\_work\12\TestResults\LOCAL SERVICE_BUILDBOX1 2016-10-19 08_54_30\In\BUILDBOX1\LOCAL SERVICE_BUILDBOX1 2016-10-19 08_54_15.coveragexml
9E577C4E-1343-4FC4-BC51-CA75DE04C8C7.sonar.sources=
9E577C4E-1343-4FC4-BC51-CA75DE04C8C7.sonar.tests=
C:\agent\_work\12\s\Seeds\XXXX.WebApp.Advisor\solution\src\XXXX.WebApp.Advisor.CrossCuttings.Constants\Parameter.cs,
C:\agent\_work\12\s\Seeds\XXXX.WebApp.Advisor\solution\src\XXXX.WebApp.Advisor.CrossCuttings.Constants\Properties\AssemblyInfo.cs,
C:\agent\_work\12\s\Seeds\XXXX.WebApp.Advisor\solution\src\XXXX.WebApp.Advisor.CrossCuttings.Constants\packages.config
Ответ №2:
И дополнительный файл дополнительно подчеркивает проблему. Файл ‘ProjectInfo.log’
Product projects
---------------------------------------
C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutionsrcXXXX.WebApp.Advisor.Presentation.MVC5XXXX.WebApp.Advisor.Presentation.MVC5.csproj
Test projects
---------------------------------------
C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutionsrcXXXX.WebApp.Advisor.CrossCuttings.ConfigurationXXXX.WebApp.Advisor.CrossCuttings.Configuration.csproj
C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutionsrcXXXX.WebApp.Advisor.CrossCuttings.ConstantsXXXX.WebApp.Advisor.CrossCuttings.Constants.csproj
C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutiontestXXXX.WebApp.Advisor.CrossCuttings.Logging.UTestXXXX.WebApp.Advisor.CrossCuttings.Logging.UTest.csproj
C:agent_work12sSeedsXXXX.WebApp.AdvisorsolutionsrcXXXX.WebApp.Advisor.CrossCuttings.LoggingXXXX.WebApp.Advisor.CrossCuttings.Logging.csproj