Skip to content

Commit

Permalink
docs_developpers : lintr tips in md format
Browse files Browse the repository at this point in the history
  • Loading branch information
melpetera authored Dec 3, 2021
1 parent 93f3060 commit 83adda3
Showing 1 changed file with 56 additions and 56 deletions.
112 changes: 56 additions & 56 deletions docs_developers/lintr.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,76 @@ Here one can find some examples of lintr warning messages,
illustrated with examples to help enhancing one's code to pass the checks.

Structure:
`lintr message`
e.g.:
example that generate the error message
`lintr message`
e.g.:
example that generate the error message
lintr-compliant solution

or

`lintr message`
`lintr message`
comment to help solve the issue


## List of examples

`Avoid 1:length(...) expressions, use seq_len.`
e.g.:
the following: my_object <- 1:length(A)
should be: my_object <- seq_len(length(A))

`Avoid 1:nrow(...) expressions, use seq_len.`
e.g.:
the following: my_object <- 1:nrow(A)
should be: my_object <- seq_len(nrow(A))
`Avoid 1:length(...) expressions, use seq_len.`
e.g.:
the following: my_object <- 1:length(A)
should be: my_object <- seq_len(length(A))

`Commas should always have a space after.`
e.g.:
the following: my_object <- c("toto","titi")
should be: my_object <- c("toto", "titi")
`Avoid 1:nrow(...) expressions, use seq_len.`
e.g.:
the following: my_object <- 1:nrow(A)
should be: my_object <- seq_len(nrow(A))

`Commented code should be removed.`
if you really NEED it to appear for understanding purpose, comment it in a documented sentence
`Commas should always have a space after.`
e.g.:
the following: my_object <- c("toto","titi")
should be: my_object <- c("toto", "titi")

`Do not place spaces around code in parentheses or square brackets.`
e.g.:
the following: my_object <- c( A[ 1, 2], B[ 3, 4 ] )
should be: my_object <- c(A[1, 2], B[3, 4])
`Commented code should be removed.`
if you really NEED it to appear for understanding purpose, comment it in a documented sentence

`Only use double-quotes.`
e.g.:
the following: my_object <- c('toto', 'titi')
should be: my_object <- c("toto", "titi")
`Do not place spaces around code in parentheses or square brackets.`
e.g.:
the following: my_object <- c( A[ 1, 2], B[ 3, 4 ] )
should be: my_object <- c(A[1, 2], B[3, 4])

`Place a space before left parenthesis, except in a function call.`
e.g.:
the following: if(toto) {titi}
should be: if (toto) {titi}
`Only use double-quotes.`
e.g.:
the following: my_object <- c('toto', 'titi')
should be: my_object <- c("toto", "titi")

`Put spaces around all infix operators.`
e.g.:
the following: list_arguments<-parseCommandArgs(evaluate=FALSE)
should be: list_arguments <- parseCommandArgs(evaluate = FALSE)

`Remove spaces before the left parenthesis in a function call.`
e.g.:
the following: my_fct <- function (toto, titi) {...}
should be: my_fct <- function(toto, titi) {...}

`There should be a space between right parenthesis and an opening curly brace.`
e.g.:
the following: if (toto){titi}
should be: if (toto) {titi}

`Trailing whitespace is superfluous.`
i.e. no whitespaces at the end of lines

`Use <-, not =, for assignment.`
e.g.:
the following: list_arguments = parseCommandArgs(evaluate = FALSE)
should be: list_arguments <- parseCommandArgs(evaluate = FALSE)
`Place a space before left parenthesis, except in a function call.`
e.g.:
the following: if(toto) {titi}
should be: if (toto) {titi}

`Variable and function name style should be snake_case.`
`Put spaces around all infix operators.`
e.g.:
the following: myNewObject <- "toto"
should be: my_new_object <- "toto"
the following: list_arguments<-parseCommandArgs(evaluate=FALSE)
should be: list_arguments <- parseCommandArgs(evaluate = FALSE)

`Remove spaces before the left parenthesis in a function call.`
e.g.:
the following: my_fct <- function (toto, titi) {...}
should be: my_fct <- function(toto, titi) {...}

`There should be a space between right parenthesis and an opening curly brace.`
e.g.:
the following: if (toto){titi}
should be: if (toto) {titi}

`Trailing whitespace is superfluous.`
i.e. no whitespaces at the end of lines

`Use <-, not =, for assignment.`
e.g.:
the following: list_arguments = parseCommandArgs(evaluate = FALSE)
should be: list_arguments <- parseCommandArgs(evaluate = FALSE)

`Variable and function name style should be snake_case.`
e.g.:
the following: myNewObject <- "toto"
should be: my_new_object <- "toto"

0 comments on commit 83adda3

Please sign in to comment.