@Override public List<Violation> check( ConfigurationServiceImpl configuration, RuleDTO rootRule, RuleDTO currentRule) { this.violations = new ArrayList<Violation>(); this.mappings = CheckConformanceUtilClass.filterClassesFrom(currentRule); this.physicalClasspathsFrom = mappings.getMappingFrom(); List<Mapping> physicalClasspathsTo = mappings.getMappingTo(); DependencyDTO[] dependencies = analyseService.getAllDependencies(); for (Mapping classPathFrom : physicalClasspathsFrom) { for (Mapping classPathTo : physicalClasspathsTo) { for (DependencyDTO dependency : dependencies) { if (dependency.from.equals(classPathFrom.getPhysicalPath()) && dependency.to.equals(classPathTo.getPhysicalPath()) && Arrays.binarySearch(classPathFrom.getViolationTypes(), dependency.type) >= 0) { Violation violation = createViolation(rootRule, classPathFrom, classPathTo, dependency, configuration); violations.add(violation); } } } } return violations; }
@Override public List<Violation> check( ConfigurationServiceImpl configuration, RuleDTO rootRule, RuleDTO currentRule) { this.violations = new ArrayList<Violation>(); this.violationtypefactory = new ViolationTypeFactory().getViolationTypeFactory(configuration); this.mappings = CheckConformanceUtilFilter.filter(currentRule); this.physicalClasspathsFrom = mappings.getMappingFrom(); List<Mapping> physicalClasspathsTo = mappings.getMappingTo(); for (Mapping classPathFrom : physicalClasspathsFrom) { for (Mapping classPathTo : physicalClasspathsTo) { DependencyDTO[] dependencies = analyseService.getDependenciesFrom(classPathFrom.getPhysicalPath()); DependencyDTO[] allowedDependencies = analyseService.getDependencies( classPathFrom.getPhysicalPath(), classPathTo.getPhysicalPath(), currentRule.violationTypeKeys); for (DependencyDTO dependency : dependencies) { if (allowedDependencies.length != 0) { for (DependencyDTO allowedDependency : allowedDependencies) { if (dependency != allowedDependency) { Message message = new Message(rootRule); LogicalModule logicalModuleFrom = new LogicalModule(classPathFrom); LogicalModule logicalModuleTo = new LogicalModule(classPathTo); LogicalModules logicalModules = new LogicalModules(logicalModuleFrom, logicalModuleTo); final Severity violationTypeSeverity = getViolationTypeSeverity(dependency.type); Severity severity = CheckConformanceUtilSeverity.getSeverity( configuration, super.severity, violationTypeSeverity); Violation violation = createViolation( dependency, 1, this.key, logicalModules, false, message, severity); violations.add(violation); } } } else { Message message = new Message(rootRule); LogicalModule logicalModuleFrom = new LogicalModule(classPathFrom); LogicalModule logicalModuleTo = new LogicalModule(classPathTo); LogicalModules logicalModules = new LogicalModules(logicalModuleFrom, logicalModuleTo); final Severity violationTypeSeverity = getViolationTypeSeverity(dependency.type); Severity severity = CheckConformanceUtilSeverity.getSeverity( configuration, super.severity, violationTypeSeverity); Violation violation = createViolation(dependency, 1, this.key, logicalModules, false, message, severity); violations.add(violation); } } } } return violations; }