Skip to content
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

refactor: Refactoring the Result Class #7176

Open
wants to merge 11 commits into
base: 2.x
Choose a base branch
from

Conversation

YongGoose
Copy link
Contributor

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

fixes #7158

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

Copy link

codecov bot commented Feb 22, 2025

Codecov Report

Attention: Patch coverage is 41.50943% with 31 lines in your changes missing coverage. Please review.

Project coverage is 52.13%. Comparing base (679a2e0) to head (c8d355a).
Report is 2 commits behind head on 2.x.

Files with missing lines Patch % Lines
...ache/seata/namingserver/manager/NamingManager.java 12.50% 14 Missing ⚠️
...eata/namingserver/controller/NamingController.java 30.00% 7 Missing ⚠️
...ata/server/controller/VGroupMappingController.java 0.00% 4 Missing ⚠️
...seata/server/console/impl/AbstractLockService.java 0.00% 2 Missing ⚠️
...che/seata/server/controller/ClusterController.java 0.00% 2 Missing ⚠️
...in/java/org/apache/seata/common/result/Result.java 50.00% 1 Missing ⚠️
...eata/namingserver/controller/HealthController.java 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #7176      +/-   ##
============================================
- Coverage     52.20%   52.13%   -0.07%     
- Complexity     6817     6864      +47     
============================================
  Files          1154     1169      +15     
  Lines         41116    41429     +313     
  Branches       4820     4848      +28     
============================================
+ Hits          21464    21601     +137     
- Misses        17611    17775     +164     
- Partials       2041     2053      +12     
Files with missing lines Coverage Δ
...main/java/org/apache/seata/common/result/Code.java 89.47% <100.00%> (ø)
...ava/org/apache/seata/common/result/PageResult.java 87.71% <100.00%> (ø)
...a/org/apache/seata/common/result/SingleResult.java 100.00% <100.00%> (+15.38%) ⬆️
...in/java/org/apache/seata/common/result/Result.java 77.77% <50.00%> (+24.44%) ⬆️
...eata/namingserver/controller/HealthController.java 50.00% <0.00%> (ø)
...seata/server/console/impl/AbstractLockService.java 9.09% <0.00%> (ø)
...che/seata/server/controller/ClusterController.java 8.88% <0.00%> (+0.19%) ⬆️
...ata/server/controller/VGroupMappingController.java 11.76% <0.00%> (+2.24%) ⬆️
...eata/namingserver/controller/NamingController.java 28.57% <30.00%> (-10.32%) ⬇️
...ache/seata/namingserver/manager/NamingManager.java 49.39% <12.50%> (-6.57%) ⬇️

... and 15 files with indirect coverage changes


public Result() {
this(SUCCESS.code, SUCCESS.msg);
Copy link
Member

Choose a reason for hiding this comment

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

An implicit success isn't a great design choice because it doesn't align with the conventional understanding of a zero value. If it needs to represent success, it's better to make it clear in the method name rather than assigning it to a default constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch :)
Done in 3b4370f !

@YongGoose YongGoose requested a review from slievrly February 23, 2025 00:42
Comment on lines -393 to +392
Result<String> res = createGroup(namespace, vGroup, clusterName, unitName);
SingleResult<Void> res = createGroup(namespace, vGroup, clusterName, unitName);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One of the refactorings I made was distinguishing between setting the message of Result as a String and making the generic type of Result a String—these are separate concerns.

I understand that there are many instances of this pattern in the code.
I plan to focus on refactoring this part as well.

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.

Refactoring: Refactoring the Result Class
3 participants