fix: resolve all lintr violations in R/ and vignettes/#43
Conversation
…and vignettes/ Fixes 1752 linting violations: styler scope=spaces for infix_spaces, manual wrapping for line_length (120 char limit) per gDRstyle::checkPackage requirements.
There was a problem hiding this comment.
Code Review
This pull request performs a comprehensive reformatting of the R source files to improve code style and consistency, primarily by adding spaces around operators and keywords. The review identified several critical copy-paste errors in the trackSize method implementations for various track classes (BedpeInteractionsTrack, GWASTrack, GWASUrlTrack, GenomicAlignmentTrack, and QuantitativeTrack), where the code incorrectly attempts to access a non-existent vcf.obj slot. Additionally, a logic error caused by operator precedence was found in R/igvR.R regarding the validation of metadata columns.
|
|
||
| function(obj) { | ||
| if(!is.null(obj@vcf.obj)) | ||
| if (!is.null(obj@vcf.obj)) |
There was a problem hiding this comment.
The trackSize method for BedpeInteractionsTrack incorrectly attempts to access a vcf.obj slot, which does not exist in this class (it inherits from DataFrameAnnotationTrack). This appears to be a copy-paste error from VariantTrack. It should instead return the number of rows in the coreObject data frame.
return(nrow(obj@coreObject))|
|
||
| function(obj) { | ||
| if(!is.null(obj@vcf.obj)) | ||
| if (!is.null(obj@vcf.obj)) |
There was a problem hiding this comment.
|
|
||
| function(obj) { | ||
| if(!is.null(obj@vcf.obj)) | ||
| if (!is.null(obj@vcf.obj)) |
|
|
||
| function(obj) { | ||
| if(!is.null(obj@vcf.obj)) | ||
| if (!is.null(obj@vcf.obj)) |
| function(obj){ | ||
| if(!is.null(obj@vcf.obj)) | ||
| function(obj) { | ||
| if (!is.null(obj@vcf.obj)) |
There was a problem hiding this comment.
| gr <- track@coreObject | ||
| # identify score column. we want just chrom, start, end, score | ||
| if(!ncol(mcols(gr)) == 1) stop("must have exactly one numeric metadata column") | ||
| if (!ncol(mcols(gr)) == 1) stop("must have exactly one numeric metadata column") |
There was a problem hiding this comment.
The logical negation !ncol(mcols(gr)) == 1 is incorrect due to operator precedence in R. The ! operator is evaluated before ==. This means !ncol(...) will evaluate to FALSE for any non-zero number of columns, and FALSE == 1 will always be FALSE. This should be changed to ncol(mcols(gr)) != 1 to correctly check that there is exactly one metadata column.
if (ncol(mcols(gr)) != 1) stop("must have exactly one numeric metadata column")
Summary
R/source files andvignettes/stylerwithscope="spaces"to all R/ filesUCSCBedGraphQuantitativeTrack.Rnow usesis()(from fix: resolve BiocCheck NOTEs and add working local CI via Podman #42) with proper spacing (from this branch)Test plan
gDRstyle::checkPackagewithskip_lint = FALSEreports 0 linting violations