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

Need to scan assignment and equality testing for un-spaced operations #1

Closed
Argel-Tal opened this issue Feb 22, 2022 · 2 comments
Closed

Comments

@Argel-Tal
Copy link
Owner

  • a==b needs to come back as 2 un-spaced operators. Currently unchecked for
  • var=x needs to come back as 1 un-spaced operator. Currently unchecked for

Should be recommending a == b & var = x

TO DO:

  1. Replace
  countOperatorNoSpace <- length(setdiff(stringr::str_extract_all(codeRaw, "[\\+\\-\\*].")[[1]], 
                                         unlist(stringr::str_match_all(str_extract_all(codeRaw, "[\\+\\-\\*].")[[1]], ". "))))
  listOperatorNoSpace <- setdiff(stringr::str_extract_all(codeRaw, "[\\+\\-\\*].")[[1]], 
                                 unlist(stringr::str_match_all(stringr::str_extract_all(codeRaw, "[\\+\\-\\*].")[[1]], ". ")))
  
  countOperatorNoSpace1 <- length(setdiff(stringr::str_extract_all(codeRaw, ".[\\+\\-\\*]")[[1]], 
                                         unlist(stringr::str_match_all(str_extract_all(codeRaw, ".[\\+\\-\\*]")[[1]], " ."))))
  listOperatorNoSpace1 <- setdiff(stringr::str_extract_all(codeRaw, ".[\\+\\-\\*]")[[1]], 
                                 unlist(stringr::str_match_all(stringr::str_extract_all(codeRaw, ".[\\+\\-\\*]")[[1]], " .")))

with

  countOperatorNoSpace <- length(setdiff(stringr::str_extract_all(codeRaw, "[\\+\\-\\*\\=].")[[1]], 
                                         unlist(stringr::str_match_all(str_extract_all(codeRaw, "[\\+\\-\\*\\=].")[[1]], ". "))))
  listOperatorNoSpace <- setdiff(stringr::str_extract_all(codeRaw, "[\\+\\-\\*\\=].")[[1]], 
                                 unlist(stringr::str_match_all(stringr::str_extract_all(codeRaw, "[\\+\\-\\*\\=].")[[1]], ". ")))
  
  countOperatorNoSpace1 <- length(setdiff(stringr::str_extract_all(codeRaw, ".[\\+\\-\\*\\=]")[[1]], 
                                         unlist(stringr::str_match_all(str_extract_all(codeRaw, ".[\\+\\-\\*\\=]")[[1]], " ."))))
  listOperatorNoSpace1 <- setdiff(stringr::str_extract_all(codeRaw, ".[\\+\\-\\*\\=]")[[1]], 
                                 unlist(stringr::str_match_all(stringr::str_extract_all(codeRaw, ".[\\+\\-\\*\\=]")[[1]], " .")))
  1. Recompile and re-upload package
@Argel-Tal
Copy link
Owner Author

tested the to be swapped code, all works 😄

@Argel-Tal
Copy link
Owner Author

may want to exclude == from the count and list of un-spaced operators

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

No branches or pull requests

1 participant