-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
align args asserts; align args defaults; logger in test #1008
Conversation
This still needs some work - back to the draft. I need to clear up the way how title is handled:
|
Unit Tests Summary 1 files 19 suites 11s ⏱️ Results for commit e4e5411. ♻️ This comment has been updated with latest results. |
Code Coverage Summary
Diff against main
Results for commit: e4e5411 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align argument assertions
I believe asserting and converting is superior to converting and asserting, see specific comment below.
align argument defaults for header, footer, etc.
While we are here, the description of header
and is borderline confusing:
#' @param header (`shiny.tag` or `character`) \cr
#' the header of the app. Note shiny code placed here (and in the footer
#' argument) will be placed in the app's `ui` function so code which needs to be placed in the `ui` function
#' (such as loading `CSS` via [htmltools::htmlDependency()]) should be included here.
Could this be improved somewhat?
Also consider combining header
and footer
#' @parem header,footer (`shiny.tag` or `character`) \cr
#' the header and footer of the app (...)
Lastly, I would also consider changing the order of the arguments by putting filter
before title
but that may be too serious a change.
(Withholding logger discussion until the simple things are agreed upon.)
Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Pawel Rucki <12943682+pawelru@users.noreply.github.com>
Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com> Signed-off-by: Pawel Rucki <12943682+pawelru@users.noreply.github.com>
Yes - fixed and simplified this. There was an idea of combining this one one but there are reports that it does not work nicely when inheriting - https://stackoverflow.com/questions/39762443/inherit-roxygen2-documentation-for-multiple-arguments-in-r-package. Decided to keep it separate.
I agree. This should be a separate issue discussed separately. Didn't want to propose not backwards compatible changes here. |
…title, header, footer; similar reorg in modules()
Thank you all for expressing your thoughts. I have applied this as you suggested, i.e. assert - convert. When doing this I noticed two possible disadvantages that have not been raised yet. This is possibly not super DRY as we might repeat similar condition three times. Let me give you an example:
as opposed to two times only (which is also not great tbh)
Now, let's imagine that this condition is not wrapped into a nice function but there are multiple combined conditions. Let's go further and imagine that these conditions requires internals from other packages or in general: logic that suppose to be encapsulated elsewhere. Such situation is observable in case of There is also one more thing. Usually we have one and only one desired class and there are few additional ones that are allowed and then converted into the desired. If we put additional classes into the assertions upfront then those will be listed in the error message. In case there are multiple additional ones, users might interpret that they need to put some effort into converting an additional one into the other additional one whereas we actually want them to convert into the desired one. Let's take an example (dummy code):
A valid interpretation of the above could be "I need to put names into the list" whereas I feel we should say "please convert to teal_data" instead. |
You right, probably we will always repeat some code. When the same argument is passed from function to function we should add assert to each function. I like your idea of having asserts grouped and arranged by the argument but In the same time I'm against it. Asserts are filling gap of the week typing in R. I prefer to have all asserts on the top of the function to communicate to developer what is the desired type (@param arg types in the documentation is a derivate of the assert not the opposite).
This is interesting point of view. I'm not sure, I think when the wrong type is provided the answer should be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I don't have any objections anymore
Signed-off-by: Pawel Rucki <12943682+pawelru@users.noreply.github.com>
Signed-off-by: Pawel Rucki <12943682+pawelru@users.noreply.github.com>
Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Pawel Rucki <12943682+pawelru@users.noreply.github.com>
Thanks all for the valuable feedback 👍 Much appreciated. I think we ended up with a good conventions to carry forward. |
ready for review
Unfortunately it grew more than I expected initially and I should have been split it into few for the review convenience...
Currently on main we have two approaches for assert and convert. Please find below examples (note the order)
modules
:teal/R/init.R
Line 121 in e98eab0
teal/R/init.R
Lines 133 to 138 in e98eab0
data
:teal/R/init.R
Lines 105 to 108 in e98eab0
teal/R/init.R
Line 120 in e98eab0
I decided to follow the latter one.
header
,footer
, etc.data
ormodules
.