chore(grails-data-graphql): root-level cleanup (GraphQLEntityHelper, GraphQLServiceManager, Schema) - #16207
Open
borinquenkid wants to merge 3 commits into
Open
Conversation
mapping was declared null then conditionally reassigned across four if/else-if branches before being read - the same shape flagged elsewhere in this cleanup as a false "assignment is not used" warning once IntelliJ's flow analysis loses track of a variable reassigned across many branches. Extracted the reflection lookup (findGraphqlProperty), the graphql-value-to-GraphQLMapping conversion (toGraphQLMapping, with each branch returning directly), and the overall build/verify sequence (buildMapping) into their own methods, so getMapping itself is now a single containsKey-check plus a single build+cache assignment. Added direct unit coverage for getMapping via a Stub(PersistentEntity) (no static graphql property, a Boolean true, an unsupported property type that should throw IllegalMappingException, and cache identity across repeated calls) - previously it was only exercised indirectly through getDescription and other specs' Closure-based mappings. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Groovy methods are public by default; the explicit modifier was redundant. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
When no entity contributes any query fields, the method fell off the end without a return statement instead of explicitly returning null. Behavior is unchanged (Groovy allows the implicit null under CompileStatic), but the fall-through was ambiguous to both the reader and the compiler's control-flow analysis. Already covered by DisableAllOpSpec, which asserts generate() returns null when every entity's operations are disabled. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 task
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## test/grails-data-graphql-coverage #16207 +/- ##
======================================================================
Coverage ? 53.4210%
Complexity ? 19464
======================================================================
Files ? 2081
Lines ? 98993
Branches ? 17361
======================================================================
Hits ? 52883
Misses ? 38561
Partials ? 7549 🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: cc285e7 Learn more about TestLens at testlens.app/docs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #16201. Three small root-package fixes:
GraphQLEntityHelper#getMapping: consolidated a four-branch reassignment ofmappinginto single-return helper methods (findGraphqlProperty,toGraphQLMapping,buildMapping), fixing a false "assignment is not used" flag. Added direct unit coverage (previously only exercised indirectly viagetDescription).GraphQLServiceManager#getService: removed a redundantpublicmodifier (Groovy methods are public by default).Schema#generate(): made the implicitnullreturn explicit when no entity contributes any query fields, satisfying "not all execution paths return a value" with no behavior change (already covered byDisableAllOpSpec).Test plan
./gradlew :grails-data-graphql-core:test :grails-data-graphql:test :grails-data-graphql-core:codeStyle :grails-data-graphql:codeStylepasses🤖 Generated with Claude Code