Skip to content

Commit

Permalink
clean tweaks -> rmvd empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnCoene committed Jul 11, 2017
1 parent d061462 commit fa4201d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/clean.R
Expand Up @@ -6,6 +6,7 @@
#'
#' @details Example of comment removed
#' \code{UNCLASSIFIED U.S. Department of State Case No. F-2014-20439 Doc No. C05765911 Date: 08/31/2015}
#' look at the source code for more details \code{rm_comments}
#'
#' @examples
#' \dontrun{
Expand All @@ -19,8 +20,9 @@
rm_comments <- function(emails){
if(missing(emails)) stop("must pass emails")
lapply(emails, function(x){
x <- gsub("UNCLASSIFIED U.S. Department of State Case \\w+?[[:punct:]]?[[:space:]]", "", x)
x <- gsub("F-[0-9]+-[0-9]+?\\sDoc\\sNo.?\\s[A-Z][0-9]{8}?\\sDate[[:punct:]]\\s[0-9]{2}[[:punct:]][0-9]{2}[[:punct:]][0-9]{4}", "", x)
x <- x[!grepl("UNCLASSIFIED U.S. Department of State Case \\w+?[[:punct:]]?[[:space:]]", x)]
x <- x[!grepl("F-[0-9]+-[0-9]+?\\sDoc\\sNo.?\\s[A-Z][0-9]{8}?\\sDate[[:punct:]]\\s[0-9]{2}[[:punct:]][0-9]{2}[[:punct:]][0-9]{4}", x)]
x <- x[!grepl("RELEASE IN", x)]
return(x)
})
}
1 change: 1 addition & 0 deletions man/rm_comments.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit fa4201d

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R/clean.R:8:1: style: Lines should not be more than 80 characters.

​#' \code{UNCLASSIFIED U.S. Department of State Case No. F-2014-20439 Doc No. C05765911 Date: 08/31/2015}
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/clean.R:21:5: style: Place a space before left parenthesis, except in a function call.

​  if(missing(emails)) stop("must pass emails")
    ^

R/clean.R:23:1: style: Lines should not be more than 80 characters.

​    x <- x[!grepl("UNCLASSIFIED U.S. Department of State Case \\w+?[[:punct:]]?[[:space:]]", x)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/clean.R:24:1: style: Lines should not be more than 80 characters.

​    x <- x[!grepl("F-[0-9]+-[0-9]+?\\sDoc\\sNo.?\\s[A-Z][0-9]{8}?\\sDate[[:punct:]]\\s[0-9]{2}[[:punct:]][0-9]{2}[[:punct:]][0-9]{4}", x)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/edge.R:6:1: style: Lines should not be more than 80 characters.

​#' @param emails Data frame of emails as returned by \code{\link{search_emails}},
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/edge.R:26:36: style: Commas should always have a space after.

​  emails <- emails[emails$to != "",] # filter
                                   ^

R/edge.R:27:38: style: Commas should always have a space after.

​  emails <- emails[emails$from != "",]
                                     ^

R/edge.R:30:44: warning: no visible binding for global variable β€˜to’, Did you mean 'ts'?

​  clean <- emails[with(emails, !grepl(";", to) & !grepl(";", from)),] # split
                                           ^~

R/edge.R:30:62: warning: no visible binding for global variable β€˜from’, Did you mean 'proj'?

​  clean <- emails[with(emails, !grepl(";", to) & !grepl(";", from)),] # split
                                                             ^~~~

R/edge.R:30:69: style: Commas should always have a space after.

​  clean <- emails[with(emails, !grepl(";", to) & !grepl(";", from)),] # split
                                                                    ^

R/edge.R:31:41: warning: no visible binding for global variable β€˜to’, Did you mean 'ts'?

​  raw <- emails[with(emails, grepl(";", to) | grepl(";", from)),]
                                        ^~

R/edge.R:31:58: warning: no visible binding for global variable β€˜from’, Did you mean 'proj'?

​  raw <- emails[with(emails, grepl(";", to) | grepl(";", from)),]
                                                         ^~~~

R/edge.R:31:65: style: Commas should always have a space after.

​  raw <- emails[with(emails, grepl(";", to) | grepl(";", from)),]
                                                                ^

R/edge.R:32:11: warning: no visible global function definition for β€˜raw2clean’

​  tail <- raw2clean(raw) # process raw
          ^~~~~~~~~

R/edge.R:36:5: style: Place a space before left parenthesis, except in a function call.

​  if(!is.null(args)){ # if meta-data
    ^

R/edge.R:36:21: style: Opening curly braces should never go on their own line and should always be followed by a new line.

​  if(!is.null(args)){ # if meta-data
                    ^

R/edge.R:47:53: style: Commas should always have a space after.

​  src_tgt <- src_tgt[order(-src_tgt[ncol(src_tgt)]),] # arrange by weight
                                                    ^

R/emails.R:18:1: style: Lines should not be more than 80 characters.

​#' @source \url{http://graphics.wsj.com/hillary-clinton-email-documents/api/search.php?subject=&to=&from=&start=&end=&sort=docDate&order=desc&docid=&limit=27159&offset=0}
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/extractor.R:25:20: style: Only use double-quotes.

​  os <- Sys.info()['sysname'] # get os
                   ^~~~~~~~~

R/extractor.R:26:3: warning: no visible global function definition for β€˜checkOS’

​  checkOS(os, dest)
  ^~~~~~~

R/extractor.R:27:10: warning: no visible global function definition for β€˜OStoURI’

​  lst <- OStoURI(os) # check os
         ^~~~~~~

R/extractor.R:30:10: warning: no visible global function definition for β€˜decompress_fun’

​  dec <- decompress_fun(temp_zip) # get decompress function
         ^~~~~~~~~~~~~~

R/extractor.R:32:31: style: Put spaces around all infix operators.

​  unlink("temp_zip", recursive=TRUE) # delete temp zip once unzipped
                             ~^~

R/extractor.R:33:13: warning: no visible global function definition for β€˜OS2folder’

​  folder <- OS2folder(os)
            ^~~~~~~~~

R/extractor.R:41:1: style: Trailing blank lines are superfluous.

​
^

R/get_emails.R:59:1: style: Lines should not be more than 80 characters.

​#' @seealso \code{\link{get_xpdf}}, \code{\link{download_emails}}, \code{\link{extract_emails}}
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/get_emails.R:64:33: style: Variable or function name should be snake_case.

​get_emails <- function(release, save.dir = getwd(), extractor, ...){
                                ^~~~~~~~

R/get_emails.R:78:3: warning: no visible global function definition for β€˜lin_warn’

​  lin_warn()
  ^~~~~~~~

R/get_emails.R:79:10: warning: no visible global function definition for β€˜checkRelease’

​  uri <- checkRelease(release) # check release input and return URL
         ^~~~~~~~~~~~

R/get_emails.R:91:28: style: Commas should always have a space after.

​    pdf <- paste0(temp_dir,"\\", files[i])
                           ^

R/get_emails.R:92:28: style: Commas should always have a space after.

​    txt <- paste0(save.dir,"/", dest[i])
                           ^

R/get_emails.R:93:1: style: Lines should not be more than 80 characters.

​    system(paste(extractor, "-enc UTF-8 -nopgbrk", ..., pdf, txt, sep = " "), wait = TRUE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/get_emails.R:94:28: style: Put spaces around all infix operators.

​    setTxtProgressBar(pb, i/length(files))
                          ~^~

R/get_emails.R:123:1: style: Lines should not be more than 80 characters.

​#' extarct_contents(emails = "HRC_Email_296", dest = "./emails_txt", extractor = ext)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/get_emails.R:131:37: style: Variable or function name should be snake_case.

​extract_emails <- function(release, save.dir = getwd(), extractor, ...){
                                    ^~~~~~~~

R/get_emails.R:132:1: style: Lines should not be more than 80 characters.

​  if(missing(release) || missing(extractor)) stop("must pass release and extractor.")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/get_emails.R:132:5: style: Place a space before left parenthesis, except in a function call.

​  if(missing(release) || missing(extractor)) stop("must pass release and extractor.")
    ^

R/get_emails.R:140:1: style: Lines should not be more than 80 characters.

​    system(paste(extractor, "-enc UTF-8 -nopgbrk", ..., pdf, txt, sep = " "), wait = TRUE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/get_emails.R:141:28: style: Put spaces around all infix operators.

​    setTxtProgressBar(pb, i/length(files))
                          ~^~

R/get_emails.R:179:38: style: Variable or function name should be snake_case.

​download_emails <- function(release, save.dir = getwd()){
                                     ^~~~~~~~

R/get_emails.R:180:5: style: Place a space before left parenthesis, except in a function call.

​  if(missing(release)) stop("must pass release.")
    ^

R/get_emails.R:181:10: warning: no visible global function definition for β€˜checkRelease’

​  uri <- checkRelease(release) # check release input and return URL
         ^~~~~~~~~~~~

R/get_emails.R:182:1: style: Lines should not be more than 80 characters.

​  download.file(uri, destfile = paste0(save.dir, "/", release, ".zip")) # download
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/helpers.R:37:1: style: Lines should not be more than 80 characters.

​    scan(paste0(dir, "/", files[[x]]), what="", sep="\n", blank.lines.skip = TRUE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/helpers.R:37:44: style: Put spaces around all infix operators.

​    scan(paste0(dir, "/", files[[x]]), what="", sep="\n", blank.lines.skip = TRUE)
                                          ~^~

R/helpers.R:37:52: style: Put spaces around all infix operators.

​    scan(paste0(dir, "/", files[[x]]), what="", sep="\n", blank.lines.skip = TRUE)
                                                  ~^~

R/helpers.R:48:1: style: Lines should not be more than 80 characters.

​#' @param emails list of email contents, as returned by \code{\link{load_emails}}
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/helpers.R:82:1: style: Lines should not be more than 80 characters.

​  d <- stringr::str_extract_all(string = emails, pattern='\\w+\\s\\d+(st)?(nd)?(rd)?(th)?,\\s+\\d+')
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/helpers.R:82:57: style: Put spaces around all infix operators.

​  d <- stringr::str_extract_all(string = emails, pattern='\\w+\\s\\d+(st)?(nd)?(rd)?(th)?,\\s+\\d+')
                                                       ~^~

R/helpers.R:82:58: style: Only use double-quotes.

​  d <- stringr::str_extract_all(string = emails, pattern='\\w+\\s\\d+(st)?(nd)?(rd)?(th)?,\\s+\\d+')
                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/search.R:38:26: style: Opening curly braces should never go on their own line and should always be followed by a new line.

​  if (internal == FALSE) { # encode subject if fetching from WSJ
                         ^

R/search.R:42:1: style: Lines should not be more than 80 characters.

​    uri <- paste0("http://graphics.wsj.com/hillary-clinton-email-documents/api/",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/search.R:59:63: style: Commas should always have a space after.

​      emails <- emails[grep(toupper(subject), emails$subject),]
                                                              ^

R/search.R:62:40: style: Commas should always have a space after.

​      emails <- emails[emails$to == to,]
                                       ^

R/search.R:65:44: style: Commas should always have a space after.

​      emails <- emails[emails$from == from,]
                                           ^

R/search.R:68:57: style: Commas should always have a space after.

​      emails <- emails[emails$docDate <= as.Date(start),]
                                                        ^

R/search.R:71:55: style: Commas should always have a space after.

​      emails <- emails[emails$docDate >= as.Date(end),]
                                                      ^

R/utils.R:7:1: style: Variable or function name should be snake_case.

​checkRelease <- function(x){
^~~~~~~~~~~~

R/utils.R:10:16: warning: no visible binding for global variable β€˜db’, Did you mean 'df'?

​    release <- db[db$name == x, "uri"]
               ^~

R/utils.R:10:16: warning: no visible binding for global variable β€˜db’, Did you mean 'df'?

​    release <- db[db$name == x, "uri"]
               ^~

R/utils.R:12:12: style: Place a space before left parenthesis, except in a function call.

​  } else if(!x %in% db$name && length(x) == 1) {
           ^

R/utils.R:13:19: warning: no visible binding for global variable β€˜db’, Did you mean 'df'?

​    msg <- paste0(db$name, collapse = ", ")
                  ^~

R/utils.R:20:1: style: Variable or function name should be snake_case.

​OStoURI <- function(x){
^~~~~~~

R/utils.R:21:5: style: Place a space before left parenthesis, except in a function call.

​  if(x == "Windows"){
    ^

R/utils.R:27:12: style: Place a space before left parenthesis, except in a function call.

​  } else if(x == "Darwin") {
           ^

R/utils.R:39:5: style: Place a space before left parenthesis, except in a function call.

​  if(length(temp_zip[grep("tar.gz", temp_zip)])){
    ^

R/utils.R:41:12: style: Place a space before left parenthesis, except in a function call.

​  } else if(length(temp_zip[grep("zip", temp_zip)])){
           ^

R/utils.R:46:1: style: Variable or function name should be snake_case.

​OS2folder <- function(x){
^~~~~~~~~

R/utils.R:47:5: style: Place a space before left parenthesis, except in a function call.

​  if(x == "Windows"){
    ^

R/utils.R:51:12: style: Place a space before left parenthesis, except in a function call.

​  } else if(x == "Darwin") {
           ^

R/utils.R:58:1: style: Variable or function name should be snake_case.

​checkOS <- function(os, dest){
^~~~~~~

R/utils.R:60:5: style: Place a space before left parenthesis, except in a function call.

​  if(os == "Windows" && !dest %in% "C:/"){
    ^

R/utils.R:62:10: style: Place a space before left parenthesis, except in a function call.

​    while(!tolower(x) %in% c("y", "n")){
         ^

R/utils.R:64:1: style: Lines should not be more than 80 characters.

​                                   dest, "drive. It is adviced to install it in",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/utils.R:65:1: style: Lines should not be more than 80 characters.

​                                   "C:/ (even on 64 bit) \nProceed anyway? [y/n]\n"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/utils.R:67:7: style: Place a space before left parenthesis, except in a function call.

​    if(tolower(x) != "y") stop("Change dest directory", call. = FALSE)
      ^

R/utils.R:70:5: style: Place a space before left parenthesis, except in a function call.

​  if(os == "mac"){
    ^

R/utils.R:72:10: style: Place a space before left parenthesis, except in a function call.

​    while(!tolower(x) %in% c("y", "n")){
         ^

R/utils.R:74:1: style: Lines should not be more than 80 characters.

​                                   "get_xpdf has not been tested on your OS, would you like to continue anyway?"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/utils.R:76:7: style: Place a space before left parenthesis, except in a function call.

​    if(tolower(x) != "y") stop("Change dest directory", call. = FALSE)
      ^

R/utils.R:82:20: style: Only use double-quotes.

​  os <- Sys.info()['sysname'] # get os
                   ^~~~~~~~~

R/utils.R:83:5: style: Place a space before left parenthesis, except in a function call.

​  if(os == "Linux"){
    ^

R/utils.R:85:10: style: Place a space before left parenthesis, except in a function call.

​    while(!tolower(x) %in% c("y", "n")){
         ^

R/utils.R:87:1: style: Lines should not be more than 80 characters.

​                                    "get_emails makes use of the tmp folder which by defaults requires root access, ",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/utils.R:91:7: style: Place a space before left parenthesis, except in a function call.

​    if(tolower(x) != "y") stop("Download manually", call. = FALSE)
      ^

R/utils.R:94:1: style: Trailing blank lines are superfluous.

​
^

Please sign in to comment.