Skip to content

Commit

Permalink
Handle missing arguments in calls properly
Browse files Browse the repository at this point in the history
Fixes #145
  • Loading branch information
jimhester committed May 4, 2016
1 parent 9c17dcc commit 600cb82
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: lintr
Title: Static R Code Analysis
Version: 1.0.0
Version: 1.0.0.9000
Authors@R: person("Jim", "Hester", email = "james.f.hester@gmail.com", role = c("aut", "cre"))
URL: https://github.com/jimhester/lintr
BugReports: https://github.com/jimhester/lintr/issues
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# lintr 1.0.0.9000 #

* Commas linter handles missing arguments calls properly (#145)

# lintr 1.0.0 #
* bugfix to work with testthat 1.0.0

Expand Down
3 changes: 2 additions & 1 deletion R/commas_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ commas_linter <- function(source_file) {

start_of_line <- re_matches(line, rex(start, spaces, ","))

if (has_token && !start_of_line) {
empty_comma <- substr(line, comma_loc - 2L, comma_loc - 1L) %==% ", "
if (has_token && !start_of_line && !empty_comma) {

lints[[length(lints) + 1L]] <-
Lint(
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-commas_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,12 @@ test_that("returns the correct linting", {
expect_lint("\"fun(1 ,1)\"",
NULL,
commas_linter)

expect_lint("a[1, , 2]",
NULL,
commas_linter)

expect_lint("a[1, , 2, , 3]",
NULL,
commas_linter)
})

2 comments on commit 600cb82

@richelbilderbeek
Copy link

Choose a reason for hiding this comment

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

Awesome! Thanks!

@rentrop
Copy link

Choose a reason for hiding this comment

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

@jimhester As this is >6 Month old... When are you going to publish it on CRAN?

Please sign in to comment.