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

#735 CheckedScalar #738

Merged
merged 7 commits into from
Apr 2, 2018
Merged

#735 CheckedScalar #738

merged 7 commits into from
Apr 2, 2018

Conversation

Vatavuk
Copy link
Contributor

@Vatavuk Vatavuk commented Mar 13, 2018

See #735 CheckedScalar introduced

@codecov-io
Copy link

codecov-io commented Mar 13, 2018

Codecov Report

Merging #738 into master will increase coverage by 5.39%.
The diff coverage is 97.5%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ Complexity Δ
...main/java/org/cactoos/scalar/InheritanceLevel.java 100% <100%> (ø) 6 <6> (?)
...rc/main/java/org/cactoos/scalar/CheckedScalar.java 95.45% <95.45%> (ø) 6 <6> (?)
src/main/java/org/cactoos/iterable/RangeOf.java 81.81% <0%> (ø) 1% <0%> (ø) ⬇️
...n/java/org/cactoos/matchers/TeeInputHasResult.java 100% <0%> (ø) 6% <0%> (?)
src/main/java/org/cactoos/io/BytesOf.java 94.2% <0%> (+2.89%) 29% <0%> (+1%) ⬆️
src/main/java/org/cactoos/io/InputOf.java 90% <0%> (+3.33%) 29% <0%> (+1%) ⬆️
...main/java/org/cactoos/io/WriterAsOutputStream.java 84% <0%> (+4%) 11% <0%> (+1%) ⬆️
src/main/java/org/cactoos/io/ReaderAsBytes.java 100% <0%> (+8.33%) 8% <0%> (+1%) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c5554b...258af34. Read the comment docs.

@0crat 0crat added the scope label Mar 14, 2018
@0crat
Copy link
Collaborator

0crat commented Mar 14, 2018

Job #738 is now in scope, role is REV

@0crat
Copy link
Collaborator

0crat commented Mar 14, 2018

This pull request #738 is assigned to @fabriciofx/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.

@Vatavuk
Copy link
Contributor Author

Vatavuk commented Mar 18, 2018

@fabriciofx ping

@0crat
Copy link
Collaborator

0crat commented Mar 19, 2018

@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.

@Vatavuk Vatavuk mentioned this pull request Mar 20, 2018
Copy link
Contributor

@proshin-roman proshin-roman left a 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,
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@0crat
Copy link
Collaborator

0crat commented Mar 22, 2018

@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.

@0crat
Copy link
Collaborator

0crat commented Mar 24, 2018

The user @fabriciofx/z resigned from #738, please stop working. Reason for job resignation: It is older than 10 days, see §8

@0crat
Copy link
Collaborator

0crat commented Mar 24, 2018

Resigned on delay, see §8: -15 points just awarded to @fabriciofx/z

@0crat
Copy link
Collaborator

0crat commented Mar 24, 2018

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;
Copy link
Contributor

@proshin-roman proshin-roman Mar 25, 2018

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?

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

@Vatavuk Vatavuk Mar 25, 2018

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.

@Vatavuk
Copy link
Contributor Author

Vatavuk commented Mar 25, 2018

@neonailol What do you think about the above comments/changes?

/**
* Function that wraps exception.
*/
private final Func<Exception, E> wrapped;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@Vatavuk
Copy link
Contributor Author

Vatavuk commented Mar 27, 2018

@neonailol Is this PR good to merge?

@neonailol
Copy link
Contributor

@Vatavuk yes, all seems to be good

@neonailol
Copy link
Contributor

@rultor good to merge

@rultor
Copy link
Collaborator

rultor commented Mar 27, 2018

@rultor good to merge

@neonailol Thanks for your request. @yegor256 Please confirm this.

@Vatavuk
Copy link
Contributor Author

Vatavuk commented Mar 27, 2018

@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?

@Vatavuk
Copy link
Contributor Author

Vatavuk commented Mar 28, 2018

@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;
Copy link
Owner

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;
Copy link
Owner

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.

@yegor256
Copy link
Owner

@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

@Vatavuk
Copy link
Contributor Author

Vatavuk commented Mar 30, 2018

@yegor256 fixed. Thx for the link.

final int level = new InheritanceLevel(
exp.getClass(), wrapped.getClass()
).value();
final int unrelated = 999;
Copy link
Owner

@yegor256 yegor256 Mar 30, 2018

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

@yegor256
Copy link
Owner

@Vatavuk see above

@Vatavuk
Copy link
Contributor Author

Vatavuk commented Mar 30, 2018

@yegor256 fixed

@0crat
Copy link
Collaborator

0crat commented Mar 30, 2018

@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.

@0crat
Copy link
Collaborator

0crat commented Mar 30, 2018

@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.

Copy link
Contributor

@neonailol neonailol left a 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

@Vatavuk
Copy link
Contributor Author

Vatavuk commented Mar 31, 2018

@yegor256 ping

@yegor256
Copy link
Owner

yegor256 commented Apr 2, 2018

@rultor merge

@rultor
Copy link
Collaborator

rultor commented Apr 2, 2018

@rultor merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 258af34 into yegor256:master Apr 2, 2018
@rultor
Copy link
Collaborator

rultor commented Apr 2, 2018

@rultor merge

@yegor256 Done! FYI, the full log is here (took me 9min)

@0crat
Copy link
Collaborator

0crat commented Apr 2, 2018

@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

@0crat 0crat removed the scope label Apr 2, 2018
@0crat
Copy link
Collaborator

0crat commented Apr 2, 2018

The job #738 is now out of scope

@0crat
Copy link
Collaborator

0crat commented Apr 2, 2018

Payment to ARC for a closed pull request, as in §28: +10 point(s) just awarded to @yegor256/z

@Vatavuk Vatavuk deleted the 735 branch April 2, 2018 19:10
@elenavolokhova
Copy link

@neonailol According to our Policy:

The code reviewer found at least three problems in the code

No issues were found by you in this case.
Please, confirm that you will try to find at least three problems next time.

@neonailol
Copy link
Contributor

@elenavolokhova i confirm

@elenavolokhova
Copy link

@0crat quality bad

@0crat
Copy link
Collaborator

0crat commented Apr 3, 2018

Quality is low, no payment, see §31

@0crat
Copy link
Collaborator

0crat commented Apr 3, 2018

Quality review completed: +8 point(s) just awarded to @elenavolokhova/z

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.

8 participants