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

Print a message when no lints found #2643

Merged
merged 8 commits into from
Aug 5, 2024
Merged

Print a message when no lints found #2643

merged 8 commits into from
Aug 5, 2024

Conversation

IndrajeetPatil
Copy link
Collaborator

Closes #2640

library(lintr)
lint(text = "x <- 1L", linters = all_linters())
#> ℹ No lints found.

Created on 2024-08-04 with reprex v2.1.1

R/methods.R Outdated Show resolved Hide resolved
@IndrajeetPatil
Copy link
Collaborator Author

Windows failures seem spurious:

> checking top-level files ... NOTE
  Non-standard file/directory found at top level:
    'install.ps1'

Copy link

codecov bot commented Aug 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.96%. Comparing base (f0d9407) to head (63b0017).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2643   +/-   ##
=======================================
  Coverage   97.96%   97.96%           
=======================================
  Files         126      126           
  Lines        5760     5761    +1     
=======================================
+ Hits         5643     5644    +1     
  Misses        117      117           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

rstudio_source_markers(x)
} else {
# Empty lints
cli_inform(c(i = "No lints found."))
Copy link
Collaborator

@MichaelChirico MichaelChirico Aug 4, 2024

Choose a reason for hiding this comment

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

this is a classed signal:

class(tryCatch(cli::cli_inform("xxx"), condition=identity))
# [1] "rlang_message" "message"       "condition"

Is that appropriate? I might have expected just cat() here, I guess {cli} adds nice aesthetics -- are there any analogues for "plain text to terminal"? cli::cli_text(c(i = "No lints found.")) drops the i formatting.

(or perhaps a message is appropriate, WDYT?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Message seems ok to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we could use cat(), but I also think there are benefits to having this as a classed signal over cat() (e.g. the messages will show up in logs).

If we don't want a classed signal, either cli_alert() or its sibling should work:

cli::cli_alert_success("No lints found")
#> ✔ No lints found

class(tryCatch(cli::cli_alert_success("No lints found"), condition=identity))
#> [1] "cli_message" "condition"

Created on 2024-08-05 with reprex v2.1.1

So we can have our pretty aesthetics cake and eat it too.

NEWS.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@AshesITR AshesITR left a comment

Choose a reason for hiding this comment

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

LGTM. The Windows failure looks like it needs reporting as a bug to r-lib/actions.

@IndrajeetPatil
Copy link
Collaborator Author

LGTM. The Windows failure looks like it needs reporting as a bug to r-lib/actions.

Done: r-lib/actions#898

AshesITR
AshesITR previously approved these changes Aug 5, 2024
@MichaelChirico
Copy link
Collaborator

MichaelChirico commented Aug 5, 2024

Still waver a bit on whether signalling a condition is really the right thing to do for code that's performing fine, in fact congratulatory.

But, I don't think it actually matters -- we are a "front end" package & I can't think of any scenario where the difference between cat()/message() would actually matter for our users. So, let's proceed for simplicity's sake.

@MichaelChirico MichaelChirico merged commit 3358539 into main Aug 5, 2024
18 checks passed
@MichaelChirico MichaelChirico deleted the f2640-no-lint-msg branch August 5, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide feedback when no lints are found
3 participants