Skip to content

This package simply aims to reproduce an issue encountered while working on a bigger project when using pipes (%>%).

Notifications You must be signed in to change notification settings

janclod/testPipes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 

Repository files navigation

testPipes

This package simply aims to reproduce an issue encountered while working on a bigger project when using pipes (%>%).

ISSUE

GHA fails to build on macOS and Ubuntu when pipes are used in more than one single file when pipes do not start on a new line. No errors locally (Linux).

IS THIS A BUG? NO

BRIEF SOLUTION TO THE ISSUE

On GHA, remember to install the package that you are testing by running R CMD INSTALL . on Linux and macOS systems.

Add this to your yaml file after 'Installing dependencies'

- name: Install package
if: runner.os == 'macOS' || runner.os == 'Linux'
run: R CMD INSTALL .

Detailed description of issue

examples of breaking code according to lintr

Example of code that breaks on GHA:

data.frame(col1 = c1, col2 = c2) %>% stats::na.omit()

Everything on one line: lintr does not like this!

On GHA, lintr::expect_lint_free() throws the following error:
Warning: no visible global function definition for ‘%>%’

examples of working code according to lintr

Example of code that builds without erros on GHA:

data.frame(col1 = c1,
          col2 = c2) %>% stats::na.omit()

Each pipe is on a new line: lintr likes this! <3

linter analysis

After some digging, it seems that the object_usage_linter is responsible for breaking the code. This linter harnesses the codetools package. This linter calls codetools::checkUsage on closures. In this specific case, this will look something like this:

codetools::checkUsage(function1 <- function(x) {
  c1 <- as.numeric(x$col1)
  c2 <- as.numeric(x$col2)
  data.frame(col1 = c1, col2 = c2) %>% stats::na.omit()
})

About

This package simply aims to reproduce an issue encountered while working on a bigger project when using pipes (%>%).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published