Skip to content

resolve static analysis warnings#12

Merged
ypriverol merged 18 commits intobigbio:devfrom
Shen-YuFei:dev
Mar 17, 2026
Merged

resolve static analysis warnings#12
ypriverol merged 18 commits intobigbio:devfrom
Shen-YuFei:dev

Conversation

@Shen-YuFei
Copy link
Contributor

Fix all static analysis warnings detected by flake8, bandit, pylint, and opengrep:

  • F401/F541/F841/F821 — Remove unused imports, f-strings without placeholders, unused variables; add missing List import
  • B101 — Replace assert with if not: raise AssertionError
  • B310 — Replace urlretrieve/urlopen with build_opener().open() + URL scheme validation
  • E1120 — Add default values to Click CLI function parameters
  • Command Injection — Replace subprocess.run with runpy.run_path()
  • SQL Injection — Use parameterized read_parquet(?); replace + concatenation with str.join
  • Bare except / Try-Except-Pass — Specify exception types + add logging.warning()

Copilot AI review requested due to automatic review settings March 17, 2026 10:55
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0ef2b012-2702-46c6-aea8-7d6c37b596cb

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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

❤️ Share

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

Tip

You can customize the tone of the review comments and chat replies.

Configure the tone_instructions setting to customize the tone of the review comments and chat replies. For example, you can set the tone to Act like a strict teacher, Act like a pirate and more.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses static-analysis findings across the codebase (tests, library modules, and benchmark scripts) to satisfy tools like flake8, pylint, bandit, and opengrep, with a focus on removing unused code, tightening security around downloads/SQL, and silencing flagged patterns.

Changes:

  • Removed unused imports/variables and adjusted function signatures/defaults to satisfy static analyzers.
  • Replaced flagged patterns (e.g., urlretrieve downloads, string-built SQL) with safer alternatives (scheme validation, parameterized DuckDB read_parquet(?)).
  • Updated benchmark/test scripts to avoid linter/security flags (including switching a benchmark runner from subprocess to runpy).

Reviewed changes

Copilot reviewed 53 out of 53 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/test_tmm_normalization.py Avoid unused variable by discarding fit_transform result.
tests/test_quantification_accuracy.py Replace urlretrieve with opener-based download + scheme validation; replace some f-strings/asserts.
tests/test_peptide_normalize.py Avoid unused variable by discarding return value.
tests/test_hierarchical_normalization.py Avoid unused variable by discarding fit_transform result.
tests/test_file_utils.py Replace assert with explicit AssertionError raising (Bandit B101).
tests/test_batch_correction_integration.py Remove unused imports.
mokume/reports/workflow_comparison.py Remove unused imports.
mokume/reports/interactive.py Remove unused plotly Python import (HTML uses Plotly CDN).
mokume/reports/init.py Use importlib.util.find_spec for optional dependency detection.
mokume/quantification/ratio.py Replace string-interpolated parquet scan with parameterized read_parquet(?) approach.
mokume/quantification/maxlfq.py Replace optional dependency import check with find_spec.
mokume/quantification/ibaq.py Remove unused import.
mokume/quantification/directlfq.py Replace optional dependency import check with find_spec.
mokume/preprocessing/filters/run_qc.py Remove unused imports / typing cleanup.
mokume/preprocessing/filters/protein.py Remove unused typing imports.
mokume/preprocessing/filters/pipeline.py Remove unused typing imports.
mokume/preprocessing/filters/peptide.py Remove unused typing imports.
mokume/preprocessing/filters/base.py Remove unused typing imports.
mokume/postprocessing/batch_correction.py Replace optional dependency import check with find_spec; remove unused imports.
mokume/plotting/init.py Use find_spec to detect optional plotting dependencies.
mokume/pipeline/stages.py Remove unused import.
mokume/pipeline/features_to_proteins.py Remove unused import.
mokume/normalization/tmm.py Remove unused typing import.
mokume/normalization/peptide.py Remove unused imports/constants; add explicit __all__ re-exports.
mokume/mokume_cli.py Add defaults to Click-invoked command function parameters.
mokume/commands/visualize.py Add defaults to Click-invoked command function parameters.
mokume/analysis/differential_expression.py Remove unused imports.
environment.yaml Adjust NumPy pin; add plotly/statsmodels to conda env.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/run_benchmark.py Replace subprocess.run with runpy.run_path; index-based step execution.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/12_optimal_pipeline.py Remove unused import.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/11_preprocessing_filters.py Remove unused vars/clean up prints.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/10_imputation_benchmark.py Remove unused imports/vars; small cleanup.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/09_quant_norm_interaction.py Remove unused imports/vars; small cleanup.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/08_normalization_grid.py Remove unused vars; small cleanup.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/07_tmm_normalization_benchmark.py Remove unused import.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/05_cross_technology_correlation.py Remove unused imports.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/04_stability_metrics.py Remove unused imports.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/03_fold_change_accuracy.py Remove unused imports/vars; small cleanup.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/02_variance_decomposition.py Replace bare except with logged warning; import logging.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/01_grid_search_methods.py Replace f-string without placeholders.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/00_generate_ibaq.py Replace urlretrieve with opener-based download + scheme validation.
benchmarks/quant-pxd007683-tmt-vs-lfq/scripts/00_download_data.py Replace urlretrieve/urlopen with opener-based download + scheme validation + progress loop.
benchmarks/quant-hela-method-comparison/scripts/run_benchmark.py Remove unused import.
benchmarks/quant-hela-method-comparison/scripts/config.py Remove unused imports/typing.
benchmarks/quant-hela-method-comparison/scripts/06_method_correlation_plots.py Remove unused imports/vars; minor cleanup.
benchmarks/quant-hela-method-comparison/scripts/05_generate_plots.py Remove unused imports/constants.
benchmarks/quant-hela-method-comparison/scripts/04_compute_metrics.py Minor print cleanup / typing cleanup.
benchmarks/quant-hela-method-comparison/scripts/03_run_quantification.py Remove unused imports/constants; minor print cleanup.
benchmarks/quant-hela-method-comparison/scripts/02_prepare_peptides.py Remove unused imports/vars.
benchmarks/quant-hela-method-comparison/scripts/01_download_data.py Replace urlretrieve/urlopen with opener-based download + scheme validation; tighten exception handling.
benchmarks/batch-quartet-multilab/scripts/run_benchmark.py Replace bare except with logged warning; remove unused imports/vars.
benchmarks/batch-quartet-multilab/scripts/plot_results.py Remove unused import.
benchmarks/batch-quartet-multilab/scripts/comprehensive_analysis.py Remove unused imports/vars; minor cleanup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +71 to +75
if urllib.parse.urlparse(PRIDE_DATASET_URL).scheme not in ("http", "https"):
raise ValueError(f"URL scheme not allowed: {PRIDE_DATASET_URL}")
_opener = urllib.request.build_opener()
with _opener.open(PRIDE_DATASET_URL) as response, open(zip_path, "wb") as out_file:
shutil.copyfileobj(response, out_file)
Comment on lines +60 to 62
validated = _validate_step(step_index)
if validated is None:
return False
Comment on lines 49 to 53
def _is_directlfq_available() -> bool:
"""Check if DirectLFQ package is installed."""
try:
import directlfq
return True
except ImportError:
return False
import importlib.util
return importlib.util.find_spec("directlfq") is not None

Comment on lines +41 to +47
help="Write log to this file.",
)
def cli(log_level: str, log_file: Path):
def cli(log_level: str = "debug", log_file: Path = None):
dependencies:
- python>=3.9
- scikit-learn
- pyopenms
Comment on lines 88 to 91
if urllib.parse.urlparse(base_url).scheme not in ("http", "https"):
raise ValueError(f"URL scheme not allowed: {base_url}")
response = _opener.open(base_url, timeout=30)
content = response.read().decode('utf-8')
@ypriverol ypriverol self-requested a review March 17, 2026 11:24
@ypriverol ypriverol merged commit f99d157 into bigbio:dev Mar 17, 2026
4 checks passed
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.

3 participants