Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function accepting a single arbitrary string triggers an issue #65

Closed
helske opened this issue Nov 23, 2021 · 2 comments
Closed

Function accepting a single arbitrary string triggers an issue #65

helske opened this issue Nov 23, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@helske
Copy link
Contributor

helske commented Nov 23, 2021

I have a few functions in bssm where one argument can be used to define arbitrary names for a vector. This seems to throw a note in autotest:

autotest_package(package = "bssm", functions = "ssm_mng", test = TRUE)

-- autotesting bssm --

v [1 / 1]: ssm_mng
# A tibble: 1 x 9
  type       test_name          fn_name parameter   parameter_type   operation                            content           test  yaml_hash      
  <chr>      <chr>              <chr>   <chr>       <chr>            <chr>                                <chr>             <lgl> <chr>          
1 diagnostic random_char_string ssm_mng state_names single character random character string as parameter does not match a~ TRUE  b9e6da23bdae30~

I'm not sure what would be to correct solution here?

@mpadge mpadge added the bug Something isn't working label Nov 23, 2021
@mpadge
Copy link
Member

mpadge commented Nov 24, 2021

I'm a bit unsure about this one too. It happens because current code just checks for match.arg, and issues a diagnostic if that's not used. That's obviously inadequate, and maybe the best approach might be a more sophisticated grep of doc entries, like for #66? We'd just need to establish a condition under which match.arg tests would not be run, maybe something like whenever param descriptions include the terms "name" or "label"? What do you think? An alternative would be to try to diagnose when match.arg should be checked, perhaps via a grep for things like "class" or "type", but that seems more dangerous and restrictive.

Proposal

chk_match_arg <- !grepl("name|label|text|string", rd_text,, ignore.case = TRUE)

@helske
Copy link
Contributor Author

helske commented Nov 24, 2021

Yes, this is tricky. I think the word "arbitrary" could be checked as that would be a pretty clear indication that everything should be accepted. I can also envision cases where the argument is used for subsetting vector, data frame etc (the argument should be a column name present in some other input data). In these cases, we should see an error if we modify the argument value randomly, but the function could use other mechanisms than match.arg for checking the validity of the input.

@mpadge mpadge closed this as completed in 8543475 Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants