10 October 2019

We all get stuck

We all want to improve & we can all help each other

Hurdles to Open Source Contribution

Let’s do something for the community …

git terminology

FORK - Make me a copy of this repo(sitory) on github

PULL - Download this repo to my computer

(Make the changes you need)

ADD / COMMIT - Add these changes to my local copy of this repo

PUSH - Upload my updated version of this repo to github

PULL REQUEST - Tell the author of this repo that they can include my changes

Live section:

On Open Source Contributions

Not all contributions are code contributions [… or docs …]

…

Just helping people filter, and curate, and figure-out what is in a ticket and if it’s really important… I can’t tell you how useful this is

Heather C Miller: Interviewed on CoRecursive podcast (2019-09-15)

lintr and your code

library(lintr) # lintr 2.0.0; author: Jim Hester
# Temp file
abc = 123
my.df <- data.frame(x = 1:3, y = rnorm(3))
is_it_a_matrix <- sapply(1:3, function(x) rbinom(x, 10, 0.5))
message("superfluous_semicolon");
lint(filename = f)
## /home/ah327h/workshops/glar_201910/temp/lint_me.R:2:5: style: Use <-, not =, for assignment.
## abc = 123
##     ^
## /home/ah327h/workshops/glar_201910/temp/lint_me.R:3:1: style: Variable and function name style should be snake_case.
## my.df <- data.frame(x = 1:3, y = rnorm(3))
## ^~~~~

My first lintr issue (2017-06-27)

My first lintr PR (2018-09-17)

GitHub

  • Accepted 2018-09-18

  • Got into CRAN lintr Sept 2019

  • What happened in between?

(Note : I was really fixing a problem with my package dupree)

How to find collaborators?

A Common Theme:

  • One (few) main developer

  • Lots of open issues

    • questions, duplicates, bugs, feature requests

    • unlabelled or solved issues

  • To help: Curate and Filter

    • label the issues

    • close fixed issues

    • ask for / find a reproducible example

[But uncommon: Few packages, but many package developers, depend on lintr)]

How to find a project to help?

explainerr - a sandbox project for learning git and regexes

https://github.com/russHyde/explainerr/

explainerr::explain("object of type 'closure' is not subsettable")
## An example where this error comes up is when you've used [square brackets]
##   instead of (parentheses) to surround the arguments to a function.
## 
##   If you wanted the `mean` of the numbers 1, 2 and 3, you should call
##   `mean(c(1, 2, 3))`, but it's easy to call `mean[c(1, 2, 3)]` by mistake. In R,
##   the square brackets are used for subsetting - `v[2]` pulls out the
##   second entry of `v` (where `v` may be a list or a vector or something).
## 
##   So the syntax `mean[c(1, 2, 3)]` is attempting to get R to pull out the first
##   three entries of some vector called mean; but `mean` is a function and so
##   can't be subset in this way.
## 
##   Examples of non-subsettable things:
## 
##   mean[1:2]        # mean is a function (a `closure`), did you expect `mean(1:2)`?
##   c[1]             # c is a function (a `builtin`), did you mean `c(1)`?
##   `[`[1]           # `[` is a function (a `special`)
##   globalenv()[1]   # globalenv() returns an `environment`
## 

Cheers

Appendix

Me & R

Experimental things on github (@russHyde)

  • dupree
    • duplicate code detection (built on lintr)
  • polyply
    • extend dplyr verbs to sets of data-frames
  • bioinformatics stuff

Recent contributions to bigger projects

Non-default linters

lint(
  filename = f,
  linters = with_defaults(
    assignment_linter = NULL, # "abc = 123" is fine
    fns = undesirable_function_linter(), # catch `sapply`
    semis = semicolon_terminator_linter()
  )
)
## /home/ah327h/workshops/glar_201910/temp/lint_me.R:3:1: style: Variable and function name style should be snake_case.
## my.df <- data.frame(x = 1:3, y = rnorm(3))
## ^~~~~
## /home/ah327h/workshops/glar_201910/temp/lint_me.R:4:19: warning: Function "sapply" is undesirable. As an alternative, use vapply() or lapply().
## is_it_a_matrix <- sapply(1:3, function(x) rbinom(x, 10, 0.5))
##                   ^~~~~~
## /home/ah327h/workshops/glar_201910/temp/lint_me.R:5:33: style: Trailing semicolons are not needed.
## message("superfluous_semicolon");
##                                 ^