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

(#227) Refactor setting schema reference attribute #326

Merged
merged 1 commit into from
May 1, 2019
Merged

Conversation

gsnoff
Copy link
Contributor

@gsnoff gsnoff commented Apr 27, 2019

As per #227:

Refactored the addition of xsi:noNamespaceSchemaLocation to generated metric.xml into applying a few Xembly instructions instead of an XSL transformation.

Three instructions were eventually needed—one to point the cursor to the metric element (since it points above the root element by default), one to declare the XML namespace of the schema location attribute, and one to set the location itself.

@0crat
Copy link
Collaborator

0crat commented Apr 27, 2019

Job #326 is now in scope, role is REV

@codecov-io
Copy link

codecov-io commented Apr 27, 2019

Codecov Report

Merging #326 into master will increase coverage by 0.2%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #326     +/-   ##
===========================================
+ Coverage     75.58%   75.79%   +0.2%     
  Complexity      184      184             
===========================================
  Files            34       34             
  Lines          1102     1099      -3     
  Branches         88       87      -1     
===========================================
  Hits            833      833             
+ Misses          238      236      -2     
+ Partials         31       30      -1
Impacted Files Coverage Δ Complexity Δ
src/main/java/org/jpeek/Report.java 100% <100%> (+6.66%) 6 <1> (ø) ⬇️

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 c3d214e...b753f7f. Read the comment docs.

@0crat
Copy link
Collaborator

0crat commented Apr 27, 2019

This pull request #326 is assigned to @ilyakharlamov/z, here is why; the budget is 15 minutes, see §4; please, read §27 and when you decide to accept the changes, inform @paulodamaso/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; there will be no monetary reward for this job

this.params
).transform(this.skeleton);
return new XMLDocument(
new Xembler(
Copy link
Contributor

Choose a reason for hiding this comment

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

In this class, sometimes resources are accessed viathis.getClass().getResource() sometimes via Report.class.getResource(). Need to decide which way you want to use and stick to it, so it would be uniform across the whole class (either one way or another).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ilyakharlamov Fixed. Turns out the this.getClass() form isn’t used anywhere else in the project.

Sources.DUMMY,
this.params
).transform(this.skeleton).node()
)
Copy link
Contributor

Choose a reason for hiding this comment

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

If we replace that with just applyQuietly( new XSLDocument( this.getClass().getResourceAsStream(name) ).transform(this.skeleton).node() ) all the unit test pass just fine. This means that either this.params is not needed or isn't tested. So we need to either remove this.params at all, or add a unit test that checks whether those params really work.

Copy link
Contributor Author

@gsnoff gsnoff Apr 28, 2019

Choose a reason for hiding this comment

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

@ilyakharlamov Currently only C3.xsl and OCC.xsl metric templates in src/main/resources/org/jpeek/metrics have a <xsl:param/> tag defining a parameter labeled ctors, and it seems that OCC.xsl doesn’t even use the parameter. C3.xsl is a work in progress, see #175.

Maybe leave a puzzle here or in ReportTest.java describing the impediment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ilyakharlamov FYI, added the puzzle.

* 'metric.xsd' in the generated 'metric.xml' is too complex for
* the task at hand. Refactor towards a simpler solution that
* ideally would just require one or two Xembly instructions to
* add the required attribute.
*/
@SuppressWarnings("unchecked")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a need for @SuppressWarnings("unchecked") here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gsnoff
Copy link
Contributor Author

gsnoff commented Apr 28, 2019

@ilyakharlamov Please see my comments in the review above.

)
).applyQuietly(
new XSLDocument(
new TextOf(res).asString(),
Copy link
Contributor

@ilyakharlamov ilyakharlamov Apr 28, 2019

Choose a reason for hiding this comment

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

Replace that with OO: new TextOf( new ResourceOf( new FormattedText( "org/jpeek/metrics/%s.xsl", this.metric ) ) ).asString(), , everything above, all those ifs, can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@ilyakharlamov ilyakharlamov left a comment

Choose a reason for hiding this comment

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

  1. Make the OO change inxml() above
  2. Rebase so that commit history looks nice, clean and atomic

Also apply stylistic fixes suggested in reviews to the pull request.
@gsnoff
Copy link
Contributor Author

gsnoff commented Apr 28, 2019

@ilyakharlamov

1. Make the OO change in`xml()` above

2. Rebase so that commit history looks nice, clean and atomic

Done.

@ilyakharlamov
Copy link
Contributor

@paulodamaso good to merge

@gsnoff
Copy link
Contributor Author

gsnoff commented Apr 29, 2019

@ilyakharlamov There also might be a possible optimization of putting the Xembler object into a static field, since all created Xembler instances used by the xml() method are identical. Not sure how this would align with coding conventions here…

@ilyakharlamov
Copy link
Contributor

@Protagores there are many, dozens or even hundreds of performance optimizations are possible here but sometimes it can make the code less readable, harder to test, etc. So quite often, when choosing between the performance and reliability, you can only pick one or another but not both. Those projects focus on OO and clarity, not performance as you may notice. That's a topic for another conversation.

@paulodamaso
Copy link
Collaborator

@Protagores and @ilyakharlamov , thanks for the solution and the discussion above!

@paulodamaso
Copy link
Collaborator

@rultor merge

@rultor
Copy link
Collaborator

rultor commented May 1, 2019

@rultor merge

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

@rultor rultor merged commit b753f7f into cqfn:master May 1, 2019
@rultor
Copy link
Collaborator

rultor commented May 1, 2019

@rultor merge

@paulodamaso Done! FYI, the full log is here (took me 15min)

@0crat
Copy link
Collaborator

0crat commented May 1, 2019

@fabriciofx/z please review this job completed by @ilyakharlamov/z, as in §30; the job will be fully closed and all payments will be made when the quality review is completed

@0crat
Copy link
Collaborator

0crat commented May 1, 2019

The job #326 is now out of scope

@0crat
Copy link
Collaborator

0crat commented May 1, 2019

Job #326 is not in the agenda of @ilyakharlamov/z, can't inspect

@0crat 0crat removed the scope label May 1, 2019
@0crat
Copy link
Collaborator

0crat commented May 1, 2019

There is an unrecoverable failure on my side. Please, submit it here:

PID: 4@3fa7eecc-23cb-48b5-bb3b-959c05894b2d, thread: pool-5-thread-3
com.amazonaws.http.AmazonHttpClient$RequestExecutor[1638] com.amazonaws.services.sqs.model.AmazonSQSException: We encountered an internal error. Please try again. (Service: AmazonSQS; Status Code: 500; Error Code: InternalError; Request ID: 6a897573-f711-5355-86d2-2037df1eb096)

0.46.9: CID: 58e30012-eadf-4966-8c10-c17b3c524e44, Type: "Make payment"

@0crat
Copy link
Collaborator

0crat commented May 1, 2019

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

@fabriciofx
Copy link

@0crat quality acceptable

@0crat
Copy link
Collaborator

0crat commented Jun 21, 2019

Order was finished, quality is "acceptable": +15 point(s) just awarded to @ilyakharlamov/z

@0crat
Copy link
Collaborator

0crat commented Jun 21, 2019

Quality review completed: +4 point(s) just awarded to @fabriciofx/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