private bool IsFullyBoundProject(ISolutionRuleSetsInformationProvider ruleSetInfoProvider, IRuleSetSerializer ruleSetSerializer, BindingConfiguration binding, Project project) { var languages = ProjectToLanguageMapper.GetAllBindingLanguagesForProject(project); return(languages.All(l => IsFullyBoundProject(ruleSetInfoProvider, ruleSetSerializer, binding, project, l))); }
private bool IsFullyBoundProject(ISolutionRuleSetsInformationProvider ruleSetInfoProvider, IRuleSetSerializer ruleSetSerializer, BindingConfiguration binding, Project project, Core.Language language) { Debug.Assert(binding != null); Debug.Assert(project != null); // If solution is not bound/is missing a rules configuration file, no need to go further var slnLevelBindingConfigFilepath = CalculateSonarQubeSolutionBindingConfigPath(ruleSetInfoProvider, binding, language); if (!fileSystem.File.Exists(slnLevelBindingConfigFilepath)) { return(false); } if (!BindingRefactoringDumpingGround.IsProjectLevelBindingRequired(project)) { return(true); // nothing else to check } // Projects that required project-level binding should be using RuleSets for configuration, // so we assume that the solution-level config file is a ruleset. RuleSet sonarQubeRuleSet = ruleSetSerializer.LoadRuleSet(slnLevelBindingConfigFilepath); if (sonarQubeRuleSet == null) { return(false); } RuleSetDeclaration[] declarations = ruleSetInfoProvider.GetProjectRuleSetsDeclarations(project).ToArray(); return(declarations.Length > 0 && // Need at least one declarations.All(declaration => this.IsRuleSetBound(ruleSetSerializer, project, declaration, sonarQubeRuleSet))); }
private void SetValidSolutionRuleSetPerProjectKind() { ISolutionRuleSetsInformationProvider rsInfoProvider = this.ruleSetInfoProvider; foreach (var project in this.projectHelper.FilteredProjects) { string solutionRuleSet = rsInfoProvider.CalculateSolutionSonarQubeRuleSetFilePath( this.solutionBinding.CurrentBinding.ProjectKey, Language.ForProject(project)); this.fileSystem.RegisterFile(solutionRuleSet); } }
public SolutionBindingInformationProvider(IServiceProvider serviceProvider) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } this.serviceProvider = serviceProvider; ruleSetInfoProvider = this.serviceProvider.GetService <ISolutionRuleSetsInformationProvider>(); ruleSetInfoProvider.AssertLocalServiceIsNotNull(); }
private void SetValidSolutionRuleSetPerProjectKind() { ISolutionRuleSetsInformationProvider rsInfoProvider = this.ruleSetInfoProvider; foreach (var project in this.projectHelper.FilteredProjects) { string solutionRuleSet = rsInfoProvider.CalculateSolutionSonarQubeRuleSetFilePath( this.configProvider.ProjectToReturn.ProjectKey, Language.ForProject(project), SonarLintMode.LegacyConnected); this.fileSystem.RegisterFile(solutionRuleSet); } }
internal /* for testing */ UnboundProjectFinder(IServiceProvider serviceProvider, IFileSystem fileSystem) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } this.serviceProvider = serviceProvider; ruleSetInfoProvider = this.serviceProvider.GetService <ISolutionRuleSetsInformationProvider>(); ruleSetInfoProvider.AssertLocalServiceIsNotNull(); this.fileSystem = fileSystem; }
public CFamilyRuleConfigProvider(IHost host, IActiveSolutionBoundTracker activeSolutionBoundTracker, IUserSettingsProvider userSettingsProvider, ILogger logger, ICFamilyRulesConfigProvider sonarWayProvider, IFileSystem fileSystem) { this.activeSolutionBoundTracker = activeSolutionBoundTracker; this.userSettingsProvider = userSettingsProvider; this.logger = logger; solutionInfoProvider = host.GetService <ISolutionRuleSetsInformationProvider>(); solutionInfoProvider.AssertLocalServiceIsNotNull(); this.sonarWayProvider = sonarWayProvider; this.serializer = new RulesSettingsSerializer(fileSystem, logger); this.effectiveConfigCalculator = new EffectiveRulesConfigCalculator(logger); }
public RuleSetReferenceChecker(IServiceProvider serviceProvider, ILogger logger) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); ruleSetInfoProvider = serviceProvider.GetService <ISolutionRuleSetsInformationProvider>(); ruleSetInfoProvider.AssertLocalServiceIsNotNull(); ruleSetSerializer = serviceProvider.GetService <IRuleSetSerializer>(); ruleSetSerializer.AssertLocalServiceIsNotNull(); }
private static string CalculateProjectRuleSetFullPath(ISolutionRuleSetsInformationProvider ruleSetInfoProvider, Project project, RuleSetDeclaration declaration) { string projectRuleSet; if (!ruleSetInfoProvider.TryGetProjectRuleSetFilePath(project, declaration, out projectRuleSet)) { // Use the original property value to attempt to load the rule set with the directories information, during FindConflicts projectRuleSet = declaration.RuleSetPath; // We do want to continue and add this rule set rather than skip over it since it maybe the case that // the user moved it to some other location which is relative to the rule set directories property // and we will be able to find it during rule set conflicts analysis. } return(projectRuleSet); }
internal /* for testing purposes */ DeprecatedSonarRuleSetManager(IActiveSolutionBoundTracker activeSolutionBoundTracker, IActiveSolutionTracker activeSolutionTracker, IProjectSystemHelper projectSystemHelper, ISolutionRuleSetsInformationProvider ruleSetProvider, ILogger logger) { if (activeSolutionBoundTracker == null) { throw new ArgumentNullException(nameof(activeSolutionBoundTracker)); } if (activeSolutionTracker == null) { throw new ArgumentNullException(nameof(activeSolutionTracker)); } if (projectSystemHelper == null) { throw new ArgumentNullException(nameof(projectSystemHelper)); } if (ruleSetProvider == null) { throw new ArgumentNullException(nameof(ruleSetProvider)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } this.activeSolutionBoundTracker = activeSolutionBoundTracker; this.activeSolutionTracker = activeSolutionTracker; this.projectSystemHelper = projectSystemHelper; this.ruleSetProvider = ruleSetProvider; this.logger = logger; this.activeSolutionBoundTracker.SolutionBindingChanged += OnSolutionBindingChanged; this.activeSolutionTracker.ActiveSolutionChanged += OnActiveSolutionChanged; if (this.activeSolutionBoundTracker.CurrentConfiguration != null && this.activeSolutionBoundTracker.CurrentConfiguration.Mode != NewConnectedMode.SonarLintMode.LegacyConnected) { WarnIfAnyProjectHasSonarRuleSet(); } }
private static string CalculateSonarQubeSolutionBindingConfigPath(ISolutionRuleSetsInformationProvider ruleSetInfoProvider, BindingConfiguration binding, Core.Language language) => ruleSetInfoProvider.CalculateSolutionSonarQubeRuleSetFilePath( binding.Project.ProjectKey, language, binding.Mode);
private static string CalculateProjectRuleSetFullPath(ISolutionRuleSetsInformationProvider ruleSetInfoProvider, Project project, RuleSetDeclaration declaration) { string projectRuleSet; if (!ruleSetInfoProvider.TryGetProjectRuleSetFilePath(project, declaration, out projectRuleSet)) { // Use the original property value to attempt to load the rule set with the directories information, during FindConflicts projectRuleSet = declaration.RuleSetPath; // We do want to continue and add this rule set rather than skip over it since it maybe the case that // the user moved it to some other location which is relative to the rule set directories property // and we will be able to find it during rule set conflicts analysis. } return projectRuleSet; }