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

IEP-1049: Add a validation for esp-idf path in the install tools dialog #986

Merged
merged 8 commits into from
Aug 30, 2024

Conversation

alirana01
Copy link
Collaborator

@alirana01 alirana01 commented Jun 12, 2024

Description

Added validation in tools installation to check for idf directory

Fixes # (IEP-1049)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

Select a directory that is not ESP-IDF the installation dialog should reflect proper error message and valid idf directory should allow installation of tools

Test Configuration:

  • ESP-IDF Version: any
  • OS (Windows,Linux and macOS): all

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • New Features

    • Enhanced validation logic for IDF tools and paths, providing clearer error messages and improved checks.
    • Introduced a method to dynamically retrieve the IDF version using Git.
  • Refactor

    • Simplified version validation process and IDF tool path handling.
    • Removed unnecessary method prompting users about spaces in project paths.
  • Bug Fixes

    • Improved clarity of error messages related to missing IDF Python scripts and improper directory selection.
  • Documentation

    • Updated user-facing messages for better clarity regarding the installation process and handling of directory paths.

@alirana01 alirana01 self-assigned this Jun 12, 2024
Copy link

coderabbitai bot commented Jun 12, 2024

Warning

Rate limit exceeded

@alirana01 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 59 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 00b6d37 and 4997418.

Walkthrough

The updates significantly enhance the validation and error handling for the ESP-IDF tool installation in the Espressif IDE. Key improvements include new methods for retrieving and validating the IDF version, clearer error messages for better user feedback, and a more streamlined logic for handling spaces in paths, contributing to an overall more robust installation experience.

Changes

File Path Change Summary
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java Enhanced version validation logic; added methods for retrieving the IDF version via Git and improved error handling related to spaces in paths.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/Messages.java Renamed message for clarity and introduced a new message for space-related versioning issues.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/messages.properties Updated user-facing messages to clarify the identification of the ESP-IDF directory and the impact of spaces in paths for versions beyond 5.0.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java Simplified logic for setting the IDF version, ensuring consistent retrieval and improving code readability with new comments.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/manager/pages/ESPIDFMainTablePage.java Cleaned up the code by removing an unused LaunchBarListener import, enhancing code clarity.

Poem

In the garden where code doth bloom,
Version checks chase away the gloom.
Clear messages guide with a gentle sway,
Helping the users find their way.
With each update, we hop with delight,
Espressif's tools shine ever so bright! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ebbf7de and 1a2044e.

Files selected for processing (3)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/Messages.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/messages.properties (1 hunks)
Files skipped from review due to trivial changes (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/Messages.java
Additional comments not posted (2)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/messages.properties (1)

5-5: The updated error message is clear and aligns with the PR objectives to enhance user feedback during the installation process.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (1)

400-403: The validation logic correctly checks for the presence of idf.py and idf_tools.py in the specified directory, aligning with the PR objectives. This ensures that the user has selected a valid ESP-IDF directory.

Comment on lines 400 to 429
String idfToolsPyPth = idfPath + File.separator + "tools" + File.separator + "idf_tools.py"; //$NON-NLS-1$ //$NON-NLS-2$
if (!new File (idfPyPath).exists() && !new File (idfToolsPyPth).exists())
{
setErrorMessage(MessageFormat.format(Messages.IDFDownloadPage_CantfindIDFpy, idfPath));
setErrorMessage(MessageFormat.format(Messages.IDFDownloadPage_CantfindProperEspIDFDirectory, idfPath));
Copy link

Choose a reason for hiding this comment

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

Consider using a constant for the repeated path segment "tools" to enhance maintainability.

- String idfPyPath = idfPath + File.separator + "tools" + File.separator + "idf.py";
- String idfToolsPyPth = idfPath + File.separator + "tools" + File.separator + "idf_tools.py";
+ final String TOOLS_DIR = "tools";
+ String idfPyPath = idfPath + File.separator + TOOLS_DIR + File.separator + "idf.py";
+ String idfToolsPyPth = idfPath + File.separator + TOOLS_DIR + File.separator + "idf_tools.py";
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String idfToolsPyPth = idfPath + File.separator + "tools" + File.separator + "idf_tools.py"; //$NON-NLS-1$ //$NON-NLS-2$
if (!new File (idfPyPath).exists() && !new File (idfToolsPyPth).exists())
{
setErrorMessage(MessageFormat.format(Messages.IDFDownloadPage_CantfindIDFpy, idfPath));
setErrorMessage(MessageFormat.format(Messages.IDFDownloadPage_CantfindProperEspIDFDirectory, idfPath));
final String TOOLS_DIR = "tools";
String idfPyPath = idfPath + File.separator + TOOLS_DIR + File.separator + "idf.py";
String idfToolsPyPth = idfPath + File.separator + TOOLS_DIR + File.separator + "idf_tools.py"; //$NON-NLS-1$ //$NON-NLS-2$
if (!new File (idfPyPath).exists() && !new File (idfToolsPyPth).exists())
{
setErrorMessage(MessageFormat.format(Messages.IDFDownloadPage_CantfindProperEspIDFDirectory, idfPath));

@@ -397,9 +397,10 @@ private void validate()
}

String idfPyPath = idfPath + File.separator + "tools" + File.separator + "idf.py"; //$NON-NLS-1$ //$NON-NLS-2$
if (!new File (idfPyPath).exists())
String idfToolsPyPth = idfPath + File.separator + "tools" + File.separator + "idf_tools.py"; //$NON-NLS-1$ //$NON-NLS-2$
if (!new File (idfPyPath).exists() && !new File (idfToolsPyPth).exists())
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use constants for idf.py and idf_tools.py from the IDFConstants file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -397,9 +397,10 @@ private void validate()
}

String idfPyPath = idfPath + File.separator + "tools" + File.separator + "idf.py"; //$NON-NLS-1$ //$NON-NLS-2$
if (!new File (idfPyPath).exists())
String idfToolsPyPth = idfPath + File.separator + "tools" + File.separator + "idf_tools.py"; //$NON-NLS-1$ //$NON-NLS-2$
if (!new File (idfPyPath).exists() && !new File (idfToolsPyPth).exists())
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to show an error message even if one of the files does not exist.

if (!new File(idfPyPath).exists() || !new File(idfToolsPyPath).exists())
{
    // show error message
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kolipakakondal Thanks for the feedback but we are already setting error message on wizard do you think we should show another popup message to user on an already opened popup wizard?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kolipakakondal
Copy link
Collaborator

@AndriiFilippov please verify once the PR comments are addressed!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1a2044e and 1299009.

Files selected for processing (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (2 hunks)
Additional comments not posted (3)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (3)

41-41: Good practice: Use of constants for path segments.

The import of IDFConstants is a good practice for maintainability and consistency in path handling.


400-401: Improvement: Use of constants for path segments.

The use of IDFConstants.TOOLS_FOLDER, IDFConstants.IDF_PYTHON_SCRIPT, and IDFConstants.IDF_TOOLS_SCRIPT improves maintainability and consistency.


402-404: Validation logic: Ensure both files exist.

The updated validation logic correctly checks for the existence of both idf.py and idf_tools.py files. The error message is appropriately updated.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1299009 and abf6392.

Files selected for processing (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java

Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

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

LGTM @alirana01

@AndriiFilippov
Copy link
Collaborator

@alirana01 hi !

Tested under:
OS - Windows 10

select any folder with white space. The white space validation was executed. Then, the absence of the esp-idf folder was not validated, allowing the process to proceed with the incorrect folder.

image

THEN:
image

@kolipakakondal
Copy link
Collaborator

nce of the esp-idf folder was no

@alirana01 Can you please look into this?

Can we also avoid showing error message popups on the wizard? Instead, we could show error messages in the wizard's message area at the top.?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between abf6392 and 103eaf9.

Files selected for processing (4)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (6 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/Messages.java (2 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/messages.properties (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java (1 hunks)
Additional comments not posted (10)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/Messages.java (2)

12-12: Updated message constant name is clear and descriptive.

The new name IDFDownloadPage_CantfindProperEspIDFDirectory is more descriptive and aligns with the purpose of the message.


25-25: New message constant added for version space error.

The new constant IDFDownloadPage_VersionSpaceError provides clarity for the specific error condition related to ESP-IDF version and path spaces.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/messages.properties (2)

5-5: Updated message provides clearer instructions.

The updated message now clearly instructs users to select a valid ESP-IDF directory.


13-13: New message added for version space error.

The new message ESP-IDF build system supports spaces in paths after v5.0. Please choose a different directory or continue if your ESP-IDF version supports spaces. provides clear guidance to users regarding path spaces and version compatibility.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java (2)

110-112: Added environment variables for IDF component manager and maintainer.

The addition of these environment variables (IDF_COMPONENT_MANAGER and IDF_MAINTAINER) ensures that the necessary settings are applied for the build process.


119-143: Simplified version retrieval logic.

The refactored code simplifies the process of retrieving and setting the IDF version from idf.py. The previous commented-out code has been removed, and the new logic is more straightforward.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (4)

400-412: Added version validation for paths with spaces.

The new logic checks if the ESP-IDF version supports spaces in paths and sets appropriate error messages if not. This ensures better user feedback and prevents issues with unsupported versions.


415-419: Improved error handling for missing idf.py and idf_tools.py.

The updated code uses constants from IDFConstants and provides a more descriptive error message if the required files are not found.


475-518: New method getIdfVersionUsingGit for version retrieval.

This method uses git describe to retrieve the ESP-IDF version, improving the accuracy of version detection.


520-561: New method isVersionGreaterOrEqual for version comparison.

This method compares the current version with a minimum required version, ensuring compatibility checks are accurate.

@AndriiFilippov
Copy link
Collaborator

@alirana01 hi !

Tested under:
OS - Windows 10

It now let you to select ESP-IDF with spaces in path like this:
image

BUT downloading validation a bit broken.
to reproduce: select release 4.4 and folder with spaces.
image

and now switch version to >=5.0 - bug ⛔
image

The same works for opposite way: select >=5.0 - it pass validation and then select v4.4 - no validation
image

@AndriiFilippov
Copy link
Collaborator

Probably we should delete this part of info message. It does not make sense.
image

@alirana01
Copy link
Collaborator Author

@AndriiFilippov please verify after the builds and also make sure to test on mac and linix

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 103eaf9 and c77ed3d.

Files selected for processing (2)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (8 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/messages.properties (1 hunks)
Additional comments not posted (8)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/messages.properties (2)

5-5: LGTM! Improved clarity in the error message.

The updated message provides clearer guidance by specifying the issue and emphasizing the importance of selecting a valid directory.


13-13: LGTM! Clear and necessary guidance for users.

The new message addresses potential issues with directory paths containing spaces for versions of ESP-IDF after 5.0.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (6)

408-420: Ensure version check logic is correct.

The version check logic has been added to handle paths containing spaces.

Ensure that the getIdfVersionUsingGit method returns the correct version format and that the isVersionGreaterOrEqual method accurately compares versions.


423-427: Good use of constants for paths.

The use of constants from IDFConstants improves maintainability.


483-526: Ensure command execution and output parsing is correct.

The method retrieves the IDF version using Git commands and parses the output.

Ensure that the command execution and output parsing handle all possible scenarios and edge cases.


528-569: Ensure version comparison logic is correct.

The method compares versions using regular expressions.

Ensure that the version comparison logic handles all possible scenarios and edge cases.


465-465: Ensure error messages are set correctly.

The error message for directory paths containing spaces has been updated.

Ensure that the error message is set correctly based on the validation results.


421-421: Ensure page completion status is set correctly.

The page completion status is set based on the validation results.

Ensure that the page completion status is set correctly based on the validation results.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c77ed3d and a1ab991.

Files selected for processing (4)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (8 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/Messages.java (2 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/messages.properties (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/messages.properties
Additional comments not posted (11)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/Messages.java (2)

12-12: Renamed variable improves clarity.

The variable IDFDownloadPage_CantfindIDFpy has been renamed to IDFDownloadPage_CantfindProperEspIDFDirectory, which enhances clarity regarding the purpose of the string.


25-25: New variable for version space error.

The new variable IDFDownloadPage_VersionSpaceError has been added to handle error messaging related to version space issues. This is a good addition for enhancing user feedback.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java (3)

110-112: Added environment variable settings.

The environment variables IDF_COMPONENT_MANAGER and IDF_MAINTAINER are being set directly. This is a useful addition for ensuring the correct environment setup.


119-135: Removed conditional logic for setting IDF version.

The conditional logic for setting the IDF version has been removed, simplifying the process. This change improves code readability and maintainability.


135-143: Simplified IDF version retrieval logic.

The logic for retrieving the IDF version has been simplified by always using the output from idfPy. This ensures consistency in setting the IDF version.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (6)

11-13: Added imports for new functionality.

The imports for ArrayList, HashMap, and List have been added to support the new functionality introduced in the file.


115-122: Added selection listener for version combo.

The versionCombo now has a selection listener that triggers validation when a version is selected. This ensures that the selected version is always validated.


408-420: Added version validation for IDF path with spaces.

The validate method now includes a check for the IDF version if the path contains spaces. This ensures that only valid versions are accepted.


423-427: Improved error handling for missing files.

The error handling for missing idf.py and idf_tools.py files has been improved. This ensures that users are informed when required files are missing.


483-526: New method for retrieving IDF version using Git.

The getIdfVersionUsingGit method retrieves the IDF version using Git commands. This is a useful addition for ensuring compatibility with the specified version requirements.


528-569: New method for comparing version strings.

The isVersionGreaterOrEqual method compares two version strings to determine if one is greater than or equal to the other. This is a useful addition for version validation.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a1ab991 and 0b9852f.

Files selected for processing (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/manager/pages/ESPIDFMainTablePage.java (1 hunks)
Files skipped from review due to trivial changes (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/manager/pages/ESPIDFMainTablePage.java

@AndriiFilippov
Copy link
Collaborator

@alirana01 hi !

Tested under:
OS - Windows 11 / MacOS

Well, since we have removed releasev4.4 from Download versions list - it became more easier :D

I don't like only this behave- when we select just empty folder(with whitespaces) the validation starts for "release <5.0" not the validation for esp-idf folder.

image

So, my point is: the validation for release <v5.0 should be just in case if the v4.4 selected in a folder with whitespace like here:
image

But if the empty folder selected, this message does not have any sense:

image

instead should be:
image

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0b9852f and 2f1db17.

Files selected for processing (5)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (8 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/Messages.java (2 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/messages.properties (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/manager/pages/ESPIDFMainTablePage.java (1 hunks)
Files skipped from review due to trivial changes (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/manager/pages/ESPIDFMainTablePage.java
Additional comments not posted (12)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/Messages.java (2)

12-12: Clarify message identifier.

The identifier IDFDownloadPage_CantfindProperEspIDFDirectory provides a clearer context than the previous name. This change enhances the semantic clarity of the message.


25-25: Add new error message for version space issues.

The new string IDFDownloadPage_VersionSpaceError is introduced to handle errors related to spaces in paths for ESP-IDF versions. This addition improves user feedback during the installation process.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/messages.properties (2)

5-5: Clarify error message for directory validation.

The updated message IDFDownloadPage_CantfindProperEspIDFDirectory provides clearer guidance by specifying the issue with the ESP-IDF directory. This change enhances user understanding.


13-13: Introduce error message for version space issues.

The new entry IDFDownloadPage_VersionSpaceError informs users about the limitations on spaces in paths for ESP-IDF versions. This addition improves user guidance during the installation process.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java (3)

110-112: Set default environment variables.

The addition of IDF_COMPONENT_MANAGER and IDF_MAINTAINER environment variables is a good practice for ensuring consistent build environments.


119-134: Streamline IDF version retrieval logic.

The commented-out conditional block simplifies the logic by always retrieving the IDF version using getIdfVersionFromIdfPy(). This change improves maintainability by removing unnecessary checks.


135-143: Ensure consistent IDF version setting.

The refactored logic ensures that the IDF version is consistently retrieved and set, which is crucial for maintaining accurate environment configurations.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (5)

408-420: Ensure consistent error handling for version checks.

The logic for handling version checks when spaces are present in the path is clear. However, ensure that the error message is consistently set and cleared to avoid user confusion.

Verification successful

Consistent error handling for version checks is confirmed.

The logic for setting and clearing the error message Messages.IDFDownloadPage_VersionSpaceError is consistent and correctly implemented. The error message is set when the version check fails and cleared appropriately when the conditions are met. No further issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the error message handling logic is consistent.

# Test: Check for consistent setting and clearing of error messages related to version checks.
rg --type java -A 5 $'setErrorMessage' | rg 'VersionSpaceError'

Length of output: 547


483-526: Verify command execution and error handling.

The method correctly constructs and executes the Git command to retrieve the IDF version. Ensure that the command execution and error handling are robust, especially in diverse environments.

Verification successful

Command Execution and Error Handling Verified

The method getIdfVersionUsingGit uses the runInBackground method from ProcessBuilderFactory, which is consistently used across the codebase for executing commands. This indicates that the command execution and error handling are robust and consistent with other parts of the system. No issues found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the robustness of command execution and error handling.

# Test: Check for correct usage of ProcessBuilder and error handling in command execution.
rg --type java -A 5 $'ProcessBuilderFactory' | rg 'runInBackground'

Length of output: 3167


528-569: Verify version comparison logic.

The method accurately compares version strings using regex and numerical comparison. Ensure that the regex pattern matches the expected version format and handles edge cases correctly.

Verification successful

Version comparison logic is correct.

The regex pattern \\d+\\.\\d+\\.\\d+ accurately matches version strings in the format X.Y.Z, and the method correctly compares these versions numerically. No issues found with the implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the version comparison logic.

# Test: Check for correct regex pattern and comparison logic in version comparison.
rg --type java -A 5 $'isVersionGreaterOrEqual' | rg 'Pattern.compile'

Length of output: 189


423-424: Verify usage of constants for file paths.

The usage of constants for file paths from IDFConstants is appropriate. Ensure that all relevant paths are using constants to improve maintainability.

Verification successful

Usage of Constants for File Paths Verified

The usage of constants from IDFConstants for file paths in IDFDownloadPage.java is consistent with best practices and is correctly implemented. All relevant paths in the snippet provided are using constants, which improves maintainability. No further changes are necessary.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of constants for file paths.

# Test: Check for usage of constants from IDFConstants for file paths.
rg --type java -A 5 $'IDFConstants' | rg 'TOOL'

Length of output: 5503


Line range hint 370-374:
Ensure comprehensive validation for executables.

The method checks for the presence of Git and Python executables. Ensure that the validation logic is comprehensive and error messages are clear and informative.

Verification successful

Validation logic for executables is comprehensive and informative.

The validateGitAndPython() method provides clear and specific error messages for missing Git and Python executables, ensuring that users receive informative feedback when validation fails. This addresses the review comment's concern effectively.

  • Error messages such as "Git executable not found" and "Python executable not found" are set, indicating comprehensive validation logic.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify comprehensive validation for Git and Python executables.

# Test: Check for validation logic and error messages related to executable paths.
rg --type java -A 5 $'validateGitAndPython' | rg 'setErrorMessage'

Length of output: 283


Script:

#!/bin/bash
# Description: Search for all uses of setErrorMessage in the file to check for specific error messages.

# Test: Find all instances of setErrorMessage in the file.
rg --type java 'setErrorMessage' bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java

Length of output: 732

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2f1db17 and 00b6d37.

Files selected for processing (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java (8 hunks)
Files skipped from review as they are similar to previous changes (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFDownloadPage.java

Copy link
Collaborator

@sigmaaa sigmaaa left a comment

Choose a reason for hiding this comment

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

LGTM. Please take a look at the comments

Logger.log(IDFCorePlugin.getPlugin(),
IDFCorePlugin.errorStatus("Unable to get the process status.", null)); //$NON-NLS-1$
}
String cmdOutput = status.getMessage();
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have check for status == null but we are not using break in that condition, so here is possible NPE

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

Comment on lines 119 to 134
// if (StringUtil.isEmpty(idfToolSet.getEnvVars().get(IDFEnvironmentVariables.ESP_IDF_VERSION)))
// {
// IStatus status = getIdfVersionFromIdfPy();
// String cmdOutput = status.getMessage();
// Pattern pattern = Pattern.compile("v(\\d+\\.\\d+\\.\\d+)");
// Matcher matcher = pattern.matcher(cmdOutput.toLowerCase());
// if (matcher.find())
// {
// idfToolSet.setIdfVersion(matcher.group(1));
// }
// idfToolSet.getEnvVars().put(IDFEnvironmentVariables.ESP_IDF_VERSION, idfToolSet.getIdfVersion());
// }
// else
// {
// idfToolSet.setIdfVersion(idfToolSet.getEnvVars().get(IDFEnvironmentVariables.ESP_IDF_VERSION));
// }
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we remove the commented code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed

@AndriiFilippov
Copy link
Collaborator

@alirana01 hi !

Tested under:
OS - Windows 11 / MacOS arm64

LGTM 👍

@kolipakakondal kolipakakondal merged commit c736f3e into master Aug 30, 2024
5 of 6 checks passed
@kolipakakondal kolipakakondal deleted the IEP-1049 branch August 30, 2024 07:23
@kolipakakondal kolipakakondal added this to the v3.1.0 milestone Sep 4, 2024
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.

4 participants