-
Notifications
You must be signed in to change notification settings - Fork 165
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
#735 CheckedScalar #738
#735 CheckedScalar #738
Conversation
Codecov Report
@@ Coverage Diff @@
## master #738 +/- ##
============================================
+ Coverage 77.69% 83.09% +5.39%
- Complexity 1158 1261 +103
============================================
Files 222 225 +3
Lines 3349 3407 +58
Branches 191 195 +4
============================================
+ Hits 2602 2831 +229
+ Misses 700 529 -171
Partials 47 47
Continue to review full report at Codecov.
|
Job #738 is now in scope, role is |
@fabriciofx ping |
@fabriciofx/z this job was assigned to you 5 days ago. It will be taken away from you soon, unless you close it, see §8. Read this and this, please. |
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.
Just a comment about static method
* @param cderived Derived class | ||
* @return Integer Level | ||
*/ | ||
private static int calculateLevel(final Class<?> cderived, |
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.
@Vatavuk this static method can be (and should be) refactored to non-static and then both input parameters will be available via this
modifier.
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.
@proshin-roman Thx for the comment, fixed.
@fabriciofx/z this job was assigned to you 8 days ago. It will be taken away from you soon, unless you close it, see §8. Read this and this, please. |
The user @fabriciofx/z resigned from #738, please stop working. Reason for job resignation: It is older than 10 days, see §8 |
Resigned on delay, see §8: -15 points just awarded to @fabriciofx/z |
This pull request #738 is assigned to @neonailol/z, here is why; the budget is 15 minutes, see §4; please, read §27 and when you decide to accept the changes, inform @yegor256/z (the architect) right in this ticket; if you decide that this PR should not be accepted ever, also inform the architect; this blog post will help you understand what is expected from a code reviewer |
/** | ||
* Function that wraps exception. | ||
*/ | ||
private final Func<Exception, E> func; |
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.
@Vatavuk I believe wrapper
would be the name exactly explains the purpose of this field. But I know about "no -er" rule... Damn :) Still func
is not the best name. Could you try to find any better word?
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.
@proshin-roman I changed the name to wrapped
although there are many classes that use func
as a field variable name. For example: SolidScalar
, StickyScalar
, RetryScalar
...
* @return E Wrapped exception | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
private E wrappedException(final Exception exp) { |
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.
@Vatavuk I think the whole this logic about comparing exceptions is wrong and might lead to a problem: let's say I have this code
new CheckedScalar<Integer, IOException>(
new ScalarOf(1),
(ex) ->new IOException("New custom message", ex)
);
In case of IOException thrown in scalar, your logic will erase my error message, but I wouldn't expect this. So, I would suggest to not add this extra-logic and just throw what the function returns.
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.
@proshin-roman You are right. I introduced that logic because I was concerned about unnecessary boxing of exceptions but above example clearly reveals a side effect. I removed it.
@neonailol What do you think about the above comments/changes? |
/** | ||
* Function that wraps exception. | ||
*/ | ||
private final Func<Exception, E> wrapped; |
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.
@Vatavuk wrapped
is an object, that was wrapped, right? But we have an object that does this wrapping - wrapper
:) I'm 100% sure it should be wrapper. Do you think we can use wrapper
name?
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.
@proshin-roman I don't agree, I want to name my objects/variables by what they are not by what they do. This variable represents wrapped exception.
@neonailol Is this PR good to merge? |
@Vatavuk yes, all seems to be good |
@rultor good to merge |
@neonailol Thanks for your request. @yegor256 Please confirm this. |
@yegor256 @neonailol Maybe I've rushed this one a little. I am still concerned about unnecessary wrapping of identical type exceptions. I have an idea how to avoid this and still preserve error messages in the example above. Can I push a new commit? |
@neonailol Can you review the last commit. I apologize for the inconvenience but the solution occurred to me almost the same time you approved the changes. |
/** | ||
* Classes are not related. | ||
*/ | ||
private static final int NOT_RELATED = 999; |
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.
@Vatavuk why not Integer.MAX_VALUE
? Would be more logical.
/** | ||
* Classes are identical. | ||
*/ | ||
private static final int IDENTICAL = 0; |
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.
@Vatavuk I would remove this constant, it's not really helpful. Just use zero and MAX_VALUE.
@Vatavuk see above. In general, try to stay away from constants, they are indicators of wrong design. http://www.yegor256.com/2015/07/06/public-static-literals.html |
@yegor256 fixed. Thx for the link. |
final int level = new InheritanceLevel( | ||
exp.getClass(), wrapped.getClass() | ||
).value(); | ||
final int unrelated = 999; |
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.
@Vatavuk this should be replaced with MAX_VALUE too, I believe
@Vatavuk see above |
@yegor256 fixed |
@neonailol/z this job was assigned to you 6days ago. It will be taken away from you soon, unless you close it, see §8. Read this and this, please. |
@neonailol/z this job was assigned to you 6days ago. It will be taken away from you soon, unless you close it, see §8. Read this and this, please. |
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.
@rultor good to merge
@yegor256 ping |
@rultor merge |
@elenavolokhova/z please review this job completed by @neonailol/z, as in §30; the job will be fully closed and all payments will be made when the quality review is completed |
The job #738 is now out of scope |
@neonailol According to our Policy:
No issues were found by you in this case. |
@elenavolokhova i confirm |
@0crat quality bad |
Quality is low, no payment, see §31 |
Quality review completed: +8 point(s) just awarded to @elenavolokhova/z |
See #735
CheckedScalar
introduced