-
Notifications
You must be signed in to change notification settings - Fork 4
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
add ctor specialization #23
Conversation
@yegor256 PR is ready for review |
@volodya-lombrozo please, help me review this |
@advasileva eoc 0.11.1 should work just fine |
@yegor256 updated eoc to the latest version, it works, thanks) |
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.
@advasileva Several suggestions:
- Try to inline variables as much as possible. Article
- The PR is quite large. I believe It would be great to send that changes at least in 2 separate PRs: (1) for
2-1-to-objects
and (2)2-2-calls-replacement
. - You test both transformations at once in a single test, It would be great to have separate unit tests for each transformation. Unit tests actually help to understand the code behaviour in different cases and improve overall architecture.
Makefile
Outdated
mvn clean install -Dmaven.test.skip -Pqulice | ||
cp target/speco-1.0-SNAPSHOT-jar-with-dependencies.jar speco.jar | ||
|
||
lint: ##@Dev Rebuild app without linting and tests |
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.
@advasileva Is it allowed to have several targets with the same name lint
?
https://stackoverflow.com/questions/43718595/two-targets-with-the-same-name-in-a-makefile
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.
@volodya-lombrozo In this case, it is a "copy-paste" error
@ParameterizedTest | ||
@ValueSource(strings = {"simple"}) | ||
public void convertsFromXmir(final String name, @TempDir final Path temp) throws IOException { | ||
final Path output = this.runSpeco(this.xmirs.resolve(name), temp, false); |
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.
@advasileva You can inline that variable
for (final Path path : Files.newDirectoryStream(output)) { | ||
@ParameterizedTest | ||
@ValueSource(strings = {"booms", "pets"}) | ||
public void convertsFromEo(final String name, @TempDir final Path temp) throws IOException { |
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.
@advasileva Probably you can inline output
and produced
variables.
Please read this article: https://www.yegor256.com/2015/09/01/redundant-variables-are-evil.html
* @param second Directory | ||
* @throws IOException Iff IO error | ||
*/ | ||
private void compare(final Path first, final Path second) throws IOException { |
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.
@advasileva You can inline variables here too
} else { | ||
base = this.xmirs; | ||
} | ||
private Path runSpeco(final Path base, final Path temp, final boolean iseo) throws IOException { |
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.
@advasileva The method could be static
.
Probably we can also inline some variables here.
* @param second Directory | ||
* @throws IOException Iff IO error | ||
*/ | ||
private void compare(final Path first, final Path second) throws IOException { |
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.
@advasileva The method could be static
} | ||
|
||
/** | ||
* Compares two directpries. |
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.
@advasileva Typo
* | ||
* @param first Directory | ||
* @param second Directory | ||
* @throws IOException Iff IO error |
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.
@advasileva Did you mean "If"?
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.
@volodya-lombrozo no, this is an abbreviation of "if and only if"
* @param second Directory | ||
* @throws IOException Iff IO error | ||
*/ | ||
private void compare(final Path first, final Path second) throws IOException { |
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.
@advasileva Please, give more meaningful names for that variables. It's hard to understand their purpose. You can also add some information to JavaDoc
@volodya-lombrozo I didn't catch point 2, is it better for me now to create two (or three with a separate PR for tests) branches, transfer changes there, and then make edits? Or first make edits to this PR, and then create new PRs? |
@advasileva You can leave as is - it's for the future. As for tests - too, you can just create "@todo Write separate unit test". |
@volodya-lombrozo okay, a good opportunity to try pdd) At first I thought of splitting it into several parts when I was writing #22, but I didn't do that so that no one would have to review and edit a lot of intermediate code. |
f5d2bfb
to
cb7b817
Compare
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.
@advasileva Good. Few small comments
final StringWriter writer = new StringWriter(); | ||
IOUtils.copy(process.getInputStream(), writer); | ||
final String[] output = writer.toString().split("\\r?\\n"); | ||
final String[] result = Arrays.copyOfRange(output, 11, output.length - 1); | ||
return Arrays.asList(result); | ||
return Arrays.asList(Arrays.copyOfRange(output, 11, output.length - 1)); |
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.
@advasileva Why exactly 11
?
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.
@advasileva (Optional) If you want, you can use cactoos
classes instead - they are more convenient, as to me:
new Split(new TextOf(process.getInputStream(), "\\r?\\n");
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.
@volodya-lombrozo 11
is a magic number that I counted myself. That's how many lines the eoc
output takes up until the program output itself. As far as I know, this is the output only for eoc link
and I can read the program output only for eoc --alone dataize app
.
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.
@advasileva It's better to add such description of magic
numbers into JavaDoc.
@@ -90,8 +90,7 @@ public void exec() throws IOException { | |||
source = this.input; | |||
} | |||
for (final Path path : Files.newDirectoryStream(source)) { | |||
final XML before; | |||
before = Speco.getParsedXml(new XMLDocument(Files.readString(path))); | |||
final XML before = Speco.getParsedXml(new XMLDocument(Files.readString(path))); | |||
final String after; | |||
if (this.eolang) { | |||
after = new XMIR( |
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.
@advasileva You have code duplication here Speco.applyTrain(before).toString()
, apparently you can move that upper
.github/workflows/xcop.yml
Outdated
@@ -1,15 +0,0 @@ | |||
--- | |||
name: xcop |
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.
@advasileva We fixed problem with xcop
. g4s8/xcop-action#4
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.
@volodya-lombrozo It's still redundant (because it is checked in the maven build), but let it be
|
||
/** | ||
* Test to test the operation of the command line tool. | ||
* | ||
* @since 0.0.1 | ||
* @todo #22:90min add separate unit-test for each transformation, | ||
* which would run step by step and check the intermediate results, |
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.
@advasileva Can we add single indent for @todo
description?
* @todo #22:90min add separate unit-test for each transformation,
* which would run step by step and check the intermediate results,
* for example, use yml packs as in dejump.
this helps to highlight the text of the task
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.
@advasileva Looks good to me
@yegor256 can we try to merge it? |
@rultor merge |
Implementation of #22
Test case
Now the following test passes:
transforms to
and outputs
Limitation: works correctly only for objects with one free attribute.
Dev solutions
xcop
action was deleted because it docker build fails in the workflow andxcop
are already runs in the maven build.eoc
old version0.10.0
is used because the latest release0.10.1
fails on windows (I can add an issue, but there are already failed GHA there).