-
Notifications
You must be signed in to change notification settings - Fork 127
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
Enable jtcop #3113
Enable jtcop #3113
Conversation
@volodya-lombrozo could you check this one, 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.
@c71n93 Well done! Just a few suggestions.
@@ -71,7 +71,8 @@ void binarizesWithoutErrors(@TempDir final Path temp) throws Exception { | |||
.withProgram(BinarizeMojoTest.SRC.resolve("twice-rust.eo")); | |||
} | |||
Assertions.assertDoesNotThrow( | |||
() -> maven.execute(new FakeMaven.Binarize()) | |||
() -> maven.execute(new FakeMaven.Binarize()), | |||
"TO ADD ASSERTION MESSAGE" |
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.
@c71n93 I would suggest to create a single static field and to use it everywhere instead.
Something like is as follows:
/**
* Don't forget to add 'todo' puzzle to remove this field later
*/
public static final String TODO_MESSAGE = "TO ADD ASSERTION MESSAGE";
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.
(In this case you might need to suppress some checkstyle and PMD warnings)
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 I think it is better to keep repeating message where it is allowed. The advantages of this is that you will not need to think about deleting unused field when meaningful messages will be added. And I don't see any disadvantages.
We already have a check for this, and this check prohibits more than 5 repetitions of the same values (and in such cases I did as you suggested).
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.
@c71n93, I haven't clearly understood the "advantages" you described. To me, they actually seem like disadvantages. Anyway.
Please take another look at this code and pay attention to the comment. I suggested this change intentionally.
Why we should opt for only one field instead of many different fields and repeated "TO ADD ASSERTION MESSAGE"
constants:
- You have only one place where you define this message.
- You have only one place where you can add a todo puzzle for further changes.
- It's the only place that has a bad smell. Otherwise you infecting the codebase by suboptimal code in many places.
Otherwise, if you leave it as it is:
- You need to add a separate puzzle for each field.
- If you leave the "TO ADD ASSERTION MESSAGE" constants (that aren't attached to any field and a puzzle), we will just forget to replace them with meaningful messages.
- You have to deal with the checkstyle check:
this check prohibits more than 5 repetitions of the same values
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.
@c71n93 Moreover, in the future versions of jtcop
we will forbid the usage of static literals. So, later we will need to remove all of this static literals.
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.
@c71n93 Maybe we will add three similar constants for each submodule:
// todo: remove this field from 'eo-runtime'
public static final String TODO_MESSAGE = "TO ADD ASSERTION MESSAGE";
// todo: remove this field from 'eo-parser'
public static final String TODO_MESSAGE = "TO ADD ASSERTION MESSAGE";
// todo: remove this field from 'eo-maven-plugin'
public static final String TODO_MESSAGE = "TO ADD ASSERTION MESSAGE";
In this case we will have 3 separate todos which will be much easier to fix and we don't need to think how to share the same field across modules. What do you think?
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.
Yes, it is some sort of duplication, but it's simple, as for me.
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.
add such public static fields with todo to any test class
Not exactly, I suggest to leave only one field and use it across all of the other classes.
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 Ok, understood. I free to choose any class in every submodule?
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.
@c71n93 Yes, it doesn't matter which class you will choose, since we will remove it later.
@@ -180,7 +180,8 @@ void parsesSuccessfully(final String code) { | |||
new InputOf(code) | |||
); | |||
Assertions.assertDoesNotThrow( | |||
syntax::parsed | |||
syntax::parsed, | |||
EoSyntaxTest.EMPTY_MSG |
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.
@c71n93 Maybe it's better to use the same constant value "TO ADD ASSERTION MESSAGE"
here? Otherwise we might forget to add a meaningful message later.
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 I think we can rename EMPTY_MSG
to TODO_MESSAGE
as you suggested above. We can't use value "TO ADD ASSERTION MESSAGE"
because checkstyle prohibits many repetitions of the same value.
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 or maybe TO_ADD_MESSAGE
would be better?
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.
@c71n93 I'm not sure that we can use 3 words in constant identifiers. Most probably, checkstyle will forbid TO_ADD_MESSAGE
constant, but you can try.
@c71n93 @volodya-lombrozo I would suggest also to add todo to rewrite all strings "TO_ADD_MESSAGE" with really meaningful messages in all tests |
@maxonfjvipon I agree, but where to add this todo? I think it should be only one todo, because If we add it to every test class it would be too many issues. |
@c71n93 I think it does not really matter, It can be any test |
@@ -71,7 +71,8 @@ void binarizesWithoutErrors(@TempDir final Path temp) throws Exception { | |||
.withProgram(BinarizeMojoTest.SRC.resolve("twice-rust.eo")); | |||
} | |||
Assertions.assertDoesNotThrow( | |||
() -> maven.execute(new FakeMaven.Binarize()) | |||
() -> maven.execute(new FakeMaven.Binarize()), | |||
"TO ADD ASSERTION MESSAGE" |
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.
@c71n93, I haven't clearly understood the "advantages" you described. To me, they actually seem like disadvantages. Anyway.
Please take another look at this code and pay attention to the comment. I suggested this change intentionally.
Why we should opt for only one field instead of many different fields and repeated "TO ADD ASSERTION MESSAGE"
constants:
- You have only one place where you define this message.
- You have only one place where you can add a todo puzzle for further changes.
- It's the only place that has a bad smell. Otherwise you infecting the codebase by suboptimal code in many places.
Otherwise, if you leave it as it is:
- You need to add a separate puzzle for each field.
- If you leave the "TO ADD ASSERTION MESSAGE" constants (that aren't attached to any field and a puzzle), we will just forget to replace them with meaningful messages.
- You have to deal with the checkstyle check:
this check prohibits more than 5 repetitions of the same values
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.
@c71n93 Can you move this description directly to the field javadoc, not to a class:
/** @todo #2297:60m Replace all appearances of {@link AtCompositeTest#TO_ADD_MESSAGE} field in
* eo-runtime with meaningful assert messages. Don't forget to remove
* {@link AtCompositeTest#TO_ADD_MESSAGE} field and remove public modifier from this class if no
longer need. */
public static final String TO_ADD_MESSAGE = AtCompositeTest.TO_ADD_MESSAGE;
b060827
to
b477065
Compare
@volodya-lombrozo could you check again 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.
@c71n93 Well done! Looks good to me. Thank you for the contribution.
@yegor256 could you check this one, please? |
1 similar comment
@yegor256 could you check this one, please? |
@rultor merge |
Closes #2297
PR-Codex overview
This PR updates test assertion messages to use a constant
AtCompositeTest.TO_ADD_MESSAGE
.Detailed summary
AtCompositeTest.TO_ADD_MESSAGE
constant