Skip to content

Robustness fixes + review report#27

Closed
jimianelli wants to merge 1 commit into
mainfrom
fix/robustness-review
Closed

Robustness fixes + review report#27
jimianelli wants to merge 1 commit into
mainfrom
fix/robustness-review

Conversation

@jimianelli
Copy link
Copy Markdown
Contributor

No description provided.

@jimianelli
Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

1 similar comment
@jimianelli
Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

@jimianelli
Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

@jimianelli jimianelli requested a review from Copilot May 22, 2026 10:25
@jimianelli
Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

1 similar comment
@jimianelli
Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Copy link
Copy Markdown

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

Adds a Quarto-based review report to the repository and applies a set of small robustness/maintainability fixes to the jjmR R package code (file existence checks, safer option handling, and removal of eval(parse())).

Changes:

  • Added reviews/ artifacts: the review source (.qmd), rendered HTML, and a patch file capturing the proposed fixes.
  • Hardened model reading/execution paths (readJJM(), .getOutFile(), .runJJM()) and improved error handling for missing outputs.
  • Simplified/safer internals: replaced eval(parse()) with do.call(), added column-count validation in get_index_fits(), and relaxed strict class checks with inherits().

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
reviews/jjmr_review.qmd Adds the review report source document describing issues and recommended fixes.
reviews/jjmr_review.html Adds rendered HTML version of the report.
reviews/jjmr_fixes.patch Adds a patch file containing the proposed code changes for reference.
R/readJJMConfig.R Fixes readJJMConfig.jjm.output() by adding the missing output argument.
R/readJJM.R Adds explicit output-file existence checks and warning for missing .rep files.
R/jjmr-internal.R Makes .getOutFile() tolerant of missing files and fixes .runJJM() adflags handling.
R/jjm.output-internal.R Makes .combineModels() class checks robust via inherits().
R/get_index_fits.R Adds validation to ensure expected index-fit column counts before renaming.
R/compareModels.R Replaces eval(parse()) command assembly with do.call().
Comments suppressed due to low confidence (1)

R/readJJMConfig.R:44

  • The new output argument in readJJMConfig.jjm.output() is later shadowed by output = .getJjmConfig(...) in the same function (and similarly in readJJMConfig.default). This makes the code harder to reason about and can lead to subtle bugs if output is referenced after the assignment. Rename the return variable (e.g., cfg/config) to avoid clobbering the output parameter.
readJJMConfig.jjm.output = function(model, path, input=NULL, output="results", ...) {
  
  ctl  = .getCtlFile(model=model, path=path) # path to ctl file
  dat  = .getDatFile(ctl=ctl, input=input) # path to dat file
  
  reps = .getRepFiles(model=model, output=output)

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

Comment thread reviews/jjmr_review.qmd

## Scope

Review of the R package source in `jjmr/`, focusing on likely bugs, robustness, and maintainability issues. Notes below reference file names and functions.
Comment thread reviews/jjmr_review.qmd
Comment on lines +12 to +20
## Executive summary

Primary risks are hard failures during routine use: (1) `readJJMConfig.jjm.output()` errors immediately due to an undefined `output`; (2) `.runJJM()` can build an empty command when `adflags = NULL`; and (3) `readJJM()` can fail before reading outputs because `normalizePath()` expects existing files. Secondary issues affect robustness and reproducibility (assumptions about fixed column counts and shared fleet metadata), plus maintainability items (use of `eval(parse())`, strict class checks). Fixes are small, localized, and low‑risk.

## Summary (high‑priority items)

- **Confirmed runtime error** in `readJJMConfig.jjm.output()` due to an undefined `output` variable.
- **Likely runtime error** in `.runJJM()` when `adflags = NULL` (default): the current check uses `exists("adflags")`, which is always `TRUE` and can collapse the command to `character(0)`.
- **Potential failure** in `readJJM()`/`.getOutFile()` when output files are missing because `normalizePath()` defaults to `mustWork = TRUE`.
Comment thread reviews/jjmr_review.html
Comment on lines +61 to +72
<script src="jjmr_review_files/libs/clipboard/clipboard.min.js"></script>
<script src="jjmr_review_files/libs/quarto-html/quarto.js" type="module"></script>
<script src="jjmr_review_files/libs/quarto-html/tabsets/tabsets.js" type="module"></script>
<script src="jjmr_review_files/libs/quarto-html/axe/axe-check.js" type="module"></script>
<script src="jjmr_review_files/libs/quarto-html/popper.min.js"></script>
<script src="jjmr_review_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="jjmr_review_files/libs/quarto-html/anchor.min.js"></script>
<link href="jjmr_review_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="jjmr_review_files/libs/quarto-html/quarto-syntax-highlighting-ed96de9b727972fe78a7b5d16c58bf87.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="jjmr_review_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="jjmr_review_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="jjmr_review_files/libs/bootstrap/bootstrap-d6a003b94517c951b2d65075d42fb01b.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light">
Comment thread reviews/jjmr_review.qmd
Comment on lines +1 to +6
---
title: "jjmR Code Review"
format: html
execute:
eval: false
---
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.

2 participants