Public-Health-Scotland / phsmethods

An R package to standardise methods used in Public Health Scotland (https://public-health-scotland.github.io/phsmethods/)
https://public-health-scotland.github.io/phsmethods/
54 stars 13 forks source link

Add cli, and update `format_postcode` to use it #81

Closed Moohan closed 2 years ago

Moohan commented 2 years ago

I was trying to fix an issue with the warning from format_postode being garbled when used within mutate.

Since I can't do a reprex on the RStudio server I'll add some screen grabs!

Expected output with a vector: image

Garbled output when used within mutate (probably the standard use-case) image

I thought that using cli to format the warning might fix this issue, it turned out that it doesn't and after testing on RStudio Desktop v1.3 and seeing that the warning looks fine, I now suspect that it's the old version of RStudio we have on the server which is actually causing the issue.

Since I'd already done the work to use {cli} I thought I'd open this PR, as the cli formatted warnings do look a bit nicer, and are much easier to read thanks to all the built-in formatting.

It would be a pretty simple job to roll out the usage of cli to the other messages, warnings and errors in the package too if you wanted.

codecov[bot] commented 2 years ago

Codecov Report

Merging #81 (6ff6765) into dev (3fb87e5) will increase coverage by 1.15%. The diff coverage is 100.00%.

@@             Coverage Diff             @@
##              dev       #81      +/-   ##
===========================================
+ Coverage   98.84%   100.00%   +1.15%     
===========================================
  Files          12        12              
  Lines         346       338       -8     
===========================================
- Hits          342       338       -4     
+ Misses          4         0       -4     
Impacted Files Coverage Δ
R/age_calculate.R 100.00% <100.00%> (ø)
R/format_postcode.R 100.00% <100.00%> (ø)
R/dob_from_chi.R 100.00% <0.00%> (+7.01%) :arrow_up:

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

Tina815 commented 2 years ago

Thanks James. This does look like a better option. As long as you tested it and can confirm it works in RStudio desktop I'll be happy to approve it.