import org.slf4j.LoggerFactory;
import org.sonar.api.batch.ResourceFilter;
import org.sonar.api.resources.Resource;
+import org.sonar.api.resources.Scopes;
/**
* @since 1.12
private ResourceFilter[] filters;
public ResourceFilters(ResourceFilter[] filters) {
- this.filters = (filters==null ? new ResourceFilter[0] : filters);
+ this.filters = (filters == null ? new ResourceFilter[0] : filters);
}
public ResourceFilters() {
*/
public boolean isExcluded(Resource resource) {
boolean ignored = false;
- int index = 0;
- while (!ignored && index < filters.length) {
- ResourceFilter filter = filters[index];
- ignored = filter.isIgnored(resource);
- if (ignored && LOG.isDebugEnabled()) {
- LOG.debug("Resource {} is excluded by the filter {}", resource, filter);
+ if (Scopes.isHigherThanOrEquals(resource, Scopes.FILE)) {
+ int index = 0;
+ while (!ignored && index < filters.length) {
+ ResourceFilter filter = filters[index];
+ ignored = filter.isIgnored(resource);
+ if (ignored && LOG.isDebugEnabled()) {
+ LOG.debug("Resource {} is excluded by the filter {}", resource, filter);
+ }
+ index++;
}
- index++;
}
return ignored;
}