Skip to content

Modernize C++ code and improve code quality #10

Description

@dennisklein

Summary

Modernize the codebase to use C++20 features and improve overall code quality.

Proposed Changes

High Priority

  • Replace custom starts_with() function (main.cpp:34-42) with standard library std::string_view::starts_with() available in C++20

    • Update CMakeLists.txt: target_compile_features(${target} PRIVATE cxx_std_20)
    • Add fallback implementation for older compilers if needed
  • Add validation for script path existence and executability in init() function

    • Currently checks s_singularity_script.empty() but default is always set
    • Validate that the script exists and has execute permissions during initialization
  • Improve environment variable override logic (main.cpp:417-422)

    • SLURM_SINGULARITY_BIND check only happens if s_bind_mounts.empty()
    • Consider allowing environment variables to consistently override CLI options

Medium Priority

  • Rename Buttocks class to SpankWrapper or SpankContext (main.cpp:61)

    • While humorous, a professional name improves maintainability
    • Makes code more accessible to new contributors
  • Re-enable and improve input validation for bind paths (main.cpp:269-277)

    • Currently has commented-out space-checking code
    • Add comprehensive validation: invalid characters, path traversal attempts, etc.
  • Review static state usage (main.cpp:210-217)

    • Plugin uses inline static variables
    • Document thread-safety guarantees or refactor if needed for concurrent Slurm environments

Benefits

  • More maintainable and modern codebase
  • Better integration with standard C++ library
  • Improved robustness through validation

Compatibility Considerations

  • C++20 may not be available on older systems
  • Consider maintaining C++17 compatibility with conditional compilation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions