Remove superfluous comments

Use '^\s+//\ \~\ .*$' and '^\s+//\ ============+$' regular expression
searches to remove superfluous comments.

Prior to this commit, many classes would have comments to indicate
blocks of code (such as constructors/methods/instance fields). These
added a lot of noise and weren't all that helpful, especially given
the outline views available in most modern IDEs.

Issue gh-8945
This commit is contained in:
Phillip Webb
2020-07-23 15:09:07 -07:00
committed by Rob Winch
parent b7fc18262d
commit 71bc145ae4
406 changed files with 12 additions and 2190 deletions

View File

@@ -23,9 +23,6 @@ package org.springframework.security;
*/
public interface ITargetObject {
// ~ Methods
// ========================================================================================================
Integer computeHashCode(String input);
int countLength(String input);

View File

@@ -35,9 +35,6 @@ package org.springframework.security;
*/
public class OtherTargetObject extends TargetObject implements ITargetObject {
// ~ Methods
// ========================================================================================================
public String makeLowerCase(String input) {
return super.makeLowerCase(input);
}

View File

@@ -28,20 +28,11 @@ import javax.sql.DataSource;
*/
public class PopulatedDatabase {
// ~ Static fields/initializers
// =====================================================================================
private static TestDataSource dataSource = null;
// ~ Constructors
// ===================================================================================================
private PopulatedDatabase() {
}
// ~ Methods
// ========================================================================================================
public static DataSource getDataSource() {
if (dataSource == null) {
setupDataSource();

View File

@@ -26,9 +26,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
*/
public class TargetObject implements ITargetObject {
// ~ Methods
// ========================================================================================================
public Integer computeHashCode(String input) {
return input.hashCode();
}

View File

@@ -29,9 +29,6 @@ import org.springframework.security.access.SecurityConfig;
*/
public class SecurityConfigTests {
// ~ Methods
// ========================================================================================================
@Test
public void testHashCode() {
SecurityConfig config = new SecurityConfig("TEST");
@@ -85,9 +82,6 @@ public class SecurityConfigTests {
assertThat(config.toString()).isEqualTo("TEST");
}
// ~ Inner Classes
// ==================================================================================================
private class MockConfigAttribute implements ConfigAttribute {
private String attribute;

View File

@@ -30,9 +30,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
@PermitAll
public interface BusinessService extends Serializable {
// ~ Methods
// ========================================================================================================
@Secured({ "ROLE_ADMIN" })
@RolesAllowed({ "ROLE_ADMIN" })
@PreAuthorize("hasRole('ROLE_ADMIN')")

View File

@@ -202,9 +202,6 @@ public class Jsr250MethodSecurityMetadataSourceTests {
assertThat(accessAttributes.toArray()[0].toString()).isEqualTo("ROLE_DERIVED");
}
// ~ Inner Classes
// ======================================================================================================
public static class A {
public void noRoleMethod() {

View File

@@ -48,14 +48,8 @@ import org.springframework.security.core.GrantedAuthority;
*/
public class SecuredAnnotationSecurityMetadataSourceTests {
// ~ Instance fields
// ================================================================================================
private SecuredAnnotationSecurityMetadataSource mds = new SecuredAnnotationSecurityMetadataSource();
// ~ Methods
// ========================================================================================================
@Test
public void genericsSuperclassDeclarationsAreIncludedWhenSubclassesOverride() {
Method method = null;

View File

@@ -147,9 +147,6 @@ public class MethodExpressionVoterTests {
return Target.class.getMethod("methodTakingACollection", Collection.class);
}
// ~ Inner Classes
// ==================================================================================================
private interface Target {
void methodTakingAnArray(Object[] args);

View File

@@ -190,9 +190,6 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
assertThat(expression.getExpressionString()).isEqualTo("hasRole('ROLE_PERSON')");
}
// ~ Inner Classes
// ==================================================================================================
public interface ReturnVoid {
void doSomething(List<?> param);

View File

@@ -32,9 +32,6 @@ import org.springframework.security.util.SimpleMethodInvocation;
*/
public class AbstractSecurityInterceptorTests {
// ~ Methods
// ========================================================================================================
@Test(expected = IllegalArgumentException.class)
public void detectsIfInvocationPassedIncompatibleSecureObject() {
MockSecurityInterceptorWhichOnlySupportsStrings si = new MockSecurityInterceptorWhichOnlySupportsStrings();
@@ -58,9 +55,6 @@ public class AbstractSecurityInterceptorTests {
si.afterPropertiesSet();
}
// ~ Inner Classes
// ==================================================================================================
private class MockSecurityInterceptorReturnsNull extends AbstractSecurityInterceptor {
private SecurityMetadataSource securityMetadataSource;

View File

@@ -40,8 +40,6 @@ import org.springframework.security.util.SimpleMethodInvocation;
@SuppressWarnings("unchecked")
public class AfterInvocationProviderManagerTests {
// ~ Methods
// ========================================================================================================
@Test
public void testCorrectOperation() throws Exception {
AfterInvocationProviderManager manager = new AfterInvocationProviderManager();
@@ -147,9 +145,6 @@ public class AfterInvocationProviderManagerTests {
assertThat(manager.supports(MethodInvocation.class)).isTrue();
}
// ~ Inner Classes
// ==================================================================================================
/**
* Always returns the constructor-defined <code>forceReturnObject</code>, provided the
* same configuration attribute was provided. Also stores the secure object it

View File

@@ -28,9 +28,6 @@ import org.springframework.security.access.SecurityConfig;
*/
public class NullRunAsManagerTests {
// ~ Methods
// ========================================================================================================
@Test
public void testAlwaysReturnsNull() {
NullRunAsManager runAs = new NullRunAsManager();

View File

@@ -71,9 +71,6 @@ public class MethodSecurityInterceptorTests {
private ApplicationEventPublisher eventPublisher;
// ~ Methods
// ========================================================================================================
@Before
public final void setUp() {
SecurityContextHolder.clearContext();

View File

@@ -34,8 +34,6 @@ import org.springframework.security.access.method.MethodSecurityMetadataSource;
*/
public class MethodSecurityMetadataSourceAdvisorTests {
// ~ Methods
// ========================================================================================================
@Test
public void testAdvisorReturnsFalseWhenMethodInvocationNotDefined() throws Exception {
Class<TargetObject> clazz = TargetObject.class;

View File

@@ -69,9 +69,6 @@ public class AspectJMethodSecurityInterceptorTests {
private ProceedingJoinPoint joinPoint;
// ~ Methods
// ========================================================================================================
@Before
public final void setUp() {
MockitoAnnotations.initMocks(this);

View File

@@ -58,9 +58,6 @@ public class MethodInvocationPrivilegeEvaluatorTests {
private final List<ConfigAttribute> role = SecurityConfig.createList("ROLE_IGNORED");
// ~ Methods
// ========================================================================================================
@Before
public final void setUp() {
SecurityContextHolder.clearContext();

View File

@@ -37,8 +37,6 @@ import org.springframework.security.core.Authentication;
@SuppressWarnings("unchecked")
public class AbstractAccessDecisionManagerTests {
// ~ Methods
// ========================================================================================================
@Test
public void testAllowIfAccessDecisionManagerDefaults() {
List list = new Vector();
@@ -131,9 +129,6 @@ public class AbstractAccessDecisionManagerTests {
}
}
// ~ Inner Classes
// ==================================================================================================
private class MockDecisionManagerImpl extends AbstractAccessDecisionManager {
protected MockDecisionManagerImpl(List<AccessDecisionVoter<? extends Object>> decisionVoters) {

View File

@@ -35,9 +35,6 @@ import java.util.Iterator;
*/
public class DenyAgainVoter implements AccessDecisionVoter<Object> {
// ~ Methods
// ========================================================================================================
public boolean supports(ConfigAttribute attribute) {
if ("DENY_AGAIN_FOR_SURE".equals(attribute.getAttribute())) {
return true;

View File

@@ -37,9 +37,6 @@ import java.util.Iterator;
*/
public class DenyVoter implements AccessDecisionVoter<Object> {
// ~ Methods
// ========================================================================================================
public boolean supports(ConfigAttribute attribute) {
if ("DENY_FOR_SURE".equals(attribute.getAttribute())) {
return true;

View File

@@ -23,21 +23,12 @@ package org.springframework.security.access.vote;
*/
public class SomeDomainObject {
// ~ Instance fields
// ================================================================================================
private String identity;
// ~ Constructors
// ===================================================================================================
public SomeDomainObject(String identity) {
this.identity = identity;
}
// ~ Methods
// ========================================================================================================
public String getParent() {
return "parentOf" + identity;
}

View File

@@ -24,9 +24,6 @@ package org.springframework.security.access.vote;
*/
public class SomeDomainObjectManager {
// ~ Methods
// ========================================================================================================
public void someServiceMethod(SomeDomainObject someDomainObject) {
}

View File

@@ -36,9 +36,6 @@ import org.springframework.security.authentication.TestingAuthenticationToken;
*/
public class UnanimousBasedTests {
// ~ Methods
// ========================================================================================================
private UnanimousBased makeDecisionManager() {
RoleVoter roleVoter = new RoleVoter();
DenyVoter denyForSureVoter = new DenyVoter();

View File

@@ -34,14 +34,8 @@ import java.util.*;
*/
public class AbstractAuthenticationTokenTests {
// ~ Instance fields
// ================================================================================================
private List<GrantedAuthority> authorities = null;
// ~ Methods
// ========================================================================================================
@Before
public final void setUp() {
authorities = AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO");
@@ -136,9 +130,6 @@ public class AbstractAuthenticationTokenTests {
verify(principal, times(1)).getName();
}
// ~ Inner Classes
// ==================================================================================================
private class MockAuthenticationImpl extends AbstractAuthenticationToken {
private Object credentials;

View File

@@ -29,8 +29,6 @@ import org.springframework.security.core.authority.AuthorityUtils;
*/
public class AuthenticationTrustResolverImplTests {
// ~ Methods
// ========================================================================================================
@Test
public void testCorrectOperationIsAnonymous() {
AuthenticationTrustResolverImpl trustResolver = new AuthenticationTrustResolverImpl();

View File

@@ -358,9 +358,6 @@ public class ProviderManagerTests {
return new ProviderManager(provider);
}
// ~ Inner Classes
// ==================================================================================================
private static class MockProvider implements AuthenticationProvider {
public Authentication authenticate(Authentication authentication) throws AuthenticationException {

View File

@@ -29,9 +29,6 @@ import org.springframework.security.core.authority.AuthorityUtils;
*/
public class UsernamePasswordAuthenticationTokenTests {
// ~ Methods
// ========================================================================================================
@Test
public void authenticatedPropertyContractIsSatisfied() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("Test", "Password",

View File

@@ -33,9 +33,6 @@ import org.springframework.security.core.authority.AuthorityUtils;
*/
public class AnonymousAuthenticationProviderTests {
// ~ Methods
// ========================================================================================================
@Test
public void testDetectsAnInvalidKey() {
AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider("qwerty");

View File

@@ -37,8 +37,6 @@ public class AnonymousAuthenticationTokenTests {
private final static List<GrantedAuthority> ROLES_12 = AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO");
// ~ Methods
// ========================================================================================================
@Test
public void testConstructorRejectsNulls() {
try {

View File

@@ -70,8 +70,6 @@ public class DaoAuthenticationProviderTests {
private static final List<GrantedAuthority> ROLES_12 = AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO");
// ~ Methods
// ========================================================================================================
@Test
public void testAuthenticateFailsForIncorrectPasswordCase() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "KOala");
@@ -684,9 +682,6 @@ public class DaoAuthenticationProviderTests {
verify(encoder, times(0)).matches(anyString(), anyString());
}
// ~ Inner Classes
// ==================================================================================================
private class MockUserDetailsServiceReturnsNull implements UserDetailsService {
public UserDetails loadUserByUsername(String username) {

View File

@@ -32,9 +32,6 @@ import org.springframework.security.core.AuthenticationException;
*/
public class AuthenticationEventTests {
// ~ Methods
// ========================================================================================================
private Authentication getAuthentication() {
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken("Principal",
"Credentials");

View File

@@ -28,9 +28,6 @@ import org.springframework.security.core.Authentication;
*/
public class LoggerListenerTests {
// ~ Methods
// ========================================================================================================
private Authentication getAuthentication() {
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken("Principal",
"Credentials");

View File

@@ -52,18 +52,12 @@ import org.springframework.security.core.session.SessionDestroyedEvent;
*/
public class JaasAuthenticationProviderTests {
// ~ Instance fields
// ================================================================================================
private ApplicationContext context;
private JaasAuthenticationProvider jaasProvider;
private JaasEventCheck eventCheck;
// ~ Methods
// ========================================================================================================
@Before
public void setUp() {
String resName = "/" + getClass().getName().replace('.', '/') + ".xml";
@@ -284,9 +278,6 @@ public class JaasAuthenticationProviderTests {
.isNull();
}
// ~ Inner Classes
// ==================================================================================================
private static class MockLoginContext extends LoginContext {
boolean loggedOut = false;

View File

@@ -26,16 +26,10 @@ import org.springframework.security.authentication.jaas.event.JaasAuthentication
*/
public class JaasEventCheck implements ApplicationListener<JaasAuthenticationEvent> {
// ~ Instance fields
// ================================================================================================
JaasAuthenticationFailedEvent failedEvent;
JaasAuthenticationSuccessEvent successEvent;
// ~ Methods
// ========================================================================================================
public void onApplicationEvent(JaasAuthenticationEvent event) {
if (event instanceof JaasAuthenticationFailedEvent) {
failedEvent = (JaasAuthenticationFailedEvent) event;

View File

@@ -40,9 +40,6 @@ import static org.assertj.core.api.Assertions.fail;
*/
public class SecurityContextLoginModuleTests {
// ~ Instance fields
// ================================================================================================
private SecurityContextLoginModule module = null;
private Subject subject = new Subject(false, new HashSet<>(), new HashSet<>(), new HashSet<>());
@@ -50,9 +47,6 @@ public class SecurityContextLoginModuleTests {
private UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("principal",
"credentials");
// ~ Methods
// ========================================================================================================
@Before
public void setUp() {
this.module = new SecurityContextLoginModule();

View File

@@ -28,9 +28,6 @@ import org.springframework.security.authentication.jaas.AuthorityGranter;
*/
public class TestAuthorityGranter implements AuthorityGranter {
// ~ Methods
// ========================================================================================================
public Set<String> grant(Principal principal) {
Set<String> rtnSet = new HashSet<>();

View File

@@ -29,9 +29,6 @@ import javax.security.auth.callback.TextInputCallback;
*/
public class TestCallbackHandler implements JaasAuthenticationCallbackHandler {
// ~ Methods
// ========================================================================================================
public void handle(Callback callback, Authentication auth) {
if (callback instanceof TextInputCallback) {
TextInputCallback tic = (TextInputCallback) callback;

View File

@@ -28,18 +28,12 @@ import javax.security.auth.spi.LoginModule;
*/
public class TestLoginModule implements LoginModule {
// ~ Instance fields
// ================================================================================================
private String password;
private String user;
private Subject subject;
// ~ Methods
// ========================================================================================================
public boolean abort() {
return true;
}

View File

@@ -32,9 +32,6 @@ import org.springframework.security.core.Authentication;
*/
public class RemoteAuthenticationManagerImplTests {
// ~ Methods
// ========================================================================================================
@Test(expected = RemoteAuthenticationException.class)
public void testFailedAuthenticationReturnsRemoteAuthenticationException() {
RemoteAuthenticationManagerImpl manager = new RemoteAuthenticationManagerImpl();

View File

@@ -35,9 +35,6 @@ import static org.assertj.core.api.Assertions.fail;
*/
public class RemoteAuthenticationProviderTests {
// ~ Methods
// ========================================================================================================
@Test
public void testExceptionsGetPassedBackToCaller() {
RemoteAuthenticationProvider provider = new RemoteAuthenticationProvider();
@@ -107,9 +104,6 @@ public class RemoteAuthenticationProviderTests {
assertThat(provider.supports(UsernamePasswordAuthenticationToken.class)).isTrue();
}
// ~ Inner Classes
// ==================================================================================================
private class MockRemoteAuthenticationManager implements RemoteAuthenticationManager {
private boolean grantAccess;

View File

@@ -35,8 +35,6 @@ import static org.assertj.core.api.Assertions.fail;
*/
public class RememberMeAuthenticationProviderTests {
// ~ Methods
// ========================================================================================================
@Test
public void testDetectsAnInvalidKey() {
RememberMeAuthenticationProvider aap = new RememberMeAuthenticationProvider("qwerty");

View File

@@ -36,8 +36,6 @@ public class RememberMeAuthenticationTokenTests {
private static final List<GrantedAuthority> ROLES_12 = AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO");
// ~ Methods
// ========================================================================================================
@Test
public void testConstructorRejectsNulls() {
try {

View File

@@ -29,8 +29,6 @@ import org.springframework.context.support.MessageSourceAccessor;
*/
public class SpringSecurityMessageSourceTests {
// ~ Methods
// ========================================================================================================
@Test
public void testOperation() {
SpringSecurityMessageSource msgs = new SpringSecurityMessageSource();

View File

@@ -30,8 +30,6 @@ import org.springframework.security.core.context.SecurityContextImpl;
*/
public class SecurityContextHolderTests {
// ~ Methods
// ========================================================================================================
@Before
public final void setUp() {
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);

View File

@@ -29,8 +29,6 @@ import org.springframework.security.core.Authentication;
*/
public class SecurityContextImplTests {
// ~ Methods
// ========================================================================================================
@Test
public void testEmptyObjectsAreEquals() {
SecurityContextImpl obj1 = new SecurityContextImpl();

View File

@@ -29,8 +29,6 @@ import org.junit.Test;
*/
public class SessionInformationTests {
// ~ Methods
// ========================================================================================================
@Test
public void testObject() throws Exception {
Object principal = "Some principal object";

View File

@@ -37,9 +37,6 @@ public class SessionRegistryImplTests {
private SessionRegistryImpl sessionRegistry;
// ~ Methods
// ========================================================================================================
@Before
public void setUp() {
sessionRegistry = new SessionRegistryImpl();

View File

@@ -39,9 +39,6 @@ public class UserTests {
private static final List<GrantedAuthority> ROLE_12 = AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO");
// ~ Methods
// ========================================================================================================
@Test
public void equalsReturnsTrueIfUsernamesAreTheSame() {
User user1 = new User("rod", "koala", true, true, true, true, ROLE_12);

View File

@@ -37,8 +37,6 @@ public class EhCacheBasedUserCacheTests {
private static CacheManager cacheManager;
// ~ Methods
// ========================================================================================================
@BeforeClass
public static void initCacheManaer() {
cacheManager = CacheManager.create();

View File

@@ -29,9 +29,6 @@ import org.springframework.security.core.userdetails.User;
*/
public class NullUserCacheTests {
// ~ Methods
// ========================================================================================================
private User getUser() {
return new User("john", "password", true, true, true, true,
AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));

View File

@@ -39,8 +39,6 @@ public class SpringCacheBasedUserCacheTests {
private static CacheManager cacheManager;
// ~ Methods
// ========================================================================================================
@BeforeClass
public static void initCacheManaer() {
cacheManager = new ConcurrentMapCacheManager();

View File

@@ -39,9 +39,6 @@ import static org.mockito.Mockito.verify;
*/
public class JdbcDaoImplTests {
// ~ Methods
// ========================================================================================================
private JdbcDaoImpl makePopulatedJdbcDao() {
JdbcDaoImpl dao = new JdbcDaoImpl();
dao.setDataSource(PopulatedDatabase.getDataSource());