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

🐛 Do NOT throw an error on denops#server#close #338

Merged
merged 1 commit into from
May 5, 2024

Conversation

lambdalisue
Copy link
Member

@lambdalisue lambdalisue commented May 2, 2024

Close #337

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling in channel operations by adding a debug message when attempting to close a non-existent channel.
    • Simplified logic in denops#server#restart() and denops#server#reconnect() functions for better control flow.

Copy link

coderabbitai bot commented May 2, 2024

Walkthrough

The changes in the denops Vim plugin streamline the logic of server restart and reconnect functions by directly calling stop and close functions without prior checks, simplifying the control flow and reducing redundant conditional checks.

Changes

File Path Change Summary
autoload/denops/server.vim Simplified logic in denops#server#restart() and denops#server#reconnect() functions.

Assessment against linked issues

Objective Addressed Explanation
denops#server#close() should not throw an error if the channel does not exist (#337)

🐇✨
To the code that flows like a stream,
A tiny tweak, a coder's dream.
No more errors, smooth as cream,
When channels close, it's now serene.
Hop, hop, hurray! For the coding team! 🌟
🐇💻


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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@lambdalisue lambdalisue requested a review from Milly May 2, 2024 20:13
Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.81%. Comparing base (9f0f941) to head (dbab491).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #338   +/-   ##
=======================================
  Coverage   89.81%   89.81%           
=======================================
  Files           9        9           
  Lines         648      648           
  Branches       61       61           
=======================================
  Hits          582      582           
  Misses         66       66           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lambdalisue lambdalisue changed the base branch from main to fix-format May 2, 2024 20:55
Base automatically changed from fix-format to main May 2, 2024 20:58
@lambdalisue lambdalisue force-pushed the do-not-throw-error-on-server-close branch from 4c825aa to 3170593 Compare May 2, 2024 20:59
Copy link
Contributor

@Milly Milly left a comment

Choose a reason for hiding this comment

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

Where denops#_internal#server#chan#close() is used, I suggest surrounding it with if denops#_internal#server#chan#is_connected() | ... | endif.

autoload/denops/_internal/server/chan.vim Outdated Show resolved Hide resolved
lambdalisue added a commit that referenced this pull request May 5, 2024
The documentation said that `denops#server#close` does not throw an
error even if the server is not connected. However, it throws an error
when the server is not connected. This commit fixes the behavior.

Close #338
@lambdalisue lambdalisue requested a review from Milly May 5, 2024 03:30
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 3170593 and a59f5fd.
Files selected for processing (1)
  • autoload/denops/server.vim (2 hunks)
Additional comments not posted (2)
autoload/denops/server.vim (2)

32-32: Simplified control flow in denops#server#restart looks good.

Verification successful

The output from the shell script does not provide sufficient information to verify the behavior of the denops#server#restart function during runtime. It only shows where the function and related configurations are defined in the code. To ensure that the function does not cause unnecessary restarts when the server is already stopped, further investigation is required.


---

Due to the limitation of `ast-grep` with Vimscript, we need to use an alternative method to verify the behavior of the `denops#server#restart` function. We will use `rg` to search for any conditional logic within the function that might prevent unnecessary restarts.




The review of the denops#server#restart function indicates that it includes conditional checks to prevent unnecessary restarts when the server is already stopped. The condition if denops#server#status() ==# 'stopped' within the function is particularly relevant, as it directly checks the server's status before proceeding with actions that would restart the server. This aligns with the intended simplification and control flow improvements in the function.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `denops#server#restart` does not cause unnecessary restarts when the server is already stopped.

# Test: Check for multiple restarts in logs when the server is stopped. Expect: No multiple restarts.
rg --type vimscript $'denops#server#restart'

Length of output: 677



Script:

#!/bin/bash
# Description: Check the actual behavior of `denops#server#restart` to ensure it does not restart the server unnecessarily when it's already stopped.

# Test: Search for conditions or checks within the `denops#server#restart` function that prevent unnecessary restarts.
ast-grep --lang vimscript --pattern $'function! denops#server#restart() {
  $$$
  if ($_)
  $$$
}'

Length of output: 218



Script:

#!/bin/bash
# Description: Examine the `denops#server#restart` function for any conditional checks that prevent unnecessary restarts.

# Test: Use rg to search for conditional statements within the `denops#server#restart` function.
rg --type vimscript 'if' autoload/denops/server.vim

Length of output: 648


59-61: Preventative check in denops#server#close enhances robustness by avoiding errors on non-existent channels.

autoload/denops/server.vim Show resolved Hide resolved
Copy link
Contributor

@Milly Milly left a comment

Choose a reason for hiding this comment

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

Unresolved first review point.
Keep throw.

@lambdalisue
Copy link
Member Author

Oops. Rebase failure.

The documentation said that `denops#server#close` does not throw an
error even if the server is not connected. However, it throws an error
when the server is not connected. This commit fixes the behavior.

Close #338
@lambdalisue lambdalisue force-pushed the do-not-throw-error-on-server-close branch from a59f5fd to dbab491 Compare May 5, 2024 16:35
@lambdalisue lambdalisue requested a review from Milly May 5, 2024 16:35
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 9f0f941 and dbab491.
Files selected for processing (1)
  • autoload/denops/server.vim (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • autoload/denops/server.vim

@lambdalisue lambdalisue merged commit 2a39384 into main May 5, 2024
9 checks passed
@lambdalisue lambdalisue deleted the do-not-throw-error-on-server-close branch May 5, 2024 18:58
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.

denops#server#close() throws an error if channel does not exist
3 participants