-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PSM-671 Introduce a check for test method names #6
Conversation
b59ddb3
to
3a08bc6
Compare
Tested against PSM and seems to work correctly ✅ diff git . --stat
id-support/src/test/java/tech/picnic/id/validators/UserIdTest.java | 2 +-
jooq-support/src/test/java/com/picnic/jooq/test/JooqPostgresTestContainerTest.java | 2 +-
mongodb-support/src/test/java/com/picnic/mongo/test/SpringMongoDBTestContainerTest.java | 8 ++++----
rest-support/src/test/java/com/picnic/rest/AbstractRxHttpClientTest.java | 2 +-
security-support/security-support-commons/src/test/java/tech/picnic/security/aspect/SystemRoleAnalyzerInvocationsTest.java | 2 +-
security-support/security-support-webflux/src/test/java/tech/picnic/security/webflux/SecurityContextPropagatorTest.java | 2 +-
security-support/security-support-webflux/src/test/java/tech/picnic/security/webflux/access/SecuredReactiveMethodInterceptorTest.java | 10 +++++-----
security-support/security-support-webflux/src/test/java/tech/picnic/security/webflux/auth/PicnicAuthenticationTokenTest.java | 2 +-
security-support/security-support-webflux/src/test/java/tech/picnic/security/webflux/auth/PicnicAuthoritiesManagerTest.java | 10 +++++-----
security-support/security-support-webflux/src/test/java/tech/picnic/security/webflux/authproxy/AuthProxyHeadersConverterTest.java | 2 +-
test-support/src/main/java/com/picnic/testing/AbstractArchitectureTest.java | 10 +++++-----
test-support/src/main/java/com/picnic/testing/AbstractMainApplicationTest.java | 4 ++--
webapp-support/webapp-support-webmvc/src/test/java/tech/picnic/webapp/webmvc/ContextForwardingScheduledThreadPoolExecutorTest.java | 4 ++--
13 files changed, 30 insertions(+), 30 deletions(-) |
710576d
to
86f7f2a
Compare
After the new changes, running again against PSM: diff git . --stat
general-components/src/test/java/com/picnic/validators/PicnicEmailValidatorTest.java | 2 +-
jooq-support/src/test/java/com/picnic/jooq/test/JooqPostgresTestContainerTest.java | 2 +-
logging-support/src/test/java/tech/picnic/logging/PasswordFilteringConverterTest.java | 2 +-
messaging-support/src/test/java/com/picnic/messaging/ChainableContentHandlerAdaptorTest.java | 2 +-
messaging-support/src/test/java/com/picnic/messaging/amqp/RabbitMQConsumerTest.java | 2 +-
messaging-support/src/test/java/com/picnic/messaging/amqp/RoutingTemplateTest.java | 2 +-
mongodb-support/src/test/java/com/picnic/mongo/test/SpringMongoDBTestContainerTest.java | 8 ++++----
rest-support/src/test/java/com/picnic/rest/AbstractRxHttpClientTest.java | 2 +-
scalyr-support/src/test/java/com/picnic/scalyr/ScalyrServiceIntegrationTest.java | 2 +-
security-support/security-support-webflux/src/test/java/tech/picnic/security/webflux/PicnicAuthenticationTest.java | 2 +-
security-support/security-support-webflux/src/test/java/tech/picnic/security/webflux/PicnicAuthorizationTest.java | 2 +-
security-support/security-support-webflux/src/test/java/tech/picnic/security/webflux/SecurityContextPropagatorTest.java | 2 +-
security-support/security-support-webflux/src/test/java/tech/picnic/security/webflux/access/SecuredReactiveMethodInterceptorTest.java | 10 +++++-----
security-support/security-support-webflux/src/test/java/tech/picnic/security/webflux/webhookkey/WebhookAuthenticationTest.java | 2 +-
slack-support/src/test/java/com/picnic/slack/client/SlackIntegrationTest.java | 2 +-
swagger-support/swagger-support-commons/src/test/java/com/picnic/swagger/SchemaGenerationTest.java | 2 +-
swagger-support/swagger-support-webflux/src/test/java/com/picnic/swagger/webflux/SwaggerWebFluxConfigTest.java | 2 +-
vault-support/src/test/java/com/picnic/vault/VaultPropertiesTest.java | 2 +-
webapp-support/webapp-support-webmvc/src/test/java/tech/picnic/webapp/webmvc/DateTimeRequestParamFormattingTest.java | 2 +-
webapp-support/webapp-support-webmvc/src/test/java/tech/picnic/webapp/webmvc/PicnicTraceLoggingInterceptorTest.java | 2 +-
webapp-support/webapp-support-webmvc/src/test/java/tech/picnic/webapp/webmvc/RxHttpClientContextPropagationTest.java | 2 +-
webapp-support/webapp-support-webmvc/src/test/java/tech/picnic/webapp/webmvc/SwaggerWebMvcConfigTest.java | 2 +-
webclient-support/webclient-support-agent/src/test/java/tech/picnic/webclient/WebClientAgentTest.java | 6 +++---
webclient-support/webclient-support-commons/src/test/java/tech/picnic/webclient/ErrorResponseFilterFunctionTest.java | 4 ++--
webclient-support/webclient-support-commons/src/test/java/tech/picnic/webclient/LoggingExchangeFilterFunctionTest.java | 2 +-
webclient-support/webclient-support-commons/src/test/java/tech/picnic/webclient/WebClientConfigTest.java | 2 +-
wiw-support/src/test/java/tech/picnic/wiw/WhenIWorkAuthTest.java | 2 +-
wiw-support/src/test/java/tech/picnic/wiw/WhenIWorkTest.java | 2 +-
28 files changed, 38 insertions(+), 38 deletions(-) |
86f7f2a
to
2440393
Compare
2440393
to
37208bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased and added a commit. Left a few XXX
comments in the code, but I think we can defer those. If you're okay with my changes I'll merge :)
...ne-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/JunitMethodDeclarationCheck.java
Outdated
Show resolved
Hide resolved
MethodSymbol sym = ASTHelpers.getSymbol(tree); | ||
|
||
if (sym == null | ||
|| OVERRIDE_ANNOTATION.matches(tree, state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we cater for this, should we also omit warnings for public methods in abstract classes?
annotations(AT_LEAST_ONE, isType("java.lang.Override")); | ||
|
||
@Override | ||
public Description matchMethod(MethodTree tree, VisitorState state) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not abstract
, we can also require the class to be package-private.
Actually we can require that none of the members of such a class are public, and the fields should be private.
Edit: but let's defer that to another PR.
...ne-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/JunitMethodDeclarationCheck.java
Outdated
Show resolved
Hide resolved
...ne-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/JunitMethodDeclarationCheck.java
Outdated
Show resolved
Hide resolved
...ne-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/JunitMethodDeclarationCheck.java
Outdated
Show resolved
Hide resolved
SuggestedFixes.removeModifiers(tree, state, ILLEGAL_MODIFIERS.toArray(Modifier[]::new)) | ||
.ifPresent(builder::merge); | ||
/* Remove the 'test' prefix, if possible. */ | ||
renameMethod(tree, state, sym.getQualifiedName().toString()).ifPresent(builder::merge); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it's unlikely to cause issues in practice, I guess it'd be more correct to only attempt this for actual test methods; will push a proposal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing: in theory this could cause a method name clash. Likely not worth the hassle of catering for this, but let's flag it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also thought about the case where the old method name is referred in a JavaDoc, but it doesn't seem to be easy to fix. Anyways, it'd cause a compilation error and it'd be easy to fix it by hand.
...ontrib/src/test/java/tech/picnic/errorprone/bugpatterns/JunitMethodDeclarationCheckTest.java
Outdated
Show resolved
Hide resolved
...ontrib/src/test/java/tech/picnic/errorprone/bugpatterns/JunitMethodDeclarationCheckTest.java
Outdated
Show resolved
Hide resolved
...ontrib/src/test/java/tech/picnic/errorprone/bugpatterns/JunitMethodDeclarationCheckTest.java
Outdated
Show resolved
Hide resolved
...ne-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/JUnitMethodDeclarationCheck.java
Outdated
Show resolved
Hide resolved
Thanks for your feedback @Stephan202 , your changes LGTM :). Added a small commit with some tweaks. |
Tnx! Will merge :) |
Extra information ℹ️