Skip to content

Improve Input Validation and Increase Test Coverage #746

@ssuyashhhh

Description

@ssuyashhhh

Description

Many CLI-based projects in this repository do not properly validate user input, which can cause crashes when invalid values are entered. Additionally, several modules lack automated tests, making it difficult to detect regressions and ensure reliability.

Proposed Improvements

Input Validation

  • Validate all user inputs before processing.
  • Handle invalid numeric inputs gracefully.
  • Prevent crashes caused by ValueError and similar exceptions.
  • Display clear error messages and prompt users to retry.
  • Create reusable helper functions for common validation tasks.

Testing

  • Add comprehensive PyTest test cases.
  • Cover normal cases, edge cases, and invalid inputs.
  • Add tests for mathematical utilities, generators, and reusable helper functions.
  • Aim for at least 80% code coverage.

Code Quality

  • Refactor duplicated validation logic into reusable functions.
  • Add type hints where appropriate.
  • Improve exception handling.
  • Ensure executable scripts use:
    if name == "main":
    main()

Acceptance Criteria

  • User input is validated before processing.
  • Invalid input no longer crashes applications.
  • Shared validation helpers are implemented.
  • New PyTest test cases are added.
  • Existing functionality remains unchanged.
  • Code coverage reaches at least 80% where feasible.

Benefits

  • Improved user experience
  • Reduced runtime errors
  • Better maintainability
  • Easier future contributions
  • Increased confidence through automated testing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions