void (@NotNull PsiClass aClass) { super.visitClass(aClass); if (aClass.isInterface() || aClass.isRecord() || aClass.isEnum()) { // the problem can't be fixed for an interface, so let's not report it // a record has an equals method implemented by default // an enum has a default final compareTo() method, no need to check return; } final PsiClass comparableClass = JavaPsiFacade.getInstance(aClass.getProject()).findClass(CommonClassNames.JAVA_LANG_COMPARABLE, aClass.getResolveScope()); if (comparableClass == null || !aClass.isInheritor(comparableClass, true)) { return; } final PsiMethod[] comparableMethods = comparableClass.findMethodsByName(HardcodedMethodConstants.COMPARE_TO, false); if (comparableMethods.length == 0) { // incorrect/broken jdk return; } final PsiMethod comparableMethod = MethodSignatureUtil.findMethodBySuperMethod(aClass, comparableMethods[0], false); if (comparableMethod == null || comparableMethod.hasModifierProperty(PsiModifier.ABSTRACT) || comparableMethod.getBody() == null) { return; } final PsiClass objectClass = ClassUtils.findObjectClass(aClass); if (objectClass == null) { return; } final PsiMethod[] equalsMethods = objectClass.findMethodsByName(HardcodedMethodConstants.EQUALS, false); if (equalsMethods.length != 1) { // incorrect/broken jdk return; } final PsiMethod equalsMethod = MethodSignatureUtil.findMethodBySuperMethod(aClass, equalsMethods[0], false); if (equalsMethod != null && !equalsMethod.hasModifierProperty(PsiModifier.ABSTRACT)) { return; } final String docCommentText = StringUtil.collapseWhiteSpace(getActualCommentText(aClass.getDocComment())); if (StringUtil.containsIgnoreCase(docCommentText, "this class has a natural ordering that is inconsistent with equals")) { // see Comparable.compareTo() javadoc return; } registerClassError(aClass, aClass); }