Skip to content

chore: improve code quality and documentation - #1

Open
AungMyoKyaw wants to merge 1 commit into
masterfrom
chore/improve-code-quality-and-documentation
Open

AungMyoKyaw wants to merge 1 commit into
masterfrom
chore/improve-code-quality-and-documentation

Conversation

@AungMyoKyaw

Copy link
Copy Markdown
Owner

Summary

This PR improves code quality, security, and documentation for the docker-run-zsh plugin.

Changes

  • Added .gitignore - Ignores common editor/IDE files, OS generated files, and temporary files
  • Improved README documentation:
    • Added clear feature list
    • Added practical examples with specific image names
    • Added options table
    • Added Antigen and manual installation methods
    • Added requirements section
    • Fixed alt text (was "dotfiles", now "docker-run-zsh demo")
  • Code quality improvements:
    • Added input validation with helpful error messages
    • Added _docker_run_usage() helper function
    • Used local variables instead of global uppercase variables (security best practice)
    • Used ${PWD} instead of $(pwd) for better performance and reliability
    • Fixed typo "demon" -> "daemon" in comments
    • Added comprehensive function documentation
    • Added shebang and file header documentation

Security Improvements

  • Changed from global uppercase variables (IMAGE, PORT) to local lowercase variables (image, port) to prevent variable pollution in the shell environment
  • Added input validation to prevent running Docker commands with empty image names

Test plan

  • Source the plugin file and verify no syntax errors
  • Test rdk without arguments - should show usage error
  • Test rdk ubuntu:latest - should run container with bash
  • Test rdk node:18 3000 - should run container with port mapping
  • Test rdksh alpine:latest - should run container with sh
  • Test rdkd redis:latest 6379 - should run container in detached mode
  • Verify README renders correctly on GitHub

- Add .gitignore for common editor, OS, and temporary files
- Improve README with better structure, examples, and installation methods
- Fix alt text in demo image (was "dotfiles", now "docker-run-zsh demo")
- Add input validation and error handling to all functions
- Use local variables instead of global caps (security improvement)
- Use ${PWD} instead of $(pwd) for better performance
- Fix typo "demon" -> "daemon" in comments
- Add usage helper function for better user experience
- Add comprehensive function documentation
- Add shebang and file header documentation
Copilot AI review requested due to automatic review settings February 15, 2026 17:30

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 improves the docker-run-zsh plugin by adding comprehensive documentation, input validation, better variable scoping, and a .gitignore file. The changes focus on code quality, security, and user experience improvements.

Changes:

  • Added input validation with helpful error messages and usage function
  • Converted global uppercase variables to local lowercase variables for better security
  • Enhanced documentation with function headers, comprehensive README updates, and fixed typos
  • Added .gitignore to exclude common editor, OS, and temporary files

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
docker-run-zsh.plugin.zsh Added shebang, header documentation, input validation, usage helper function, and converted to local variables
README.md Enhanced with features list, practical examples, installation methods (Antigen, manual), requirements section, and improved formatting
.gitignore Added patterns for editor/IDE files, OS-generated files, temporary files, and test files

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

Comment thread docker-run-zsh.plugin.zsh
Comment on lines +39 to +41
docker run --rm -it -v "${PWD}":/src:cached -p "${port}":"${port}" "${image}" bin/bash
else
docker run --rm -it -v "${PWD}":/src:cached "${image}" bin/bash

Copilot AI Feb 15, 2026

Copy link

Choose a reason for hiding this comment

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

The path to bash should be /bin/bash (with a leading slash) instead of bin/bash. Without the leading slash, Docker will look for bin/bash relative to the working directory instead of as an absolute path, which will likely fail.

Suggested change
docker run --rm -it -v "${PWD}":/src:cached -p "${port}":"${port}" "${image}" bin/bash
else
docker run --rm -it -v "${PWD}":/src:cached "${image}" bin/bash
docker run --rm -it -v "${PWD}":/src:cached -p "${port}":"${port}" "${image}" /bin/bash
else
docker run --rm -it -v "${PWD}":/src:cached "${image}" /bin/bash

Copilot uses AI. Check for mistakes.
Comment thread docker-run-zsh.plugin.zsh
Comment on lines +39 to +41
docker run --rm -it -v "${PWD}":/src:cached -p "${port}":"${port}" "${image}" bin/bash
else
docker run --rm -it -v "${PWD}":/src:cached "${image}" bin/bash

Copilot AI Feb 15, 2026

Copy link

Choose a reason for hiding this comment

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

The path to bash should be /bin/bash (with a leading slash) instead of bin/bash. Without the leading slash, Docker will look for bin/bash relative to the working directory instead of as an absolute path, which will likely fail.

Suggested change
docker run --rm -it -v "${PWD}":/src:cached -p "${port}":"${port}" "${image}" bin/bash
else
docker run --rm -it -v "${PWD}":/src:cached "${image}" bin/bash
docker run --rm -it -v "${PWD}":/src:cached -p "${port}":"${port}" "${image}" /bin/bash
else
docker run --rm -it -v "${PWD}":/src:cached "${image}" /bin/bash

Copilot uses AI. Check for mistakes.
Comment thread docker-run-zsh.plugin.zsh
Comment on lines +62 to +64
docker run --rm -it -v "${PWD}":/src:cached -p "${port}":"${port}" "${image}" bin/sh
else
docker run --rm -it -v "${PWD}":/src:cached "${image}" bin/sh

Copilot AI Feb 15, 2026

Copy link

Choose a reason for hiding this comment

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

The path to sh should be /bin/sh (with a leading slash) instead of bin/sh. Without the leading slash, Docker will look for bin/sh relative to the working directory instead of as an absolute path, which will likely fail.

Suggested change
docker run --rm -it -v "${PWD}":/src:cached -p "${port}":"${port}" "${image}" bin/sh
else
docker run --rm -it -v "${PWD}":/src:cached "${image}" bin/sh
docker run --rm -it -v "${PWD}":/src:cached -p "${port}":"${port}" "${image}" /bin/sh
else
docker run --rm -it -v "${PWD}":/src:cached "${image}" /bin/sh

Copilot uses AI. Check for mistakes.
Comment thread docker-run-zsh.plugin.zsh
Comment on lines +62 to +64
docker run --rm -it -v "${PWD}":/src:cached -p "${port}":"${port}" "${image}" bin/sh
else
docker run --rm -it -v "${PWD}":/src:cached "${image}" bin/sh

Copilot AI Feb 15, 2026

Copy link

Choose a reason for hiding this comment

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

The path to sh should be /bin/sh (with a leading slash) instead of bin/sh. Without the leading slash, Docker will look for bin/sh relative to the working directory instead of as an absolute path, which will likely fail.

Suggested change
docker run --rm -it -v "${PWD}":/src:cached -p "${port}":"${port}" "${image}" bin/sh
else
docker run --rm -it -v "${PWD}":/src:cached "${image}" bin/sh
docker run --rm -it -v "${PWD}":/src:cached -p "${port}":"${port}" "${image}" /bin/sh
else
docker run --rm -it -v "${PWD}":/src:cached "${image}" /bin/sh

Copilot uses AI. Check for mistakes.
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