From b5d499e2ebf53ba84d312c95d175e850a1f7c168 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 24 Jul 2020 18:42:11 -0700 Subject: [PATCH] Remove empty block Refactor a few classes so that empty blocks are not longer used. For example, rather than: if(x) { } else { i++; } use: if(!x) { i++; } Issue gh-8945 --- .../config/doc/SpringSecurityXsdParser.java | 27 +++++++++---------- etc/checkstyle/checkstyle-suppressions.xml | 2 -- ...ctAuthenticationProcessingFilterTests.java | 5 +--- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/config/src/test/java/org/springframework/security/config/doc/SpringSecurityXsdParser.java b/config/src/test/java/org/springframework/security/config/doc/SpringSecurityXsdParser.java index cc690fb088..bb81c4b893 100644 --- a/config/src/test/java/org/springframework/security/config/doc/SpringSecurityXsdParser.java +++ b/config/src/test/java/org/springframework/security/config/doc/SpringSecurityXsdParser.java @@ -85,9 +85,7 @@ public class SpringSecurityXsdParser { if ("attribute".equals(name)) { attrs.add(attr(c)); } - else if ("element".equals(name)) { - } - else { + else if (!"element".equals(name)) { attrs.addAll(attrs(c)); } }); @@ -105,22 +103,21 @@ public class SpringSecurityXsdParser { Collection attrgrp = new ArrayList<>(); element.children().forEach(c -> { - if ("element".equals(c.simpleName())) { - - } - else if ("attributeGroup".equals(c.simpleName())) { - if (c.attribute("name") != null) { - attrgrp.addAll(attrgrp(c)); + if (!"element".equals(c.simpleName())) { + if ("attributeGroup".equals(c.simpleName())) { + if (c.attribute("name") != null) { + attrgrp.addAll(attrgrp(c)); + } + else { + String name = c.attribute("ref").split(":")[1]; + XmlNode attrGrp = findNode(element, name); + attrgrp.addAll(attrgrp(attrGrp)); + } } else { - String name = c.attribute("ref").split(":")[1]; - XmlNode attrGrp = findNode(element, name); - attrgrp.addAll(attrgrp(attrGrp)); + attrgrp.addAll(attrgrps(c)); } } - else { - attrgrp.addAll(attrgrps(c)); - } }); return attrgrp; diff --git a/etc/checkstyle/checkstyle-suppressions.xml b/etc/checkstyle/checkstyle-suppressions.xml index 370491d8e3..3fd9f4387c 100644 --- a/etc/checkstyle/checkstyle-suppressions.xml +++ b/etc/checkstyle/checkstyle-suppressions.xml @@ -3,7 +3,6 @@ "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "https://checkstyle.org/dtds/suppressions_1_2.dtd"> - @@ -32,7 +31,6 @@ - diff --git a/web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilterTests.java index 492eda2854..be8d0831a9 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilterTests.java @@ -533,10 +533,7 @@ public class AbstractAuthenticationProcessingFilterTests { } public void doFilter(ServletRequest request, ServletResponse response) { - if (expectToProceed) { - - } - else { + if (!expectToProceed) { fail("Did not expect filter chain to proceed"); } }