Skip to content

Print a message when no lints found#2643

Merged
MichaelChirico merged 8 commits into
mainfrom
f2640-no-lint-msg
Aug 5, 2024
Merged

Print a message when no lints found#2643
MichaelChirico merged 8 commits into
mainfrom
f2640-no-lint-msg

Conversation

@IndrajeetPatil

Copy link
Copy Markdown
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

Comment thread R/methods.R Outdated
@IndrajeetPatil

Copy link
Copy Markdown
Collaborator Author

Windows failures seem spurious:

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

@IndrajeetPatil
IndrajeetPatil requested a review from AshesITR August 4, 2024 21:41
@codecov

codecov Bot commented Aug 4, 2024

Copy link
Copy Markdown

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.

Comment thread R/methods.R
rstudio_source_markers(x)
} else {
# Empty lints
cli_inform(c(i = "No lints found."))

@MichaelChirico MichaelChirico Aug 4, 2024

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
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.

Comment thread NEWS.md Outdated

@AshesITR AshesITR left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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

MichaelChirico commented Aug 5, 2024

Copy link
Copy Markdown
Collaborator

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.

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