Skip to content

Migrate plain enums to enum class - #8622

Merged
timosachsenberg merged 9 commits into
developfrom
migrate-samplestate-enum
Jan 12, 2026
Merged

timosachsenberg merged 9 commits into
developfrom
migrate-samplestate-enum

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jan 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Migrate plain enums to scoped enum classes for improved type safety
  • Convert Sample::SampleState, OpenMS_OS, OpenMS_Architecture, and various other enums
  • Update all usages across source files, tests, GUI visualizers, and pyOpenMS bindings
  • Add proper static_cast for array indexing and Qt widget methods
  • Update pyOpenMS test files for new nested enum naming convention
  • reason: only enum classes are proper types in cython/python

Test plan

  • C++ tests pass
  • pyOpenMS tests pass (277/280, 3 failures are missing test data files)
  • GUI visualizers compile and link successfully

🤖 Generated with Claude Code

taanvi2205 and others added 8 commits January 9, 2026 11:22
This commit fixes all test file compilation errors introduced by the enum class migration (commit 66cee84). The changes address two main issues:

1. Array indexing with enum class values now requires static_cast<size_t>()
2. Unscoped enum references updated to use proper EnumClass::VALUE syntax
- Add missing enum class prefixes for SIZE_OF_* constants in helper
  functions (MassAnalyzer, Sample, InstrumentSettings, DataProcessing,
  SpectrumSettings)
- Fix type mismatch in RangeUtils.h: compare Polarity enum directly
  instead of casting to Int
- Add wrap-attach annotation to ChecksumType in SourceFile.pxd for
  proper pyOpenMS wrapper generation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Convert plain enums to enum class for type safety
- Add SIZE_OF_* sentinel values
- Update all usages to use scoped enum syntax
- Expose both enum classes in pyOpenMS via BuildInfo.pxd

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Update code to use proper enum class syntax after enum migration:
- GUI visualizers: Add static_cast for array indexing and setCurrentIndex
- C++ tests: Use fully qualified enum names (e.g., Class::EnumType::VALUE)
- pyOpenMS tests: Update enum references (Type_IonDetector -> Type,
  MZTrafoModel_MODELTYPE -> MZTrafoModel.MODELTYPE, etc.)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

11 files out of 161 files are above the max files limit of 150.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 migrates plain enums to scoped enum classes (C++11 feature) across the OpenMS codebase for improved type safety. The migration includes several enum types such as Sample::SampleState, SpectrumSettings::SpectrumType, ProteinIdentification::PeakMassType, MassAnalyzer enums, and many others. All usages have been updated across C++ source files, tests, GUI visualizers, and pyOpenMS bindings with proper scoping (e.g., ClassName::EnumType::VALUE) and static_cast conversions where needed for array indexing and Qt widget operations.

Reviewed changes

Copilot reviewed 162 out of 162 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/topp/*.cpp Updated enum comparisons and assignments to use scoped enum class syntax
src/tests/topp/*.csv Added new test data file for OpenNuXL
src/tests/class_tests/openms/source/*.cpp Updated test assertions to use enum class scoping and static_cast for array indexing
src/pyOpenMS/pxds/*.pxd Changed enum declarations to cdef enum class with proper wrap-attach directives
src/pyOpenMS/tests/unittests/*.py Updated Python tests to use nested enum naming convention (e.g., Class.EnumType.VALUE)
src/openms_gui/source/VISUAL/*.cpp Added static_cast conversions for Qt widget methods and array indexing
src/openms/source/**/*.cpp Updated enum initializations, switch cases, comparisons, and array indexing throughout

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

yolo

@timosachsenberg
timosachsenberg deleted the migrate-samplestate-enum branch January 12, 2026 15:48
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.

pyOpenMS: IMTypes.toString overloading doesn't work correctly for different enum types

3 participants