Skip to content

Enabling checkstyle for test and integration test folders #3631

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

Merged
merged 3 commits into from
Dec 16, 2022

Conversation

cenedhryn
Copy link
Contributor

@cenedhryn cenedhryn commented Dec 15, 2022

…and adds a check to prohibit the @ignore annotation

Motivation and Context

Using the @Ignore annotation in the code base mostly leads to stale code that we don't resolve. It's also led to bugs in a couple of instances. By adding a checkstyle rule to stop coders from using @Ignore, the intent is to create a mechanism through which we resolve ambiguous issues promptly by removing tests or taking other actions when testing.

Modifications

Testing

Tested locally.

Finding annotations

Example test run: Adding one @ignore annotation at class level and and one at test method level for two tests in the auth module, one in the integration test folder it and one in the standard test folder test.

➜  aws-sdk-java-v2 git:(salande/detect-disabled-tests) ✗ mvn checkstyle:check -pl :auth          
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------< software.amazon.awssdk:auth >---------------------
[INFO] Building AWS Java SDK :: Auth 2.18.40-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-checkstyle-plugin:3.1.2:check (default-cli) @ auth ---
[INFO] Starting audit...
[ERROR] aws-sdk-java-v2/core/auth/src/test/java/software/amazon/awssdk/auth/signer/AbstractAws4SignerTest.java:24:1: @Ignore annotation is not allowed [NoIgnoreAnnotations]
[ERROR] aws-sdk-java-v2/core/auth/src/test/java/software/amazon/awssdk/auth/signer/AbstractAws4SignerTest.java:27:5: @Ignore annotation is not allowed [NoIgnoreAnnotations]
[ERROR] aws-sdk-java-v2/core/auth/src/it/java/software/amazon/awssdk/auth/credentials/InstanceProfileCredentialsProviderIntegrationTest.java:32:1: @Ignore annotation is not allowed [NoIgnoreAnnotations]
[ERROR] aws-sdk-java-v2/core/auth/src/it/java/software/amazon/awssdk/auth/credentials/InstanceProfileCredentialsProviderIntegrationTest.java:52:5: @Ignore annotation is not allowed [NoIgnoreAnnotations]
Audit done.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.956 s
[INFO] Finished at: 2022-12-15T09:49:50-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.2:check (default-cli) on project auth: Failed during checkstyle execution: There are 4 errors reported by Checkstyle 8.42 with software/amazon/awssdk/checkstyle.xml ruleset. -> [Help 1]

Running checks on the whole repo

Running just checkstyle, locally, takes 25s.

mvn checkstyle:check -pl !'build-tools' 
[INFO] AWS Java SDK :: Test :: Region Testing 2.18.40-SNAPSHOT SUCCESS [  0.054 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  24.868 s
[INFO] Finished at: 2022-12-15T10:34:06-08:00
[INFO] ------------------------------------------------------------------------

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@cenedhryn cenedhryn requested a review from a team as a code owner December 15, 2022 18:07
@cenedhryn cenedhryn changed the title Enabling checkstyle for test and integration test folders and adds a … Enabling checkstyle for test and integration test folders Dec 15, 2022
@cenedhryn cenedhryn force-pushed the salande/detect-disabled-tests branch from 316dc9c to 6f17f77 Compare December 15, 2022 19:57
Copy link
Contributor

@millems millems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this appreciably slow down the build?

@cenedhryn
Copy link
Contributor Author

Does this appreciably slow down the build?

No

@cenedhryn cenedhryn enabled auto-merge (squash) December 15, 2022 23:17
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@cenedhryn cenedhryn merged commit 6b985d4 into master Dec 16, 2022
@cenedhryn cenedhryn deleted the salande/detect-disabled-tests branch December 16, 2022 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants