public void execute()

in enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/RequireExplicitDependencyScope.java [48:74]


    public void execute() throws EnforcerRuleException {
        int numMissingDependencyScopes = 0;
        List<Dependency> dependencies = project.getOriginalModel().getDependencies(); // this is the non-effective
        // model but the original one
        // without inheritance and
        // interpolation resolved
        // check scope without considering inheritance
        for (Dependency dependency : dependencies) {
            getLog().debug("Found dependency " + dependency);
            if (dependency.getScope() == null) {
                getLog().warnOrError(() -> new StringBuilder()
                        .append("Dependency ")
                        .append(dependency.getManagementKey())
                        .append(" @ ")
                        .append(formatLocation(project, dependency.getLocation("")))
                        .append(" does not have an explicit scope defined!"));
                numMissingDependencyScopes++;
            }
        }
        if (numMissingDependencyScopes > 0) {
            ChoiceFormat scopesFormat = new ChoiceFormat("1#scope|1<scopes");
            String logCategory = getLevel() == EnforcerLevel.ERROR ? "errors" : "warnings";
            throw new EnforcerRuleException("Found " + numMissingDependencyScopes + " missing dependency "
                    + scopesFormat.format(numMissingDependencyScopes)
                    + ". Look at the " + logCategory + " emitted above for the details.");
        }
    }