Skip to content

Replace Qt headers with STL/Boost equivalents - #8840

Merged
timosachsenberg merged 1 commit into
developfrom
feature/replace-qt-headers-with-stl-boost
Mar 5, 2026
Merged

timosachsenberg merged 1 commit into
developfrom
feature/replace-qt-headers-with-stl-boost

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Replace QRegularExpression with std::regex in MascotGenericFile.cpp and InspectOutfile.cpp
  • Replace QFile + QTextStream with std::ifstream in 3 CHEMISTRY data providers (RibonucleotideTSVDataProvider, ModomicsJSONDataProvider, MonosaccharideDB)
  • Replace QCryptographicHash + QFile with a self-contained SHA1 implementation (RFC 3174) + std::ifstream in FileHandler.cpp
  • Remove dead includes: QDebug from File.cpp, QDir from MultiplexClustering.cpp

Total: 9 Qt header includes removed across 8 files.

Test plan

  • All modified components build cleanly (no warnings)
  • DimMapper_test passes
  • RibonucleotideDB_test passes (covers TSV + JSON data providers)
  • InspectOutfile_test passes
  • MascotGenericFile_test passes
  • MultiplexClustering_test passes
  • FileHandler_test SHA1 hash matches expected value d50d5144cc3805749b9e8d16f3bc8994979d8142

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Modernized internal file I/O operations by replacing Qt-based file reading with standard C++ streams.
    • Updated regular expression handling to use C++ standard library instead of Qt implementations.
    • Replaced Qt cryptographic hashing with standard C++ implementation.
    • Removed Qt framework includes from several modules to reduce build dependencies.

Replace 9 Qt header includes across 8 files with standard C++/Boost
alternatives to reduce Qt coupling:

- QRegularExpression → std::regex (MascotGenericFile, InspectOutfile)
- QFile + QTextStream → std::ifstream (3 CHEMISTRY data providers)
- QCryptographicHash + QFile → self-contained SHA1 + std::ifstream (FileHandler)
- Remove dead includes: QDebug (File.cpp), QDir (MultiplexClustering.cpp)

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

coderabbitai Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR systematically removes Qt framework dependencies across OpenMS core modules by replacing Qt-based I/O, regex, and hashing implementations with C++ standard library equivalents (std::ifstream, std::regex, and a custom SHA-1 implementation). Changes span file reading, JSON parsing, data validation, and cryptographic hashing while maintaining existing error handling and behavior.

Changes

Cohort / File(s) Summary
File I/O Migration to std::ifstream
src/openms/source/CHEMISTRY/ModomicsJSONDataProvider.cpp, src/openms/source/CHEMISTRY/MonosaccharideDB.cpp, src/openms/source/CHEMISTRY/RibonucleotideTSVDataProvider.cpp
Replaced QFile/QTextStream with std::ifstream for JSON and TSV reading. RibonucleotideTSVDataProvider adds UTF-8 prime character normalization and graceful error handling for parse failures with line skipping.
Regex Migration to std::regex
src/openms/source/FORMAT/InspectOutfile.cpp, src/openms/source/FORMAT/MascotGenericFile.cpp
Replaced QRegularExpression with std::regex; updated version extraction and filename sanitization logic to use std::smatch and std::regex_replace.
Cryptographic Hashing Implementation
src/openms/source/FORMAT/FileHandler.cpp
Removed QCryptographicHash dependency and implemented custom SHA-1 processor in anonymous namespace for binary file hashing with chunk-based accumulation.
Qt Include Cleanup
src/openms/source/FEATUREFINDER/MultiplexClustering.cpp, src/openms/source/SYSTEM/File.cpp
Removed unused Qt includes (QDir, QDebug) with no functional impact.

Possibly related issues

Possibly related PRs

Poem

🐰 Qt files fade and streams depart,
Standard C++ plays the part,
SHA hashes bloom from custom code,
Regex routes the parsing road,
Dependencies shed, the framework's light—
Pure stdlib shines so bright! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main objective: replacing Qt headers with STL/Boost equivalents, which is the primary theme across all 8 files modified in this changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/replace-qt-headers-with-stl-boost

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
src/openms/source/FORMAT/FileHandler.cpp (1)

680-684: Consider logging or throwing on file-open failure instead of silent empty return.

Returning an empty string when the file cannot be opened fails silently. Downstream callers like MzQCFile.cpp (line 237) embed this hash directly into JSON output. An empty hash could corrupt metadata without any warning.

Consider logging an error or throwing an exception for consistency with the project's error handling patterns.

♻️ Suggested improvement
     std::ifstream file(filename, std::ios::binary);
     if (!file.is_open())
     {
-      return "";
+      OPENMS_LOG_ERROR << "Failed to open file for hashing: " << filename << "\n";
+      return "";
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/FORMAT/FileHandler.cpp` around lines 680 - 684, The code
that opens the file (the std::ifstream file(filename, std::ios::binary) block in
FileHandler.cpp) currently returns an empty string on failure; instead, either
log an error or throw an exception so failures are not silent — replace the
"return \"\"" with a clear failure path such as throwing
std::runtime_error(fmt::format("Failed to open file for hashing: {}", filename))
or calling the project's error logger with the filename and reason, so callers
(e.g., the code that embeds this hash in MzQCFile) receive an explicit error
rather than an empty hash.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/openms/source/FORMAT/FileHandler.cpp`:
- Around line 680-684: The code that opens the file (the std::ifstream
file(filename, std::ios::binary) block in FileHandler.cpp) currently returns an
empty string on failure; instead, either log an error or throw an exception so
failures are not silent — replace the "return \"\"" with a clear failure path
such as throwing std::runtime_error(fmt::format("Failed to open file for
hashing: {}", filename)) or calling the project's error logger with the filename
and reason, so callers (e.g., the code that embeds this hash in MzQCFile)
receive an explicit error rather than an empty hash.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 349122f0-505a-41e1-b034-4ad6c6ab38c6

📥 Commits

Reviewing files that changed from the base of the PR and between be7efde and a7fa3f9.

📒 Files selected for processing (8)
  • src/openms/source/CHEMISTRY/ModomicsJSONDataProvider.cpp
  • src/openms/source/CHEMISTRY/MonosaccharideDB.cpp
  • src/openms/source/CHEMISTRY/RibonucleotideTSVDataProvider.cpp
  • src/openms/source/FEATUREFINDER/MultiplexClustering.cpp
  • src/openms/source/FORMAT/FileHandler.cpp
  • src/openms/source/FORMAT/InspectOutfile.cpp
  • src/openms/source/FORMAT/MascotGenericFile.cpp
  • src/openms/source/SYSTEM/File.cpp
💤 Files with no reviewable changes (2)
  • src/openms/source/FEATUREFINDER/MultiplexClustering.cpp
  • src/openms/source/SYSTEM/File.cpp

@timosachsenberg
timosachsenberg merged commit 3f3445a into develop Mar 5, 2026
19 checks passed
@timosachsenberg
timosachsenberg deleted the feature/replace-qt-headers-with-stl-boost branch March 5, 2026 13:57
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.

1 participant