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 WarnIfAnyProjectHasSonarRuleSet() { var hasAnySonarRule = this.projectSystemHelper.GetSolutionProjects() .SelectMany(p => ruleSetProvider.GetProjectRuleSetsDeclarations(p)) .Any(HasAnySonarRule); if (hasAnySonarRule) { this.logger.WriteLine(DeprecationMessage); } }
public bool IsReferencedByAllDeclarations(Project project, string targetRuleSetFilePath) { var declarations = ruleSetInfoProvider.GetProjectRuleSetsDeclarations(project).ToArray(); logger.WriteLine(Strings.Bind_ProjectRulesetDeclarations, project.Name, string.Join(Environment.NewLine + " ", declarations.Select(x => x.ToString()))); var isRuleSetBound = declarations.Length > 0 && declarations.All(declaration => IsReferenced(declaration, targetRuleSetFilePath)); return(isRuleSetBound); }