private static List < DependencyError > checkForbiddenSection ( final Dependencies dependencies , final Package < NotDependsOn > forbiddenPkg , final ClassInfo classInfo ) { final List < DependencyError > errors = new ArrayList < DependencyError > ( ) ; final Iterator < String > it = classInfo . getImports ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { final String importedPkg = it . next ( ) ; if ( ! importedPkg . equals ( classInfo . getPackageName ( ) ) ) { final NotDependsOn ndo = Utils . findForbiddenByName ( dependencies . getAlwaysForbidden ( ) , importedPkg ) ; if ( ndo != null ) { errors . add ( new DependencyError ( classInfo . getName ( ) , importedPkg , ndo . getComment ( ) ) ) ; } else { final NotDependsOn dep = Utils . findForbiddenByName ( forbiddenPkg . getDependencies ( ) , importedPkg ) ; if ( dep != null ) { final String comment ; if ( dep . getComment ( ) == null ) { comment = forbiddenPkg . getComment ( ) ; } else { comment = dep . getComment ( ) ; } errors . add ( new DependencyError ( classInfo . getName ( ) , importedPkg , comment ) ) ; } } } } return errors ; }
Checks the dependencies for a package from the forbidden section .