Repository navigation
Support wrapping of enum classes. Remove boost smart_ptr and bump up autowrap - #8405
timosachsenberg merged 12 commits into
Conversation
This converts the ActivationMethod enum in the Precursor class from a plain C++ enum to a scoped enum class for improved type safety: - Prevents implicit conversion to integers - Requires explicit member qualification (e.g., Precursor::ActivationMethod::CID) - Fixes Cython compilation issues with pyOpenMS bindings Changes made: - Modified Precursor.h: enum -> enum class, array sizes use static_cast - Modified Precursor.cpp: Added static_assert for array size validation, updated array indexing to use static_cast<size_t>() - Updated Precursor.pxd for Cython: cdef enum -> cdef enum class - Updated all usages across codebase (format handlers, analysis modules, TOPP tools, GUI components, tests) to use qualified enum syntax - Added compile-time assertions to ensure array sizes match enum count
WalkthroughConvert Precursor::ActivationMethod to a scoped Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (1)src/openms/**/*.{cpp,h,hpp,cc,cxx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🧠 Learnings (7)📚 Learning: 2025-08-05T12:43:11.681ZApplied to files:
📚 Learning: 2025-08-05T12:43:11.681ZApplied to files:
📚 Learning: 2025-08-05T12:43:11.681ZApplied to files:
📚 Learning: 2025-08-14T10:19:54.371ZApplied to files:
📚 Learning: 2025-10-21T13:02:16.431ZApplied to files:
📚 Learning: 2025-08-05T12:43:11.681ZApplied to files:
📚 Learning: 2025-08-05T12:43:11.681ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
🔇 Additional comments (3)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
src/openms_gui/source/VISUAL/VISUALIZER/PrecursorVisualizer.cpp (1)
54-77: Fix enum‑class loop bounds to restore compilation
enum class Precursor::ActivationMethodno longer implicitly converts to an integer, so conditions likefor (Size i = 0; i < Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; ++i)are ill‑formed and will fail to compile. The same applies in
store().Convert the enum size to an integral once and cast indices back to
ActivationMethodwhere needed. For example:- activation_methods_->clear(); - for (Size i = 0; i < Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; ++i) + activation_methods_->clear(); + const auto am_count = static_cast<Size>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD); + for (Size i = 0; i < am_count; ++i) { QListWidgetItem * item = new QListWidgetItem(activation_methods_); - item->setText(QString::fromStdString(Precursor::NamesOfActivationMethod[static_cast<size_t>(i)])); - if (temp_.getActivationMethods().count(Precursor::ActivationMethod(i)) == 1) + const auto am = static_cast<Precursor::ActivationMethod>(i); + item->setText(QString::fromStdString(Precursor::NamesOfActivationMethod[static_cast<size_t>(am)])); + if (temp_.getActivationMethods().count(am) == 1) { item->setCheckState(Qt::Checked); }and in
store():- ptr_->getActivationMethods().clear(); - for (UInt i = 0; i < Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; ++i) + ptr_->getActivationMethods().clear(); + const auto am_count = static_cast<UInt>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD); + for (UInt i = 0; i < am_count; ++i) { if (activation_methods_->item(i)->checkState() == Qt::Checked) { - ptr_->getActivationMethods().insert(Precursor::ActivationMethod(i)); + ptr_->getActivationMethods().insert(static_cast<Precursor::ActivationMethod>(i)); } }This keeps behavior identical while making the enum‑class usage valid.
Also applies to: 91-98
src/topp/FileFilter.cpp (1)
439-452: Repair ActivationMethod loops to avoid enum‑class/integer comparison errorsThe
spectra:*_activationhandling now usesenum class Precursor::ActivationMethod, but the loops still compare an integer index to the enum:for (Size i = 0; i < Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; ++i)This is ill‑formed with an enum class and will not compile. The logic only needs the numeric range for indexing
NamesOfActivationMethod, so casting the enum size once is sufficient. For example:- setValidStrings_("spectra:remove_activation", Precursor::NamesOfActivationMethod, (int)Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD); + setValidStrings_("spectra:remove_activation", + Precursor::NamesOfActivationMethod, + static_cast<int>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD)); ... - for (Size i = 0; i < Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; ++i) + const auto am_count = static_cast<Size>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD); + for (Size i = 0; i < am_count; ++i) { if (Precursor::NamesOfActivationMethod[static_cast<size_t>(i)] == remove_activation) { exp.getSpectra().erase(remove_if(exp.begin(), exp.end(), HasActivationMethod<MapType::SpectrumType>(ListUtils::create<String>(remove_activation))), exp.end()); } } ... - for (Size i = 0; i < Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; ++i) + const auto am_count = static_cast<Size>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD); + for (Size i = 0; i < am_count; ++i) { if (Precursor::NamesOfActivationMethod[static_cast<size_t>(i)] == select_activation) { exp.getSpectra().erase(remove_if(exp.begin(), exp.end(), HasActivationMethod<MapType::SpectrumType>(ListUtils::create<String>(select_activation), true)), exp.end()); } }This preserves existing behavior while making the enum‑class usage compile correctly.
Also applies to: 911-933
src/openms/source/FORMAT/HANDLERS/MzXMLHandler.cpp (2)
225-235: Fix enum‑class usage in activation parsing (pointer arithmetic)The
std::findrange and end iterator currently usePrecursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHODdirectly in pointer arithmetic:auto it = std::find(Precursor::NamesOfActivationMethodShort, Precursor::NamesOfActivationMethodShort + Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD, activation); if (it != Precursor::NamesOfActivationMethodShort + Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD) { spectrum_data_.back().spectrum.getPrecursors().back().getActivationMethods() .insert(Precursor::ActivationMethod(it - Precursor::NamesOfActivationMethodShort)); }With
ActivationMethodnow anenum class, adding it to a pointer is ill‑formed. Also, the conversion from pointer difference toActivationMethodshould be explicit. A minimal, type‑safe fix:- auto it = std::find(Precursor::NamesOfActivationMethodShort, - Precursor::NamesOfActivationMethodShort + Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD, - activation); - - if (it != Precursor::NamesOfActivationMethodShort + Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD) - { - spectrum_data_.back().spectrum.getPrecursors().back().getActivationMethods().insert(Precursor::ActivationMethod(it - Precursor::NamesOfActivationMethodShort)); - } + const auto am_count = static_cast<std::size_t>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD); + auto it = std::find(Precursor::NamesOfActivationMethodShort, + Precursor::NamesOfActivationMethodShort + am_count, + activation); + if (it != Precursor::NamesOfActivationMethodShort + am_count) + { + const auto idx = static_cast<std::size_t>(it - Precursor::NamesOfActivationMethodShort); + spectrum_data_.back().spectrum.getPrecursors().back().getActivationMethods() + .insert(static_cast<Precursor::ActivationMethod>(idx)); + }This keeps the mapping logic but makes the enum‑class conversions explicit and valid.
1008-1020: Repair activationMethod attribute indexing (parentheses and enum casts)The
activationMethodattribute writeout currently has two problems:
- Syntactically, the
static_cast<size_t>calls are missing closing parentheses.- Semantically, we should cast the
ActivationMethodenum directly, without an intermediateint, and also cast the CID fallback.Current code (simplified):
if (!precursor.getActivationMethods().empty()) { os << " activationMethod=\"" - << Precursor::NamesOfActivationMethodShort[static_cast<size_t>(int(*(precursor.getActivationMethods().begin()))] << "\" "; } ... - os << " activationMethod=\"" << Precursor::NamesOfActivationMethodShort[static_cast<size_t>(Precursor::ActivationMethod::CID] << "\" ";Corrected version:
if (!precursor.getActivationMethods().empty()) { // must not be empty, but technically only ETD, ECD, CID are allowed in mzXML 3.1 - os << " activationMethod=\"" << Precursor::NamesOfActivationMethodShort[static_cast<size_t>(int(*(precursor.getActivationMethods().begin()))] << "\" "; + const auto am = *precursor.getActivationMethods().begin(); + os << " activationMethod=\"" + << Precursor::NamesOfActivationMethodShort[static_cast<std::size_t>(am)] + << "\" "; } else if (options_.getForceMQCompatability()) { // a missing activation would make old MQ versions crash... OPENMS_LOG_WARN << "Warning: An MS2 scan does not have data on it's activation method. Using 'CID' as fallback!\n"; - os << " activationMethod=\"" << Precursor::NamesOfActivationMethodShort[static_cast<size_t>(Precursor::ActivationMethod::CID] << "\" "; + os << " activationMethod=\"" + << Precursor::NamesOfActivationMethodShort[static_cast<std::size_t>(Precursor::ActivationMethod::CID)] + << "\" "; }This compiles cleanly under the enum‑class change and preserves the intended behavior (first activation method name, CID fallback for MQ compatibility).
🧹 Nitpick comments (2)
src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp (1)
1747-1871: ScopedActivationMethodusage in activation CV parsing looks consistentAll activation CV accessions under
<activation>are now mapped to the correspondingPrecursor::ActivationMethod::<NAME>entries for both spectra and chromatograms, without changing the surrounding logic. The mapping table (CID/PD/PSD/SID/BIRD/ECD/IMD/SORI/HCID/LCID/PHD/ETD/ETciD/EThcD/PQD/TRAP/HCD/INSOURCE/LIFT) matches the enum names and is symmetric with the writer below, so behavior should be unchanged while gaining type safety.You could later consider factoring the duplicated accession→enum mapping for spectra and chromatograms into a small helper to avoid divergence in future edits, but this is optional and outside this PR’s main scope.
Also applies to: 1913-1993
src/openms/source/METADATA/Precursor.cpp (1)
115-157: Indexing and iteration over activation methods correctly adapted to scoped enumThe accessors now index via
static_cast<size_t>(m)wheremisActivationMethod, and the “all names” helpers reserve/iterate up tostatic_cast<size_t>(ActivationMethod::SIZE_OF_ACTIVATIONMETHOD). This is the right way to use the scoped enum as an array index and pairs cleanly with the size-based static_asserts above.If you ever want to decouple the loops from the sentinel, you could use
std::size(NamesOfActivationMethod)/std::size(NamesOfActivationMethodShort)in the for‑conditions, but that’s optional given the existing static_asserts.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (19)
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.h(1 hunks)src/openms/include/OpenMS/KERNEL/RangeUtils.h(1 hunks)src/openms/include/OpenMS/METADATA/Precursor.h(3 hunks)src/openms/source/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.cpp(2 hunks)src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp(1 hunks)src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp(1 hunks)src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp(3 hunks)src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp(2 hunks)src/openms/source/FORMAT/HANDLERS/MzXMLHandler.cpp(1 hunks)src/openms/source/METADATA/Precursor.cpp(6 hunks)src/openms/source/QC/Ms2SpectrumStats.cpp(1 hunks)src/openms_gui/source/VISUAL/VISUALIZER/PrecursorVisualizer.cpp(2 hunks)src/pyOpenMS/pxds/Precursor.pxd(1 hunks)src/tests/class_tests/openms/source/MzDataFile_test.cpp(1 hunks)src/tests/class_tests/openms/source/MzMLFile_test.cpp(2 hunks)src/tests/class_tests/openms/source/Precursor_test.cpp(9 hunks)src/tests/class_tests/openms/source/RangeUtils_test.cpp(4 hunks)src/topp/FileFilter.cpp(4 hunks)src/topp/FileInfo.cpp(2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/include/OpenMS/KERNEL/RangeUtils.hsrc/openms/include/OpenMS/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.hsrc/openms/source/FORMAT/FLASHDeconvSpectrumFile.cppsrc/openms/source/QC/Ms2SpectrumStats.cppsrc/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cppsrc/openms/include/OpenMS/METADATA/Precursor.hsrc/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cppsrc/openms/source/FORMAT/HANDLERS/MzMLHandler.cppsrc/openms/source/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.cppsrc/openms/source/FORMAT/HANDLERS/MzXMLHandler.cppsrc/openms/source/METADATA/Precursor.cpp
src/openms/include/OpenMS/**/*.h
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Add Doxygen comments for new public methods and classes
Files:
src/openms/include/OpenMS/KERNEL/RangeUtils.hsrc/openms/include/OpenMS/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.hsrc/openms/include/OpenMS/METADATA/Precursor.h
src/tests/class_tests/openms/**/*.cpp
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write unit tests for new functionality
Files:
src/tests/class_tests/openms/source/MzMLFile_test.cppsrc/tests/class_tests/openms/source/MzDataFile_test.cppsrc/tests/class_tests/openms/source/Precursor_test.cppsrc/tests/class_tests/openms/source/RangeUtils_test.cpp
🧠 Learnings (8)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms
Applied to files:
src/openms/include/OpenMS/KERNEL/RangeUtils.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/openms/source/QC/Ms2SpectrumStats.cppsrc/tests/class_tests/openms/source/MzMLFile_test.cppsrc/tests/class_tests/openms/source/MzDataFile_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/pyOpenMS/**/*.h : Add Doxygen comments for new public methods and classes in pyOpenMS bindings
Applied to files:
src/pyOpenMS/pxds/Precursor.pxd
📚 Learning: 2025-06-16T15:48:09.667Z
Learnt from: FreezB11
Repo: OpenMS/OpenMS PR: 7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:4-4
Timestamp: 2025-06-16T15:48:09.667Z
Learning: In OpenMS .pxd files, the established pattern for extern from statements is to include angle brackets inside the string literal, like `cdef extern from "<OpenMS/PATH/TO/FILE.h>" namespace "OpenMS":`. This is consistent across all existing quantitation method .pxd files and other .pxd files in the OpenMS codebase.
Applied to files:
src/pyOpenMS/pxds/Precursor.pxd
📚 Learning: 2025-06-16T15:49:26.504Z
Learnt from: FreezB11
Repo: OpenMS/OpenMS PR: 7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:1-3
Timestamp: 2025-06-16T15:49:26.504Z
Learning: In OpenMS Python bindings (.pxd files), derived quantitation method classes like TMTThirtyTwoPlexQuantitationMethod only need to declare their constructors. All other public methods (getName, getChannelInformation, getNumberOfChannels, getIsotopeCorrectionMatrix, getReferenceChannel) are inherited from the base IsobaricQuantitationMethod class and don't need to be redeclared explicitly.
Applied to files:
src/pyOpenMS/pxds/Precursor.pxdsrc/openms/source/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/tests/class_tests/openms/source/MzMLFile_test.cppsrc/tests/class_tests/openms/source/MzDataFile_test.cppsrc/tests/class_tests/openms/source/Precursor_test.cppsrc/tests/class_tests/openms/source/RangeUtils_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`
Applied to files:
src/tests/class_tests/openms/source/MzMLFile_test.cppsrc/tests/class_tests/openms/source/MzDataFile_test.cppsrc/tests/class_tests/openms/source/Precursor_test.cppsrc/tests/class_tests/openms/source/RangeUtils_test.cpp
📚 Learning: 2025-09-03T12:58:20.032Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.
Applied to files:
src/tests/class_tests/openms/source/MzDataFile_test.cpp
🧬 Code graph analysis (3)
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.h (1)
src/openms/source/METADATA/Precursor.cpp (1)
Precursor(68-82)
src/tests/class_tests/openms/source/Precursor_test.cpp (2)
src/openms/source/METADATA/Precursor.cpp (3)
Precursor(68-82)getAllShortNamesOfActivationMethods(148-157)getAllShortNamesOfActivationMethods(148-148)src/openms/include/OpenMS/METADATA/Precursor.h (1)
set(96-209)
src/openms/source/FORMAT/HANDLERS/MzXMLHandler.cpp (1)
src/topp/FileInfo.cpp (4)
os(128-138)os(128-128)os(637-2187)os(637-637)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-win
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- GitHub Check: build-lnx
- GitHub Check: build-lnx-arm
🔇 Additional comments (31)
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (1)
1561-1564: LGTM!The scoped enum syntax
Precursor::ActivationMethod::HCIDandPrecursor::ActivationMethod::HCDis correctly applied, aligning with the project-wide migration toenum class.src/openms/include/OpenMS/KERNEL/RangeUtils.h (1)
328-335: LGTM!The
static_cast<size_t>(am)is correctly applied for array indexing, which is required since scoped enum classes don't implicitly convert to integers.src/openms/include/OpenMS/METADATA/Precursor.h (1)
58-83: LGTM!The conversion from unscoped enum to
enum class ActivationMethodis correctly implemented:
- Scoped enum prevents implicit integer conversion, improving type safety.
- Array size declarations correctly use
static_cast<size_t>(ActivationMethod::SIZE_OF_ACTIVATIONMETHOD).- Existing Doxygen comments for individual values are preserved.
src/tests/class_tests/openms/source/RangeUtils_test.cpp (4)
263-265: LGTM!The scoped enum syntax
Precursor::ActivationMethod::PSDandPrecursor::ActivationMethod::BIRDis correctly applied for inserting activation methods into the set.
274-276: LGTM!Correctly updated to use scoped enum
Precursor::ActivationMethod::BIRD.
285-287: LGTM!Correctly updated to use scoped enum
Precursor::ActivationMethod::LCID.
295-297: LGTM!Correctly updated to use scoped enum
Precursor::ActivationMethod::PD.src/topp/FileInfo.cpp (1)
1436-1441: ActivationMethod indexing changes are correct and type-safeUsing
static_cast<size_t>to indexNamesOfActivationMethodShort/NamesOfActivationMethodfromPrecursor::ActivationMethodvalues is exactly what’s needed after converting toenum class. No behavior change, and array bounds are still tied to the enum size elsewhere.Also applies to: 1592-1595
src/openms/source/QC/Ms2SpectrumStats.cpp (1)
64-67: Safe cast for ActivationMethod meta valueThe added
static_cast<size_t>when indexingNamesOfActivationMethodShortfrom the first activation method fixes the enum-class typing without changing behavior; emptiness is checked beforehand, so no additional edge cases are introduced.src/tests/class_tests/openms/source/MzDataFile_test.cpp (1)
144-157: Test enum qualification aligned with scoped ActivationMethodSwitching to
Precursor::ActivationMethod::CID/SIDmatches the new enum class and keeps the test semantics identical.src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp (1)
328-333: Guarded ActivationMethod-to-index conversion looks goodThe
< SIZE_OF_ACTIVATIONMETHODcheck plusstatic_cast<size_t>(dspec.getActivationMethod())produces a safe index intoNamesOfActivationMethodShortunder the new scoped enum.src/openms/source/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.cpp (2)
118-118: LGTM!The activation list size calculation correctly uses the scoped enum
Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHODfor the array bounds.
430-430: LGTM!The indexing into
NamesOfActivationMethodcorrectly usesstatic_cast<size_t>()with the scoped enum valuesPrecursor::ActivationMethod::HCIDandPrecursor::ActivationMethod::HCD, consistent with the enum class refactor pattern used elsewhere in the PR.src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp (2)
663-667: LGTM!The bounds check correctly uses
Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHODwithstatic_cast<int>()for comparison against the SQLite integer column value. The subsequent cast toOpenMS::Precursor::ActivationMethodon line 666 properly converts back to the scoped enum type for insertion.
806-810: LGTM!Consistent with the chromatogram handling above, the spectrum precursor bounds check correctly uses the scoped enum
Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHODwith appropriate casting.src/pyOpenMS/pxds/Precursor.pxd (1)
64-108: LGTM!The Cython declaration correctly transitions from
cdef enumtocdef enum classwith the explicit C++ namespace string"OpenMS::Precursor::ActivationMethod". This properly exposes the scoped enum class to the Python bindings and aligns with the C++ header changes.src/tests/class_tests/openms/source/Precursor_test.cpp (11)
75-77: LGTM!Test correctly uses the scoped enum
Precursor::ActivationMethod::CID.
81-85: LGTM!The set declaration uses
set<Precursor::ActivationMethod>and insertion uses the scoped enum value correctly.
89-95: LGTM!Consistent scoped enum usage in
getActivationMethodsAsStringtest.
99-105: LGTM!Consistent scoped enum usage in
getActivationMethodsAsShortStringtest.
107-115: LGTM!Both static method tests correctly compare the result size against
static_cast<size_t>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD), which is the proper way to convert the scoped enum sentinel to a size type.
190-218: LGTM!Copy constructor test correctly uses scoped enum
Precursor::ActivationMethod::CID.
220-255: LGTM!Move constructor test correctly uses both
Precursor::ActivationMethod::CIDandPrecursor::ActivationMethod::BIRDscoped enum values.
257-301: LGTM!Copy assignment operator test correctly uses scoped enum.
303-339: LGTM!Move assignment operator test correctly uses scoped enum values.
356-360: LGTM!Equality operator test correctly uses scoped enum.
405-409: LGTM!Inequality operator test correctly uses scoped enum.
src/tests/class_tests/openms/source/MzMLFile_test.cpp (2)
449-452: LGTM!Test assertions correctly use scoped enum syntax
Precursor::ActivationMethod::CIDandPrecursor::ActivationMethod::PDfor verifying activation methods loaded from the mzML file.
464-466: LGTM!Test assertion correctly uses
Precursor::ActivationMethod::ETDscoped enum value.src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp (1)
3866-3955: Activation method serialization correctly updated to scoped enumThe checks in
writePrecursor_now useprecursor.getActivationMethods().count(Precursor::ActivationMethod::<NAME>)for all supported methods, and the emitted PSI-MS accessions/names still match the read-side mappings (including ETciD/EThcD, HCID/LCID, INSOURCE, LIFT, etc.). Indexing and logic are unchanged apart from the scoped enum qualification, so this preserves mzML I/O behavior while aligning with the new enum class.src/openms/source/METADATA/Precursor.cpp (1)
16-66: Array sizing and compile-time checks forActivationMethodlook soundDeclaring
NamesOfActivationMethodandNamesOfActivationMethodShortwith sizestatic_cast<size_t>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD)and adding the twostatic_asserts gives a robust guarantee that the arrays stay in sync with the enum’s sentinel size. The use ofstatic_cast<size_t>on the scoped enum in these constant expressions is correct and keeps the mapping safe under the newenum class.
…lExtractor.h Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Add explicit static_cast for ActivationMethod enum class: - MzDataHandler.cpp: Cast to UInt for writeCVS_ call - MzMLSqliteHandler.cpp: Cast to int when storing activation_method
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp (1)
663-667: Tighten lower-bound validation for activation_method integersThe new
static_cast<int>(OpenMS::Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD)usage is correct for anenum class, but the check still allows any value< SIZE_OF_ACTIVATIONMETHODand!= -1. Corrupted data with values< -1would still pass and be cast to an invalidActivationMethodvalue.Consider tightening both conditions to explicitly enforce a non‑negative range:
- if (sqlite3_column_type(stmt, 12) != SQLITE_NULL && sqlite3_column_int(stmt, 12) != -1 - && sqlite3_column_int(stmt, 12) < static_cast<int>(OpenMS::Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD)) + if (sqlite3_column_type(stmt, 12) != SQLITE_NULL) + { + const int activation = sqlite3_column_int(stmt, 12); + if (activation >= 0 && + activation < static_cast<int>(OpenMS::Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD)) + { + precursor.getActivationMethods().insert( + static_cast<OpenMS::Precursor::ActivationMethod>(activation)); + } + }and analogously for the spectrum case at column 15.
This keeps semantics for
-1(treated as “no activation”), while rejecting other negative garbage values instead of casting them into the enum.Also applies to: 806-810
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/openms/source/FORMAT/HANDLERS/MzDataHandler.cpp(1 hunks)src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp(4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/source/FORMAT/HANDLERS/MzDataHandler.cppsrc/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: build-lnx-arm
- GitHub Check: build-lnx
- GitHub Check: build-win
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
- GitHub Check: build-and-test (macos-26, xcode, 26.0)
- GitHub Check: cppcheck-test
🔇 Additional comments (3)
src/openms/source/FORMAT/HANDLERS/MzDataHandler.cpp (1)
978-978: LGTM! Explicit cast correctly handles enum class conversion.The
static_cast<UInt>is necessary because enum class values don't implicitly convert to integers. The cast target matches thewriteCVS_function signature, and bounds checking is handled withinwriteCVS_at lines 1459-1463.src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp (2)
1117-1123: Enum-class → int cast for precursor activation method is correctThe change to
activation_method = static_cast<int>(*prec.getActivationMethods().begin());is the right way to persist the
enum class ActivationMethodas an integer, and it preserves the previous behavior of storing the first (only) activation method when present.
1330-1334: Enum-class → int cast for chromatogram activation method is correctSame as in the spectra path, the explicit
activation_method = static_cast<int>(*prec.getActivationMethods().begin());is appropriate for
enum class ActivationMethodand keeps the existing semantics of writing a single activation method code into the database.
- Add static_cast<size_t>() for pointer arithmetic with SIZE_OF_ACTIVATIONMETHOD - Fix missing closing parentheses in static_cast expressions for array indexing
- PrecursorVisualizer.cpp: Add static_cast for loop comparisons with SIZE_OF_ACTIVATIONMETHOD - FileFilter.cpp: Add static_cast for loop comparisons with SIZE_OF_ACTIVATIONMETHOD - FLASHDeconvSpectrumFile.cpp: Add static_cast for enum comparison
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/openms_gui/source/VISUAL/VISUALIZER/PrecursorVisualizer.cpp (2)
56-77: Scoped enum loop bound is correct; consider explicit enum casts and simplifying QListWidgetItem usageThe new loop bound using
static_cast<Size>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD)is consistent with theenum classchange and looks correct.Two small, non-blocking cleanups you may want to do while touching this code:
- Make the conversion from the loop index to the scoped enum explicit and idiomatic, e.g.:
for (Size i = 0; i < static_cast<Size>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD); ++i) { const auto method = static_cast<Precursor::ActivationMethod>(i); QListWidgetItem* item = new QListWidgetItem(activation_methods_); item->setText(QString::fromStdString(Precursor::NamesOfActivationMethod[i])); if (temp_.getActivationMethods().count(method) == 1) { // ... } // ... }
- With
QListWidgetItem(activation_methods_), the item is already inserted into the list;activation_methods_->addItem(item);is redundant and can be dropped to avoid double-insertion confusion:- QListWidgetItem * item = new QListWidgetItem(activation_methods_); + QListWidgetItem * item = new QListWidgetItem(activation_methods_); // ... - activation_methods_->addItem(item);These are style/clarity improvements only; existing behavior remains the same with your loop-bound change.
92-98: Loop bound cast instore()is fine; optionally align index type and enum cast withupdate_()The new bound
static_cast<UInt>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD)is correct and matches the enum-class-based size.For consistency and readability, you might:
- Use the same index type as in
update_()(e.g.Size) unless there is a specific reason to preferUInthere.- Mirror the explicit scoped-enum cast as suggested above:
for (Size i = 0; i < static_cast<Size>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD); ++i) { if (activation_methods_->item(static_cast<int>(i))->checkState() == Qt::Checked) { ptr_->getActivationMethods().insert(static_cast<Precursor::ActivationMethod>(i)); } }This keeps the enum usage explicit and consistent across
update_()andstore(), and makes the intent around scoped-enum conversions clearer.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp(1 hunks)src/openms_gui/source/VISUAL/VISUALIZER/PrecursorVisualizer.cpp(2 hunks)src/topp/FileFilter.cpp(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/topp/FileFilter.cpp
🧰 Additional context used
📓 Path-based instructions (1)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp
🧠 Learnings (3)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Applied to files:
src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations
Applied to files:
src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: build-and-test (macos-26, xcode, 26.0)
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: build-and-test (macos-15-intel, xcode, 16.0.0)
- GitHub Check: build-lnx-arm
- GitHub Check: build-macos-arm
- GitHub Check: build-lnx
- GitHub Check: build-macos
- GitHub Check: build-win
- GitHub Check: cppcheck-test
🔇 Additional comments (1)
src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp (1)
330-333: Scoped enum handling and bounds check for activation method look goodCasting the scoped
ActivationMethodtosize_tfor both the< SIZE_OF_ACTIVATIONMETHODguard and the array index is correct and consistent with the newenum classsemantics, and the check prevents any out-of-range access toNamesOfActivationMethodShort. No further changes needed here.
…60-01LmhYPcZ8NpWGru4zeX8Mbi
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (5)
src/openms_gui/source/VISUAL/LayerDataChrom.cpp (1)
23-23: Remove unused Boost include.After migrating to
std::make_shared, this Boost header is no longer needed.Apply this diff:
-#include <boost/make_shared.hpp>src/openms_gui/source/VISUAL/APPLICATIONS/TOPPViewBase.cpp (1)
67-67: Remove unusedboost/make_shared.hppinclude at line 67.The verification confirms this include is no longer needed. The file contains only this single Boost include, and there are no remaining usages of
boost::make_sharedorboost::shared_ptrin the code. After the migration tostd::make_shared, this include should be removed.src/topp/OpenSwathWorkflow.cpp (2)
459-522: Fix missing standard headers for new utilitiesThe new helpers and data structures in this file rely on standard library components that are not explicitly included here:
is_valid_winandapply_windowusestd::isfinite(Line 541), which formally requires<cmath>.loadPriorityPeptideSequencesand thepriority_peptidesset (Lines 620, 1005) usestd::unordered_set, which requires<unordered_set>.Compilation may currently succeed via transitive includes, but this is not guaranteed and can break when headers change. It’s safer for this TU to include the needed headers directly, e.g.:
#include <cassert> #include <limits> + +#include <cmath> +#include <unordered_set>Also applies to: 541-607, 620-661, 770-805, 960-987, 1004-1051, 1110-1186, 1188-1317
459-522: Minor robustness & logging issues in auto window estimationA few small points in the new auto-estimation logic:
parseEstimateExtractionWindows_treats an empty string as “none” (all flags false), although the docstring says empty/malformed values should raiseInvalidParameter. If you want strict behavior, consider an explicitif (s.empty()) throw ...;after trimming.- In the nonlinear calibration branch (Lines 1188+), the warning messages for MS2/MS1 m/z use
calibration_result.ms2_mz_window_ppm/.ms1_mz_window_ppmeven though the applied estimates come fromestimated_mz_extraction_window/estimated_ms1_mz_extraction_windowreturned byOpenSwathCalibrationWorkflow. This makes the log slightly misleading; using theestimated_*variables in the message would better reflect what was actually computed in the nonlinear step.These don’t affect numerical results but tightening them would make configuration errors and logs easier to interpret.
Also applies to: 541-607, 770-805, 1110-1186, 1188-1317
src/openms/include/OpenMS/ANALYSIS/OPENSWATH/MRMScoring.h (1)
11-11: Add<memory>include for FeatureType alias
FeatureTypeis now defined asstd::shared_ptr<OpenSwath::IFeature>, but this header does not include<memory>itself. To keep the header self-contained and avoid relying on transitive includes, it would be safer to add:#pragma once -#include <string> +#include <string> +#include <memory>Also applies to: 62-62
🧹 Nitpick comments (30)
src/topp/MRMMapper.cpp (1)
139-146: Smart‑pointer migration is correct; consider more idiomatic constructionThe switch to
std::shared_ptrhere is functionally fine, but you can simplify and decouple from the concrete pointer type by constructing via the alias andmake_shared:- DataProcessingPtr dp = std::shared_ptr<DataProcessing>(new DataProcessing(dp_)); + DataProcessingPtr dp = std::make_shared<DataProcessing>(dp_);This avoids the explicit
new, is the usual modern C++ pattern, and keeps the code aligned withDataProcessingPtrif its underlying type ever changes again.src/tests/class_tests/openms/source/MzCalibration_test.cpp (1)
74-74: Pointer type migration looks good; considerstd::make_sharedfor modern idiom.The change from
boost::shared_ptrtostd::shared_ptris correct and aligns with the PR's modernization effort.Optionally, prefer
std::make_sharedfor exception safety and efficiency:-std::shared_ptr<DataProcessing> p_(new DataProcessing(p)); +auto p_ = std::make_shared<DataProcessing>(p);src/topp/MRMTransitionGroupPicker.cpp (1)
252-260: Change tostd::shared_ptrlooks correct; considerstd::make_sharedfor idiomatic styleThe migration to
std::shared_ptr<PeakMap>here is fine and keeps the surrounding logic unchanged. For more idiomatic modern C++, you could simplify the allocation:- std::shared_ptr<PeakMap > exp ( new PeakMap ); + auto exp = std::make_shared<PeakMap>();This is slightly clearer, avoids repeating the type, and is the common pattern in newer codebases.
src/openms_gui/include/OpenMS/VISUAL/PlotCanvas.h (1)
911-931: Prefermake_sharedand rely on the alias instead of explicitstd::shared_ptrThe initialization on Line 917 is correct but a bit verbose and hard-wires
std::shared_ptrdespite havingDataProcessingPtr:DataProcessingPtr p = std::shared_ptr<DataProcessing>(new DataProcessing);Consider simplifying to avoid raw
new, use single-allocationmake_shared, and rely on the alias:DataProcessingPtr p = std::make_shared<DataProcessing>(); // or even: auto p = std::make_shared<DataProcessing>();This keeps the code shorter and better aligned with modern C++ practices while preserving flexibility if
DataProcessingPtrever changes.src/topp/OpenSwathFileSplitter.cpp (1)
107-123: Preferstd::make_sharedforexp_metaconstructionMinor style/idiom nit: consider using
std::make_sharedinstead ofnewwithstd::shared_ptrfor better clarity and slightly improved exception safety.- std::shared_ptr<ExperimentalSettings> exp_meta(new ExperimentalSettings); + auto exp_meta = std::make_shared<ExperimentalSettings>();This keeps the behavior identical while following modern C++ conventions.
src/openms_gui/source/VISUAL/TVIdentificationViewController.cpp (1)
981-985: Switch tostd::make_sharedis correct; optionally modernize neighboring shared_ptr constructionThe change to
ExperimentSharedPtrType new_exp_sptr = std::make_shared<AnnotatedMSRun>();is a clean, type-safe replacement for the former Boost
make_sharedusage and keeps ownership semantics intact when passingnew_exp_sptrintoaddPeakLayer.As an optional follow-up for consistency with this migration, you could also construct
od_dummyviastd::make_shared<OnDiscMSExperiment>()(or the corresponding alias) instead ofnew OnDiscMSExperiment(), but this is not required for correctness here.src/openms/source/FORMAT/IBSpectraFile.cpp (1)
78-107:guessExperimentType_migration tostd::shared_ptris sound; considerstd::make_shared.The switch of the return type to
std::shared_ptr<IsobaricQuantitationMethod>and the logic for selecting the concrete quantitation method are consistent and behavior-preserving. You may optionally modernize the three return sites to usestd::make_shared<...>()for slightly better performance and exception safety:- if (cm.getColumnHeaders().size() == 4) - { - return std::shared_ptr<IsobaricQuantitationMethod>(new ItraqFourPlexQuantitationMethod); - } + if (cm.getColumnHeaders().size() == 4) + { + return std::make_shared<ItraqFourPlexQuantitationMethod>(); + } else if (cm.getColumnHeaders().size() == 6) { - return std::shared_ptr<IsobaricQuantitationMethod>(new TMTSixPlexQuantitationMethod); + return std::make_shared<TMTSixPlexQuantitationMethod>(); } else if (cm.getColumnHeaders().size() == 8) { - return std::shared_ptr<IsobaricQuantitationMethod>(new ItraqEightPlexQuantitationMethod); + return std::make_shared<ItraqEightPlexQuantitationMethod>(); }src/tests/class_tests/openms/source/SwathMapMassCorrection_test.cpp (2)
166-166: Preferstd::make_sharedover directnewfor exception safety and efficiency.The conversion from
boost::shared_ptrtostd::shared_ptrmodernizes the codebase effectively. However, using directnewwith the shared_ptr constructor is less exception-safe and performs two allocations instead of one.Consider applying this pattern to improve exception safety and performance:
- std::shared_ptr<PeakMap > exp(new PeakMap); + std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();- std::shared_ptr<PeakMap > exp2(new PeakMap); + std::shared_ptr<PeakMap> exp2 = std::make_shared<PeakMap>();Also applies to: 189-189
437-437: Preferstd::make_sharedover directnewfor exception safety and efficiency.Same recommendation as the earlier section: the modernization to
std::shared_ptris good, but usingstd::make_sharedwould be more idiomatic and safer.Apply this pattern:
- std::shared_ptr<PeakMap > exp(new PeakMap); + std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();- std::shared_ptr<PeakMap > exp2(new PeakMap); + std::shared_ptr<PeakMap> exp2 = std::make_shared<PeakMap>();- std::shared_ptr<PeakMap > exp_ms1(new PeakMap); + std::shared_ptr<PeakMap> exp_ms1 = std::make_shared<PeakMap>();Also applies to: 478-478, 518-518
doc/code_examples/Tutorial_GUI_Plot1D.cpp (1)
32-32: Optional: also modernizeon_disc_exp_sptrconstructionFor consistency with the move to standard smart pointers, you could consider changing
LayerDataBase::ODExperimentSharedPtrType on_disc_exp_sptr(new OnDiscMSExperiment());to a
std::make_shared-based construction (ifODExperimentSharedPtrTypeis now an alias forstd::shared_ptr<OnDiscMSExperiment>), e.g.:LayerDataBase::ODExperimentSharedPtrType on_disc_exp_sptr = std::make_shared<OnDiscMSExperiment>();Purely stylistic; not required for this PR.
src/openms/include/OpenMS/FORMAT/DATAACCESS/SwathFileConsumer.h (1)
303-306: std::shared_ptr migration looks fine; consider modernized construction and explicit includeThe switch from
boost::shared_ptrtostd::shared_ptrforswath_maps_/ms1_map_and the variousexplocals is semantically correct and keeps the existing ownership model intact. As small optional cleanups:
Use
std::make_sharedto constructPeakMapinstances instead ofstd::shared_ptr<PeakMap>(new PeakMap(...))for better readability, exception safety, and slightly reduced allocations, e.g.:std::shared_ptr exp(new PeakMap(settings_));
swath_maps_.push_back(exp);
- swath_maps_.push_back(std::make_shared(settings_));
and similarly for `ms1_map_` and the `ensureMapsAreFilled_` allocations.
Where you immediately assign to a member or vector element, you can also skip the temporary and assign directly:
std::shared_ptr exp(new PeakMap);
swath_maps_[i] = exp;
- swath_maps_[i] = std::make_shared();
- If not already done elsewhere, consider adding an explicit
#include <memory>in this header to avoid depending on transitive includes forstd::shared_ptr.These are non-blocking style improvements; the current code is functionally OK. Based on learnings, this also keeps memory usage efficient for large datasets.
Also applies to: 345-347, 361-363, 440-442, 460-462, 500-506, 513-519
src/tests/class_tests/openms/source/MRMFeatureFinderScoring_test.cpp (3)
59-59: Consider using std::make_shared for better practices.While the current approach works, prefer
std::make_shared<PeakMap>()overnew PeakMapfor improved exception safety and performance (single allocation for control block and object).Apply this diff:
- std::shared_ptr<PeakMap> swath_map (new PeakMap); + std::shared_ptr<PeakMap> swath_map = std::make_shared<PeakMap>(); TransitionGroupMapType transition_group_map; MRMFeatureFinderScoring::MRMTransitionGroupType transition_group; // Load the chromatograms (mzML) and the meta-information (TraML) - std::shared_ptr<PeakMap> exp (new PeakMap); + std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();Also applies to: 64-64
221-221: Consider using std::make_shared for better practices.Same as the previous test section - prefer
std::make_shared<PeakMap>()overnew PeakMap.Apply this diff:
- std::shared_ptr<PeakMap> swath_map (new PeakMap); + std::shared_ptr<PeakMap> swath_map = std::make_shared<PeakMap>(); TransitionGroupMapType transition_group_map; // Load the chromatograms (mzML) and the meta-information (TraML) - std::shared_ptr<PeakMap> exp (new PeakMap); + std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();Also applies to: 225-225
307-307: Consider using std::make_shared for better practices.Same recommendation - prefer
std::make_shared<PeakMap>()overnew PeakMap.Apply this diff:
- std::shared_ptr<PeakMap> exp (new PeakMap); + std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();src/topp/OpenSwathRTNormalizer.cpp (1)
197-198: Usestd::make_sharedfor improved performance and exception safety.The migration from
boost::shared_ptrtostd::shared_ptris correct. The recommendation to preferstd::make_sharedover directnewallocation is valid and follows patterns already established in the codebase (e.g.,MRMFeatureFinderScoring.cpplines 161–162). Benefits include single allocation of control block and object together, and stronger exception safety.The design where
swath_mapremains empty is intentional—it serves as a separate data structure distinct fromxic_map, which is populated with chromatogram data. Both empty and populated maps are passed togetSpectrumAccessOpenMSPtras intended.Apply this refactor:
- std::shared_ptr<MapType> swath_map (new MapType()); // the map with the extracted ion chromatograms - std::shared_ptr<MapType> xic_map (new MapType()); + std::shared_ptr<MapType> swath_map = std::make_shared<MapType>(); // the map with the extracted ion chromatograms + std::shared_ptr<MapType> xic_map = std::make_shared<MapType>();src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp (1)
431-431: Avoid duplicating MS1 PeakMap copies; reuse a single sharedPeakMapandSpectrumAccessPtr.Right now
ms_data_is copied twice onto the heap: once viastd::make_shared<MSExperiment>(ms_data_)forsetMS1Map(Line 431) and again viastd::make_shared<PeakMap>(ms_data_)forspec_temp(Lines 510–512). For large MS1 experiments this is a noticeable, unnecessary memory overhead, since both consumers only need read‑only access to the same data.You can create a single
std::shared_ptr<PeakMap>once, build oneSpectrumAccessPtrfrom it, and reuse that both forfeat_finder_.setMS1Mapand for extraction, while still allowingms_data_.reset()later to free the original member:@@ - feat_finder_.setStrictFlag(false); - // to use MS1 Swath scores: - feat_finder_.setMS1Map(SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(std::make_shared<MSExperiment>(ms_data_))); + feat_finder_.setStrictFlag(false); + // to use MS1 Swath scores: + std::shared_ptr<PeakMap> shared = std::make_shared<PeakMap>(ms_data_); + OpenSwath::SpectrumAccessPtr ms1_access = + SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(shared); + feat_finder_.setMS1Map(ms1_access); @@ - std::shared_ptr<PeakMap> shared = std::make_shared<PeakMap>(ms_data_); - OpenSwath::SpectrumAccessPtr spec_temp = - SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(shared); + OpenSwath::SpectrumAccessPtr spec_temp = ms1_access;This keeps a single heap copy of the MS1 data and a single
SpectrumAccessOpenMSinstance, reusing them in both places, while preserving existing semantics forms_data_.reset()and uses ofsharedlater in the function.Also applies to: 510-512
src/openms/source/FORMAT/HANDLERS/CachedMzMLHandler.cpp (1)
239-257: std::shared_ptr migration for DataProcessing looks fineSwitching
dpfromboost::shared_ptrtostd::shared_ptrin both metadata writers preserves behavior and matches the wider migration. If you touch this again, you could optionally modernize toauto dp = std::make_shared<DataProcessing>();to avoid repeating the type and the rawnew, but that’s not required here.Also applies to: 282-300
src/openms/include/OpenMS/FORMAT/XMassFile.h (1)
131-156: std::shared_ptr usage is fine; minor modernization possibleSwitching
data_processing_vectortostd::shared_ptr<DataProcessing>preserves the original semantics when passing intospectrum.setDataProcessing. If you touch this again, you could:
- Prefer the alias
DataProcessingPtr(if available) for consistency with other code, and/or- Use
std::make_shared<DataProcessing>(data_processing)instead of an explicitnew.Also ensure at least one included header in this file pulls in
<memory>so this header does not rely on transitive includes.src/tests/class_tests/openms/source/OpenSwathSpectrumAccessOpenMS_test.cpp (1)
18-18: std::shared_ptr migration in tests looks consistentThe switch from
boost::shared_ptrtostd::shared_ptrforPeakMapandOpenSwath::ISpectrumAccessin this test file is consistent with the updatedSpectrumAccessOpenMSAPI and keeps the test behavior unchanged. If you ever touch this again, you could replace thenew PeakMappatterns withstd::make_shared<PeakMap>()to avoid rawneweven in tests.Also applies to: 34-37, 49-54, 63-64, 72-87, 95-97, 112-113, 145-147, 168-170, 185-187, 206-208, 231-233, 252-254, 286-288, 317-319, 331-333
src/openms/source/APPLICATIONS/TOPPBase.cpp (1)
2354-2365: DataProcessing pointer migration preserves behaviorCreating one
std::shared_ptr<DataProcessing>and pushing it to all spectra and chromatograms matches the previous ownership model with Boost pointers. If you want to modernize further,auto dp_ = std::make_shared<DataProcessing>(dp);would avoid explicitnew.src/openms/source/KERNEL/OnDiscMSExperiment.cpp (1)
36-45: std::shared_ptr migration looks correct; considerstd::make_sharedfor clarityAssigning
meta_ms_experiment_viastd::shared_ptr<PeakMap>(new PeakMap)is functionally fine and consistent with the previous Boost usage. If you touch this again, considermeta_ms_experiment_ = std::make_shared<PeakMap>();to be more idiomatic and slightly cheaper in allocations.src/tests/class_tests/openms/source/ChromatogramSettings_test.cpp (1)
379-385: Test adapts correctly to std::shared_ptr; minor style tweak possibleUsing
DataProcessingPtr dp = std::shared_ptr<DataProcessing>(new DataProcessing);is correct for the updated alias. You could simplify toDataProcessingPtr dp = std::make_shared<DataProcessing>();(orauto dp = std::make_shared<DataProcessing>();) for cleaner, idiomatic test code.src/openms/include/OpenMS/FORMAT/HANDLERS/MzXMLHandler.h (1)
169-173: data_processing_ switched to std::shared_ptr consistentlyChanging
data_processing_tostd::vector<std::shared_ptr<DataProcessing>>is consistent with the rest of the migration away from Boost smart pointers and should be ABI‑compatible for internal use. Optionally, you could use the existingDataProcessingPtralias for consistency with other code paths.src/tests/class_tests/openms/source/SpectrumSettings_test.cpp (1)
281-283: Preferstd::make_shared(and/orDataProcessingPtr) for clarity and efficiencyAll three sites construct
DataProcessingviastd::shared_ptr<DataProcessing>(new DataProcessing). You can tighten this up and avoid the rawnewby usingmake_shared, which also makes the intent clearer:- DataProcessingPtr dp = std::shared_ptr<DataProcessing>(new DataProcessing); + DataProcessingPtr dp = std::make_shared<DataProcessing>();and analogously at the other two occurrences.
Also applies to: 328-330, 375-382
src/openms/include/OpenMS/FORMAT/HANDLERS/MzDataHandler.h (1)
184-185: Consider explicitly including<memory>forstd::shared_ptrSwitching
data_processing_tostd::shared_ptr<DataProcessing>is correct, but this header doesn’t include<memory>itself. To avoid depending on transitive includes from other headers, consider adding:#include <memory>near the other standard includes, or ensure it’s guaranteed via a central header.
src/openms/source/ANALYSIS/OPENSWATH/DATAACCESS/SpectrumAccessOpenMS.cpp (1)
30-33: Consider usingstd::make_sharedfor consistency and potential performance benefits.The change correctly uses
std::shared_ptrfor the return type. For a minor improvement, consider usingstd::make_sharedwhich provides a single allocation for both the control block and object:std::shared_ptr<OpenSwath::ISpectrumAccess> SpectrumAccessOpenMS::lightClone() const { - return std::shared_ptr<SpectrumAccessOpenMS>(new SpectrumAccessOpenMS(*this)); + return std::make_shared<SpectrumAccessOpenMS>(*this); }This pattern could also be applied to other
lightClone()implementations inSpectrumAccessSqMass,SpectrumAccessOpenMSCached,SpectrumAccessOpenMSInMemory, andSpectrumAccessQuadMZTransformingfor consistency.src/openms/source/ANALYSIS/OPENSWATH/DATAACCESS/MRMFeatureAccessOpenMS.cpp (1)
24-24: Preferstd::make_sharedfor exception safety and efficiency.While the current code is correct, using
std::make_shared<FeatureOpenMS>(...)instead ofstd::shared_ptr<FeatureOpenMS>(new FeatureOpenMS(...))provides better exception safety and typically performs a single memory allocation instead of two.Apply this refactor:
- std::shared_ptr<FeatureOpenMS> ptr = std::shared_ptr<FeatureOpenMS>(new FeatureOpenMS(mrmfeature.getFeature(*it))); + std::shared_ptr<FeatureOpenMS> ptr = std::make_shared<FeatureOpenMS>(mrmfeature.getFeature(*it));And similarly for line 32:
- std::shared_ptr<FeatureOpenMS> ptr = std::shared_ptr<FeatureOpenMS>(new FeatureOpenMS(mrmfeature.getPrecursorFeature(*it))); + std::shared_ptr<FeatureOpenMS> ptr = std::make_shared<FeatureOpenMS>(mrmfeature.getPrecursorFeature(*it));Also applies to: 32-32
src/openms/source/FORMAT/SwathFile.cpp (1)
57-57: Preferstd::make_sharedfor PeakMap allocations.Consider using
std::make_shared<PeakMap>()instead ofstd::shared_ptr<PeakMap>(new PeakMap)for better exception safety and memory efficiency.Apply this refactor pattern at lines 57, 200, 294, and 302:
- std::shared_ptr<PeakMap > exp(new PeakMap); + std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();Also applies to: 200-200, 294-294, 302-302
src/tests/class_tests/openms/source/SwathFile_test.cpp (1)
109-109: Consider usingstd::make_sharedin tests for consistency.While not critical in test code, using
std::make_shared<ExperimentalSettings>()instead ofstd::shared_ptr<ExperimentalSettings>(new ExperimentalSettings())would align with modern C++ best practices.Apply this pattern:
- std::shared_ptr<ExperimentalSettings> meta = std::shared_ptr<ExperimentalSettings>(new ExperimentalSettings()); + std::shared_ptr<ExperimentalSettings> meta = std::make_shared<ExperimentalSettings>();Also applies to: 132-132, 161-161, 194-194
src/tests/class_tests/openms/source/SpectrumAccessQuadMZTransforming_test.cpp (1)
24-24: Consider usingstd::make_sharedin test helpers.For consistency with modern C++ practices, consider using
std::make_shared<PeakMap>()instead ofstd::shared_ptr<PeakMap>(new PeakMap).- std::shared_ptr<PeakMap > exp2(new PeakMap); + std::shared_ptr<PeakMap> exp2 = std::make_shared<PeakMap>();And at line 45:
-std::shared_ptr<PeakMap > exp(new PeakMap); +std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();Also applies to: 45-45
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp (1)
459-460: UsePeakMapinmake_sharedfor type clarity and consistency
getSpectrumAccessOpenMSPtris declared withconst std::shared_ptr<PeakMap>&, while this call usesstd::make_shared<MSExperiment>(ms_data_). IfPeakMapis an alias forMSExperiment, this is functionally fine, but using the alias directly would be clearer and consistent with the rest of the file (e.g. line 764) and with the factory signature:- feat_finder_.setMS1Map(SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(std::make_shared<MSExperiment>(ms_data_))); + feat_finder_.setMS1Map( + SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr( + std::make_shared<PeakMap>(ms_data_)));Also note that this performs a full copy of
ms_data_; combined with the additional copy at line 764 this keeps two heap copies of the MS1 data alive duringrunSingleGroup_. This mirrors the previous boost-based behavior, but if memory becomes an issue for very large datasets, it might be worth refactoring to share a singlestd::shared_ptr<PeakMap>between the MS1 map and chromatogram extraction path.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/openms/source/FEATUREFINDER/FeatureFinderAlgorithmMetaboIdent.cpp(1 hunks)src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/openms/source/FEATUREFINDER/FeatureFinderAlgorithmMetaboIdent.cpp
🧰 Additional context used
📓 Path-based instructions (1)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms
Applied to files:
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
📚 Learning: 2025-08-14T10:19:54.371Z
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 8167
File: src/topp/Digestor.cpp:200-226
Timestamp: 2025-08-14T10:19:54.371Z
Learning: In OpenMS (C++ bioinformatics framework), use boost random libraries instead of std library random distributions for cross-platform reproducible random number generation, as std library distributions are not reproducible across platforms.
Applied to files:
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Applied to files:
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
🧬 Code graph analysis (1)
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp (1)
src/openms/source/ANALYSIS/OPENSWATH/DATAACCESS/SimpleOpenMSSpectraAccessFactory.cpp (2)
getSpectrumAccessOpenMSPtr(41-54)getSpectrumAccessOpenMSPtr(41-41)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: build-lnx
- GitHub Check: build-lnx-arm
- GitHub Check: build-macos
- GitHub Check: build-win
- GitHub Check: build-macos-arm
- GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (macos-26, xcode, 26.0)
- GitHub Check: build-and-test (macos-15-intel, xcode, 16.0.0)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- GitHub Check: cppcheck-test
🔇 Additional comments (1)
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp (1)
764-819: Std smart‑pointer migration here looks correctThe migration to
std::shared_ptr<PeakMap>andstd::make_shared<PeakMap>(ms_data_)integrates cleanly withSimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(shared)and the subsequent use of(*shared)[0]for chromatogram annotation. The lifetime ofsharedandspec_tempis confined to the extraction loop, andms_data_.reset()happens only after all uses, so there are no new ownership or lifetime issues introduced by this change.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
Looks good and since tests pass should be correct. |
|
@timosachsenberg This PR destroyed dozens of APIs in pyopenms!! Please fix this. And also please fix the workarounds introduced due to removal of those APIs (e.g. changes to drange) |
|
Will provide a fix. And a test. |
Remove all 5 wrap-ignore comments that were added in PR #8405: - ChromatogramPeak.pxd: Removed wrap-ignore from constructor, getPosition(), and setPosition() - DRange.pxd: Removed wrap-ignore from constructor and encloses() method Co-authored-by: jpfeuffer <[email protected]>
Summary by CodeRabbit
Bug Fixes
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.