Skip to content

refactor: remove Qt string API from core library (breaking) - #8940

Merged
timosachsenberg merged 35 commits into
developfrom
remove-qt/pr5a-string-api
Mar 20, 2026
Merged

timosachsenberg merged 35 commits into
developfrom
remove-qt/pr5a-string-api

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Breaking API change: Removes String(const QString&), String::toQString(), DataValue(const QString&), DataValue::toQString()
  • StringUtils::number() now uses snprintf instead of QString::number
  • StringListUtils::fromQStringList() removed
  • Qt5Port.h deleted
  • All remaining .toQString() calls in core removed (~20 files)
  • Zero Qt references remain in src/openms/include/ and src/openms/source/
  • Part 5/7 of removing Qt6::Core from libOpenMS core library

Depends on: PRs #8936, #8937, #8938, #8939

Test plan

  • String_test, DataValue_test pass
  • All 26 related tests pass
  • grep -r "QtCore\|QString\|toQString" src/openms/ returns zero matches

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor

    • Modernized external process execution and argument handling for more reliable tool launches.
    • Standardized string and file-path conversions across the UI, reducing conversion inconsistencies.
    • Removed legacy Qt-specific public string conversion APIs from core data types.
  • Dependencies

    • Added boost-process to enable the improved process management implementation.

@coderabbitai

coderabbitai Bot commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough
📝 Walkthrough
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch remove-qt/pr5a-string-api

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

Actionable comments posted: 6

Note

Due to the large number of review comments, Critical severity comments were prioritized as inline comments.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (6)
src/openms/source/FORMAT/DATAACCESS/SiriusFragmentAnnotation.cpp (1)

305-329: ⚠️ Potential issue | 🟠 Major

Open the fragment file from the std::filesystem::path directly.

The code correctly converts the user-provided workspace path to std::filesystem::path using to_path(), which handles UTF-8 encoding on Windows. However, ifstream(sirius_result_file.string()) immediately converts it back to a narrow string, which uses the current code page on Windows instead of UTF-8. This causes the original Unicode safety to be lost and can break annotation loading for non-ASCII workspace paths on Windows.

💡 Suggested change
-        ifstream fragment_annotation_file(sirius_result_file.string());
+        ifstream fragment_annotation_file(sirius_result_file);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/FORMAT/DATAACCESS/SiriusFragmentAnnotation.cpp` around
lines 305 - 329, The file is opened using
ifstream(fragment_annotation_file.string()), which converts the
std::filesystem::path back to a narrow string and loses UTF-8 safety on Windows;
change the open to construct std::ifstream directly from the
std::filesystem::path (use sirius_result_file as the constructor argument) so
the path is passed as a path object (avoid calling .string()), keeping
Unicode-safe behavior when creating fragment_annotation_file.
src/topp/NovorAdapter.cpp (2)

180-197: ⚠️ Potential issue | 🔴 Critical

Fix the remaining toQString() call at line 315.

Line 315 calls sl[10].toQString(), but OpenMS::String::toQString() is being removed in this PR. The code will not compile without this fix. Pass the String directly to setMetaValue() instead.

Suggested fix
-      ph.setMetaValue("aaScore", sl[10].toQString());
+      ph.setMetaValue("aaScore", sl[10]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/NovorAdapter.cpp` around lines 180 - 197, Replace the remaining call
to OpenMS::String::toQString() (the sl[10].toQString() usage) with the raw
OpenMS::String when calling setMetaValue; locate the code that invokes
setMetaValue(...) with sl[10].toQString() and pass sl[10] directly (or convert
to std::string if setMetaValue overload requires it) so you remove the
toQString() call and restore compilation.

177-197: ⚠️ Potential issue | 🟠 Major

Call std::filesystem::absolute() or std::filesystem::weakly_canonical() instead of canonical().

std::filesystem::canonical() throws std::filesystem::filesystem_error when the path does not exist. The "executable" parameter defaults to "novor.jar" with the skipexists flag enabled, allowing non-existent paths. The uncaught exception will terminate the tool before it can emit a controlled error message. Use absolute() or weakly_canonical() instead, which do not throw for missing paths.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/NovorAdapter.cpp` around lines 177 - 197, The code currently calls
std::filesystem::canonical on the executable path (in NovorAdapter.cpp where
executable is set from getStringOption_("executable")), which will throw if the
path doesn't exist; replace that call with std::filesystem::weakly_canonical (or
std::filesystem::absolute) to normalize the path without throwing for missing
files, keeping the resulting string assigned back to executable; ensure the
normalization block references the same variable (executable) and remove any
uncaught-exception assumptions so the later missing-file checks and controlled
error paths still run.
src/openms/source/SYSTEM/File.cpp (1)

177-190: ⚠️ Potential issue | 🔴 Critical

Prevent silent overwrite when overwrite_existing is false.

On POSIX, std::filesystem::rename overwrites an existing destination file. The current guard only executes when overwrite_existing is true, leaving line 189 unprotected. When the destination exists and overwrite_existing is false, the guard is skipped and fs::rename silently overwrites the file, violating the API contract.

🐛 Proposed fix
-    if (overwrite_existing && exists(to) && !remove(to))
+    if (exists(to))
     {
-      if (verbose)
+      if (!overwrite_existing)
       {
-        OPENMS_LOG_ERROR << "Error: Could not overwrite existing file '" << to << "'\n";
+        if (verbose)
+        {
+          OPENMS_LOG_ERROR << "Error: Destination file '" << to << "' already exists.\n";
+        }
+        return false;
+      }
+      if (!remove(to))
+      {
+        if (verbose)
+        {
+          OPENMS_LOG_ERROR << "Error: Could not overwrite existing file '" << to << "'\n";
+        }
+        return false;
       }
-      return false;
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/File.cpp` around lines 177 - 190, The current guard
is inverted causing silent overwrites: change the logic around
overwrite_existing and exists(to) so that when overwrite_existing is false and
the destination exists you immediately log an error and return false (use
exists(to) and !overwrite_existing); when overwrite_existing is true and
exists(to) attempt to remove(to) and log/return false if removal fails; only
call fs::rename(to_path(from), to_path(to), rename_ec) after these checks
succeed. Refer to symbols overwrite_existing, exists(to), remove(to),
fs::rename, to_path in File.cpp to locate and update the checks accordingly.
src/openms/source/SYSTEM/PythonInfo.cpp (1)

37-46: ⚠️ Potential issue | 🟠 Major

Guard against nullptr when PATH is unset.

getenv("PATH") returns nullptr when the PATH environment variable is unset. Assigning this directly to OpenMS::String will crash the error-reporting path. Always check the return value before use. Also ensure <cstdlib> is included for std::getenv.

Safe PATH lookup
         static String path;
         if (path.empty())
         {
-          path = getenv("PATH");
+          if (const char* env_path = std::getenv("PATH"))
+          {
+            path = env_path;
+          }
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/PythonInfo.cpp` around lines 37 - 46, The
error-reporting code in PythonInfo.cpp uses getenv("PATH") directly and assigns
it to OpenMS::String path without checking for nullptr; update the block around
the getenv usage (the static String path variable) to call std::getenv, check
the returned char* for nullptr before assigning to path (use an empty string or
a fallback message when nullptr), and ensure <cstdlib> is included so
std::getenv is declared; keep the rest of the message construction (ss << ...)
unchanged but use the safe path value when printing.
src/topp/CometAdapter.cpp (1)

299-300: ⚠️ Potential issue | 🔴 Critical

This file still depends on the removed String::toQString() API.

Line 300: comet_version.toQString() won't compile once the Qt string interop is removed from OpenMS::String. Convert through QString::fromStdString(static_cast<std::string>(comet_version)) before merging.

Recommended fix
-    if (auto match = comet_version_regex.match(comet_version.toQString().remove(' ')); match.hasMatch())
+    QString normalized_version = QString::fromStdString(static_cast<std::string>(comet_version));
+    normalized_version.remove(' ');
+    if (auto match = comet_version_regex.match(normalized_version); match.hasMatch())
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/CometAdapter.cpp` around lines 299 - 300, The code uses the removed
OpenMS::String::toQString() API when matching comet_version; replace
comet_version.toQString().remove(' ') with
QString::fromStdString(static_cast<std::string>(comet_version)).remove(' ') so
the QRegularExpression match uses a QString created from the std::string
conversion of comet_version (leave comet_version_regex and the match logic
unchanged).
🟠 Major comments (17)
src/openms/include/OpenMS/DATASTRUCTURES/StringUtils.h-203-208 (1)

203-208: ⚠️ Potential issue | 🟠 Major

Fix silent truncation in StringUtils::number.

The fixed 64-byte buffer at line 205 is insufficient for doubles formatted with higher precision values or large exponents. For example, formatting 1e+308 with precision 50 requires ~360 bytes, far exceeding the buffer. The function silently truncates without detecting errors.

Proposed fix (two-pass formatting)
-    [[maybe_unused]] static String number(double d, UInt n)
-    {
-      char buf[64];
-      std::snprintf(buf, sizeof(buf), "%.*f", static_cast<int>(n), d);
-      return String(buf);
-    }
+    [[maybe_unused]] static String number(double d, UInt n)
+    {
+      const int precision = static_cast<int>(n);
+      const int required = std::snprintf(nullptr, 0, "%.*f", precision, d);
+      if (required < 0)
+      {
+        throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Could not format floating-point value");
+      }
+
+      std::string buf(static_cast<size_t>(required) + 1, '\0');
+      std::snprintf(buf.data(), buf.size(), "%.*f", precision, d);
+      return String(buf.c_str());
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/include/OpenMS/DATASTRUCTURES/StringUtils.h` around lines 203 -
208, StringUtils::number currently uses a fixed 64-byte buffer which can
silently truncate large/ high-precision doubles; change it to a two-pass
formatting: call std::snprintf with a null buffer/size 0 (or size 1) to
determine the required length, allocate a buffer of that length (+1 for null)
(e.g. std::vector<char> or std::string), call std::snprintf again to write into
the allocated buffer, check for negative/overflow return values and handle
errors, and finally construct and return the OpenMS::String from the filled
buffer; update the method signature/implementation of StringUtils::number to use
this approach so large exponents and high precision formats are not truncated.
src/openms/source/ANALYSIS/ID/FIAMSScheduler.cpp-59-62 (1)

59-62: ⚠️ Potential issue | 🟠 Major

Handle makeDir failure before starting the sample.

Ignoring the boolean result here lets the worker continue with an invalid output location, so the real problem surfaces later inside the parallel section. Check it here and log/skip or aggregate the failure explicitly.

💡 Suggested change
       p.setValue("filename", samples_[i].at("filename"));
       p.setValue("dir_output", output_dir_ + samples_[i].at("dir_output"));
-      File::makeDir(p.getValue("dir_output").toString());
+      const String dir_output = p.getValue("dir_output").toString();
+      if (!File::makeDir(dir_output))
+      {
+        OPENMS_LOG_ERROR << "Cannot create output directory: " << dir_output << '\n';
+        continue;
+      }
       p.setValue("resolution", std::stof(samples_[i].at("resolution")));

Based on learnings, use established error handling patterns using OpenMS logging mechanisms.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/ANALYSIS/ID/FIAMSScheduler.cpp` around lines 59 - 62, The
code currently ignores the boolean return of File::makeDir when preparing each
sample (in the block using p.setValue and samples_ / output_dir_), so update
FIAMSScheduler.cpp to check the result of
File::makeDir(p.getValue("dir_output").toString()) immediately after the call;
if it fails, use the OpenMS logging macro (e.g. LOG_ERROR or the project's
established logger) to record a clear error including the filename/dir and
either skip this sample (do not enqueue it into the parallel section) or
aggregate the failure into a list to report later, ensuring no attempt is made
to process samples with invalid output locations.
src/topp/SpectraSTSearchAdapter.cpp-289-297 (1)

289-297: ⚠️ Potential issue | 🟠 Major

Add error checking for file copy operations.

The copy loop never validates whether SpectraST produced actual_path or whether the file operations succeeded. Both ifstream and ofstream can fail silently without state checking, and ofs << ifs.rdbuf() may fail partway through. The function then returns EXECUTION_OK without confirming files were copied, allowing silent failures with missing or partial output files. Additionally, output_files[i].c_str() opens a user-supplied path using the narrow C API.

Check stream state after opening (.is_open() or .fail()), verify source file exists before copy, and handle copy failures before returning success.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/SpectraSTSearchAdapter.cpp` around lines 289 - 297, The loop that
copies SpectraST output files (using temp_dir_path, spectra_files, actual_path,
ifs, ofs, and writing via ofs << ifs.rdbuf()) lacks error checks and may
silently produce missing/partial output while still returning EXECUTION_OK;
update the loop to (1) verify the source file actual_path exists
(std::filesystem::exists) before opening, (2) check if std::ifstream ifs and
std::ofstream ofs opened successfully (use .is_open() or .fail()), (3) perform
the copy with robust checks—either use std::filesystem::copy_file with overwrite
options and check its return/exception, or stream-copy while checking stream
states/EOF and verifying bytes transferred, (4) close streams and on any failure
log the problematic spectra_file/actual_path/output_files[i] and return an
appropriate error code instead of EXECUTION_OK so callers know the operation
failed.
src/openms/source/SYSTEM/UpdateCheck.cpp-87-100 (1)

87-100: ⚠️ Potential issue | 🟠 Major

Keep cache file operations consistent using std::filesystem::path end-to-end.

config_path is constructed from File::getOpenMSHomePath() under the user's home directory and can contain non-ASCII characters on Windows. After switching to std::filesystem for directory creation and last_write_time(), the code falls back to std::ofstream(version_file_name.c_str()), stat(), and utime() with narrow strings, which fail on Windows for non-ASCII usernames. Hold fs::path consistently through this block and use path/error-code overloads; C++17 supports std::ofstream constructors that accept fs::path directly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/UpdateCheck.cpp` around lines 87 - 100, The code
mixes narrow-string file APIs with std::filesystem calls causing failures for
non-ASCII paths; change the block that creates/touches the cache file and
reads/modifies timestamps to operate with fs::path end-to-end: construct a
fs::path for config_path/version_file_name (use the existing to_path helper),
create directories with fs::create_directories(to_path(config_path)), open the
file with std::ofstream using the fs::path overload to "touch" it (set first_run
= true), and replace any stat()/utime() calls with
std::filesystem::last_write_time and its overload that accepts a std::error_code
(e.g., fs::last_write_time(path, time, ec)) while keeping File::readable checks
intact; ensure all filesystem calls use the error_code overloads to avoid
narrow-string APIs on Windows.
src/openms/source/MATH/STATISTICS/PosteriorErrorProbabilityModel.cpp-101-112 (1)

101-112: ⚠️ Potential issue | 🟠 Major

Keep basename-only out_plot paths working.

std::filesystem::path("OMSSA123").parent_path() is empty, so these blocks now reject the documented out_plot=OMSSA123 case instead of writing into the working directory. Only create a directory when a parent component is actually present.

Suggested fix
-        auto parent_dir = plot_path.parent_path();
-        if (parent_dir.empty())
-        {
-          OPENMS_LOG_ERROR << "Could not navigate to output directory for plots from '" << plot_path.filename().string() << "'." << std::endl;
-          return false;
-        }
-        if (!fs::exists(parent_dir) && !File::makeDir(parent_dir.string()))
+        const auto parent_dir = plot_path.parent_path();
+        if (!parent_dir.empty() && !fs::exists(parent_dir) && !File::makeDir(parent_dir.string()))
         {
-          OPENMS_LOG_ERROR << "Could not create output directory for plots '" << parent_dir.string() << "'." << std::endl;
+          OPENMS_LOG_ERROR << "Could not create output directory for plots '" << parent_dir.string() << "'.\n";
           return false;
         }

Apply the same change in both fitGumbelGauss and fit.

Also applies to: 293-303

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/MATH/STATISTICS/PosteriorErrorProbabilityModel.cpp` around
lines 101 - 112, The code incorrectly treats basename-only out_plot values as an
error because parent_path() is empty; update the logic in both fitGumbelGauss
and fit to only attempt directory creation or error when a parent component
actually exists: after computing plot_path and parent_dir (symbols plot_path,
parent_dir, param_.getValue("out_plot")), if parent_dir.empty() then skip
existence/checks and proceed (treat as current working directory), otherwise
check fs::exists(parent_dir) and call File::makeDir(parent_dir.string()) and
log/return false on failure; ensure all three places (the current block and the
corresponding block at lines ~293-303) are changed the same way.
src/openms/source/SYSTEM/File.cpp-339-350 (1)

339-350: ⚠️ Potential issue | 🟠 Major

Use effective access checks on POSIX systems, not raw permission bits.

The readable() (lines 347-350) and writable() (lines 364-367) functions on POSIX return true whenever any owner/group/other read/write permission bit is set, regardless of whether the current process can actually access the file. This ignores process ownership, group membership, and ACLs, causing these functions to incorrectly report accessible files that the process cannot read or write.

Use the standard POSIX ::access() function instead, which performs effective access checks for the current process:

Proposed fix
 `#else`
-    auto st = fs::status(p, ec);
-    if (ec) return false;
-    auto perms = st.permissions();
-    return (perms & (fs::perms::owner_read | fs::perms::group_read | fs::perms::others_read)) != fs::perms::none;
+    return ::access(file.c_str(), R_OK) == 0;
 `#endif`

And similarly for writable():

 `#else`
-      auto st = fs::status(p, ec);
-      if (ec) return false;
-      auto perms = st.permissions();
-      return (perms & (fs::perms::owner_write | fs::perms::group_write | fs::perms::others_write)) != fs::perms::none;
+      return ::access(file.c_str(), W_OK) == 0;
 `#endif`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/File.cpp` around lines 339 - 350, File::readable and
File::writable currently check raw fs::perms bits which can be wrong for the
current process; replace the POSIX branch to call ::access() on the path
returned by to_path(file) (use R_OK for readable, W_OK for writable) and return
whether ::access() == 0, keeping the Windows branch as-is; ensure you convert
the String/path to a C string (file.c_str() or p.c_str()) as appropriate and
include necessary conditional headers for ::access when compiling on non-Windows
POSIX builds.
src/topp/LuciphorAdapter.cpp-559-562 (1)

559-562: ⚠️ Potential issue | 🟠 Major

java_permgen lost its MB suffix.

The option is documented as megabytes (see line 550), but the new argument builds -XX:MaxPermSize=<n> without a unit. Per JVM specification, bare integers are interpreted as bytes. The java_memory option (line 555) correctly applies the "m" suffix—the same must be done for consistency and correctness.

Add the MB suffix
-      process_params.push_back("-XX:MaxPermSize=" + String(java_permgen));
+      process_params.push_back("-XX:MaxPermSize=" + String(java_permgen) + "m");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/LuciphorAdapter.cpp` around lines 559 - 562, The java_permgen value
is appended without the MB unit causing the JVM to interpret it as bytes; update
the code that builds the MaxPermSize argument (the push to process_params that
uses java_permgen) to append the same "m" suffix used by java_memory so it
becomes "-XX:MaxPermSize=" + String(java_permgen) + "m", ensuring consistency in
the MaxPermSize argument generation within LuciphorAdapter.cpp.
src/openms/source/SYSTEM/JavaInfo.cpp-72-95 (1)

72-95: ⚠️ Potential issue | 🟠 Major

Handle null return from getenv("PATH") before logging it.

Line 79 assigns the result of getenv("PATH") directly to a String without checking for null, which can crash during error reporting. The code then logs this potentially invalid value, defeating the purpose of the error message. Additionally, the std::endl calls at lines 86 and 95 violate the C++ guideline to avoid std::endl for performance; use '\n' instead. When switching to std::getenv, add #include <cstdlib>.

Safer PATH lookup with performance fix
          static String path;
          if (path.empty())
          {
-           path = getenv("PATH");
+           if (const char* env_path = std::getenv("PATH"))
+           {
+             path = env_path;
+           }
          }
          OPENMS_LOG_ERROR << "  You might need to add the Java binary to your PATH variable\n"
            << "  or use an absolute path+filename pointing to Java.\n"
-           << "  The current SYSTEM PATH is: '" << path << "'.\n\n"
+           << "  The current SYSTEM PATH is: '" << path << "'.\n"
`#ifdef` __APPLE__
            << "  On MacOSX, application bundles change the system PATH; Open your executable (e.g. KNIME/TOPPAS/TOPPView) from within the bundle (e.g. ./TOPPAS.app/Contents/MacOS/TOPPAS) to preserve the system PATH or use an absolute path to Java!\n"
`#endif`
-           << std::endl;
+           << '\n';
        }
        else
        {
          OPENMS_LOG_ERROR << "  You gave an absolute path to Java. Please check if it's correct.\n"
            << "  You can also try 'java' if your system path is correctly configured.\n"
-           << std::endl;
+           << '\n';

Add #include <cstdlib> to the includes section.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/JavaInfo.cpp` around lines 72 - 95, The
error-reporting block in JavaInfo.cpp currently assigns getenv("PATH") directly
to the static String path without null-checking and uses std::endl; fix it by
including <cstdlib>, replace getenv with std::getenv, check the returned char*
for null before assigning to path (use an empty string or a clear sentinel like
"<unset>" if null), and change the std::endl occurrences in this block to '\n'
to avoid flushing; update the code paths that reference path (the static String
path within the Java-Check logging branch) accordingly and keep the __APPLE__
conditional unchanged.
src/topp/PercolatorAdapter.cpp-989-995 (1)

989-995: ⚠️ Potential issue | 🟠 Major

Copy the decoy protein report from the decoy temp file.

out_pout_decoy_proteins currently receives pout_target_file_proteins, so users requesting both protein reports get the target report twice.

🛠️ Proposed fix
       if (!pout_decoy_proteins.empty())
       {
-        File::copy(pout_target_file_proteins, pout_decoy_proteins);
+        File::copy(pout_decoy_file_proteins, pout_decoy_proteins);
       }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/PercolatorAdapter.cpp` around lines 989 - 995, The second File::copy
call is using the target temp file variable (pout_target_file_proteins) for both
outputs, causing the decoy report to be duplicated; update the copy that writes
to pout_decoy_proteins to use the decoy temp file variable
(pout_decoy_file_proteins) instead so the decoy output is copied from the
correct source (adjust the File::copy call near the if
(!pout_decoy_proteins.empty()) block in PercolatorAdapter.cpp).
src/topp/MSGFPlusAdapter.cpp-454-479 (1)

454-479: ⚠️ Potential issue | 🟠 Major

Re-check that BuildSA actually created the index before returning success.

This helper is supposed to guarantee that the database index exists while the lock is held. Right now it unlocks and returns true as soon as the subprocess exits cleanly, even if db_indexfile was never produced. That turns a local, actionable failure into a later search error.

🛠️ Proposed fix
         TOPPBase::ExitCodes exit_code = runExternalProcess_(java_executable, process_params, proc_stdout, proc_stderr);
-        if (exit_code != EXECUTION_OK)
+        if (exit_code != EXECUTION_OK || !File::exists(db_indexfile))
         {
-          // if there was sth like a segfault, runExternalProcess_ will write a warning about the type of error,
-          //  but not print the output of the program.
-          OPENMS_LOG_ERROR << "The output of MSGF+'s Index Database Creation was:\nSTDOUT:\n" << proc_stdout << "\nSTDERR:\n" << proc_stderr << endl;
+          if (exit_code != EXECUTION_OK)
+          {
+            // if there was sth like a segfault, runExternalProcess_ will write a warning about the type of error,
+            //  but not print the output of the program.
+            OPENMS_LOG_ERROR << "The output of MSGF+'s Index Database Creation was:\nSTDOUT:\n" << proc_stdout << "\nSTDERR:\n" << proc_stderr << endl;
+          }
+          else
+          {
+            OPENMS_LOG_ERROR << "MSGF+ reported success, but '" << db_indexfile << "' was not created." << endl;
+          }
           lock_db.unlock();
           return false;
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/MSGFPlusAdapter.cpp` around lines 454 - 479, The code returns
success after runExternalProcess_ completes without re-checking that the
expected index file (db_indexfile) was actually created; update the block after
calling runExternalProcess_ (the call using java_executable, process_params,
proc_stdout/proc_stderr) to verify File::exists(db_indexfile) while still
holding the lock (lock_db), and if the file is missing log an OPENMS_LOG_ERROR
including proc_stdout and proc_stderr, unlock the lock_db and return false; only
when File::exists(db_indexfile) is true should you log success, release the lock
and return true (leave existing symbols BuildSA, runExternalProcess_,
db_indexfile, proc_stdout/proc_stderr, lock_db.unlock() as reference points).
src/openms/source/SYSTEM/RWrapper.cpp-63-68 (1)

63-68: ⚠️ Potential issue | 🟠 Major

Resolve bare executables before passing them to bp::child.

Both launch sites use Boost.Process' exe-args style (child(executable, bp::args(args), ...)). In that form the first argument is treated as an executable path; PATH lookup is only performed for cmd-style launches or when you explicitly use bp::search_path(). With the default "Rscript", this now fails unless the caller already supplied a fully resolved path or the executable is in the current working directory. Wrap both instances with bp::search_path(): bp::child(bp::search_path(executable), bp::args(args), ...).

Also applies to: 120-125

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/RWrapper.cpp` around lines 63 - 68, The child
process is constructed using bp::child(static_cast<std::string>(executable),
bp::args(args), ...) which treats the first argument as a literal executable
path and skips PATH lookup; replace the bare executable with
bp::search_path(executable) when constructing bp::child so PATH resolution is
performed (i.e., call bp::child(bp::search_path(executable), bp::args(args),
bp::std_out > pipe_out, bp::std_err > pipe_err)); make the same change for the
other launch site referenced around the bp::child usage at the later block
(lines 120-125) so both invocations use bp::search_path(executable) with the
same args/pipe_out/pipe_err parameters.
src/openms/source/SYSTEM/RWrapper.cpp-70-89 (1)

70-89: ⚠️ Potential issue | 🟠 Major

Drain pipes while child process is still running, not after child.wait().

Calling child.wait() before reading from the pipes creates a deadlock risk. When the child writes enough data to fill the pipe buffer (typically 64KB), it blocks waiting for the parent to consume the data. Since the parent is blocked on child.wait(), neither process can proceed. The Boost.Process documentation explicitly warns against this pattern and recommends reading while the child is running using child.running() or switching to the async API.

This issue affects two locations in the file:

  • runScript() method (lines 63–89): waits before reading both stdout and stderr
  • findR() method (lines 119–149): waits before reading stdout
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/RWrapper.cpp` around lines 70 - 89, The code
currently calls child.wait() before reading from the child's stdout/stderr (in
runScript and findR), which can deadlock; change the logic to drain the pipes
while the child is running and then wait/collect remaining data after exit: for
runScript() and findR(), replace the pattern "child.wait(); then
while(getline(pipe...))" with a loop that repeatedly reads available data from
pipe_out and pipe_err while child.running() (non-blocking reads or checking
stream availability), then call child.wait() and perform a final read to consume
any remaining data; ensure you reference and modify the runScript() and findR()
functions and use child.running() (or switch to Boost.Process async pipes) to
avoid blocking on wait before draining.
src/openms/source/DATASTRUCTURES/DateTime.cpp-484-489 (1)

484-489: ⚠️ Potential issue | 🟠 Major

Keep fields_.valid consistent with the stored date.

setTime(...) and fromString(..., "hh:mm:ss") mark the instance valid even though year/month/day remain 0, which isValidDate_ would reject. That creates states where isValid() is true but getDate()/get() return 0000-00-00, and downstream operations like addSecs() or ordering then run on nonsensical date fields. Either keep the object invalid until a real date is present, or add an explicit time-only state instead of overloading valid.

Also applies to: 506-517, 610-614, 629-636

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/DATASTRUCTURES/DateTime.cpp` around lines 484 - 489, Do not
mark the DateTime as fully valid when only time components are set: update
setTime, the fromString branch handling "hh:mm:ss", and the other places noted
(around the second occurrences) so that fields_.valid is not set to true when
year/month/day are zero; instead either (A) leave fields_.valid false until a
non-zero date is set (so isValidDate_ remains the gate for getDate/get/addSecs),
or (B) introduce an explicit fields_.time_only flag and update isValid(),
getDate(), get(), addSecs(), and ordering code to treat time-only instances
specially; modify the code paths that currently set fields_.valid (references:
setTime, fromString(...) when parsing "hh:mm:ss", and the other two similar
blocks) to implement one of these two behaviors and ensure downstream methods
check the new condition before operating on date fields.
src/openms/source/DATASTRUCTURES/DateTime.cpp-221-231 (1)

221-231: ⚠️ Potential issue | 🟠 Major

Fix fractional seconds normalization to keep the first three digits, not the last three.

For inputs with more than three fractional digits, the current code applies % 1000 which keeps the last three digits (.1234 → 234) instead of the first three milliseconds (123). This corrupts parsed timestamps.

🛠️ Suggested normalization
-                for (int i = frac_digits; i < 3; ++i) millisecond *= 10;
-                millisecond %= 1000;
+                for (int i = frac_digits; i > 3; --i)
+                {
+                  millisecond /= 10;
+                }
+                for (int i = frac_digits; i < 3; ++i)
+                {
+                  millisecond *= 10;
+                }

This issue also appears at lines 246-256 and 580-588.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/DATASTRUCTURES/DateTime.cpp` around lines 221 - 231, The
fractional-seconds normalization in DateTime.cpp incorrectly uses millisecond %=
1000 which keeps the last three digits; instead, adjust millisecond based on the
counted frac_digits: if frac_digits > 3, divide millisecond by 10 until
frac_digits == 3 (dropping trailing digits), else multiply millisecond by 10
until frac_digits == 3 (padding). Apply this fix at the parsing blocks that
reference stripped, dot_pos and millisecond (the current block and the similar
blocks around the other occurrences noted).
src/openms/source/FORMAT/OMSFileLoad.cpp-1128-1129 (1)

1128-1129: ⚠️ Potential issue | 🟠 Major

Preserve SQL NULL as JSON null.

Exporting SQLITE_NULL as "" loses the distinction between an actual empty string and a missing value. This changes the exported schema and prevents exact round-tripping of optional fields.

🛠️ Suggested fix
-          case SQLITE_NULL: record[query.getColumnName(i)] = ""; break;
+          case SQLITE_NULL: record[query.getColumnName(i)] = nullptr; break;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/FORMAT/OMSFileLoad.cpp` around lines 1128 - 1129, The
SQLITE_NULL branch currently assigns an empty string to
record[query.getColumnName(i)], which loses the distinction between NULL and
empty string; change the handling in the switch for SQLITE_NULL (in the loop
using query.getColumnName(i) / query.getColumn(i)) to assign a JSON null value
instead of "" (use whatever project JSON representation is used for null, e.g.,
Json::nullValue or the project's equivalent) so NULLs are preserved when
exporting.
src/openms/source/DATASTRUCTURES/DateTime.cpp-195-334 (1)

195-334: ⚠️ Potential issue | 🟠 Major

Add end-of-input validation to all sscanf parsers using %n format specifier.

The code accepts malformed timestamps with trailing characters. For example, "2024-01-01junk" parses successfully because sscanf only reports assigned fields and ignores unconsumed input. This affects:

  • Lines 195-334: fromString() (11+ sscanf calls)
  • Lines 450-473: setDate() (3 sscanf calls)
  • Lines 576-627: fromString(date, format) (7+ sscanf calls)

Only the yyyy-MM-ddZ case validates end-of-input explicitly. Apply the %n fix pattern to all parsers:

int consumed = 0;
if (sscanf(date.c_str(), "%d-%d-%d%n", &year, &month, &day, &consumed) != 3 ||
    consumed != static_cast<int>(date.size()))
{
  throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, date, "Invalid date");
}

Without this, invalid input silently truncates instead of raising an exception.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/DATASTRUCTURES/DateTime.cpp` around lines 195 - 334, The
fromString(), setDate(), and fromString(date, format) sscanf parsers accept
trailing garbage because they don't verify end-of-input; update every sscanf
call in these functions (e.g. in fromString(), the ISO/German/US/legacy
branches, in setDate(), and in fromString(date, format)) to include an int
consumed using the "%n" specifier and validate consumed ==
static_cast<int>(date.size()) (or treat a non-3/6/7 return or mismatched
consumed as parse failure), declaring consumed next to the sscanf and using that
check to set parsed or throw the same ParseError as other failures so malformed
strings with extra characters are rejected.
src/openms/source/SYSTEM/ExternalProcess.cpp-171-197 (1)

171-197: ⚠️ Potential issue | 🟠 Major

Fix POSIX crash detection logic: use WIFSIGNALED() instead of comparing exit codes.

On POSIX systems, child.native_exit_code() returns the raw waitpid status (where the exit code is shifted left by 8 bits), while child.exit_code() returns the decoded value. Comparing them with exit_code != child.native_exit_code() will be true for normal exits (e.g., exit(1) gives raw status 0x100 but logical exit code 1), causing the code to misclassify normal non-zero exits as crashes. The NONZERO_EXIT branch becomes unreachable. Use WIFSIGNALED(native_status) to detect signal termination correctly.

🛠️ Suggested POSIX check
+#ifndef _WIN32
+#  include <sys/wait.h>
+#endif
...
-#else
-        // On POSIX, signals cause exit_code to encode the signal (boost::process sets native_exit_code)
-        if (child.native_exit_code() != 0 && exit_code != child.native_exit_code())
+#else
+        const int native_status = child.native_exit_code();
+        if (WIFSIGNALED(native_status))
 `#endif`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/ExternalProcess.cpp` around lines 171 - 197, The
POSIX crash detection wrongly compares child.exit_code() to
child.native_exit_code(), causing normal non-zero exits to be classified as
crashes; change the POSIX branch to inspect the raw wait status with
WIFSIGNALED(child.native_exit_code()) to detect signal termination and treat
that as RETURNSTATE::CRASH (optionally use WTERMSIG to log the signal),
otherwise fall back to checking exit_code (child.exit_code()) for non-zero
returns and return RETURNSTATE::NONZERO_EXIT; update the conditional around
child.native_exit_code()/child.exit_code() and the associated error messages in
ExternalProcess.cpp accordingly.
🟡 Minor comments (2)
src/topp/MSFraggerAdapter.cpp-415-421 (1)

415-421: ⚠️ Potential issue | 🟡 Minor

Replace std::cerr with writeLogError_() and add explicit #include <cstdlib> for getenv.

Per OpenMS guidelines, use writeLogError_() for TOPP error logging instead of direct std::cerr, which bypasses the tool log handler. Additionally, getenv and strlen should be from an explicit include.

Suggested fix
+#include <cstdlib>
...
         const char* msfragger_path_env = getenv("MSFRAGGER_PATH");
-        if (msfragger_path_env == nullptr || strlen(msfragger_path_env) == 0)
+        if (msfragger_path_env == nullptr || msfragger_path_env[0] == '\0')
         {
-          std::cerr << "No executable for MSFragger could be found (also not in MSFRAGGER_PATH)!";
+          writeLogError_("No executable for MSFragger could be found (also not in MSFRAGGER_PATH)!");
           return ExitCodes::EXTERNAL_PROGRAM_NOTFOUND;
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/MSFraggerAdapter.cpp` around lines 415 - 421, Replace the direct
std::cerr usage with the TOPP logging call writeLogError_() in the
MSFraggerAdapter code path that checks getenv("MSFRAGGER_PATH"), and add an
explicit `#include` <cstdlib> at the top of the file so getenv and strlen are
declared; specifically, change the error output in the block that returns
ExitCodes::EXTERNAL_PROGRAM_NOTFOUND to call writeLogError_("No executable for
MSFragger could be found (also not in MSFRAGGER_PATH)!") (or equivalent) and
keep the subsequent this->exe = msfragger_path_env assignment unchanged.
src/openms/source/FORMAT/OMSFileLoad.cpp-1124-1130 (1)

1124-1130: ⚠️ Potential issue | 🟡 Minor

Use SQLITE_TEXT for consistency with other constants in the switch block.

All other cases in this switch statement use the SQLITE_* prefix (SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_BLOB, SQLITE_NULL). The text case should follow the same naming pattern with SQLITE_TEXT instead of SQLITE3_TEXT.

🛠️ Suggested fix
-          case SQLITE3_TEXT: record[query.getColumnName(i)] = query.getColumn(i).getText(); break;
+          case SQLITE_TEXT: record[query.getColumnName(i)] = query.getColumn(i).getText(); break;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/FORMAT/OMSFileLoad.cpp` around lines 1124 - 1130, Replace
the incorrect SQLITE3_TEXT constant in the switch handling
query.getColumn(i).getType() with SQLITE_TEXT to match the other SQLITE_*
constants; update the case in the switch (the branch that currently reads "case
SQLITE3_TEXT") to "case SQLITE_TEXT" so record assignment for text columns uses
the consistent constant in the OMSFileLoad.cpp switch handling
query.getColumn(i).
🧹 Nitpick comments (10)
src/openms/source/CONCEPT/ProgressLogger.cpp (1)

59-61: Use OpenMS::String::number() for percentage formatting instead of std::snprintf.

The code formats a float percentage with 2 decimal places using a manual buffer and std::snprintf. Per project guidelines, use String::number(percentage_value, 2) instead—OpenMS provides this static method precisely for numeric formatting with precision control. This improves consistency with the codebase's standard formatting path and eliminates manual buffer management.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/CONCEPT/ProgressLogger.cpp` around lines 59 - 61, Replace
the manual snprintf buffer with OpenMS::String::number(...) for percentage
formatting: compute the percentage using the existing expression
(static_cast<float>(value - begin_) / static_cast<float>(end_ - begin_) *
100.0f), pass that float to OpenMS::String::number(..., 2) to get a string with
two decimals, and use that string in the cout line instead of pct_buf; update
the code in ProgressLogger (ProgressLogger.cpp) where pct_buf and std::snprintf
are used and remove the manual buffer allocation.
src/openms_gui/include/OpenMS/VISUAL/DIALOGS/WizardHelper.h (1)

89-104: Consider using size_t for loop_number to prevent potential negative index access.

The parameter loop_number is int, but it indexes into loop_arg (a std::vector). If a negative value is passed, the check on line 91 does not catch it (e.g., -1 >= 2 is false), and line 102 would access largs.loop_arg[loop_number] with a negative index, causing undefined behavior.

Since loop_number represents an index and should never be negative, changing its type to size_t would provide compile-time safety and align with the coding guidelines that recommend using Size/SignedSize for STL .size() values.

Proposed fix
-      std::vector<String> getArgs(const int loop_number) const
+      std::vector<String> getArgs(const size_t loop_number) const
       {
-        if (loop_number >= (int)getLoopCount())
+        if (loop_number >= getLoopCount())
         {
           throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Internal error. The loop number you requested is too high!");
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms_gui/include/OpenMS/VISUAL/DIALOGS/WizardHelper.h` around lines 89
- 104, Change the getArgs signature to take an unsigned index type (e.g., size_t
or OpenMS::Size) instead of int to prevent negative indexing into loop_arg;
update the parameter type in the getArgs declaration/definition and all callers,
adjust the comparison to use the same unsigned type with getLoopCount(), and
ensure any exception/logic remains the same (references: getArgs, loop_number,
loop, largs.loop_arg, arg_l).
src/openms/source/KERNEL/DimMapper.cpp (2)

36-37: Consider checking std::to_chars error code for robustness.

The error code ec from std::to_chars is captured but not checked. While the 128-byte buffer should be sufficient for typical double values with reasonable precision, checking for failure provides defensive protection.

🛡️ Proposed defensive check
       char buf[128];
       auto [ptr, ec] = std::to_chars(buf, buf + sizeof(buf), value, std::chars_format::fixed, precision);
+      if (ec != std::errc{})
+      {
+        // Fallback for unexpected conversion failure
+        std::snprintf(buf, sizeof(buf), "%.*f", precision, value);
+        ptr = buf + std::strlen(buf);
+      }
       *ptr = '\0';

Note: If you add this fallback, the <cstdio> and <cstring> includes would then be needed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/KERNEL/DimMapper.cpp` around lines 36 - 37, Check the
std::to_chars error code (ec) after calling std::to_chars in DimMapper.cpp and
handle failure defensively: if ec indicates an error (e.g.,
std::errc::value_too_large), fall back to a safe formatting path such as
snprintf into the same buffer using value and precision, ensure the buffer is
null-terminated, and use that result in place of ptr; update includes to add
<cstdio> and <cstring> if needed. Reference symbols: std::to_chars call,
variables buf, value, precision, ptr, and ec.

14-15: Unused includes can be removed.

<cstdio> and <cstring> do not appear to be used in this file. The implementation only requires <charconv> (for std::to_chars) and <string> (for std::string).

🧹 Proposed fix
 `#include` <charconv>
-#include <cstdio>
-#include <cstring>
 `#include` <string>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/KERNEL/DimMapper.cpp` around lines 14 - 15, Remove the
unused headers <cstdio> and <cstring> from the top of DimMapper.cpp and keep
only the necessary headers (e.g., <charconv> for std::to_chars and <string> for
std::string); update the include block in src/openms/source/KERNEL/DimMapper.cpp
so it contains only the headers actually used by functions in DimMapper (no
references to C stdio/string.h headers).
src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp (1)

934-935: Unused error_code variable.

The ec variable is declared but never checked. If errors should be silently ignored (file doesn't exist), this is fine but the variable is then unnecessary. If errors matter, they should be logged.

♻️ Option 1: Remove unused variable (if errors are intentionally ignored)
       // delete file if present
-      std::error_code ec;
-      std::filesystem::remove(OpenMS::to_path(filename_), ec);
+      std::error_code ignored;
+      std::filesystem::remove(OpenMS::to_path(filename_), ignored);
♻️ Option 2: Use the throwing overload (if file must be deleted)
       // delete file if present
-      std::error_code ec;
-      std::filesystem::remove(OpenMS::to_path(filename_), ec);
+      if (std::filesystem::exists(OpenMS::to_path(filename_)))
+      {
+        std::filesystem::remove(OpenMS::to_path(filename_));
+      }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp` around lines 934 -
935, The local std::error_code ec is declared but never inspected after calling
std::filesystem::remove(OpenMS::to_path(filename_), ec) in MzMLSqliteHandler
(uses filename_), so either remove the unused ec and call the overload that
ignores errors, or handle/report errors: replace with the throwing overload
std::filesystem::remove(OpenMS::to_path(filename_)) inside a try/catch and log
failures, or check ec after the current call and log or return on error; update
the code in MzMLSqliteHandler accordingly to pick one of these paths.
src/openms/include/OpenMS/SYSTEM/PathUtils.h (1)

16-22: Consider adding @brief Doxygen documentation.

Per coding guidelines, public headers should include Doxygen documentation with @brief. The current /// comment is helpful but doesn't follow the Doxygen format.

📝 Suggested Doxygen documentation
 namespace OpenMS
 {
-  /// Convert a UTF-8 std::string to std::filesystem::path safely on all platforms.
-  /// On Windows, std::filesystem::path(std::string) uses the current code page, not UTF-8.
+  /**
+   * `@brief` Convert a UTF-8 std::string to std::filesystem::path safely on all platforms.
+   *
+   * On Windows, std::filesystem::path(std::string) uses the current code page (ACP), not UTF-8.
+   * This function uses std::u8string to ensure proper UTF-8 interpretation.
+   *
+   * `@param`[in] s UTF-8 encoded path string
+   * `@return` std::filesystem::path constructed from the UTF-8 string
+   */
   inline std::filesystem::path to_path(const std::string& s)

As per coding guidelines: "Doxygen documentation with @brief required".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/include/OpenMS/SYSTEM/PathUtils.h` around lines 16 - 22, Add
Doxygen `@brief` documentation for the to_path function in PathUtils.h: replace or
augment the existing triple-slash comment above inline std::filesystem::path
to_path(const std::string& s) with a Doxygen-style brief (e.g. "/// `@brief`
Convert a UTF-8 std::string to std::filesystem::path safely on all platforms.")
and retain the explanatory sentence about Windows behavior and UTF-8 so the
docstring satisfies the project's Doxygen/commenting guidelines.
src/openms/source/MATH/STATISTICS/PosteriorErrorProbabilityModel.cpp (1)

106-111: Use '\n' instead of std::endl in these log statements.

These are OpenMS log streams, so the extra flush from std::endl is unnecessary.

As per coding guidelines, "Use OpenMS logging macros and OpenMS::LogStream; avoid std::cout/err directly; avoid std::endl for performance (use \n)."

Also applies to: 298-303

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/MATH/STATISTICS/PosteriorErrorProbabilityModel.cpp` around
lines 106 - 111, Replace usages of std::endl in OpenMS log streams with '\n' to
avoid unnecessary flushes: update the OPENMS_LOG_ERROR calls in
PosteriorErrorProbabilityModel.cpp (the error message that starts "Could not
navigate to output directory for plots from" and the one that starts "Could not
create output directory for plots") to end with '\n' instead of std::endl, and
make the same change for the similar OPENMS_LOG_ERROR messages around the
298-303 region; keep the rest of the log message text unchanged and only change
the line terminator.
src/topp/SageAdapter.cpp (1)

599-603: Avoid std::endl in the new command log.

This path runs on every Sage invocation, and std::endl forces an unnecessary flush.

♻️ Small logging cleanup
-      OPENMS_LOG_INFO << "Sage command line: " << sage_executable << args_str << std::endl;
+      OPENMS_LOG_INFO << "Sage command line: " << sage_executable << args_str << '\n';
As per coding guidelines, "`**/*.cpp`: Use OpenMS logging macros and `OpenMS::LogStream`; avoid `std::cout/err` directly; avoid `std::endl` for performance (use `\n`)`."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/SageAdapter.cpp` around lines 599 - 603, The log uses std::endl
which forces a flush; update the block that constructs args_str and logs the
Sage invocation (the OPENMS_LOG_INFO usage referencing sage_executable and
arguments/args_str) to avoid std::endl and instead end the message with '\n'
(keeping the OpenMS logging macro/OpenMS::LogStream usage intact) so the log is
not force-flushed on every Sage call.
src/openms/source/APPLICATIONS/ToolHandler.cpp (1)

289-290: Prefer Size in these new .size() loops.

The new file-iteration loops switch back to size_t, which makes these helpers inconsistent with the rest of OpenMS. Using Size keeps the container-size handling aligned with repo conventions.

As per coding guidelines, "Prefer OpenMS::String for numeric formatting and parsing; use Size/SignedSize for STL .size() values in C++".

Also applies to: 314-315

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/APPLICATIONS/ToolHandler.cpp` around lines 289 - 290,
Replace the use of raw size_t in the file-iteration for-loops with OpenMS's Size
type to match project convention: change the loop headers that read "for (size_t
i = 0; i < files.size(); ++i)" (and the similar loop at the other occurrence) to
use "for (Size i = 0; i < files.size(); ++i)". Ensure the OpenMS namespace type
is used (Size) so container .size() handling is consistent with the rest of
ToolHandler.cpp and the codebase.
src/openms/source/SYSTEM/ExternalProcess.cpp (1)

22-24: Include <thread> explicitly for std::this_thread::sleep_for.

The new polling branch relies on std::this_thread::sleep_for, but this file does not include <thread>. Please include it directly instead of depending on transitive Boost headers.

🛠️ Suggested fix
 `#include` <array>
 `#include` <chrono>
+#include <thread>
 `#include` <utility>

Also applies to: 223-226

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/ExternalProcess.cpp` around lines 22 - 24, Add an
explicit include of <thread> to ExternalProcess.cpp because the new polling
branch uses std::this_thread::sleep_for; do not rely on transitive Boost
headers—update the top-of-file includes (near array/chrono/utility) to add
<thread>, and ensure any other spots in this file where the polling code calls
std::this_thread::sleep_for (the polling branch around the ExternalProcess
polling logic) will now compile cleanly.

Comment thread src/openms/source/SYSTEM/File.cpp Resolved
Comment thread src/openms/source/SYSTEM/File.cpp Resolved
Comment thread src/openms/source/SYSTEM/PythonInfo.cpp Resolved
@timosachsenberg
timosachsenberg force-pushed the remove-qt/pr5a-string-api branch from 26bfc26 to 54d2196 Compare March 18, 2026 13:02

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/openms/source/SYSTEM/PythonInfo.cpp (1)

37-46: ⚠️ Potential issue | 🟡 Minor

Guard against null return from getenv("PATH").

getenv("PATH") returns nullptr if the environment variable is not set. Assigning a null pointer to OpenMS::String may cause undefined behavior.

🛡️ Proposed fix
         static String path;
         if (path.empty())
         {
-          path = getenv("PATH");
+          const char* env_path = getenv("PATH");
+          path = env_path ? env_path : "(not set)";
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/PythonInfo.cpp` around lines 37 - 46, The code
assumes getenv("PATH") never returns null when assigning to the static
OpenMS::String path in PythonInfo.cpp; instead, guard against a null return by
checking the result of getenv("PATH") before assigning to path (use a temporary
char* env = getenv("PATH"); and only set path = env if env != nullptr, otherwise
set path to an empty string or a placeholder). Update the logic around the
static String path and the getenv call so path is always a valid OpenMS::String
and will not be constructed from a null pointer when building the error message
in the block that checks
std::filesystem::path(std::string(python_executable)).is_relative().
♻️ Duplicate comments (1)
src/openms/source/SYSTEM/PythonInfo.cpp (1)

98-103: ⚠️ Potential issue | 🔴 Critical

Pass the module name as a command-line argument, not as interpolated code.

Splicing package_name into the Python -c argument executes untrusted input as code. An attacker-controlled package name can run arbitrary Python (e.g., sys;print('injected')).

Use sys.argv[1] to pass the module name safely:

🔒 Secure fix using command-line argument
-        bp::args({"-c", "import " + static_cast<std::string>(package_name)}),
+        bp::args({
+          "-c",
+          "import importlib.util, sys; sys.exit(0 if importlib.util.find_spec(sys.argv[1]) else 1)",
+          static_cast<std::string>(package_name)
+        }),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/PythonInfo.cpp` around lines 98 - 103, The code
builds a bp::child invoking python with a "-c" string that interpolates
package_name, which allows executing untrusted code; instead construct the "-c"
argument to read the module name from sys.argv[1] (e.g. "import sys;
__import__(sys.argv[1])") and pass package_name as a separate argument in
bp::args so package_name is not executed as code. Update the bp::child call that
uses python_executable and bp::args to remove the string concatenation with
package_name and include the module name as an additional argument (referencing
python_executable, package_name, bp::child, and bp::args).
🧹 Nitpick comments (3)
src/openms/source/CONCEPT/ProgressLogger.cpp (1)

59-61: Use String::number() for numeric formatting instead of snprintf.

The fixed C buffer and std::snprintf approach is non-idiomatic here. Replace with String::number() for the percentage value to align with OpenMS conventions and improve maintainability:

String pct_str = String::number((value - begin_) / (end_ - begin_) * 100.0, 2);

This follows the canonical OpenMS numeric formatting pattern used throughout the codebase.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/CONCEPT/ProgressLogger.cpp` around lines 59 - 61, Replace
the manual C-buffer formatting that uses pct_buf and std::snprintf with
OpenMS-style numeric formatting: compute the percentage using (value - begin_) /
(end_ - begin_) * 100.0 (ensure floating-point arithmetic) and format it to 2
decimal places via String::number, then output that String in the existing cout
line (keeping the '\r' and indentation using current_recursion_depth). Update
usages of pct_buf and the snprintf call accordingly to use the new pct_str
variable.
src/openms/source/SYSTEM/JavaInfo.cpp (1)

50-50: Consider using '\n' instead of std::endl.

The coding guidelines recommend avoiding std::endl for performance. While flushing is sometimes desirable for error output, using '\n' is preferred unless explicit flush is needed.

As per coding guidelines: "avoid std::endl for performance (use \n)"

Also applies to: 89-89, 95-95

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/JavaInfo.cpp` at line 50, Replace uses of std::endl
with '\n' in the error/output message lines in JavaInfo.cpp (the stream
insertion that ends with std::endl at the shown diff and the other occurrences
around lines 89 and 95); update the stream writes that currently use std::endl
to use '\n' instead (only retain flushing if explicitly needed), e.g., modify
the output statements in the function emitting the "Please free some
resources..." message and the other two message sites to end with '\n' to avoid
an automatic flush on every line.
src/openms/source/FORMAT/OMSFileLoad.cpp (1)

1126-1131: Use JSON null for SQLITE_NULL values instead of empty strings.

Currently, SQLITE_NULL is mapped to an empty string "" (line 1129), but JSON distinguishes between null and empty string. This affects data fidelity when exporting, as consumers cannot differentiate between a NULL database column and one containing an empty string.

Change:

-          case SQLITE_NULL: record[query.getColumnName(i)] = ""; break;
+          case SQLITE_NULL: record[query.getColumnName(i)] = nullptr; break;

The nlohmann::json library correctly converts nullptr to JSON null through its implicit conversion operators.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/FORMAT/OMSFileLoad.cpp` around lines 1126 - 1131, The
SQLITE_NULL case currently assigns an empty string ("") to record[...] which
loses NULL semantics; update the switch handling for SQLITE_NULL to assign a
JSON null (e.g., record[query.getColumnName(i)] = nullptr) instead of "" so
nlohmann::json emits JSON null; change only the SQLITE_NULL branch in the switch
that uses record and query.getColumnName(i)/query.getColumn(i).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/openms/source/SYSTEM/JavaInfo.cpp`:
- Around line 78-82: Guard against getenv("PATH") returning null before
assigning to the OpenMS::String `path` in JavaInfo.cpp: call getenv("PATH") once
into a char* (e.g. tmp = getenv("PATH")), check if tmp is non-null before using
it, and only assign `path = tmp` when non-null (otherwise leave `path` empty or
set a safe default); update the static `String path` initialization logic so the
`path.empty()` check remains valid and avoids undefined behavior when getenv
returns nullptr.

---

Outside diff comments:
In `@src/openms/source/SYSTEM/PythonInfo.cpp`:
- Around line 37-46: The code assumes getenv("PATH") never returns null when
assigning to the static OpenMS::String path in PythonInfo.cpp; instead, guard
against a null return by checking the result of getenv("PATH") before assigning
to path (use a temporary char* env = getenv("PATH"); and only set path = env if
env != nullptr, otherwise set path to an empty string or a placeholder). Update
the logic around the static String path and the getenv call so path is always a
valid OpenMS::String and will not be constructed from a null pointer when
building the error message in the block that checks
std::filesystem::path(std::string(python_executable)).is_relative().

---

Duplicate comments:
In `@src/openms/source/SYSTEM/PythonInfo.cpp`:
- Around line 98-103: The code builds a bp::child invoking python with a "-c"
string that interpolates package_name, which allows executing untrusted code;
instead construct the "-c" argument to read the module name from sys.argv[1]
(e.g. "import sys; __import__(sys.argv[1])") and pass package_name as a separate
argument in bp::args so package_name is not executed as code. Update the
bp::child call that uses python_executable and bp::args to remove the string
concatenation with package_name and include the module name as an additional
argument (referencing python_executable, package_name, bp::child, and bp::args).

---

Nitpick comments:
In `@src/openms/source/CONCEPT/ProgressLogger.cpp`:
- Around line 59-61: Replace the manual C-buffer formatting that uses pct_buf
and std::snprintf with OpenMS-style numeric formatting: compute the percentage
using (value - begin_) / (end_ - begin_) * 100.0 (ensure floating-point
arithmetic) and format it to 2 decimal places via String::number, then output
that String in the existing cout line (keeping the '\r' and indentation using
current_recursion_depth). Update usages of pct_buf and the snprintf call
accordingly to use the new pct_str variable.

In `@src/openms/source/FORMAT/OMSFileLoad.cpp`:
- Around line 1126-1131: The SQLITE_NULL case currently assigns an empty string
("") to record[...] which loses NULL semantics; update the switch handling for
SQLITE_NULL to assign a JSON null (e.g., record[query.getColumnName(i)] =
nullptr) instead of "" so nlohmann::json emits JSON null; change only the
SQLITE_NULL branch in the switch that uses record and
query.getColumnName(i)/query.getColumn(i).

In `@src/openms/source/SYSTEM/JavaInfo.cpp`:
- Line 50: Replace uses of std::endl with '\n' in the error/output message lines
in JavaInfo.cpp (the stream insertion that ends with std::endl at the shown diff
and the other occurrences around lines 89 and 95); update the stream writes that
currently use std::endl to use '\n' instead (only retain flushing if explicitly
needed), e.g., modify the output statements in the function emitting the "Please
free some resources..." message and the other two message sites to end with '\n'
to avoid an automatic flush on every line.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d2a0f4a1-4081-477b-a16c-5fd6d0064185

📥 Commits

Reviewing files that changed from the base of the PR and between 26bfc26 and 54d2196.

📒 Files selected for processing (23)
  • src/openms/include/OpenMS/ANALYSIS/ID/SiriusExportAlgorithm.h
  • src/openms/include/OpenMS/CONCEPT/Qt5Port.h
  • src/openms/include/OpenMS/CONCEPT/sources.cmake
  • src/openms/include/OpenMS/DATASTRUCTURES/DataValue.h
  • src/openms/include/OpenMS/DATASTRUCTURES/String.h
  • src/openms/include/OpenMS/DATASTRUCTURES/StringListUtils.h
  • src/openms/include/OpenMS/DATASTRUCTURES/StringUtils.h
  • src/openms/include/OpenMS/DATASTRUCTURES/StringView.h
  • src/openms/include/OpenMS/FORMAT/OMSFileLoad.h
  • src/openms/source/ANALYSIS/ID/IDRipper.cpp
  • src/openms/source/ANALYSIS/OPENSWATH/OpenSwathOSWParquetWriter.cpp
  • src/openms/source/APPLICATIONS/INIUpdater.cpp
  • src/openms/source/CONCEPT/ProgressLogger.cpp
  • src/openms/source/DATASTRUCTURES/DataValue.cpp
  • src/openms/source/DATASTRUCTURES/String.cpp
  • src/openms/source/DATASTRUCTURES/StringListUtils.cpp
  • src/openms/source/FORMAT/MzTabFile.cpp
  • src/openms/source/FORMAT/OMSFileLoad.cpp
  • src/openms/source/FORMAT/QcMLFile.cpp
  • src/openms/source/KERNEL/DimMapper.cpp
  • src/openms/source/METADATA/DocumentIdentifier.cpp
  • src/openms/source/SYSTEM/JavaInfo.cpp
  • src/openms/source/SYSTEM/PythonInfo.cpp
💤 Files with no reviewable changes (10)
  • src/openms/include/OpenMS/ANALYSIS/ID/SiriusExportAlgorithm.h
  • src/openms/source/DATASTRUCTURES/DataValue.cpp
  • src/openms/include/OpenMS/DATASTRUCTURES/StringListUtils.h
  • src/openms/include/OpenMS/CONCEPT/sources.cmake
  • src/openms/source/DATASTRUCTURES/StringListUtils.cpp
  • src/openms/include/OpenMS/DATASTRUCTURES/String.h
  • src/openms/source/DATASTRUCTURES/String.cpp
  • src/openms/include/OpenMS/CONCEPT/Qt5Port.h
  • src/openms/include/OpenMS/DATASTRUCTURES/DataValue.h
  • src/openms/include/OpenMS/DATASTRUCTURES/StringView.h
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/openms/source/KERNEL/DimMapper.cpp
  • src/openms/source/METADATA/DocumentIdentifier.cpp
  • src/openms/source/FORMAT/MzTabFile.cpp
  • src/openms/include/OpenMS/DATASTRUCTURES/StringUtils.h
  • src/openms/include/OpenMS/FORMAT/OMSFileLoad.h

Comment thread src/openms/source/FORMAT/QcMLFile.cpp Resolved
Comment thread src/openms/source/SYSTEM/JavaInfo.cpp Resolved
@timosachsenberg
timosachsenberg force-pushed the remove-qt/pr5a-string-api branch from 54d2196 to 009fb70 Compare March 19, 2026 07:35

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
src/openms/source/SYSTEM/File.cpp (2)

287-297: ⚠️ Potential issue | 🟠 Major

removeDir and removeDirRecursively are functionally identical.

Both functions use fs::remove_all(), making them behave the same way. If removeDir is intended to only remove an empty directory (failing if non-empty), it should use fs::remove() instead.

Proposed fix if removeDir should only remove empty directories
 bool File::removeDir(const String& dir_name)
 {
   std::error_code ec;
-  fs::remove_all(to_path(dir_name), ec);
+  fs::remove(to_path(dir_name), ec);
   if (ec)
   {
     std::cerr << "Could not remove directory " << dir_name << ": " << ec.message() << std::endl;
     return false;
   }
   return true;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/File.cpp` around lines 287 - 297, The two methods
File::removeDir and File::removeDirRecursively are identical but should differ:
change File::removeDir to use fs::remove (which fails on non-empty dirs) instead
of fs::remove_all so it only removes empty directories; keep error handling
behavior (std::error_code ec and process of logging via std::cerr and returning
false) and leave File::removeDirRecursively using fs::remove_all for recursive
deletion.

215-227: ⚠️ Potential issue | 🟠 Major

Descendant check and error handling still needed in copyDirRecursively.

Two issues persist from past review:

  1. The canonical path check (lines 216-224) only runs when target already exists. If to_dir is inside from_dir and doesn't exist yet, create_directories will create it, then the iterator will find the newly-created directory inside source, causing infinite recursion.
  2. The ec from fs::create_directories() at line 227 is never checked.
Proposed fix
     // If target exists, check canonical to avoid copy onto self
-    if (fs::exists(target_path, ec))
+    // Check if target would be inside source (even if target doesn't exist yet)
+    auto target_check = target_path;
+    while (!fs::exists(target_check, ec) && target_check.has_parent_path() && target_check != target_check.parent_path())
+    {
+      target_check = target_check.parent_path();
+    }
+    if (fs::exists(target_check, ec))
     {
-      auto canonical_target = fs::canonical(target_path, ec);
-      if (!ec && canonical_source == canonical_target)
+      auto canonical_target = fs::canonical(target_check, ec);
+      if (!ec)
       {
-        OPENMS_LOG_ERROR << "Error: Could not copy  " << from_dir << " to " << to_dir << ". Same path given.\n";
-        return false;
+        // Check if target (or its existing ancestor) is same as or inside source
+        auto rel = canonical_target.lexically_relative(canonical_source);
+        if (canonical_source == canonical_target || 
+            (!rel.empty() && !rel.string().starts_with("..")))
+        {
+          OPENMS_LOG_ERROR << "Error: Cannot copy " << from_dir << " into itself or a subdirectory.\n";
+          return false;
+        }
       }
     }

     // make directory if not present
     fs::create_directories(target_path, ec);
+    if (ec)
+    {
+      OPENMS_LOG_ERROR << "Error: Could not create directory " << to_dir << ": " << ec.message() << "\n";
+      return false;
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/File.cpp` around lines 215 - 227, In
copyDirRecursively: perform the same-path/descendant check before calling
fs::create_directories by computing canonical_target even when target_path
doesn't exist (e.g., use fs::weakly_canonical or canonical on
target_path.parent_path() or resolve absolute paths) and compare with
canonical_source to detect if to_dir is equal to or inside from_dir (and return
false with an error via OPENMS_LOG_ERROR if so); then call
fs::create_directories(target_path, ec) and immediately check ec, logging and
returning false on error (do not proceed if create_directories fails).
🧹 Nitpick comments (3)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h (1)

13-15: Consider replacing uint with unsigned int directly instead of adding a global alias.

The using uint = unsigned int; at file scope pollutes the global namespace on MSVC for all translation units that include this header. While technically not a using namespace or using std::..., it has similar namespace hygiene implications.

Cleaner alternatives:

  1. Replace the two usages of uint in MassFeature (lines 143, 160) with unsigned int directly
  2. If uint must be preserved, move the alias inside namespace OpenMS
♻️ Suggested fix: Replace `uint` with `unsigned int`

Remove the alias:

 `#include` <OpenMS/APPLICATIONS/TOPPBase.h>
 `#include` <OpenMS/CHEMISTRY/ISOTOPEDISTRIBUTION/CoarseIsotopePatternGenerator.h>
-#ifdef _MSC_VER
-using uint = unsigned int; // POSIX uint not available on MSVC; was provided transitively via Qt
-#endif
 `#include` <OpenMS/CHEMISTRY/ISOTOPEDISTRIBUTION/IsotopeDistribution.h>

And update the struct members (around lines 143 and 160):

-      uint index;
+      unsigned int index;
-      uint ms_level;
+      unsigned int ms_level;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h` around lines
13 - 15, The file defines a global alias "using uint = unsigned int;" under
_MSC_VER which pollutes the global namespace; update the two members in struct
MassFeature (the fields currently typed as uint) to use "unsigned int" instead
of "uint" (or alternatively move the alias inside namespace OpenMS if you must
keep the short name) so the header no longer introduces a global typedef; modify
the declarations in MassFeature accordingly and remove the file-scope using uint
line.
src/openms/source/SYSTEM/UpdateCheck.cpp (1)

97-103: Consider handling last_write_time errors.

If fs::last_write_time fails (e.g., file was deleted between the File::readable() check and here), ec will be set and last_modified_time may contain an unspecified value. The comparison on line 103 would then be unreliable.

Consider checking ec before using last_modified_time:

🛡️ Suggested defensive check
       std::error_code ec;
       auto last_modified_time = fs::last_write_time(to_path(version_file_name), ec);
       auto current_time = fs::file_time_type::clock::now();
+      
+      // If we couldn't read the timestamp, proceed with the update check
+      if (ec)
+      {
+        first_run = true;
+      }

       // check if at least one day passed since last request
       if (first_run || current_time > last_modified_time + std::chrono::hours(24))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/UpdateCheck.cpp` around lines 97 - 103, The call to
fs::last_write_time in UpdateCheck.cpp may fail and set ec, making the
subsequent comparison with last_modified_time unreliable; add a check of ec
after calling fs::last_write_time (before comparing last_modified_time to
current_time) and handle the error path deterministically (e.g., treat it as if
the file is "stale" so the check proceeds, or skip the time-comparison and force
a refresh) and log or surface the filesystem error; specifically update the
block around fs::last_write_time/to_path(version_file_name) so that if ec is set
you do not use last_modified_time in the expression involving current_time, but
instead take the safe fallback path (using first_run or forcing the update).
src/openms_gui/source/VISUAL/DIALOGS/SwathTabWidget.cpp (1)

466-470: Signed/unsigned comparison warning.

Loop variable i is int but osws_orig.size() returns size_t. Consider using Size or size_t for the loop variable.

Suggested fix
-    for (int i = 0; i < osws_orig.size(); ++i)
+    for (Size i = 0; i < osws_orig.size(); ++i)

As per coding guidelines: "use Size/SignedSize for STL .size() values in C++".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms_gui/source/VISUAL/DIALOGS/SwathTabWidget.cpp` around lines 466 -
470, Change the loop index from a signed int to an unsigned Size (or size_t) to
match osws_orig.size(): replace the current for (int i = 0; i <
osws_orig.size(); ++i) loop with a loop that uses the project's Size (or size_t)
type for i so the comparison between i and osws_orig.size() is not
signed/unsigned; keep the body using QFile::remove(osws[i].toQString()) and
QFile::copy(osws_orig[i].toQString(), osws[i].toQString()) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/openms/source/SYSTEM/ExternalProcess.cpp`:
- Around line 181-205: The POSIX crash detection is incorrect and inconsistent:
replace the numeric comparison of exit_code() vs child.native_exit_code() with a
shared helper (e.g., a static bool WasTerminatedBySignal(int native_status, int
exit_code) or similar) placed near the ExternalProcess logic and call it from
both the WITH I/O and WITHOUT I/O paths so signal termination is uniformly
detected; on POSIX use WIFSIGNALED(native_status) (and WTERMSIG if you want the
signal number) to return true for crash/CRASH handling, and keep the existing
Windows checks under `#ifdef` _WIN32 so RETURNSTATE::CRASH and the verbose
callbackStdErr_ handling (using exe and exit_code) are applied the same way in
both code paths.
- Around line 83-89: The code converts bp::search_path(exe) result to
std::string (exe_str) which forces narrow-path usage; instead keep and use the
filesystem::path returned by bp::search_path and pass that path directly to
bp::child (and to bp::start_dir for working-directory calls). Replace exe_str
(std::string) with a filesystem::path (e.g., resolved or exe_path) and feed that
path into bp::child and bp::start_dir wherever exe/working-directory handling
occurs (the current search_path/resolved logic and the similar blocks later in
the file).

---

Duplicate comments:
In `@src/openms/source/SYSTEM/File.cpp`:
- Around line 287-297: The two methods File::removeDir and
File::removeDirRecursively are identical but should differ: change
File::removeDir to use fs::remove (which fails on non-empty dirs) instead of
fs::remove_all so it only removes empty directories; keep error handling
behavior (std::error_code ec and process of logging via std::cerr and returning
false) and leave File::removeDirRecursively using fs::remove_all for recursive
deletion.
- Around line 215-227: In copyDirRecursively: perform the same-path/descendant
check before calling fs::create_directories by computing canonical_target even
when target_path doesn't exist (e.g., use fs::weakly_canonical or canonical on
target_path.parent_path() or resolve absolute paths) and compare with
canonical_source to detect if to_dir is equal to or inside from_dir (and return
false with an error via OPENMS_LOG_ERROR if so); then call
fs::create_directories(target_path, ec) and immediately check ec, logging and
returning false on error (do not proceed if create_directories fails).

---

Nitpick comments:
In `@src/openms_gui/source/VISUAL/DIALOGS/SwathTabWidget.cpp`:
- Around line 466-470: Change the loop index from a signed int to an unsigned
Size (or size_t) to match osws_orig.size(): replace the current for (int i = 0;
i < osws_orig.size(); ++i) loop with a loop that uses the project's Size (or
size_t) type for i so the comparison between i and osws_orig.size() is not
signed/unsigned; keep the body using QFile::remove(osws[i].toQString()) and
QFile::copy(osws_orig[i].toQString(), osws[i].toQString()) unchanged.

In `@src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h`:
- Around line 13-15: The file defines a global alias "using uint = unsigned
int;" under _MSC_VER which pollutes the global namespace; update the two members
in struct MassFeature (the fields currently typed as uint) to use "unsigned int"
instead of "uint" (or alternatively move the alias inside namespace OpenMS if
you must keep the short name) so the header no longer introduces a global
typedef; modify the declarations in MassFeature accordingly and remove the
file-scope using uint line.

In `@src/openms/source/SYSTEM/UpdateCheck.cpp`:
- Around line 97-103: The call to fs::last_write_time in UpdateCheck.cpp may
fail and set ec, making the subsequent comparison with last_modified_time
unreliable; add a check of ec after calling fs::last_write_time (before
comparing last_modified_time to current_time) and handle the error path
deterministically (e.g., treat it as if the file is "stale" so the check
proceeds, or skip the time-comparison and force a refresh) and log or surface
the filesystem error; specifically update the block around
fs::last_write_time/to_path(version_file_name) so that if ec is set you do not
use last_modified_time in the expression involving current_time, but instead
take the safe fallback path (using first_run or forcing the update).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 83874eb6-c6a7-4722-a325-9fe709055a94

📥 Commits

Reviewing files that changed from the base of the PR and between 54d2196 and 009fb70.

📒 Files selected for processing (72)
  • doc/doxygen/parameters/TOPPDocumenter.cpp
  • src/openms/CMakeLists.txt
  • src/openms/include/OpenMS/ANALYSIS/ID/SiriusExportAlgorithm.h
  • src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h
  • src/openms/include/OpenMS/APPLICATIONS/TOPPBase.h
  • src/openms/include/OpenMS/APPLICATIONS/ToolHandler.h
  • src/openms/include/OpenMS/CONCEPT/Qt5Port.h
  • src/openms/include/OpenMS/CONCEPT/sources.cmake
  • src/openms/include/OpenMS/DATASTRUCTURES/DataValue.h
  • src/openms/include/OpenMS/DATASTRUCTURES/String.h
  • src/openms/include/OpenMS/DATASTRUCTURES/StringListUtils.h
  • src/openms/include/OpenMS/DATASTRUCTURES/StringUtils.h
  • src/openms/include/OpenMS/DATASTRUCTURES/StringView.h
  • src/openms/include/OpenMS/SYSTEM/ExternalProcess.h
  • src/openms/include/OpenMS/SYSTEM/File.h
  • src/openms/include/OpenMS/SYSTEM/PathUtils.h
  • src/openms/include/OpenMS/SYSTEM/RWrapper.h
  • src/openms/include/OpenMS/SYSTEM/sources.cmake
  • src/openms/source/ANALYSIS/ID/FIAMSScheduler.cpp
  • src/openms/source/ANALYSIS/ID/IDRipper.cpp
  • src/openms/source/ANALYSIS/OPENSWATH/OpenSwathOSWParquetWriter.cpp
  • src/openms/source/APPLICATIONS/INIUpdater.cpp
  • src/openms/source/APPLICATIONS/TOPPBase.cpp
  • src/openms/source/APPLICATIONS/ToolHandler.cpp
  • src/openms/source/CONCEPT/ClassTest.cpp
  • src/openms/source/CONCEPT/FuzzyStringComparator.cpp
  • src/openms/source/CONCEPT/ProgressLogger.cpp
  • src/openms/source/DATASTRUCTURES/DataValue.cpp
  • src/openms/source/DATASTRUCTURES/String.cpp
  • src/openms/source/DATASTRUCTURES/StringListUtils.cpp
  • src/openms/source/FEATUREFINDER/FeatureFinderAlgorithmPicked.cpp
  • src/openms/source/FORMAT/DATAACCESS/SiriusFragmentAnnotation.cpp
  • src/openms/source/FORMAT/ExperimentalDesignFile.cpp
  • src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp
  • src/openms/source/FORMAT/MascotGenericFile.cpp
  • src/openms/source/FORMAT/MzTabFile.cpp
  • src/openms/source/FORMAT/OMSFileLoad.cpp
  • src/openms/source/FORMAT/QcMLFile.cpp
  • src/openms/source/MATH/STATISTICS/PosteriorErrorProbabilityModel.cpp
  • src/openms/source/METADATA/DocumentIdentifier.cpp
  • src/openms/source/METADATA/ExperimentalDesign.cpp
  • src/openms/source/PROCESSING/CALIBRATION/InternalCalibration.cpp
  • src/openms/source/QC/DBSuitability.cpp
  • src/openms/source/QC/MQEvidenceExporter.cpp
  • src/openms/source/QC/MQMsmsExporter.cpp
  • src/openms/source/SYSTEM/ExternalProcess.cpp
  • src/openms/source/SYSTEM/File.cpp
  • src/openms/source/SYSTEM/JavaInfo.cpp
  • src/openms/source/SYSTEM/PythonInfo.cpp
  • src/openms/source/SYSTEM/RWrapper.cpp
  • src/openms/source/SYSTEM/UpdateCheck.cpp
  • src/openms_gui/include/OpenMS/VISUAL/DIALOGS/SwathTabWidget.h
  • src/openms_gui/include/OpenMS/VISUAL/DIALOGS/WizardHelper.h
  • src/openms_gui/include/OpenMS/VISUAL/MISC/ExternalProcessMBox.h
  • src/openms_gui/source/VISUAL/DIALOGS/FLASHDeconvTabWidget.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/SwathTabWidget.cpp
  • src/openms_gui/source/VISUAL/MISC/ExternalProcessMBox.cpp
  • src/openms_gui/source/VISUAL/TVToolDiscovery.cpp
  • src/tests/class_tests/openms/source/ExternalProcess_test.cpp
  • src/tests/class_tests/openms/source/TOPPBase_test.cpp
  • src/topp/CometAdapter.cpp
  • src/topp/FileConverter.cpp
  • src/topp/LuciphorAdapter.cpp
  • src/topp/MSFraggerAdapter.cpp
  • src/topp/MSGFPlusAdapter.cpp
  • src/topp/MaRaClusterAdapter.cpp
  • src/topp/NovorAdapter.cpp
  • src/topp/OpenNuXL.cpp
  • src/topp/PercolatorAdapter.cpp
  • src/topp/SageAdapter.cpp
  • src/topp/SpectraSTSearchAdapter.cpp
  • vcpkg.json
💤 Files with no reviewable changes (11)
  • src/openms/include/OpenMS/DATASTRUCTURES/StringView.h
  • src/openms/include/OpenMS/ANALYSIS/ID/SiriusExportAlgorithm.h
  • src/openms/source/METADATA/ExperimentalDesign.cpp
  • src/openms/include/OpenMS/DATASTRUCTURES/StringListUtils.h
  • src/openms/include/OpenMS/CONCEPT/sources.cmake
  • src/openms/include/OpenMS/DATASTRUCTURES/String.h
  • src/openms/source/DATASTRUCTURES/String.cpp
  • src/openms/include/OpenMS/CONCEPT/Qt5Port.h
  • src/openms/include/OpenMS/DATASTRUCTURES/DataValue.h
  • src/openms/source/DATASTRUCTURES/DataValue.cpp
  • src/openms/source/DATASTRUCTURES/StringListUtils.cpp
✅ Files skipped from review due to trivial changes (16)
  • vcpkg.json
  • src/openms/source/ANALYSIS/ID/FIAMSScheduler.cpp
  • src/openms/source/APPLICATIONS/INIUpdater.cpp
  • src/openms/source/FORMAT/OMSFileLoad.cpp
  • src/openms/source/ANALYSIS/ID/IDRipper.cpp
  • src/openms/source/QC/MQMsmsExporter.cpp
  • src/openms/include/OpenMS/SYSTEM/sources.cmake
  • src/openms/source/FEATUREFINDER/FeatureFinderAlgorithmPicked.cpp
  • src/openms/source/FORMAT/ExperimentalDesignFile.cpp
  • src/topp/MaRaClusterAdapter.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/FLASHDeconvTabWidget.cpp
  • src/openms/source/FORMAT/QcMLFile.cpp
  • src/openms/source/METADATA/DocumentIdentifier.cpp
  • src/topp/SageAdapter.cpp
  • src/openms/source/CONCEPT/FuzzyStringComparator.cpp
  • src/openms/source/ANALYSIS/OPENSWATH/OpenSwathOSWParquetWriter.cpp
🚧 Files skipped from review as they are similar to previous changes (25)
  • src/openms/source/FORMAT/MascotGenericFile.cpp
  • src/openms_gui/include/OpenMS/VISUAL/DIALOGS/SwathTabWidget.h
  • src/openms/source/FORMAT/DATAACCESS/SiriusFragmentAnnotation.cpp
  • src/openms/source/MATH/STATISTICS/PosteriorErrorProbabilityModel.cpp
  • src/openms/source/QC/MQEvidenceExporter.cpp
  • src/topp/CometAdapter.cpp
  • src/openms/include/OpenMS/APPLICATIONS/ToolHandler.h
  • src/openms/include/OpenMS/DATASTRUCTURES/StringUtils.h
  • src/topp/FileConverter.cpp
  • src/openms/source/PROCESSING/CALIBRATION/InternalCalibration.cpp
  • src/topp/SpectraSTSearchAdapter.cpp
  • src/openms/source/FORMAT/MzTabFile.cpp
  • src/topp/NovorAdapter.cpp
  • src/openms/source/SYSTEM/PythonInfo.cpp
  • src/openms/source/APPLICATIONS/ToolHandler.cpp
  • src/topp/MSGFPlusAdapter.cpp
  • src/openms_gui/source/VISUAL/MISC/ExternalProcessMBox.cpp
  • src/openms_gui/include/OpenMS/VISUAL/DIALOGS/WizardHelper.h
  • src/topp/LuciphorAdapter.cpp
  • src/topp/PercolatorAdapter.cpp
  • src/openms/source/APPLICATIONS/TOPPBase.cpp
  • src/topp/MSFraggerAdapter.cpp
  • src/openms/source/SYSTEM/RWrapper.cpp
  • src/openms/source/SYSTEM/JavaInfo.cpp
  • src/openms/source/CONCEPT/ProgressLogger.cpp

Comment on lines +83 to 89
// Resolve executable via PATH search (bp::child with a plain string does not search PATH)
std::string exe_str = static_cast<std::string>(exe);
auto resolved = bp::search_path(exe_str);
if (!resolved.empty())
{
callbackStdOut_("Running: " + (QStringList() << exe << args).join(' ') + '\n');
exe_str = resolved.string();
}

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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the ExternalProcess.cpp file to see the actual implementation
find . -name "ExternalProcess.cpp" -type f

Repository: OpenMS/OpenMS

Length of output: 103


🏁 Script executed:

# Check the actual code around the flagged lines
cd src/openms/source/SYSTEM 2>/dev/null && \
  if [ -f ExternalProcess.cpp ]; then 
    echo "=== Lines 75-125 ===" && \
    sed -n '75,125p' ExternalProcess.cpp | cat -n && \
    echo -e "\n=== Lines 200-225 ===" && \
    sed -n '200,225p' ExternalProcess.cpp | cat -n && \
    echo -e "\n=== Lines 105-120 ===" && \
    sed -n '105,120p' ExternalProcess.cpp | cat -n
  fi

Repository: OpenMS/OpenMS

Length of output: 3606


🏁 Script executed:

# Check the includes and namespace setup
head -50 src/openms/source/SYSTEM/ExternalProcess.cpp | cat -n

Repository: OpenMS/OpenMS

Length of output: 2010


🏁 Script executed:

# Search for where exe_str and resolved are used in the launch
rg -n "exe_str|bp::child|bp::spawn" src/openms/source/SYSTEM/ExternalProcess.cpp -A 3 -B 1

Repository: OpenMS/OpenMS

Length of output: 756


🏁 Script executed:

# Let's check what bp::search_path() returns and verify the type conversion
rg -n "search_path" src/openms/source/SYSTEM/ExternalProcess.cpp -B 2 -A 5

Repository: OpenMS/OpenMS

Length of output: 549


🏁 Script executed:

# Look for any tests or usage of ExternalProcess to understand the expected use cases
find . -name "*ExternalProcess*" -type f | head -20

Repository: OpenMS/OpenMS

Length of output: 345


🏁 Script executed:

# Check if there are any comments or documentation about executable paths
grep -r "non.*ascii\|unicode\|encoding" src/openms/source/SYSTEM/ --include="*.h" --include="*.cpp" | head -20

Repository: OpenMS/OpenMS

Length of output: 39


🏁 Script executed:

# Let's verify what the return type of bp::search_path is by checking Boost.Process documentation or type hints
# Also check if there are any CMakeLists or build configuration mentioning Boost.Process
find . -name "CMakeLists.txt" -o -name "*.cmake" | xargs grep -l "boost.*process\|boost_process" 2>/dev/null | head -5

Repository: OpenMS/OpenMS

Length of output: 84


🏁 Script executed:

# Check if OpenMS has Windows-specific code or UTF-8 handling patterns
rg -n "filesystem::path|std::string.*exe|wchar_t" src/openms/source/SYSTEM/ExternalProcess.cpp

Repository: OpenMS/OpenMS

Length of output: 116


🏁 Script executed:

# Let's see the complete context of the bp::child() calls to understand all parameters
sed -n '110,125p' src/openms/source/SYSTEM/ExternalProcess.cpp | cat -n

Repository: OpenMS/OpenMS

Length of output: 651


🏁 Script executed:

# Check the test file to see what kind of executables are passed
cat -n src/openms/tests/class_tests/openms/source/ExternalProcess_test.cpp | head -100

Repository: OpenMS/OpenMS

Length of output: 156


🏁 Script executed:

# Let's also check the header file to understand the API
cat -n src/openms/include/OpenMS/SYSTEM/ExternalProcess.h

Repository: OpenMS/OpenMS

Length of output: 4865


🏁 Script executed:

# Search for actual usages of ExternalProcess in the codebase
rg "ExternalProcess\(" src/ --include="*.cpp" -B 2 -A 2 | head -60

Repository: OpenMS/OpenMS

Length of output: 498


🏁 Script executed:

# Check how bp::start_dir is used - whether it also affects the wide-character promotion
rg "start_dir" src/openms/source/SYSTEM/ExternalProcess.cpp -B 1 -A 1

Repository: OpenMS/OpenMS

Length of output: 629


🏁 Script executed:

# Search for usages of ExternalProcess in the codebase
rg "\.run\(" src/ -t cpp -B 1 -A 3 | head -80

Repository: OpenMS/OpenMS

Length of output: 4518


🏁 Script executed:

# Check if there's any documentation or comments about executable paths
rg "ExternalProcess" src/openms/source/SYSTEM/ExternalProcess.cpp -B 2 -A 2

Repository: OpenMS/OpenMS

Length of output: 1575


🏁 Script executed:

# Let's see the complete function signature and implementation context
sed -n '52,130p' src/openms/source/SYSTEM/ExternalProcess.cpp | cat -n

Repository: OpenMS/OpenMS

Length of output: 3292


🏁 Script executed:

# Let's check Boost.Process documentation or type information
# First, let's see if there's any type information in Boost headers installed
find . -name "*.hpp" -path "*/boost/process*" -type f 2>/dev/null | head -5

Repository: OpenMS/OpenMS

Length of output: 39


🏁 Script executed:

# Check the actual context around line 110-118 (second location mentioned)
sed -n '105,125p' src/openms/source/SYSTEM/ExternalProcess.cpp | cat -n

Repository: OpenMS/OpenMS

Length of output: 877


🏁 Script executed:

# Check the context around line 210-218 (third location mentioned)
sed -n '205,225p' src/openms/source/SYSTEM/ExternalProcess.cpp | cat -n

Repository: OpenMS/OpenMS

Length of output: 783


🏁 Script executed:

# Let's see if there's actual usage of ExternalProcess with non-ASCII paths
rg "ExternalProcess" src/ -t cpp -B 3 -A 5 | head -100

Repository: OpenMS/OpenMS

Length of output: 5970


🏁 Script executed:

# Check if there are any Windows-specific considerations in the codebase
rg "wide\|wchar_t\|UTF.?8|filesystem::path" src/openms/source/SYSTEM/ -t cpp

Repository: OpenMS/OpenMS

Length of output: 292


🏁 Script executed:

# Let's check how bp::search_path is actually used and what its return type is
# by looking for documentation or actual usage patterns
rg "bp::search_path|search_path" src/ -t cpp -B 2 -A 2

Repository: OpenMS/OpenMS

Length of output: 4135


🏁 Script executed:

# Let's see what types are passed to bp::child in the codebase
sed -n '60,70p' src/openms/source/SYSTEM/ExternalProcess.cpp
sed -n '130,140p' src/openms/source/SYSTEM/ExternalProcess.cpp

Repository: OpenMS/OpenMS

Length of output: 850


🏁 Script executed:

# Check if there's any use of filesystem::path in the existing codebase for process/path handling
rg "filesystem::path.*child\|child.*filesystem::path" src/ -t cpp

Repository: OpenMS/OpenMS

Length of output: 39


🏁 Script executed:

# Let's check the actual executable names and working directories being passed
rg "ExternalProcess\(\)" src/ -t cpp -B 5 -A 10 | head -100

Repository: OpenMS/OpenMS

Length of output: 6931


🏁 Script executed:

# Check if there are any other uses of bp::search_path in the codebase
rg "bp::search_path\|boost::process::search_path" . -t cpp

Repository: OpenMS/OpenMS

Length of output: 39


Pass bp::search_path() result directly to bp::child without string conversion.

bp::search_path() returns filesystem::path, which Boost.Process v1 on Windows uses to trigger wide-character (wchar_t) handling for process launching. Converting to std::string via .string() bypasses this promotion and can break non-ASCII executable or working-directory names. Keep these values as filesystem::path through process creation. This pattern is already used consistently in PythonInfo.cpp, RWrapper.cpp, and JavaInfo.cpp.

Also applies to: lines 110–118, 210–218 (working directory passed to bp::start_dir())

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/ExternalProcess.cpp` around lines 83 - 89, The code
converts bp::search_path(exe) result to std::string (exe_str) which forces
narrow-path usage; instead keep and use the filesystem::path returned by
bp::search_path and pass that path directly to bp::child (and to bp::start_dir
for working-directory calls). Replace exe_str (std::string) with a
filesystem::path (e.g., resolved or exe_path) and feed that path into bp::child
and bp::start_dir wherever exe/working-directory handling occurs (the current
search_path/resolved logic and the similar blocks later in the file).

Comment on lines +181 to +205
#ifdef _WIN32
// On Windows, abnormal termination often results in specific exit codes
// like 0xC0000005 (access violation), etc.
if (exit_code < 0 || static_cast<unsigned int>(exit_code) > 0x80000000u)
#else
// On POSIX, signals cause exit_code to encode the signal (boost::process sets native_exit_code)
if (child.native_exit_code() != 0 && exit_code != child.native_exit_code())
#endif
{
error_msg = "Process '" + exe + "' crashed hard (segfault-like). Please check the log.";
if (verbose)
{
callbackStdErr_(error_msg + "\n");
}
return RETURNSTATE::CRASH;
}
else if (exit_code != 0)
{
error_msg = "Process '" + exe + "' did not finish successfully (exit code: " + String(exit_code) + "). Please check the log.";
if (verbose)
{
callbackStdErr_(error_msg + "\n");
}
return RETURNSTATE::NONZERO_EXIT;
}

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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's find and examine the ExternalProcess.cpp file
find . -name "ExternalProcess.cpp" -type f

Repository: OpenMS/OpenMS

Length of output: 103


🏁 Script executed:

# Read the relevant lines from the file
if [ -f "src/openms/source/SYSTEM/ExternalProcess.cpp" ]; then
  echo "=== Lines 181-205 ===" && \
  sed -n '181,205p' src/openms/source/SYSTEM/ExternalProcess.cpp && \
  echo -e "\n=== Lines 242-250 ===" && \
  sed -n '242,250p' src/openms/source/SYSTEM/ExternalProcess.cpp
else
  find . -name "ExternalProcess.cpp" -type f -exec sed -n '181,205p' {} + && \
  find . -name "ExternalProcess.cpp" -type f -exec sed -n '242,250p' {} +
fi

Repository: OpenMS/OpenMS

Length of output: 1465


🏁 Script executed:

# Get broader context around these lines to understand the function
if [ -f "src/openms/source/SYSTEM/ExternalProcess.cpp" ]; then
  echo "=== Context lines 170-260 ===" && \
  sed -n '170,260p' src/openms/source/SYSTEM/ExternalProcess.cpp
else
  find . -name "ExternalProcess.cpp" -type f -exec sed -n '170,260p' {} +
fi

Repository: OpenMS/OpenMS

Length of output: 2889


🏁 Script executed:

# Check for any helper functions already dealing with exit codes
if [ -f "src/openms/source/SYSTEM/ExternalProcess.cpp" ]; then
  rg -n "native_exit_code|exit_code" src/openms/source/SYSTEM/ExternalProcess.cpp | head -30
else
  find . -name "ExternalProcess.cpp" -type f -exec sh -c 'rg -n "native_exit_code|exit_code" "$1" | head -30' _ {} \;
fi

Repository: OpenMS/OpenMS

Length of output: 783


🌐 Web query:

boost.process child exit_code native_exit_code POSIX signal handling

💡 Result:

In Boost.Process (v1, the current stable version as of Boost 1.85+), the boost::process::child class manages child processes. Key methods for exit codes: - int exit_code const: Returns the portable exit code (what the subprocess returned from main). Meaningless if not waited for or if terminated. - int native_exit_code const: Returns the native, uninterpreted exit code (on POSIX, the full waitpid status word containing exit status and signal info if signaled). Also meaningless without prior wait. To use: Call child.wait (blocks until exit) or child.join first, then access either method. Without wait, values are invalid. Destructor terminates if not joined/detached. On POSIX: - wait implementations use waitpid in a loop handling EINTR, extracting status [66]. - If child exited normally: exit_code = WEXITSTATUS(status), native_exit_code = full status. - If killed by signal: exit_code typically 128 + signal (portable convention, but docs don't specify exact mapping), native_exit_code = status with WIFSIGNALED(status) true [2,13,16]. - SIGCHLD handling: Customizable via posix::sig property (set handler, ignore, or default) during spawn [7,21]. Defaults to sig.ign for spawn. Async on_exit uses signal_set for SIGCHLD [20,24]. wait_for/wait_until use sigtimedwait or fork+signal tricks [66]. Boost.Process v2 (developing) uses process/basic_process_handle with native_exit_code_type, evaluate_exit_code for portable part, process_is_running [13,16,62]. Uses pidfd_open on Linux for modern POSIX waiting. Sources confirm consistent behavior across Boost 1.71-1.85 docs [2,4,5,17,22,25,67].

Citations:


🏁 Script executed:

# Search for WIFSIGNALED, WTERMSIG, or other POSIX signal macros in the codebase
rg "WIFSIGNALED|WTERMSIG|WIFEXITED|WEXITSTATUS" src/

Repository: OpenMS/OpenMS

Length of output: 39


🏁 Script executed:

# Check what headers are included in ExternalProcess.cpp
head -50 src/openms/source/SYSTEM/ExternalProcess.cpp

Repository: OpenMS/OpenMS

Length of output: 1660


Unify crash detection across I/O modes using proper POSIX signal checking.

The POSIX crash check (line 187) compares numeric values of exit_code() and native_exit_code(), which is not the correct way to detect signal termination. On POSIX, native_exit_code() is the raw waitpid status word; signal termination should be detected using WIFSIGNALED(native_exit_code()), not value comparison.

More critically, the WITH I/O path (lines 181–205) attempts signal detection while the WITHOUT I/O path (lines 242–250) only checks exit_code != 0, causing signal termination to be classified as CRASH in one mode and NONZERO_EXIT in the other. Create a shared helper function to uniformly detect signal termination using POSIX macros, then apply it to both code paths.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/ExternalProcess.cpp` around lines 181 - 205, The
POSIX crash detection is incorrect and inconsistent: replace the numeric
comparison of exit_code() vs child.native_exit_code() with a shared helper
(e.g., a static bool WasTerminatedBySignal(int native_status, int exit_code) or
similar) placed near the ExternalProcess logic and call it from both the WITH
I/O and WITHOUT I/O paths so signal termination is uniformly detected; on POSIX
use WIFSIGNALED(native_status) (and WTERMSIG if you want the signal number) to
return true for crash/CRASH handling, and keep the existing Windows checks under
`#ifdef` _WIN32 so RETURNSTATE::CRASH and the verbose callbackStdErr_ handling
(using exe and exit_code) are applied the same way in both code paths.

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/openms/source/SYSTEM/PythonInfo.cpp (1)

40-44: ⚠️ Potential issue | 🟡 Minor

Guard against null return from getenv("PATH").

Same issue as in JavaInfo.cpp: getenv("PATH") can return nullptr if PATH is unset.

🛡️ Proposed fix
         static String path;
         if (path.empty())
         {
-          path = getenv("PATH");
+          const char* env_path = getenv("PATH");
+          path = env_path ? env_path : "(not set)";
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/PythonInfo.cpp` around lines 40 - 44, The code in
PythonInfo.cpp assigns getenv("PATH") directly to static String path without
checking for nullptr (same problem as JavaInfo.cpp); update the code that
initializes the static variable path inside the lazy block (the path variable)
to call getenv("PATH"), check for a nullptr return, and only assign a non-null
C-string (or assign an empty string) to path if getenv returns non-null —
otherwise leave path empty or set a safe default string to avoid dereferencing
nullptr.
♻️ Duplicate comments (2)
src/openms/source/SYSTEM/ExternalProcess.cpp (1)

181-205: ⚠️ Potential issue | 🟠 Major

Inconsistent crash/signal detection between I/O modes.

The WITH I/O path (lines 181-196) attempts to detect crashes using a heuristic comparing exit_code() vs native_exit_code(), while the WITHOUT I/O path (lines 242-250) only checks for non-zero exit and returns NONZERO_EXIT for all failures—including signal termination.

On POSIX, proper signal detection should use WIFSIGNALED(native_exit_code()) rather than value comparison. Consider extracting a shared helper function to unify crash detection across both code paths.

Also applies to: 242-250

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/ExternalProcess.cpp` around lines 181 - 205, The
crash detection is inconsistent between the WITH I/O and WITHOUT I/O paths:
unify logic by extracting a helper (e.g., isCrashExit or interpretChildExit)
that takes exit_code and child.native_exit_code() and returns whether the
process crashed vs exited nonzero; on POSIX implement this helper using
WIFSIGNALED(child.native_exit_code()) and WTERMSIG(...) to detect signal
termination and treat that as RETURNSTATE::CRASH, and on Windows keep the
existing abnormal-code checks (e.g., negative/large values) for
RETURNSTATE::CRASH; update both code paths to call this helper and then return
RETURNSTATE::CRASH or RETURNSTATE::NONZERO_EXIT consistently, using the same
error_msg and callbackStdErr_ behavior.
src/openms_gui/source/VISUAL/MISC/ExternalProcessMBox.cpp (1)

40-43: ⚠️ Potential issue | 🔴 Critical

String::toQString() is removed; these calls will break compilation.

Per the PR objectives, String::toQString() has been removed from the core library. Lines 42 and 54 still call error_msg.toQString(), which will fail to compile.

🐛 Proposed fix
     if (!error_msg.empty())
     {
-      QMessageBox::critical(parent, "Error", error_msg.toQString());
+      QMessageBox::critical(parent, "Error", QString::fromUtf8(error_msg.c_str()));
     }

Also at line 54:

-    if (!error_msg.empty()) QMessageBox::critical(parent, "Error", error_msg.toQString());
+    if (!error_msg.empty()) QMessageBox::critical(parent, "Error", QString::fromUtf8(error_msg.c_str()));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms_gui/source/VISUAL/MISC/ExternalProcessMBox.cpp` around lines 40 -
43, The code calls the removed String::toQString() on error_msg in
ExternalProcessMBox.cpp; replace those calls with an explicit conversion to
QString (for example QString::fromStdString(error_msg.toStdString()) or
QString::fromUtf8(error_msg.c_str()) depending on available String API) where
QMessageBox::critical(parent, "Error", ...) is invoked and at the other
occurrence; update both calls to use the chosen QString conversion so the code
compiles without String::toQString().
🧹 Nitpick comments (3)
src/openms/include/OpenMS/DATASTRUCTURES/StringUtils.h (1)

203-208: Consider handling potential truncation for extreme values.

The 64-byte buffer may be insufficient for edge cases. The %.*f format does not use scientific notation, so DBL_MAX (~1.8×10³⁰⁸) would require 309+ digits before the decimal point, plus n decimal places. While snprintf safely prevents buffer overflow, the result would be silently truncated, producing incorrect output.

For typical mass spectrometry values this is unlikely to be an issue, but for robustness consider either:

  1. Using a larger buffer (e.g., 512 bytes), or
  2. Checking snprintf's return value and handling truncation
♻️ Option 1: Larger buffer (simple fix)
   [[maybe_unused]] static String number(double d, UInt n)
   {
-    char buf[64];
+    char buf[512];
     std::snprintf(buf, sizeof(buf), "%.*f", static_cast<int>(n), d);
     return String(buf);
   }
♻️ Option 2: Check return value and use dynamic allocation if needed
   [[maybe_unused]] static String number(double d, UInt n)
   {
     char buf[64];
-    std::snprintf(buf, sizeof(buf), "%.*f", static_cast<int>(n), d);
-    return String(buf);
+    int len = std::snprintf(buf, sizeof(buf), "%.*f", static_cast<int>(n), d);
+    if (len < 0)
+    {
+      return String(); // encoding error
+    }
+    if (static_cast<size_t>(len) < sizeof(buf))
+    {
+      return String(buf);
+    }
+    // Buffer too small, allocate exact size needed
+    std::vector<char> large_buf(static_cast<size_t>(len) + 1);
+    std::snprintf(large_buf.data(), large_buf.size(), "%.*f", static_cast<int>(n), d);
+    return String(large_buf.data());
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/include/OpenMS/DATASTRUCTURES/StringUtils.h` around lines 203 -
208, The number(double d, UInt n) helper in StringUtils.h can silently truncate
when the 64-byte stack buffer is too small; modify it to detect and handle
truncation by checking snprintf's return value (the needed size) and, if it
indicates truncation or a larger size, allocate a std::string/heap buffer of the
required length and call snprintf/vsnprintf again (or simply expand the initial
buffer to a safe large size like 512 if you prefer the simpler fix); ensure the
function still returns a String constructed from the complete formatted result.
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h (1)

13-15: Avoid adding a global uint alias in a public header.

Lines 13-15 introduce a non-standard type alias at header scope, which leaks into all translation units on MSVC. Replace uint fields with OpenMS::UInt and remove this MSVC workaround. The UInt type is already available through the transitive include of MassTraceDetection.h (line 19), which includes Types.h.

♻️ Proposed fix
 `#include` <OpenMS/APPLICATIONS/TOPPBase.h>
 `#include` <OpenMS/CHEMISTRY/ISOTOPEDISTRIBUTION/CoarseIsotopePatternGenerator.h>
-#ifdef _MSC_VER
-using uint = unsigned int; // POSIX uint not available on MSVC; was provided transitively via Qt
-#endif
 `#include` <OpenMS/CHEMISTRY/ISOTOPEDISTRIBUTION/IsotopeDistribution.h>
 `#include` <OpenMS/CONCEPT/Constants.h>
 `#include` <OpenMS/CONCEPT/HashUtils.h>
@@
-      uint index;
+      UInt index;
@@
-      uint ms_level;
+      UInt ms_level;

Per coding guidelines, use OpenMS primitive types from OpenMS/CONCEPT/Types.h in all **/*.{cpp,h,hpp} files.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h` around lines
13 - 15, Remove the global MSVC-only alias "using uint = unsigned int;" from the
header and replace any use of the non-standard symbol `uint` in this file with
the OpenMS primitive `OpenMS::UInt` (e.g., update struct/class field types and
function signatures that reference `uint`); rely on the existing transitive
include of Types via `MassTraceDetection.h` (already included) or explicitly
include OpenMS/CONCEPT/Types.h if needed, and ensure no header-level
typedef/using remains that pollutes global scope.
src/openms/source/SYSTEM/RWrapper.cpp (1)

165-173: Redundant success messages when verbose is true.

When the function succeeds with verbose=true, two success messages are printed:

  1. Line 167: " success"
  2. Lines 169-172: "Trying to invoke 'Rscript' ... success"

This appears to be leftover from the refactoring.

♻️ Proposed fix to remove duplicate logging
     if (verbose)
     {
       OPENMS_LOG_INFO << " success" << std::endl;
     }
-    if (verbose)
-    {
-      OPENMS_LOG_INFO << "Trying to invoke 'Rscript' ... success" << std::endl;
-    }
     return true;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/RWrapper.cpp` around lines 165 - 173, The code
prints two success messages when verbose is true (an isolated OPENMS_LOG_INFO <<
" success" and the more descriptive OPENMS_LOG_INFO << "Trying to invoke
'Rscript' ... success"); remove the redundant short message by deleting the
first verbose conditional that logs " success" so only the descriptive "Trying
to invoke 'Rscript' ... success" remains (look for the OPENMS_LOG_INFO usage
guarded by the verbose flag in RWrapper.cpp).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/openms_gui/source/VISUAL/DIALOGS/SwathTabWidget.cpp`:
- Around line 468-469: The code calls the removed String::toQString() on osws
and osws_orig when calling QFile::remove and QFile::copy; replace those calls by
explicitly converting the OpenMS String to a QString (e.g.
QString::fromStdString(osws[i].toStdString()) or
QString::fromUtf8(osws[i].c_str())) so use
QFile::remove(QString::fromStdString(osws[i].toStdString())) and
QFile::copy(QString::fromStdString(osws_orig[i].toStdString()),
QString::fromStdString(osws[i].toStdString())); update the uses around osws,
osws_orig, QFile::remove, and QFile::copy accordingly.
- Around line 523-524: The calls to .toQString() were removed and will fail
compilation; update usages (e.g., infileToChrom(raw_files[i]).toQString() and
osw_files[i].toQString()) to construct a QString explicitly from the underlying
std::string, for example by calling QString::fromStdString(...) on the
OpenMS::String via its toStdString()/std() accessor (i.e., replace X.toQString()
with QString::fromStdString(X.toStdString()) for infileToChrom(...) and
osw_files[i]).

In `@src/topp/LuciphorAdapter.cpp`:
- Around line 559-561: The MaxPermSize argument is missing its unit suffix: when
building the JVM arg in LuciphorAdapter.cpp you should append "m" to
java_permgen just like the -Xmx handling; update the code that pushes
"-XX:MaxPermSize=" + String(java_permgen) (the block referencing java_permgen
and process_params) to produce "-XX:MaxPermSize=" + String(java_permgen) + "m"
so the JVM interprets it as megabytes.

---

Outside diff comments:
In `@src/openms/source/SYSTEM/PythonInfo.cpp`:
- Around line 40-44: The code in PythonInfo.cpp assigns getenv("PATH") directly
to static String path without checking for nullptr (same problem as
JavaInfo.cpp); update the code that initializes the static variable path inside
the lazy block (the path variable) to call getenv("PATH"), check for a nullptr
return, and only assign a non-null C-string (or assign an empty string) to path
if getenv returns non-null — otherwise leave path empty or set a safe default
string to avoid dereferencing nullptr.

---

Duplicate comments:
In `@src/openms_gui/source/VISUAL/MISC/ExternalProcessMBox.cpp`:
- Around line 40-43: The code calls the removed String::toQString() on error_msg
in ExternalProcessMBox.cpp; replace those calls with an explicit conversion to
QString (for example QString::fromStdString(error_msg.toStdString()) or
QString::fromUtf8(error_msg.c_str()) depending on available String API) where
QMessageBox::critical(parent, "Error", ...) is invoked and at the other
occurrence; update both calls to use the chosen QString conversion so the code
compiles without String::toQString().

In `@src/openms/source/SYSTEM/ExternalProcess.cpp`:
- Around line 181-205: The crash detection is inconsistent between the WITH I/O
and WITHOUT I/O paths: unify logic by extracting a helper (e.g., isCrashExit or
interpretChildExit) that takes exit_code and child.native_exit_code() and
returns whether the process crashed vs exited nonzero; on POSIX implement this
helper using WIFSIGNALED(child.native_exit_code()) and WTERMSIG(...) to detect
signal termination and treat that as RETURNSTATE::CRASH, and on Windows keep the
existing abnormal-code checks (e.g., negative/large values) for
RETURNSTATE::CRASH; update both code paths to call this helper and then return
RETURNSTATE::CRASH or RETURNSTATE::NONZERO_EXIT consistently, using the same
error_msg and callbackStdErr_ behavior.

---

Nitpick comments:
In `@src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h`:
- Around line 13-15: Remove the global MSVC-only alias "using uint = unsigned
int;" from the header and replace any use of the non-standard symbol `uint` in
this file with the OpenMS primitive `OpenMS::UInt` (e.g., update struct/class
field types and function signatures that reference `uint`); rely on the existing
transitive include of Types via `MassTraceDetection.h` (already included) or
explicitly include OpenMS/CONCEPT/Types.h if needed, and ensure no header-level
typedef/using remains that pollutes global scope.

In `@src/openms/include/OpenMS/DATASTRUCTURES/StringUtils.h`:
- Around line 203-208: The number(double d, UInt n) helper in StringUtils.h can
silently truncate when the 64-byte stack buffer is too small; modify it to
detect and handle truncation by checking snprintf's return value (the needed
size) and, if it indicates truncation or a larger size, allocate a
std::string/heap buffer of the required length and call snprintf/vsnprintf again
(or simply expand the initial buffer to a safe large size like 512 if you prefer
the simpler fix); ensure the function still returns a String constructed from
the complete formatted result.

In `@src/openms/source/SYSTEM/RWrapper.cpp`:
- Around line 165-173: The code prints two success messages when verbose is true
(an isolated OPENMS_LOG_INFO << " success" and the more descriptive
OPENMS_LOG_INFO << "Trying to invoke 'Rscript' ... success"); remove the
redundant short message by deleting the first verbose conditional that logs "
success" so only the descriptive "Trying to invoke 'Rscript' ... success"
remains (look for the OPENMS_LOG_INFO usage guarded by the verbose flag in
RWrapper.cpp).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8bb9cf75-f321-40f5-8012-d563c94efabf

📥 Commits

Reviewing files that changed from the base of the PR and between 009fb70 and 3315b00.

📒 Files selected for processing (50)
  • doc/doxygen/parameters/TOPPDocumenter.cpp
  • src/openms/CMakeLists.txt
  • src/openms/include/OpenMS/ANALYSIS/ID/SiriusExportAlgorithm.h
  • src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h
  • src/openms/include/OpenMS/APPLICATIONS/TOPPBase.h
  • src/openms/include/OpenMS/CONCEPT/Qt5Port.h
  • src/openms/include/OpenMS/CONCEPT/sources.cmake
  • src/openms/include/OpenMS/DATASTRUCTURES/DataValue.h
  • src/openms/include/OpenMS/DATASTRUCTURES/String.h
  • src/openms/include/OpenMS/DATASTRUCTURES/StringListUtils.h
  • src/openms/include/OpenMS/DATASTRUCTURES/StringUtils.h
  • src/openms/include/OpenMS/DATASTRUCTURES/StringView.h
  • src/openms/include/OpenMS/SYSTEM/ExternalProcess.h
  • src/openms/include/OpenMS/SYSTEM/RWrapper.h
  • src/openms/source/ANALYSIS/OPENSWATH/OpenSwathOSWParquetWriter.cpp
  • src/openms/source/APPLICATIONS/INIUpdater.cpp
  • src/openms/source/APPLICATIONS/TOPPBase.cpp
  • src/openms/source/CONCEPT/ProgressLogger.cpp
  • src/openms/source/DATASTRUCTURES/DataValue.cpp
  • src/openms/source/DATASTRUCTURES/String.cpp
  • src/openms/source/DATASTRUCTURES/StringListUtils.cpp
  • src/openms/source/FORMAT/MzTabFile.cpp
  • src/openms/source/FORMAT/OMSFileLoad.cpp
  • src/openms/source/PROCESSING/CALIBRATION/InternalCalibration.cpp
  • src/openms/source/QC/DBSuitability.cpp
  • src/openms/source/SYSTEM/ExternalProcess.cpp
  • src/openms/source/SYSTEM/JavaInfo.cpp
  • src/openms/source/SYSTEM/PythonInfo.cpp
  • src/openms/source/SYSTEM/RWrapper.cpp
  • src/openms_gui/include/OpenMS/VISUAL/DIALOGS/SwathTabWidget.h
  • src/openms_gui/include/OpenMS/VISUAL/DIALOGS/WizardHelper.h
  • src/openms_gui/include/OpenMS/VISUAL/MISC/ExternalProcessMBox.h
  • src/openms_gui/source/VISUAL/DIALOGS/FLASHDeconvTabWidget.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/SwathTabWidget.cpp
  • src/openms_gui/source/VISUAL/MISC/ExternalProcessMBox.cpp
  • src/openms_gui/source/VISUAL/TVToolDiscovery.cpp
  • src/tests/class_tests/openms/source/ExternalProcess_test.cpp
  • src/tests/class_tests/openms/source/TOPPBase_test.cpp
  • src/topp/CometAdapter.cpp
  • src/topp/FileConverter.cpp
  • src/topp/LuciphorAdapter.cpp
  • src/topp/MSFraggerAdapter.cpp
  • src/topp/MSGFPlusAdapter.cpp
  • src/topp/MaRaClusterAdapter.cpp
  • src/topp/NovorAdapter.cpp
  • src/topp/OpenNuXL.cpp
  • src/topp/PercolatorAdapter.cpp
  • src/topp/SageAdapter.cpp
  • src/topp/SpectraSTSearchAdapter.cpp
  • vcpkg.json
💤 Files with no reviewable changes (10)
  • src/openms/include/OpenMS/ANALYSIS/ID/SiriusExportAlgorithm.h
  • src/openms/include/OpenMS/DATASTRUCTURES/StringListUtils.h
  • src/openms/include/OpenMS/CONCEPT/sources.cmake
  • src/openms/include/OpenMS/DATASTRUCTURES/StringView.h
  • src/openms/source/DATASTRUCTURES/StringListUtils.cpp
  • src/openms/include/OpenMS/CONCEPT/Qt5Port.h
  • src/openms/include/OpenMS/DATASTRUCTURES/String.h
  • src/openms/source/DATASTRUCTURES/String.cpp
  • src/openms/source/DATASTRUCTURES/DataValue.cpp
  • src/openms/include/OpenMS/DATASTRUCTURES/DataValue.h
✅ Files skipped from review due to trivial changes (7)
  • vcpkg.json
  • src/openms/source/QC/DBSuitability.cpp
  • src/openms/source/APPLICATIONS/INIUpdater.cpp
  • src/openms/source/ANALYSIS/OPENSWATH/OpenSwathOSWParquetWriter.cpp
  • src/openms/source/FORMAT/OMSFileLoad.cpp
  • src/openms/source/CONCEPT/ProgressLogger.cpp
  • src/topp/PercolatorAdapter.cpp
🚧 Files skipped from review as they are similar to previous changes (14)
  • src/openms_gui/source/VISUAL/TVToolDiscovery.cpp
  • src/topp/FileConverter.cpp
  • src/topp/SpectraSTSearchAdapter.cpp
  • doc/doxygen/parameters/TOPPDocumenter.cpp
  • src/openms_gui/include/OpenMS/VISUAL/DIALOGS/SwathTabWidget.h
  • src/openms/source/FORMAT/MzTabFile.cpp
  • src/tests/class_tests/openms/source/TOPPBase_test.cpp
  • src/topp/MaRaClusterAdapter.cpp
  • src/topp/CometAdapter.cpp
  • src/openms/source/PROCESSING/CALIBRATION/InternalCalibration.cpp
  • src/topp/NovorAdapter.cpp
  • src/openms/include/OpenMS/APPLICATIONS/TOPPBase.h
  • src/topp/SageAdapter.cpp
  • src/openms/include/OpenMS/SYSTEM/ExternalProcess.h

Comment thread src/topp/LuciphorAdapter.cpp Resolved

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

Actionable comments posted: 9

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/openms_gui/source/VISUAL/APPLICATIONS/TOPPASBase.cpp (1)

548-563: ⚠️ Potential issue | 🟠 Major

Only return success from savePipelineAs() after the file is actually stored.

This function still returns the chosen filename and retitles the window when store() fails. The callers treat any non-empty return as success, so the tab can look saved although nothing was written.

🩹 Suggested fix
       if (!w->getScene()->store(file_name.toStdString()))
       {
         QMessageBox::warning(nullptr, tr("Error"),
                              tr("Unable to save current pipeline. Possible reason: Invalid edges due to parameter refresh."));
+        return "";
       }
       QString caption = QString::fromStdString(File::basename(file_name.toStdString()));
       w->setWindowTitle(caption);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms_gui/source/VISUAL/APPLICATIONS/TOPPASBase.cpp` around lines 548 -
563, The savePipelineAs() function currently sets the window title and returns
the chosen filename even when w->getScene()->store(...) fails; change it so the
function only updates the window title and returns the filename when store()
succeeds. Concretely, inside savePipelineAs() around the call to
w->getScene()->store(file_name.toStdString()), ensure the QMessageBox::warning
remains on failure and that you do NOT set w->setWindowTitle(...) or return the
non-empty file_name; instead only set the caption and return file_name when
store(...) returns true, and return an empty QString on failure.
🧹 Nitpick comments (10)
src/openms_gui/source/VISUAL/VISUALIZER/GradientVisualizer.cpp (1)

142-143: Pre-existing: Uses cout and endl directly.

Not introduced by this PR, but these lines use std::cout and std::endl which violates the guideline to use OpenMS logging macros. Consider addressing in a follow-up. As per coding guidelines: "Use OpenMS logging macros and OpenMS::LogStream; avoid std::cout/err directly; avoid std::endl for performance (use \n)".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms_gui/source/VISUAL/VISUALIZER/GradientVisualizer.cpp` around lines
142 - 143, Replace the direct std::cout/std::endl calls in
GradientVisualizer.cpp (the two lines printing "The sum does not add up to 100
!" and "Please check your values.") with the OpenMS logging API (e.g.
OPENMS_LOG_WARN / OPENMS_LOG_ERROR or OpenMS::LogStream) and use '\n' instead of
std::endl; ensure the messages preserve the same text and context and are routed
through the OpenMS logger rather than using cout.
src/openms_gui/source/VISUAL/Plot3DOpenGLCanvas.cpp (1)

169-169: Centralize duplicated background-color conversion.

The same conversion logic appears at Line 169 and Line 475. Extracting it into a small helper (e.g., backgroundColor_()) will reduce drift risk and simplify future parameter-format changes.

♻️ Suggested refactor
-    QColor color(QString::fromStdString(canvas_3d_.param_.getValue("background_color").toString()));
+    const QColor color = backgroundColor_();
-    QColor color(QString::fromStdString(canvas_3d_.param_.getValue("background_color").toString()));
+    const QColor color = backgroundColor_();
// Add in .cpp (and declare in the class in the header)
QColor Plot3DOpenGLCanvas::backgroundColor_() const
{
  return QColor(QString::fromStdString(canvas_3d_.param_.getValue("background_color").toString()));
}

Also applies to: 475-475

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms_gui/source/VISUAL/Plot3DOpenGLCanvas.cpp` at line 169, Duplicate
background-color conversion in Plot3DOpenGLCanvas should be centralized: add a
private helper QColor Plot3DOpenGLCanvas::backgroundColor_() const (declare it
in the class header) that returns
QColor(QString::fromStdString(canvas_3d_.param_.getValue("background_color").toString()));
then replace the two direct constructions (the ones creating QColor from
canvas_3d_.param_.getValue("background_color")) with calls to backgroundColor_()
so all conversions use the single helper.
src/topp/MetaProSIP.cpp (1)

544-560: Redundant QString() constructor wrappers.

The expression QString::fromStdString(...) + "/" + QString::fromStdString(...) already produces a QString, so the outer QString(...) wrapper is unnecessary. This pattern appears throughout the file.

♻️ Suggested simplification
-    qparam << "--slave" << "--file=" + QString(QString::fromStdString(tmp_path) + "/" + QString::fromStdString(script_filename));
+    qparam << "--slave" << "--file=" + QString::fromStdString(tmp_path) + "/" + QString::fromStdString(script_filename);

Similarly for the QFile constructors at lines 556, 559, 560:

-      QFile(QString(QString::fromStdString(tmp_path) + "/" + QString::fromStdString(filename))).copy(...);
+      QFile(QString::fromStdString(tmp_path) + "/" + QString::fromStdString(filename)).copy(...);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/MetaProSIP.cpp` around lines 544 - 560, Several calls wrap
QString::fromStdString(...) with an extra QString(...) unnecessarily (e.g., in
the QFile constructors and in building paths before QFile::copy/remove) which is
redundant; update the expressions in the block handling status == 0 to remove
the outer QString(...) wrappers and construct paths using
QString::fromStdString(tmp_path) + "/" + QString::fromStdString(script_filename)
(and similarly for filename), then pass those QString results directly to QFile
and to QFile::copy; ensure you use the same variables (tmp_path,
script_filename, filename, output_dir, file_suffix, file_extension, debug_level)
and the QFile and QString::fromStdString calls to keep types consistent.
src/topp/IDRipper.cpp (1)

150-150: Remove the unused QDir local variable.

Line 150 constructs dir but never uses it, which adds noise and can mislead readers.

♻️ Proposed cleanup
-      QDir dir(QString::fromStdString(output_directory));
       FileHandler().storeIdentifications(out, rfc.prot_idents, rfc.pep_idents, {FileTypes::IDXML});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/IDRipper.cpp` at line 150, Remove the unused local variable by
deleting the line that constructs QDir
dir(QString::fromStdString(output_directory)); in IDRipper.cpp; if the only use
of QDir was this variable also remove the corresponding `#include` <QDir> to avoid
an unused include, then rebuild to verify no references remain.
src/openms/source/SYSTEM/JavaInfo.cpp (1)

51-51: Replace std::endl with \n in logging statements.

Lines 51, 91, and 97 use std::endl in OPENMS_LOG_ERROR chains, which forces unnecessary stream flushes. Replace with newline literals (\n or '\n') to match project logging guidance.

💡 Suggested patch
-            << "  Please free some resources or if you want to run the TOPP tool nevertheless set the TOPP tools 'force' flag in order to avoid this check." << std::endl;
+            << "  Please free some resources or if you want to run the TOPP tool nevertheless set the TOPP tools 'force' flag in order to avoid this check.\n";
...
-            << std::endl;
+            << '\n';
...
-            << std::endl;
+            << '\n';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/JavaInfo.cpp` at line 51, The logging statements use
std::endl which forces flushes; update the OPENMS_LOG_ERROR message chains in
JavaInfo.cpp (where OPENMS_LOG_ERROR is invoked, e.g., the messages that end
with "Please free some resources..." and the other two occurrences near the JVM
check) to end with '\n' (or "\n") instead of std::endl so they do not force
stream flushes; keep the rest of the message text intact and only replace the
trailing std::endl tokens in those OPENMS_LOG_ERROR invocations.
src/topp/OpenSwathFileSplitter.cpp (1)

99-99: Add direct #include <QFileInfo> for include-hygiene. While QFileInfo is used at line 99, the file relies on a transitive include from <QDir>. Most similar TOPP tools in the codebase (e.g., GenericWrapper.cpp, INIUpdater.cpp) include <QFileInfo> explicitly when using it.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/OpenSwathFileSplitter.cpp` at line 99, Add an explicit include for
QFileInfo to satisfy include-hygiene: add a direct `#include` <QFileInfo> at the
top of the translation unit so the usage of QFileInfo (used to construct
QFileInfo fi(QString::fromStdString(file_in)) in OpenSwathFileSplitter.cpp) no
longer depends on transitive inclusion from QDir; update includes alongside
other Qt headers to match the style used in GenericWrapper.cpp and
INIUpdater.cpp.
src/openms_gui/source/VISUAL/SpectraIDViewTab.cpp (2)

313-313: Rename qstrseq to snake_case.

Line 313 introduces a local that doesn't match the project's C++ naming convention. qstr_seq or sequence_qt would fit the surrounding code better.

As per coding guidelines, "variables use snake_case" in C++.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms_gui/source/VISUAL/SpectraIDViewTab.cpp` at line 313, Rename the
local variable qstrseq to follow C++ snake_case naming (e.g., qstr_seq or
sequence_qt) where it's declared in SpectraIDViewTab.cpp (the line creating
QString::fromStdString(aaseq.toString())); update all references to that
variable in the surrounding function/method so builds succeed and naming matches
project conventions.

321-341: Cache the converted strings inside this nested loop.

Line 321 and Lines 332-341 rebuild the same converted strings several times per evidence/modification. Hoisting them once per iteration will cut allocations here and make the JSON assembly easier to read.

♻️ Suggested cleanup
-              if (QString::fromStdString(id_accession) == current_accession)
+              const QString accession_qt = QString::fromStdString(id_accession);
+              if (accession_qt == current_accession)
               {
                 // contains key-value of modName and vector of indices
                 QJsonObject mod_data;

                 for (int i = 0; i < (int)aaseq.size(); ++i)
                 {
                   if (aaseq[i].isModified())
                   {
                     const String& mod_name = aaseq[i].getModificationName();
+                    const QString mod_name_qt = QString::fromStdString(mod_name);

-                    if (!mod_data.contains(QString::fromStdString(mod_name)))
+                    if (!mod_data.contains(mod_name_qt))
                     {
-                      mod_data[QString::fromStdString(mod_name)] = QJsonArray{i + pep_start}; // add pep_start to get the correct location in the whole sequence
+                      mod_data[mod_name_qt] = QJsonArray{i + pep_start}; // add pep_start to get the correct location in the whole sequence
                     }
                     else
                     {
-                      QJsonArray values = mod_data.value(QString::fromStdString(mod_name)).toArray();
+                      QJsonArray values = mod_data.value(mod_name_qt).toArray();
                       // add pep_start to get the correct location in the whole sequence
                       values.push_back(i + pep_start);
-                      mod_data[QString::fromStdString(mod_name)] = values;
+                      mod_data[mod_name_qt] = values;
                     }
                   }
                 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms_gui/source/VISUAL/SpectraIDViewTab.cpp` around lines 321 - 341,
Convert repeated std::string->QString calls to cached variables: compute QString
converted_current_accession = QString::fromStdString(id_accession) once before
comparing to current_accession; inside the loop over aaseq, when
aaseq[i].isModified() cache QString mod_name_q =
QString::fromStdString(mod_name) (where mod_name =
aaseq[i].getModificationName()) and reuse mod_name_q for contains(), indexing
and value() operations on mod_data instead of calling
QString::fromStdString(mod_name) multiple times; also reuse the QJsonArray
reference/value you obtain from mod_data to push_back(i + pep_start) and then
assign it back to mod_data[mod_name_q] to eliminate duplicate conversions and
allocations.
src/openms_gui/source/VISUAL/TOPPASScene.cpp (1)

1310-1314: Route this write failure through OpenMS logging instead of std::cerr.

This error path is touched in the refactor, but it still bypasses the project log sinks and forces a flush with std::endl.

🧹 Suggested cleanup
-      std::cerr << "Could not write to logfile '" << logfile.fileName().toStdString() << "'" << std::endl;
+      OPENMS_LOG_ERROR << "Could not write to logfile '" << logfile.fileName().toStdString() << "'\n";
As per coding guidelines, "Use OpenMS logging macros and `OpenMS::LogStream`; avoid `std::cout/err` directly; avoid `std::endl` for performance (use `\n`) in C++".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms_gui/source/VISUAL/TOPPASScene.cpp` around lines 1310 - 1314, The
current failure to open QFile logfile (variable logfile created from out_dir_)
writes to std::cerr and uses std::endl; change this to use OpenMS logging
instead: replace the std::cerr line in TOPPASScene:: (where QFile logfile is
opened) with an OpenMS logging macro or LogStream (e.g., OPENMS_LOG_ERROR or
OpenMS::LogStream/LOG_ERROR) that emits the same message including
logfile.fileName(), and end the message with '\n' instead of std::endl so it
goes through the OpenMS sinks and avoids forced flushes.
src/openms_gui/source/VISUAL/TOPPASToolVertex.cpp (1)

1206-1206: Consider using QDir::separator().unicode() or a platform-independent approach.

The expression std::string(1, QDir::separator().toLatin1()) could lose information if the separator is a non-Latin1 character (unlikely on any current platform, but technically possible). This is a minor concern since path separators are ASCII on all major platforms.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms_gui/source/VISUAL/TOPPASToolVertex.cpp` at line 1206, The current
construction std::string(1, QDir::separator().toLatin1()) can lose non-Latin1
characters; update the code in TOPPASToolVertex (file
VISUAL/TOPPASToolVertex.cpp) to build the separator string using a Unicode-safe
conversion of QDir::separator() (for example use
QString(QDir::separator()).toStdString() or construct from
QDir::separator().unicode() via a UTF-8 conversion) so the path separator is
handled in a platform-independent, lossless way.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/openms_gui/source/VISUAL/DIALOGS/PythonModuleRequirement.cpp`:
- Around line 40-41: The single-line if/else that calls
PythonInfo::isPackageInstalled(...) and pushes to valid_modules or
missing_modules must be expanded to use explicit braces per style; locate the
conditional that uses python_exe, s, valid_modules and missing_modules and wrap
both the if branch and the else branch in { ... } blocks so each push_back call
is enclosed in braces.

In `@src/openms_gui/source/VISUAL/MISC/ExternalProcessMBox.cpp`:
- Around line 34-43: Replace the unsafe full-event pumping lambda passed to
ep_.run in ExternalProcessMBox::run (the []() {
QCoreApplication::processEvents(); } passed into ep_.run) with a safer call that
excludes user-input events, e.g. use
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents) so the user
cannot close/delete the parent while ep_.run is active; apply the same change to
the second overload mentioned so both ep_.run calls use the
ExcludeUserInputEvents flag instead of the current full processEvents() call.

In `@src/openms_gui/source/VISUAL/TOPPASWidget.cpp`:
- Around line 95-96: Typo in the status message: change the shortcut hint from
"CRTL" to "CTRL" where the message is emitted (see the local variable filename
and the call emit sendStatusMessage(...)); update the string passed to
sendStatusMessage to read "CTRL" instead of "CRTL" so the hint is correct.

In `@src/openms_gui/source/VISUAL/VISUALIZER/ContactPersonVisualizer.cpp`:
- Around line 48-56: The ContactPersonVisualizer::store() method fails to
persist the first name because it never writes firstname_ back to the model;
update store() to call the appropriate setter on ptr_ (e.g.,
ptr_->setFirstName(...)) using firstname_->text().toStdString() so firstname_ is
saved alongside lastname_, institution_, email_, contact_info_, url_, and
address().

In `@src/tests/class_tests/openms/source/ToolDescriptionFile_test.cpp`:
- Around line 53-55: The test reuses the ToolDescriptionFileList variable tds
across loop iterations so a previous successful load can mask subsequent
failures; before calling f.load(files[i].toStdString(), tds) (or else re-declare
tds inside the loop) reset/clear tds so each file is verified independently,
then keep the TEST_EQUAL(!tds.empty(), true) assertion to validate that the
current file produced a non-empty tds.

In `@src/topp/ExecutePipeline.cpp`:
- Around line 145-150: The writability probe concatenates
"test_file_in_the_current_directory" directly onto out_dir_name (so out_dir_name
+ "test_file..." yields a malformed path); update the check around QDir qd /
File::writable to construct a proper child path (e.g., use QDir::filePath or
append a separator before the filename) when calling File::writable, ensuring
you test out_dir_name/test_file_in_the_current_directory rather than
out_dir_nametest_file_in_the_current_directory; adjust any related logic that
sets ts.setOutDir(out_dir_name) to still use the cleaned directory path.

In `@src/topp/GenericWrapper.cpp`:
- Around line 480-486: The code currently calls
builder.start(QString::fromStdString(call)) which uses the deprecated
single-string QProcess::start and can mis-split an executable path with spaces;
change this to parse program and args and call the overload
builder.start(program, arguments). Use
QProcess::splitCommand(QString::fromStdString(call)) or first build a
QStringList from command_args and takeFirst() to separate program and arguments,
then call builder.start(program, arguments) after setting the working directory
(references: builder, tde_.working_directory, call, command_args,
QProcess::splitCommand).

In `@src/topp/INIUpdater.cpp`:
- Around line 200-203: Temporary directories created in updateTOPPAS() via
tmp_dir (used to construct TOPPASScene ts) are never removed; add the temp
directory to the tracked cleanup list or remove it explicitly after use. Locate
the tmp_dir creation and the TOPPASScene ts constructor call and either push
tmp_dir onto the existing tmp_files_ (or a new tmp_dirs_/tmp_paths_ container)
so the final cleanup loop removes it, or call QDir(tmp_dir).removeRecursively()
(or equivalent safe recursive removal) once TOPPASScene no longer needs the
directory; apply the same change to the other occurrence around the TOPPASScene
instantiation at the second location (lines noted in review).
- Around line 212-216: The backup rename (QFile::rename(...)) result is ignored
and paramFile.store(infile, p) proceeds even on failure; change INIUpdater.cpp
so that after calling QFile::rename(QString::fromStdString(infile),
QString::fromStdString(new_name)) you check its boolean return and abort the
in-place update (return an error or throw) if it fails, preventing
paramFile.store from overwriting the original; apply the same guard where the
second move occurs (the other QFile::rename call referenced around line 322) and
ensure updateINI() follows the same pattern so no store happens when the backup
move fails.

---

Outside diff comments:
In `@src/openms_gui/source/VISUAL/APPLICATIONS/TOPPASBase.cpp`:
- Around line 548-563: The savePipelineAs() function currently sets the window
title and returns the chosen filename even when w->getScene()->store(...) fails;
change it so the function only updates the window title and returns the filename
when store() succeeds. Concretely, inside savePipelineAs() around the call to
w->getScene()->store(file_name.toStdString()), ensure the QMessageBox::warning
remains on failure and that you do NOT set w->setWindowTitle(...) or return the
non-empty file_name; instead only set the caption and return file_name when
store(...) returns true, and return an empty QString on failure.

---

Nitpick comments:
In `@src/openms_gui/source/VISUAL/Plot3DOpenGLCanvas.cpp`:
- Line 169: Duplicate background-color conversion in Plot3DOpenGLCanvas should
be centralized: add a private helper QColor
Plot3DOpenGLCanvas::backgroundColor_() const (declare it in the class header)
that returns
QColor(QString::fromStdString(canvas_3d_.param_.getValue("background_color").toString()));
then replace the two direct constructions (the ones creating QColor from
canvas_3d_.param_.getValue("background_color")) with calls to backgroundColor_()
so all conversions use the single helper.

In `@src/openms_gui/source/VISUAL/SpectraIDViewTab.cpp`:
- Line 313: Rename the local variable qstrseq to follow C++ snake_case naming
(e.g., qstr_seq or sequence_qt) where it's declared in SpectraIDViewTab.cpp (the
line creating QString::fromStdString(aaseq.toString())); update all references
to that variable in the surrounding function/method so builds succeed and naming
matches project conventions.
- Around line 321-341: Convert repeated std::string->QString calls to cached
variables: compute QString converted_current_accession =
QString::fromStdString(id_accession) once before comparing to current_accession;
inside the loop over aaseq, when aaseq[i].isModified() cache QString mod_name_q
= QString::fromStdString(mod_name) (where mod_name =
aaseq[i].getModificationName()) and reuse mod_name_q for contains(), indexing
and value() operations on mod_data instead of calling
QString::fromStdString(mod_name) multiple times; also reuse the QJsonArray
reference/value you obtain from mod_data to push_back(i + pep_start) and then
assign it back to mod_data[mod_name_q] to eliminate duplicate conversions and
allocations.

In `@src/openms_gui/source/VISUAL/TOPPASScene.cpp`:
- Around line 1310-1314: The current failure to open QFile logfile (variable
logfile created from out_dir_) writes to std::cerr and uses std::endl; change
this to use OpenMS logging instead: replace the std::cerr line in TOPPASScene::
(where QFile logfile is opened) with an OpenMS logging macro or LogStream (e.g.,
OPENMS_LOG_ERROR or OpenMS::LogStream/LOG_ERROR) that emits the same message
including logfile.fileName(), and end the message with '\n' instead of std::endl
so it goes through the OpenMS sinks and avoids forced flushes.

In `@src/openms_gui/source/VISUAL/TOPPASToolVertex.cpp`:
- Line 1206: The current construction std::string(1,
QDir::separator().toLatin1()) can lose non-Latin1 characters; update the code in
TOPPASToolVertex (file VISUAL/TOPPASToolVertex.cpp) to build the separator
string using a Unicode-safe conversion of QDir::separator() (for example use
QString(QDir::separator()).toStdString() or construct from
QDir::separator().unicode() via a UTF-8 conversion) so the path separator is
handled in a platform-independent, lossless way.

In `@src/openms_gui/source/VISUAL/VISUALIZER/GradientVisualizer.cpp`:
- Around line 142-143: Replace the direct std::cout/std::endl calls in
GradientVisualizer.cpp (the two lines printing "The sum does not add up to 100
!" and "Please check your values.") with the OpenMS logging API (e.g.
OPENMS_LOG_WARN / OPENMS_LOG_ERROR or OpenMS::LogStream) and use '\n' instead of
std::endl; ensure the messages preserve the same text and context and are routed
through the OpenMS logger rather than using cout.

In `@src/openms/source/SYSTEM/JavaInfo.cpp`:
- Line 51: The logging statements use std::endl which forces flushes; update the
OPENMS_LOG_ERROR message chains in JavaInfo.cpp (where OPENMS_LOG_ERROR is
invoked, e.g., the messages that end with "Please free some resources..." and
the other two occurrences near the JVM check) to end with '\n' (or "\n") instead
of std::endl so they do not force stream flushes; keep the rest of the message
text intact and only replace the trailing std::endl tokens in those
OPENMS_LOG_ERROR invocations.

In `@src/topp/IDRipper.cpp`:
- Line 150: Remove the unused local variable by deleting the line that
constructs QDir dir(QString::fromStdString(output_directory)); in IDRipper.cpp;
if the only use of QDir was this variable also remove the corresponding `#include`
<QDir> to avoid an unused include, then rebuild to verify no references remain.

In `@src/topp/MetaProSIP.cpp`:
- Around line 544-560: Several calls wrap QString::fromStdString(...) with an
extra QString(...) unnecessarily (e.g., in the QFile constructors and in
building paths before QFile::copy/remove) which is redundant; update the
expressions in the block handling status == 0 to remove the outer QString(...)
wrappers and construct paths using QString::fromStdString(tmp_path) + "/" +
QString::fromStdString(script_filename) (and similarly for filename), then pass
those QString results directly to QFile and to QFile::copy; ensure you use the
same variables (tmp_path, script_filename, filename, output_dir, file_suffix,
file_extension, debug_level) and the QFile and QString::fromStdString calls to
keep types consistent.

In `@src/topp/OpenSwathFileSplitter.cpp`:
- Line 99: Add an explicit include for QFileInfo to satisfy include-hygiene: add
a direct `#include` <QFileInfo> at the top of the translation unit so the usage of
QFileInfo (used to construct QFileInfo fi(QString::fromStdString(file_in)) in
OpenSwathFileSplitter.cpp) no longer depends on transitive inclusion from QDir;
update includes alongside other Qt headers to match the style used in
GenericWrapper.cpp and INIUpdater.cpp.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: da277e04-f3fd-4784-8ea9-46fcd9a3471f

📥 Commits

Reviewing files that changed from the base of the PR and between 3315b00 and d3d3bb9.

📒 Files selected for processing (108)
  • src/openms/source/SYSTEM/File.cpp
  • src/openms/source/SYSTEM/JavaInfo.cpp
  • src/openms/source/SYSTEM/PythonInfo.cpp
  • src/openms_gui/include/OpenMS/VISUAL/ANNOTATION/Annotation1DPeakItem.h
  • src/openms_gui/include/OpenMS/VISUAL/FileWatcher.h
  • src/openms_gui/source/VISUAL/APPLICATIONS/GUITOOLS/TOPPAS.cpp
  • src/openms_gui/source/VISUAL/APPLICATIONS/GUITOOLS/TOPPView.cpp
  • src/openms_gui/source/VISUAL/APPLICATIONS/INIFileEditorWindow.cpp
  • src/openms_gui/source/VISUAL/APPLICATIONS/MISC/QApplicationTOPP.cpp
  • src/openms_gui/source/VISUAL/APPLICATIONS/TOPPASBase.cpp
  • src/openms_gui/source/VISUAL/APPLICATIONS/TOPPViewBase.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/DataFilterDialog.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/FLASHDeconvTabWidget.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/LayerStatisticsDialog.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/Plot2DGoToDialog.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/PythonModuleRequirement.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/PythonSelector.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/SpectrumAlignmentDialog.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/SwathTabWidget.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/TOPPASIOMappingDialog.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/TOPPASToolConfigDialog.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/TOPPViewOpenDialog.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/TOPPViewPrefDialog.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/TheoreticalSpectrumGenerationDialog.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/ToolsDialog.cpp
  • src/openms_gui/source/VISUAL/EnhancedTabBarWidgetInterface.cpp
  • src/openms_gui/source/VISUAL/FileWatcher.cpp
  • src/openms_gui/source/VISUAL/FilterList.cpp
  • src/openms_gui/source/VISUAL/InputFile.cpp
  • src/openms_gui/source/VISUAL/InputFileList.cpp
  • src/openms_gui/source/VISUAL/LayerData1DPeak.cpp
  • src/openms_gui/source/VISUAL/LayerDataBase.cpp
  • src/openms_gui/source/VISUAL/LayerListView.cpp
  • src/openms_gui/source/VISUAL/ListEditor.cpp
  • src/openms_gui/source/VISUAL/LogWindow.cpp
  • src/openms_gui/source/VISUAL/MISC/ExternalProcessMBox.cpp
  • src/openms_gui/source/VISUAL/MISC/FilterableList.cpp
  • src/openms_gui/source/VISUAL/MISC/GUIHelpers.cpp
  • src/openms_gui/source/VISUAL/OutputDirectory.cpp
  • src/openms_gui/source/VISUAL/Painter1DBase.cpp
  • src/openms_gui/source/VISUAL/Painter2DBase.cpp
  • src/openms_gui/source/VISUAL/ParamEditor.cpp
  • src/openms_gui/source/VISUAL/Plot1DCanvas.cpp
  • src/openms_gui/source/VISUAL/Plot2DCanvas.cpp
  • src/openms_gui/source/VISUAL/Plot3DCanvas.cpp
  • src/openms_gui/source/VISUAL/Plot3DOpenGLCanvas.cpp
  • src/openms_gui/source/VISUAL/PlotCanvas.cpp
  • src/openms_gui/source/VISUAL/PlotWidget.cpp
  • src/openms_gui/source/VISUAL/RecentFilesMenu.cpp
  • src/openms_gui/source/VISUAL/SpectraIDViewTab.cpp
  • src/openms_gui/source/VISUAL/SpectraTreeTab.cpp
  • src/openms_gui/source/VISUAL/TOPPASEdge.cpp
  • src/openms_gui/source/VISUAL/TOPPASInputFileListVertex.cpp
  • src/openms_gui/source/VISUAL/TOPPASMergerVertex.cpp
  • src/openms_gui/source/VISUAL/TOPPASOutputFileListVertex.cpp
  • src/openms_gui/source/VISUAL/TOPPASOutputFolderVertex.cpp
  • src/openms_gui/source/VISUAL/TOPPASOutputVertex.cpp
  • src/openms_gui/source/VISUAL/TOPPASResources.cpp
  • src/openms_gui/source/VISUAL/TOPPASScene.cpp
  • src/openms_gui/source/VISUAL/TOPPASSplitterVertex.cpp
  • src/openms_gui/source/VISUAL/TOPPASToolVertex.cpp
  • src/openms_gui/source/VISUAL/TOPPASVertex.cpp
  • src/openms_gui/source/VISUAL/TOPPASWidget.cpp
  • src/openms_gui/source/VISUAL/TVDIATreeTabController.cpp
  • src/openms_gui/source/VISUAL/TVIdentificationViewController.cpp
  • src/openms_gui/source/VISUAL/TVToolDiscovery.cpp
  • src/openms_gui/source/VISUAL/TableView.cpp
  • src/openms_gui/source/VISUAL/TreeView.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/AcquisitionInfoVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/AcquisitionVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/ContactPersonVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/DataProcessingVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/DocumentIdentifierVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/ExperimentalSettingsVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/GradientVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/HPLCVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/InstrumentVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/MetaInfoVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/PeptideIdentificationVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/ProteinIdentificationVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/SampleVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/SoftwareVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/SourceFileVisualizer.cpp
  • src/openms_gui/source/VISUAL/VISUALIZER/SpectrumSettingsVisualizer.cpp
  • src/tests/class_tests/openms/source/DataValue_test.cpp
  • src/tests/class_tests/openms/source/MzMLSqliteHandler_test.cpp
  • src/tests/class_tests/openms/source/OPXLHelper_test.cpp
  • src/tests/class_tests/openms/source/PeptideIndexing_test.cpp
  • src/tests/class_tests/openms/source/PythonInfo_test.cpp
  • src/tests/class_tests/openms/source/StringListUtils_test.cpp
  • src/tests/class_tests/openms/source/StringUtils_test.cpp
  • src/tests/class_tests/openms/source/String_test.cpp
  • src/tests/class_tests/openms/source/ToolDescriptionFile_test.cpp
  • src/topp/AssayGeneratorMetaboSirius.cpp
  • src/topp/CometAdapter.cpp
  • src/topp/ExecutePipeline.cpp
  • src/topp/GenericWrapper.cpp
  • src/topp/IDRipper.cpp
  • src/topp/INIUpdater.cpp
  • src/topp/ImageCreator.cpp
  • src/topp/MaRaClusterAdapter.cpp
  • src/topp/MetaProSIP.cpp
  • src/topp/MzMLSplitter.cpp
  • src/topp/OpenSwathFileSplitter.cpp
  • src/topp/OpenSwathWorkflow.cpp
  • src/topp/QCEmbedder.cpp
  • src/topp/QCExtractor.cpp
  • src/topp/QCShrinker.cpp
💤 Files with no reviewable changes (3)
  • src/tests/class_tests/openms/source/StringListUtils_test.cpp
  • src/tests/class_tests/openms/source/String_test.cpp
  • src/tests/class_tests/openms/source/DataValue_test.cpp
✅ Files skipped from review due to trivial changes (18)
  • src/openms_gui/source/VISUAL/DIALOGS/SpectrumAlignmentDialog.cpp
  • src/openms_gui/include/OpenMS/VISUAL/FileWatcher.h
  • src/openms_gui/source/VISUAL/APPLICATIONS/GUITOOLS/TOPPAS.cpp
  • src/topp/MzMLSplitter.cpp
  • src/openms_gui/source/VISUAL/FilterList.cpp
  • src/openms_gui/source/VISUAL/TOPPASSplitterVertex.cpp
  • src/tests/class_tests/openms/source/OPXLHelper_test.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/TOPPViewPrefDialog.cpp
  • src/topp/OpenSwathWorkflow.cpp
  • src/openms_gui/source/VISUAL/Plot2DCanvas.cpp
  • src/openms_gui/source/VISUAL/FileWatcher.cpp
  • src/openms_gui/source/VISUAL/LayerDataBase.cpp
  • src/openms_gui/source/VISUAL/Plot1DCanvas.cpp
  • src/openms_gui/source/VISUAL/TOPPASInputFileListVertex.cpp
  • src/tests/class_tests/openms/source/PythonInfo_test.cpp
  • src/openms_gui/source/VISUAL/ParamEditor.cpp
  • src/openms/source/SYSTEM/PythonInfo.cpp
  • src/topp/QCEmbedder.cpp
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/topp/CometAdapter.cpp
  • src/topp/MaRaClusterAdapter.cpp
  • src/openms_gui/source/VISUAL/DIALOGS/SwathTabWidget.cpp

Comment thread src/topp/ExecutePipeline.cpp Resolved
Comment thread src/topp/GenericWrapper.cpp Resolved
Comment thread src/topp/INIUpdater.cpp Resolved
Comment thread src/topp/INIUpdater.cpp Resolved
Remove all Qt string interop from the core library (String, DataValue,
StringUtils, StringListUtils). This is a breaking API change:

- Remove String(const QString&) constructor and String::toQString()
- Remove DataValue(const QString&) constructor, operator=(const QString&),
  and DataValue::toQString()
- Remove StringUtils::toQString() and replace QString::number() in
  StringUtils::number() with std::snprintf
- Remove StringListUtils::fromQStringList() and its QStringList include
- Remove forward declarations of QString from String.h, DataValue.h,
  StringView.h
- Delete Qt5Port.h (toQSet helper) and remove from sources.cmake
- Replace remaining .toQString() call sites in core source files
  (QcMLFile, MzTabFile, INIUpdater, ProgressLogger, OpenSwathOSWParquetWriter)
- Remove all QtCore includes from core headers and source files

After this change, zero Qt references remain in src/openms/ (headers
and sources), completing the decoupling of the core library from Qt.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@timosachsenberg
timosachsenberg force-pushed the remove-qt/pr5a-string-api branch from 1d8da0c to 2bd6f33 Compare March 19, 2026 18:28
timosachsenberg and others added 17 commits March 19, 2026 20:15
Replace all String::toQString() member calls with the free function
toQString() from OpenMS/VISUAL/MISC/QtHelpers.h. This completes the
removal of Qt string API from the core String class while maintaining
Qt interop in GUI and TOPP code via a lightweight header-only helper.

- Add QtHelpers.h with inline toQString() free functions for String
  and std::string
- Migrate ~400 callsites across 70+ files (GUI, TOPP, tests)
- Remove DataValue::toQString() test section (redundant with toString)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
TOPP tools not in TOPP_executables_with_GUIlib don't have the GUI
include path, so they can't use QtHelpers.h. Use QString::fromStdString()
directly instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The String(const QString&) constructor was removed. All implicit
conversions from QString to OpenMS::String now go through
.toStdString() to use the String(const std::string&) constructor.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Add fromQStringList() helper to QtHelpers.h (replaces removed
  StringListUtils::fromQStringList)
- Fix String(file_list[0]) where file_list is QStringList
- Remove DataValue(const QString&) and operator=(const QString&) tests
  (constructors removed from core)
- Update OPXLHelper_test and StringListUtils_test to use new helpers

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Fix fa.annotation = peak_anno (QString) in Annotation1DPeakItem.h
- Fix String s = headers.join(';') in SpectraIDViewTab.cpp

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Fix remaining implicit QString-to-String conversions in:
- TOPPASBase.cpp (3 errors: text() calls on QTreeWidget items)
- TOPPViewBase.cpp (10 errors: appendNewHeader, addDataFile calls)
- DataFilterDialog.cpp (2 errors: assignment and cast)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add .toStdString() for input_file_name (QString) passed to File::path()
and File::basename() which expect String.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Plot2DGoToDialog: return text().toStdString()
- SwathTabWidget: getCurrentOutDir_() and getFilename() to String

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…figDialog

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
g++ flags ambiguity when String (which inherits std::string) is
concatenated with a raw std::string via operator+. Wrapping in
String() resolves the overload.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…Dialog

Add .toStdString() for Qt widget text() and currentText() returned
as String.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Replace Qt5Port.h includes with inline toQSet helper in 3 files
- Fix GUIHelpers.cpp: QString args to File/FileHandler functions
- Fix GUIHelpers.cpp: QString push_back into StringList

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…ions

Comprehensive fix across 14 Visualizer files (46 lines) where Qt
widget text() (returning QString) is passed to setters expecting
const String&.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Five remaining toPlainText() calls (setComment, setCustomizations)
that return QString but pass to String-expecting setters.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
timosachsenberg and others added 14 commits March 20, 2026 05:44
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Remove redundant toQString(const String&) overload; keep only
  toQString(const std::string&) since String inherits std::string
- Add explicit .toString() for DataValue args to toQString
- Fix ParamEditor str.mid() assignment to String

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Instead of removing all Qt string API usage from GUI code (which
required hundreds of .toStdString() additions), use #ifdef with
__has_include(<QString>) to provide String(const QString&) and
toQString() as inline methods when Qt headers are available.

This keeps the core library Qt-free (no Qt symbols in libOpenMS)
while preserving seamless QString interop for GUI code.

Reverts all unnecessary GUI/TOPP/test file changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The __has_include approach included <QString> in String.h which caused
macro conflicts with Arrow headers. Instead, keep the original pattern:
forward-declare QString in String.h and implement the methods in
String.cpp (which includes <QString> safely in its own .cpp file).

This means String.h is now identical to develop — only the .cpp
implementations and other core files change.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Move Qt5Port.h from core (removed) to openms_gui/VISUAL/MISC/
- Add fromQStringList() to Qt5Port.h (replaces StringListUtils version)
- Update 3 GUI files and 2 test files to use new include path
- Remove DataValue(const QString&), toQString(), operator=(const QString&)
  test sections (APIs removed from DataValue)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
DataValue::toQString() was removed from core. Use String conversion
instead in Painter2DBase (3 calls) and SpectraIDViewTab (1 call).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Tests don't link against OpenMS_GUI so they can't include Qt5Port.h.
Remove fromQStringList test section (tests removed API), and replace
QStringList usage in OPXLHelper_test with direct StringList init.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Check QFile::rename return value before overwriting original file
  in both updateTOPPAS() and updateINI() to prevent data loss
- Clean up temporary directory created for TOPPASScene after use

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@timosachsenberg
timosachsenberg merged commit 3ef1a3b into develop Mar 20, 2026
9 checks passed
@timosachsenberg
timosachsenberg deleted the remove-qt/pr5a-string-api branch March 20, 2026 10:50
github-actions Bot pushed a commit that referenced this pull request Mar 21, 2026
Add missing changelog entries for:
- BREAKING: Qt string API removal from String/DataValue (#8940)
- BREAKING: Qt6::Core removed from libOpenMS PUBLIC CMake deps (#8965)
- BREAKING: Transitive includes trimmed from KERNEL/METADATA headers (#8946)
- Fix: segfault in FeatureLinkerUnlabeledKD with charge_merging=Any (#8944)

Co-authored-by: Copilot <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Mar 21, 2026
Add missing changelog entries for:
- BREAKING: Qt string API removal from String/DataValue (#8940)
- BREAKING: Qt6::Core removed from libOpenMS PUBLIC CMake deps (#8965)
- BREAKING: Transitive includes trimmed from KERNEL/METADATA headers (#8946)
- Fix: segfault in FeatureLinkerUnlabeledKD with charge_merging=Any (#8944)

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
github-actions Bot pushed a commit that referenced this pull request Mar 23, 2026
… reference

The String::toQString() and related Qt string interop methods were removed
from the core library in refactor #8940. Update the Windows crash debugging
FAQ code example to use the modern QString::fromStdString() equivalent,
which is the correct approach in GUI (openms_gui) code.

Co-authored-by: Copilot <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Mar 23, 2026
… reference (#8972)

The String::toQString() and related Qt string interop methods were removed
from the core library in refactor #8940. Update the Windows crash debugging
FAQ code example to use the modern QString::fromStdString() equivalent,
which is the correct approach in GUI (openms_gui) code.

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
github-actions Bot pushed a commit that referenced this pull request Mar 24, 2026
After the Qt removal refactoring (#8937-#8940, #8965), Qt6::Core is no
longer a dependency of libOpenMS itself. Update AGENTS.md to reflect
that Qt6 is required only for TOPP tools and GUI (openms_gui) builds,
and is optional when building only the core library or pyOpenMS.

Co-authored-by: Copilot <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Mar 24, 2026
…8977)

After the Qt removal refactoring (#8937-#8940, #8965), Qt6::Core is no
longer a dependency of libOpenMS itself. Update AGENTS.md to reflect
that Qt6 is required only for TOPP tools and GUI (openms_gui) builds,
and is optional when building only the core library or pyOpenMS.

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
timosachsenberg added a commit that referenced this pull request Jul 10, 2026
…9450) (#9724)

PR #9450 removed the OpenMS::String class (and StringView) in favor of
std::string / std::string_view but never added a CHANGELOG entry. Record
it as a BREAKING change in the 3.6.0 General section next to the related
Qt string-interop removal (#8940), noting the StringUtils free-function
migration path and the follow-up shim-header removal (#9468).

Co-authored-by: Claude Fable 5 <[email protected]>
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