private bool IsUpdateRequired(BoundSonarQubeProject binding, IEnumerable <Language> projectLanguages, CancellationToken token) { Debug.Assert(binding != null); IDictionary <Language, SonarQubeQualityProfile> newProfiles = null; try { newProfiles = TryGetLatestProfilesAsync(binding, projectLanguages, token).GetAwaiter().GetResult(); } catch (Exception) { this.host.Logger.WriteLine(Strings.SonarLintProfileCheckFailed); return(false); // Error, can't proceed } if (!newProfiles.Keys.All(binding.Profiles.ContainsKey)) { this.host.Logger.WriteLine(Strings.SonarLintProfileCheckSolutionRequiresMoreProfiles); return(true); // Missing profile, refresh } foreach (var keyValue in binding.Profiles) { Language language = keyValue.Key; ApplicableQualityProfile oldProfileInfo = keyValue.Value; if (!newProfiles.ContainsKey(language)) { // Not a relevant profile, we should just ignore it. continue; } SonarQubeQualityProfile newProfileInfo = newProfiles[language]; if (this.HasProfileChanged(newProfileInfo, oldProfileInfo)) { return(true); } } this.host.Logger.WriteLine(Strings.SonarLintProfileCheckQualityProfileIsUpToDate); return(false); // Up-to-date }
private void InstallPackages_Succeed(string projectKind, Language language) { // Arrange var testSubject = this.CreateTestSubject(); var progressEvents = new ConfigurableProgressStepExecutionEvents(); var progressAdapter = new FixedStepsProgressAdapter(progressEvents); ProjectMock project1 = new ProjectMock("project1") { ProjectKind = projectKind }; ProjectMock project2 = new ProjectMock("project2") { ProjectKind = projectKind }; var projectsToBind = new HashSet <Project> { project1, project2 }; var nugetPackage = new PackageName("mypackage", new SemanticVersion("1.1.0")); var packages = new Dictionary <Language, IEnumerable <PackageName> >(); packages.Add(language, new[] { nugetPackage }); ConfigurablePackageInstaller packageInstaller = this.PrepareInstallPackagesTest(testSubject, packages); // Act testSubject.InstallPackages(projectsToBind, progressAdapter, CancellationToken.None); // Assert packageInstaller.AssertInstalledPackages(project1, new[] { nugetPackage }); packageInstaller.AssertInstalledPackages(project2, new[] { nugetPackage }); this.logger.AssertOutputStrings(4); this.logger.AssertOutputStrings( string.Format(Strings.SubTextPaddingFormat, string.Format(Strings.EnsuringNugetPackagesProgressMessage, nugetPackage.Id, ((Project)project1).Name)), string.Format(Strings.SubTextPaddingFormat, string.Format(Strings.SuccessfullyInstalledNugetPackageForProject, nugetPackage.Id, ((Project)project1).Name)), string.Format(Strings.SubTextPaddingFormat, string.Format(Strings.EnsuringNugetPackagesProgressMessage, nugetPackage.Id, ((Project)project2).Name)), string.Format(Strings.SubTextPaddingFormat, string.Format(Strings.SuccessfullyInstalledNugetPackageForProject, nugetPackage.Id, ((Project)project2).Name)) ); progressEvents.AssertProgress(.5, 1.0); }
public string CalculateSolutionSonarQubeRuleSetFilePath(string ProjectKey, Language language, SonarLintMode bindingMode) { if (string.IsNullOrWhiteSpace(ProjectKey)) { throw new ArgumentNullException(nameof(ProjectKey)); } if (language == null) { throw new ArgumentOutOfRangeException(nameof(language)); } bindingMode.ThrowIfNotConnected(); string ruleSetDirectoryRoot = this.GetSolutionSonarQubeRulesFolder(bindingMode); if (string.IsNullOrWhiteSpace(ruleSetDirectoryRoot)) { throw new InvalidOperationException(Strings.SolutionIsClosed); } return(GenerateSolutionRuleSetPath(ruleSetDirectoryRoot, ProjectKey, language.FileSuffixAndExtension)); }
private SonarQubeQualityProfile ConfigureProfileExport(RoslynExportProfileResponse export, Language language, string profileName) { var profile = new SonarQubeQualityProfile("", profileName, "", false, DateTime.Now); this.sonarQubeServiceMock .Setup(x => x.GetQualityProfileAsync(It.IsAny <string>(), It.IsAny <string>(), language.ServerLanguage, It.IsAny <CancellationToken>())) .ReturnsAsync(profile); this.sonarQubeServiceMock .Setup(x => x.GetRoslynExportProfileAsync(profileName, It.IsAny <string>(), It.IsAny <SonarQubeLanguage>(), It.IsAny <CancellationToken>())) .ReturnsAsync(export); return(profile); }
ConfigFileInformation ISolutionBindingConfigFileStore.GetConfigFileInformation(Language language) { ConfigFileInformation ruleSet; this.availableFiles.TryGetValue(language, out ruleSet); return(ruleSet); }
private void ConfigureSupportedBindingProject(BindingProcessImpl.BindingProcessState internalState, Language language) { // Mark the language as supported by the host host.SupportedPluginLanguages.Add(language); // Create a dummy project and add it to the internal state var project = new ProjectMock(null); switch (language.Id) { case "VB": project.SetVBProjectKind(); break; case "CSharp": project.SetCSProjectKind(); break; default: Assert.Fail($"Test setup error: unknown language: {language}"); break; } internalState.BindingProjects.Add(project); }
public bool ProcessExport(Language language, RoslynExportProfileResponse exportProfileResponse) { // Nothing to do - just return success return(true); }
string ISolutionRuleSetsInformationProvider.CalculateSolutionSonarQubeRuleSetFilePath(string ProjectKey, Language language, SonarLintMode bindingMode) { string fileName = $"{ProjectKey}{language.FileSuffixAndExtension}"; return(Path.Combine(((ISolutionRuleSetsInformationProvider)this).GetSolutionSonarQubeRulesFolder(bindingMode), fileName)); }
public bool ProcessExport(Language language, IEnumerable <NuGetPackageInfo> nugetPackages) { // Nothing to do - just return success return(true); }
private bool IsFullyBoundProject(BindingConfiguration binding, Project project, Language language) { if (!IsSolutionBound(binding, language, out var solutionRuleSetFilePath, out var additionalFilePath)) { return(false); } var isAdditionalFileBound = additionalFileReferenceChecker.IsReferenced(project, additionalFilePath); if (!isAdditionalFileBound) { return(false); } var isRuleSetBound = ruleSetReferenceChecker.IsReferencedByAllDeclarations(project, solutionRuleSetFilePath); return(isRuleSetBound); }