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

#1090: replace picocli #1355

Merged
merged 6 commits into from
Sep 17, 2023
Merged

Conversation

hohwille
Copy link
Member

#1090

  • replace picocli with own impl (Property, Ide, etc.)
  • add ToolRepository
  • add SystemPath
  • establish software repo and symlinking
  • MacOS workaround
  • support for general options including tracing

…mPath, establish software repo and symlinking, MacOS workaround
@hohwille hohwille added this to the release:2023.09.001 milestone Sep 12, 2023
@github-actions github-actions bot added the bash related to bash shell or scripts label Sep 12, 2023
@hohwille hohwille merged commit 25a8611 into devonfw:master Sep 17, 2023
@hohwille hohwille linked an issue Sep 17, 2023 that may be closed by this pull request
Copy link
Contributor

@jan-vcapgemini jan-vcapgemini left a comment

Choose a reason for hiding this comment

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

Nice work. Lots of cool concepts.
I've mainly found some typos and missing javadocs which would make the code easier to read for me.

Comment on lines +111 to +112

private CliArgument initContext(CliArgument first) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please provide javadoc for this method.

Copy link
Member Author

Choose a reason for hiding this comment

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

In general we seem not to be on the same page about writing JavaDoc for private things.
The method initContext will initialize the context. Okay, why we need to pass the CliArgument and get CliArgument back is not obvious from the signature. I can write JavaDoc for this but my PoV is that you can read the code if you want to know this. A problem with adding JavaDoc is that it might not get maintained if the code gets changed and internal private methods tend to change often. A wrong JavaDoc is worse than no JavaDoc.
Did you ever read the book about "clean code"? If no, I would strongly recommend it...
Anyhow in this case, I am happy to add the JavaDoc and address your feedback as actually the @return would be helpful.

Copy link
Contributor

@jan-vcapgemini jan-vcapgemini Sep 21, 2023

Choose a reason for hiding this comment

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

I'm asking for javadocs because of IDE autocomplete and documentation functionalities. The more (maintained) javadocs we have for methods like these, the more the IDE's will help us to get through faster. I don't like to read each method body multiple times to understand what my params need to be and what will be returned and how.
I've not read "clean code" yet. Might give it a go later.

ide/src/main/java/com/devonfw/tools/ide/cli/Ide.java Outdated Show resolved Hide resolved
Comment on lines 110 to 111

private void add(String name, Property<?> property, boolean alias) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please provide javadoc for this method.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is clearly a point where I would strongly disagree.
There is a protected add method what is the API for commandlets inheriting from this class.
It does have JavaDoc. This private method only exists to avoid code redundancy and the only place where it is called is the protected add method. So IMHO a user would only be interested in the API and if he digs in the implementation of the protected add method and will stumble over the private one he can easily read the 12 lines of code that are purely trivial.
I would rather challenge that the existing JavaDoc like @param property the {@link Property} to register. might be a little bit short and could explain what "registration" means here. Ideally we will live a culture where every developer takes responsibility of the code and feels invited to improve JavaDoc, add JUnit coverage, etc. to all existing code.
I try my best to produce high quality code but only have very few hours a day for management, contributing and coding to this project. So sure I could write more JavaDoc, more JUnits (that is IMHO even a much bigger pain point currently).
Do not get me wrong:
Thank you for your review and feedback. I just wanted to make a clear point to match expectations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for pointing that out. I'm asking for javadocs only so that I don't have to read the method body multiple times as mentioned before. Aren't there tools which could automate the javadoc and param description using AI yet?

*/
public boolean isIdeHomeRequired() {

return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe move to a constant.

Copy link
Member Author

Choose a reason for hiding this comment

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

You seemed to miss that this method gets overridden by commandlets that do not require IDE_HOME.
So by default this is true and invoking the commandlet will fail if IDE_HOME was not found.
However, commandlets like HelpCommandlet should still be able to be invoked.
I thought the JavaDoc would explain this. Feel invited to improve the JavaDoc (e.g. add "Override this method in your commandlet if it does not require IDE_HOME being set").

Comment on lines +403 to +406
// if [ -e "${target_dir}/Applications" ]
// then
// rm "${target_dir}/Applications"
// fi
Copy link
Contributor

Choose a reason for hiding this comment

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

can be removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh great point. That is also from the "clean code" book. Never keep outcommented code. There is git for the history.
However, this was some kind of TODO for me.
This comes from here and I could not see or remember what this is for.
If we still need this, it is a bug that the Java code is missing this behavior.
After all our Java implementation (IDEasy) is still in prototype state :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend to add a // TODO: comment with a link to an issue instead of keeping outcommented code.

Comment on lines +51 to +58
/**
* @param rootDir the {@link Path} to the root directory.
* @param fileAccess the {@link FileAccess} instance.
* @param systemInfo the {@link SystemInfo} instance.
* @param logger the {@link IdeLogger} instance.
* @return the {@link ToolInstallation#linkDir() link directory}.
*/
Path findLinkDir(Path rootDir) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong javadoc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch. I moved these parameters to the constructor. Hence, they have to be removed from the JavaDoc.
Just did this: devonfw/IDEasy@9789dbb

For the record: As I said if you write lots of JavaDoc you may end up with wrong JavaDoc if it is not properly maintained. Eclipse gives me warnings for this but only for public and protected methods. So I missed this one. Thanks for your finding.

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +69 to +70

private static String computeId(String url) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add some javadoc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Same here: This method computes a unique ID from the given URL. The signature is already saying all you need. No need for private JavaDoc here.

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 case I would like to know in which format the String of the URL has to be. Otherwise I would use URL type to prevent issues with bad URL's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bash related to bash shell or scripts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate devonfw-ide from bash to Java with GraalVM
2 participants