diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/PackageWithTooManyClassesInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/PackageWithTooManyClassesInspection.java index b62f40d5cd0b..54aceb7f0461 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/PackageWithTooManyClassesInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/PackageWithTooManyClassesInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2011 Dave Griffith, Bas Leijdekkers + * Copyright 2006-2017 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,8 +39,7 @@ public class PackageWithTooManyClassesInspection extends BaseGlobalInspection { @NotNull @Override public String getDisplayName() { - return InspectionGadgetsBundle.message( - "package.with.too.many.classes.display.name"); + return InspectionGadgetsBundle.message("package.with.too.many.classes.display.name"); } @Override @@ -54,29 +53,21 @@ public class PackageWithTooManyClassesInspection extends BaseGlobalInspection { return null; } final List children = refEntity.getChildren(); - int numClasses = 0; - for (RefEntity child : children) { - if (child instanceof RefClass) { - numClasses++; - } + if (children.size() <= limit) { + return null; } + final int numClasses = (int)children.stream().filter(c -> c instanceof RefClass).count(); if (numClasses <= limit) { return null; } final String errorString = InspectionGadgetsBundle.message( "package.with.too.many.classes.problem.descriptor", - refEntity.getQualifiedName(), Integer.valueOf(numClasses), - Integer.valueOf(limit)); - return new CommonProblemDescriptor[]{ - inspectionManager.createProblemDescriptor(errorString) - }; + refEntity.getQualifiedName(), Integer.valueOf(numClasses), Integer.valueOf(limit)); + return new CommonProblemDescriptor[]{inspectionManager.createProblemDescriptor(errorString)}; } @Override public JComponent createOptionsPanel() { - return new SingleIntegerFieldOptionsPanel( - InspectionGadgetsBundle.message( - "package.with.too.many.classes.max.option"), - this, "limit"); + return new SingleIntegerFieldOptionsPanel(InspectionGadgetsBundle.message("package.with.too.many.classes.max.option"), this, "limit"); } }