Skip to content

Instantly share code, notes, and snippets.

@oroce

oroce/.lintr

Last active Apr 10, 2017
Embed
What would you like to do?
linters: with_defaults(line_length_linter(120))
exclusions: list("lint.R")

Tasks:

  • DONE cache enabled circle machine (second run is around 3.5 minutes)
  • DONE use circle test metadata
  • PENDING better xunit output generation (that sprintf is just ugly)
machine:
environment:
R_LIBS: /home/ubuntu/rlibs/
pre:
- mkdir -p $HOME/rlibs/
- sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'
- gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
- gpg -a --export E084DAB9 | sudo apt-key add -
- sudo apt-get -q -y update
- sudo apt-get -q -y -f install libicu-dev build-essential libxml2-dev libxslt-dev libssl-dev libcurl4-openssl-dev
- sudo apt-get -y install r-base r-base-dev
dependencies:
cache_directories:
- /home/ubuntu/rlibs/
override:
- Rscript -e 'if(!(require("devtools"))) install.packages("devtools", repos="http://cran.us.r-project.org", dependencies=TRUE, clean=TRUE)'
- Rscript -e 'devtools::install_github("jimhester/lintr")'
test:
override:
- CI="" Rscript --vanilla --slave lint.R *.R | tee $CIRCLE_TEST_REPORTS/lintr.xml
args <- commandArgs(trailingOnly=TRUE)
errors <- do.call("c", lapply(args, function(file) {
return (lintr::lint(file))
}));
if (length(errors) == 0) {
quit(save = "no", status = 0)
}
replace <- function(input) gsub(">", "&gt;", gsub("<", "&lt;", input))
formatted <- lapply(errors, function(i) {
file <- i[1]
line <- i[2]
col <- i[3]
type <- i[4]
msg <- i[5]
return (sprintf("<testsuite package=\"org.lintr\" time=\"0\" tests=\"1\" errors=\"1\" name=\"%s\"><testcase time=\"0\" name=\"org.lintr.%s\"><failure message=\"%s\"><![CDATA[\nline %s, col %s, %s: %s\n]]></failure></testcase></testsuite>", file, type, replace(msg), line, col, type, msg))
})
txt <- paste(formatted, collapse = '\n')
write(paste0('<testsuites>', txt, '</testsuites>'), stdout())
quit(save = "no", status = 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment