Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 27, 2025

User description

Addresses review feedback on #59 about unreachable code in get_mod. The else block was dead code since diann_mod_accession is guaranteed non-None when reached (function exits earlier if modification not found).

Changes

  • Removed redundant elif diann_mod_accession is not None check
  • Removed unreachable else block with duplicate error handling
  • Added *.parquet to .gitignore to prevent test artifacts from being committed

Before

if "TMT" in diann_mod_name or ...:
    logging.error(...)
    exit(1)
elif diann_mod_accession is not None:  # Always true here
    site = ...
    return diann_mod_accession, site
else:  # Unreachable
    logging.error(...)
    exit(1)

After

if "TMT" in diann_mod_name or ...:
    logging.error(...)
    exit(1)

site = ...
return diann_mod_accession, site

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


PR Type

Bug fix


Description

  • Removed unreachable else block in get_mod function

  • Simplified control flow by eliminating redundant conditional checks

  • Code is guaranteed to reach site processing after initial validation


Diagram Walkthrough

flowchart LR
  A["Check unsupported modifications"] -->|Found| B["Log error and exit"]
  A -->|Not found| C["Extract and process sites"]
  C -->|No sites| D["Log error and exit"]
  C -->|Sites found| E["Normalize site notation"]
  E --> F["Return modification accession and site"]
Loading

File Walkthrough

Relevant files
Bug fix
dianncfg.py
Remove unreachable else block in get_mod                                 

quantmsutils/diann/dianncfg.py

  • Removed unreachable elif diann_mod_accession is not None condition
  • Removed dead else block with duplicate error handling
  • Simplified control flow by making site processing unconditional after
    validation
  • Preserved all functional logic while improving code clarity
+22/-28 

Copilot AI self-assigned this Nov 27, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

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


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

Copy link
Contributor Author

Copilot AI commented Nov 27, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.ebi.ac.uk
    • Triggering command: /usr/bin/python python -m pytest tests/ -v (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] WIP address feedback on PTM diann handling update Remove unreachable else block in get_mod function Nov 27, 2025
Copilot AI requested a review from ypriverol November 27, 2025 07:59
Copilot finished work on behalf of ypriverol November 27, 2025 07:59
@ypriverol ypriverol marked this pull request as ready for review November 27, 2025 08:03
@qodo-code-review
Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Process termination: The new code still uses exit(1) on errors without clear audit context (e.g., user/action
identifiers), which may limit comprehensive audit trails depending on surrounding logging.

Referred Code
    logging.error(
        "quantms DIA-NN workflow only supports LFQ now! Unsupported modifications: "
        + mod
    )
    exit(1)

sites = re.findall(pattern, " ".join(mod.split(" ")[1:]))
if not sites:
    logging.error(
        f"No site specification found in modification string: {mod}"
    )
    exit(1)
site = sites[0]

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Hard exits used: The function logs and calls exit(1) instead of raising exceptions or returning errors,
which may hinder graceful degradation and upstream handling.

Referred Code
    logging.error(
        "quantms DIA-NN workflow only supports LFQ now! Unsupported modifications: "
        + mod
    )
    exit(1)

sites = re.findall(pattern, " ".join(mod.split(" ")[1:]))
if not sites:
    logging.error(
        f"No site specification found in modification string: {mod}"
    )
    exit(1)
site = sites[0]

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link

PR Code Suggestions ✨

No code suggestions found for the PR.

@daichengxin daichengxin merged commit a9251f7 into dev Nov 27, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants