Skip to content

getMadratGraph() returns false negatives on valid code #92

@0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q

Description

This regular expression

pattern <- "(readSource|calcOutput)\\( *([^=\"',]*=|) *(\"|')?([^\"',]*)[\"']?"

fails to see that calcOutput(GDP) is valid R code (as long as GDP is defined, which it does not check).

> stringi::stri_match_all_regex("calcOutput(GDP)", "(readSource|calcOutput)\\( *([^=\"',]*=|) *(\"|')?([^\"',]*)[\"']?")
[[1]]
     [,1]              [,2]         [,3] [,4] [,5]  
[1,] "calcOutput(GDP)" "calcOutput" ""   NA   "GDP)"

This leads to false negative warnings for https://github.com/pik-piam/mrcommons/blob/0041fd9d6e6a7e564f7ea10804e31523dec8d792/R/calcGDPppp.R#L20

  warning("calcGDPppp() is deprecated. Returning default 'calcOutput(GDP)' output instead. Please use mrdrivers::calcGDP() directly.")

which is not code but a string too boot.

~ WARNING: Following functions contain read or calc statements which could not be identified: 
   
~ calcGDPppp
  Please adress the type explicitly in the call to allow
~  for proper detection, e.g. readSource("MySource")

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions