Refactor: Extract duplicated code into shared nmap_utils module #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The codebase contained ~88 lines of duplicated code between main_v1.6.py and main_v1.7.py, including banner display, user input prompts, and scan type selection logic.
Changes
Created
nmap_utils.py- Shared module with 3 extracted functions:display_banner()- pyfiglet banner and welcome messageget_target_info()- prompts for IP address and port/range inputchoose_scan_type()- displays scan menu (1-12) and validates selectionRefactored
main_v1.6.py- 119 → 81 lines (32% reduction)Refactored
main_v1.7.py- 221 → 183 lines (17% reduction)Added
.gitignore- Excludes__pycache__/, virtual environments, IDE filesBefore/After
Design Notes
Each version intentionally maintains separate
construct_nmap_command()implementations due to different architectural needs:Left main_v1.1.py unchanged as it's a minimal reference implementation.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.