8000 refactor: extract and move comment formatting logic to util by emmileaf · Pull Request #1089 · googleapis/sdk-platform-java · GitHub
[go: up one dir, main page]

Skip to content

refactor: extract and move comment formatting logic to util # 8000 1089

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 10 commits into from
Nov 21, 2022

Conversation

emmileaf
Copy link
Contributor
@emmileaf emmileaf commented Nov 7, 2022

Both ClientLibraryPackageInfoComposer and ServiceClientCommentComposer currently have additional parsing logic to convert protobuf comments to a Javadoc-compatible format. For example, this handles bulleted list items with asterisks in secret manager service proto.

This PR extracts common logic to an util class, and exposes it for reuse by Spring Codegen.

[Update] Additional test-related changes from addressing code coverage:

  • Added description for echo service explicitly in TestProtoLoader since it is not parsed from source code location as an end-to-end call would
    • This allows the existing ServiceClientClassTest to cover class header comments that are also formatted with the util’s logic
  • Added ClientLibraryPackageInfoComposerTest as a golden-updating test

@emmileaf emmileaf marked this pull request as ready for review November 8, 2022 16:06
@emmileaf emmileaf requested review from a team as code owners November 8, 2022 16:06
Copy link
Contributor
@diegomarquezp diegomarquezp left a comment

Choose a reason for hiding this comment

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

LGTM - nice cleanup!

Copy link
Collaborator
@blakeli0 blakeli0 left a comment

Choose a reason for hiding this comment

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

Please resolve the comments

@emmileaf
Copy link
Contributor Author
emmileaf commented Nov 9, 2022

Regarding the code coverage:

The use of this logic/util method in the two composers is covered by the integration tests (e.g. redis golden file). Sonar is unhappy with coverage because the existing composer unit tests (e.g. through ServiceClientClassComposerTest) do not hit any of this logic - it only applies when services or methods have a .description() field, which showcase services do not.

Todo: will need to look more into how Parser gets descriptions for services and methods to see if unit test resources can be updated to cover comment parsing in existing Composer tests, or if this behavior needs to be separately mocked.

@sonarqubecloud
Copy link
sonarqubecloud bot commented Nov 9, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

86.0% 86.0% Coverage
0.0% 0.0% Duplication

@emmileaf
Copy link
Contributor Author
emmileaf commented Nov 9, 2022

Some additional test-related changes from addressing code coverage:

  • Added description for echo service explicitly in TestProtoLoader since it is not parsed from source code location as an end-to-end call would
    • This allows the existing ServiceClientClassTest to cover class header comments that are also formatted with the util’s logic
  • Added ClientLibraryPackageInfoComposerTest as a golden-updating test

@emmileaf emmileaf merged commit 52a2dd0 into main Nov 21, 2022
@emmileaf emmileaf deleted the refactor-comment-formatter branch November 21, 2022 15:07
emmileaf added a commit that referenced this pull request Nov 30, 2022
* Extracts common logic to an util class, and exposes it for reuse
* Adds description for echo service explicitly in TestProtoLoader since it is not parsed from source code location as an end-to-end call would (this allows the existing ServiceClientClassTest to cover class header comments that are also formatted with the util’s logic)
* Adds ClientLibraryPackageInfoComposerTest as a golden-updating test
suztomo pushed a commit that referenced this pull request Dec 16, 2022
* Extracts common logic to an util class, and exposes it for reuse
* Adds description for echo service explicitly in TestProtoLoader since it is not parsed from source code location as an end-to-end call would (this allows the existing ServiceClientClassTest to cover class header comments that are also formatted with the util’s logic)
* Adds ClientLibraryPackageInfoComposerTest as a golden-updating test
suztomo pushed a commit that referenced this pull request Mar 21, 2023
🤖 I have created a release *beep* *boop*
---


### Updating meta-information for bleeding-edge SNAPSHOT release.

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
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.

5 participants
0