Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples to documentation: Part-7 (q-s) #1674

Merged
merged 19 commits into from
Oct 11, 2022
Merged

Conversation

IndrajeetPatil
Copy link
Collaborator

Part of #1492

@codecov-commenter
Copy link

codecov-commenter commented Oct 11, 2022

Codecov Report

Merging #1674 (ef84b97) into main (615f72a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1674   +/-   ##
=======================================
  Coverage   98.70%   98.70%           
=======================================
  Files         103      103           
  Lines        4489     4495    +6     
=======================================
+ Hits         4431     4437    +6     
  Misses         58       58           
Impacted Files Coverage Δ
R/function_left_parentheses_linter.R 100.00% <ø> (ø)
R/redundant_equals_linter.R 100.00% <ø> (ø)
R/redundant_ifelse_linter.R 100.00% <ø> (ø)
R/regex_subset_linter.R 100.00% <ø> (ø)
R/semicolon_linter.R 100.00% <ø> (ø)
R/seq_linter.R 100.00% <ø> (ø)
R/spaces_inside_linter.R 100.00% <ø> (ø)
R/spaces_left_parentheses_linter.R 100.00% <ø> (ø)
R/sprintf_linter.R 100.00% <ø> (ø)
R/string_boundary_linter.R 100.00% <ø> (ø)
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@MichaelChirico
Copy link
Collaborator

can you check the coverage report?

@IndrajeetPatil
Copy link
Collaborator Author

If I am reading this correctly, the coverage drop in methods.R

Screenshot 2022-10-11 at 19 11 06

is due to change here

Screenshot 2022-10-11 at 19 11 27

But this change wasn't made in this PR, so it's confusing why the coverage drop is associated with this PR.

@IndrajeetPatil
Copy link
Collaborator Author

Okay, this one is surprising:

Screenshot 2022-10-11 at 19 19 33

@@ -2,6 +2,19 @@
#'
#' Check that all left parentheses have a space before them unless they are in a function call.
#'
#' @examples
#' # will produce lints
#' lint(
Copy link
Collaborator

Choose a reason for hiding this comment

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

in an earlier linter (function_left_parentheses_linter? is that the name?) we showed if/function signature examples, should we do the reverse here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what you mean by "reverse" here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Complementary examples to these:

#' # okay
#' lint(
#' text = "mean(x)",
#' linters = function_left_parentheses_linter()
#' )
#'
#' lint(
#' text = "stats::sd(c(x, y, z))",
#' linters = function_left_parentheses_linter()
#' )
#'
#' lint(
#' text = "if (TRUE) x else y",
#' linters = function_left_parentheses_linter()
#' )
#'
#' lint(
#' text = "foo <- function(x) (x + 1)",
#' linters = function_left_parentheses_linter()
#' )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So including the okay examples but with a space to show that this doesn't lint with spaces_left linter?

library(lintr)

lint(
  text = "mean (x)",
  linters = spaces_left_parentheses_linter()
)

lint(
  text =  "stats::sd (c (x, y, z))",
  linters = spaces_left_parentheses_linter()
)

lint(
  text =  "if (TRUE) x else y",
  linters = spaces_left_parentheses_linter()
)

lint(
  text =  "foo <- function (x) (x + 1)",
  linters = spaces_left_parentheses_linter()
)

Created on 2022-10-11 with reprex v2.0.2

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, now I'm doubting everything :)

I definitely don't think examples like mean (x) are helpful... but maybe the better thing to do is just remove the if() example from function_left_parentheses_linter()? Since if() is irrelevant to that linter, and is covered here instead.

And then add cross-links between these two linters' help pages since they're so closely related.

WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

SGTM. I have made the necessary changes. See if this is better.

R/sprintf_linter.R Outdated Show resolved Hide resolved
R/sprintf_linter.R Outdated Show resolved Hide resolved
@MichaelChirico MichaelChirico merged commit 02b9682 into main Oct 11, 2022
@MichaelChirico MichaelChirico deleted the 1492_examples_rs branch October 11, 2022 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants