-
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
feat(#1602): discover depends on place #2432
feat(#1602): discover depends on place #2432
Conversation
eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java
Outdated
Show resolved
Hide resolved
@volodya-lombrozo please have a look one more time |
* | ||
* @since 0.31.0 | ||
*/ | ||
public final class OnDefault implements ObjectName { |
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.
@maxonfjvipon I believe this change should be done in a separate PR. Please take a look that issue:
#2420
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'm not sure in such particular case. OnDefault
is just one more ObjectName
without complex behaviour.
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.
@maxonfjvipon From the issue description:
Apparently we have to create a class which will parse raw string into two parts value and
optional version.
We have the same split
function among many classes (The same we can say about DELIMETER
static field). Hence, I believe this issue exactly about this.
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 suggest to extend the #2420 so it affected this class too
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 believe adding OnDefault
class is not about solving the problem #2420. It's just one more object name. Yes, with code duplication, that will be somehow resolved after solving #2420.
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.
@maxonfjvipon Let's do it for now. But I would recommend to solve #2420 issue first and then return to that PR.
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 yes, let's leave this as it. Object versioning has higher priority than refactoring at the moment
eo-maven-plugin/src/test/java/org/eolang/maven/DiscoverMojoTest.java
Outdated
Show resolved
Hide resolved
eo-maven-plugin/src/main/java/org/eolang/maven/name/OnVersioned.java
Outdated
Show resolved
Hide resolved
eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java
Outdated
Show resolved
Hide resolved
@volodya-lombrozo please have a look one more time |
* | ||
* @since 0.31.0 | ||
*/ | ||
public final class OnDefault implements ObjectName { |
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.
@maxonfjvipon From the issue description:
Apparently we have to create a class which will parse raw string into two parts value and
optional version.
We have the same split
function among many classes (The same we can say about DELIMETER
static field). Hence, I believe this issue exactly about this.
@@ -42,15 +43,24 @@ public final class OnVersioned implements ObjectName { | |||
/** | |||
* Default hash. | |||
*/ | |||
private final CommitHash hsh; | |||
private final Unchecked<CommitHash> hsh; |
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.
@maxonfjvipon Why do we need this overcomplication? I didn't find any usage of the next constructor:
public OnVersioned(final ObjectName origin, final Scalar<CommitHash> hash) {
this(new Unchecked<>(origin::toString), new Unchecked<>(hash));
}
And to be honest, I don't see the reason for it.
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 here. Scalar is needed because explicit new OnDefault(tojo).hash()
may fail with IndexOutOfBounds
exception if tojo does not contain delimiter |
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.
@maxonfjvipon I see, thank you. Maybe it's better to let it fail as fast as possible? Otherwise it looks like you are trying to swallow the exception or use exceptions for flow control (both of the approaches don't lead to a good design).
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 should not fail at this step at all. Pay a bit more attention to the code:
new OnSwap(
tojo.contains(OnReplaced.DELIMITER),
new OnVersioned(
replaced,
new OnDefault(tojo)::hash
),
replaced
)
If condition tojo.contains(OnReplaced.DELIMITER)
is FALSE, the first object will be never evaluated, the second one will be - replaced
. But we need to construct it here and it should now fail on the construction step
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 maybe we will add one more object name for such cases, but there's only one for now, so there's no need
eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java
Outdated
Show resolved
Hide resolved
* Otherwise, try to append a version from tojo if there's no one already | ||
* | ||
* @param name Object name with tag on not. | ||
* @param tojo Current tojo. |
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.
@maxonfjvipon Is it a tojo
? Maybe we can name it as a "default object name", or "default version"?
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 an identifier of tojo
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.
@maxonfjvipon But what is the identifier of tojo in this context?
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 just a name of it as string
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.
@maxonfjvipon You treat it as an object name with hash, or I'm wrong?
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 with or without. But if I wrap tojo.identifier()
into OnDefault
somewhere before this function, I'll not be able check if it contains hash or not. The check should happen in this function, that's why I pass tojo String
not as ObjectName
@volodya-lombrozo please have a look one more time |
@Graur Could you take a look, please? |
@Graur please review this one since Volodya is not able now |
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.
@maxonfjvipon I believe it's good to merge
@yegor256 please have a look |
@rultor merge |
Ref: #1602
More details here
PR-Codex overview
This PR focuses on hiding a static constant
DELIMITER
to avoid code duplication in multiple places.Detailed summary
OnReplaced
class to includeOnDefault
in the list of places whereDELIMITER
is used.OnDefault
to handle default object names.DiscoverMojo
class to use theOnDefault
class for object discovery.