Skip to content

Refactor: Remove unreachable code in ChannelSftp._put() method#1077

Open
iyrinnn wants to merge 2 commits into
mwiede:masterfrom
iyrinnn:fix/remove-dead-code-channel-sftp
Open

Refactor: Remove unreachable code in ChannelSftp._put() method#1077
iyrinnn wants to merge 2 commits into
mwiede:masterfrom
iyrinnn:fix/remove-dead-code-channel-sftp

Conversation

@iyrinnn

@iyrinnn iyrinnn commented Jul 3, 2026

Copy link
Copy Markdown
  • Removed hardcoded 'dontcopy = true' variable that made conditional branches unreachable
  • Eliminated dead code blocks (lines 569-571, 583-589, 633-641)
  • Inlined the only-executed logic for better clarity
  • No functional changes, only removed dead code paths
  • Build verified: mvn clean compile passes successfully

- Removed hardcoded 'dontcopy = true' variable that made conditional branches unreachable
- Eliminated dead code blocks (lines 569-571, 583-589, 633-641)
- Inlined the only-executed logic for better clarity
- No functional changes, only removed dead code paths
- Build verified: mvn clean compile passes successfully
Copilot AI review requested due to automatic review settings July 3, 2026 06:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors ChannelSftp._put(InputStream, ...) by removing a hardcoded flag and the associated unreachable branches, leaving only the actually executed “no-copy” write path to improve readability without changing behavior.

Changes:

  • Removed the always-true dontcopy flag and deleted the unreachable !dontcopy branches.
  • Inlined the effective buffer setup (data = obuf.buffer, _s, _datalen) for the remaining execution path.
  • Simplified the sendWRITE(...) callsite to the only reachable variant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/com/jcraft/jsch/ChannelSftp.java Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@iyrinnn iyrinnn closed this Jul 3, 2026
@iyrinnn iyrinnn reopened this Jul 3, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

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.

2 participants