Пример #1
0
 public void EvaluateMethodsHavingCorrectAttributes(IAnalysisReportInProgress report, string parentClassName, RuleDescription description)
 {
     if (!_methodDeclarationInfo.Attributes.Any())
     {
         report.Add(_violationFactory.ProjectScopedRuleViolation(description, $"Method {_methodDeclarationInfo.Name} in class {parentClassName} does not have any attribute"));
     }
 }
 public void ApplyTo(
     AssemblyName name,
     IReadOnlyDictionary <string, string> properties,
     IAnalysisReportInProgress report)
 {
     if (properties.ContainsKey(_propertyName))
     {
         var propertyValue = properties[_propertyName];
         if (!_expectedPropertyValuePattern.IsMatchedBy(propertyValue))
         {
             report.Add(_violationFactory.ProjectScopedRuleViolation(_ruleDescription, $"Project {name} has {_propertyName}:{propertyValue}"));
         }
     }
     else
     {
         report.Add(_violationFactory.ProjectScopedRuleViolation(_ruleDescription, $"Project {name} does not have {_propertyName} set explicitly"));
     }
 }
Пример #3
0
 public void CheckNamespacesCorrectness(IAnalysisReportInProgress report, RuleDescription description)
 {
     //bug get rid of this code here. Move this to rule as another interface
     if (_declaredNamespaces.Count == 0)
     {
         report.Add(_ruleViolationFactory.ProjectScopedRuleViolation(description, ViolationDescription("has no namespace declared"))
                    );
     }
     else if (_declaredNamespaces.Count > 1)
     {
         report.Add(_ruleViolationFactory.ProjectScopedRuleViolation(description, ViolationDescription($"declares multiple namespaces: {NamespacesString()}")));
     }
     else if (!_declaredNamespaces.Contains(CorrectNamespace()))
     {
         report.Add(_ruleViolationFactory.ProjectScopedRuleViolation(description, ViolationDescription($"has incorrect namespace {_declaredNamespaces.Single()}"))
                    );
     }
 }
        public void Evaluate(AssemblyName projectAssemblyName,
                             INamespacesDependenciesCache namespacesCache,
                             IAnalysisReportInProgress report)
        {
            var cycles = namespacesCache.RetrieveCycles();

            if (cycles.Any())
            {
                report.Add(
                    _ruleViolationFactory.NoCyclesRuleViolation(Description(), projectAssemblyName, cycles));
            }
        }
Пример #5
0
        public void Evaluate(AssemblyName projectAssemblyName,
                             INamespacesDependenciesCache namespacesCache,
                             IAnalysisReportInProgress report)
        {
            var paths = namespacesCache.RetrievePathsBetween(_dto.FromPattern, _dto.ToPattern);

            if (paths.Any())
            {
                report.Add(
                    _ruleViolationFactory.NoUsingsRuleViolation(Description(), projectAssemblyName, paths));
            }
        }
Пример #6
0
        public void Check(IAnalysisReportInProgress report, IProjectDependencyPath dependencyPath)
        {
            var dependingAssembly = dependencyPath.AssemblyWithNameMatching(_dependingAssemblyNamePattern);

            if (dependingAssembly.Exists())
            {
                var dependencyAssembly = dependencyPath.AssemblyMatching(_condition, dependingAssembly);
                if (dependencyAssembly.IsNotBefore(dependingAssembly))
                {
                    var pathRuleViolation = _ruleViolationFactory.PathRuleViolation(
                        _condition.Description(),
                        dependencyPath.SegmentBetween(dependingAssembly, dependencyAssembly));
                    report.Add(pathRuleViolation);
                }
            }
            report.FinishedEvaluatingRule(_condition.Description());
        }