Skip to content

Lint rev(sort()) calls - #3066

Merged
Bisaloo merged 5 commits into
mainfrom
rev-sort
Jul 6, 2026
Merged

Bisaloo merged 5 commits into
mainfrom
rev-sort

Conversation

@Bisaloo

@Bisaloo Bisaloo commented Jul 3, 2026 •

Copy link
Copy Markdown
Collaborator

Fix #2614.

Comment thread R/sort_linter.R Outdated
rev_sort_lints <- xml_nodes_to_lints(
rev_sort_calls,
source_expression = source_expression,
lint_message = "Use sort(x, decreasing = TRUE) instead of rev(sort(x)). If present, `na.last` value needs to be flipped",

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.

This could eventually be tweaked/improved to display the exact call users should use, including the updated na.last value but I'm hoping this is good enough for a first pass.

@codecov

codecov Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.25%. Comparing base (2c390ae) to head (bf229fd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3066   +/-   ##
=======================================
  Coverage   99.25%   99.25%           
=======================================
  Files         128      128           
  Lines        7388     7396    +8     
=======================================
+ Hits         7333     7341    +8     
  Misses         55       55           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread R/sort_linter.R Outdated
source_expression = source_expression,
lint_message = paste(
"Use sort(x, decreasing = TRUE) instead of rev(sort(x)).
If present, `na.last` value needs to be flipped"

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.

Agree we can improve this later

Comment thread R/sort_linter.R Outdated
rev_sort_calls,
source_expression = source_expression,
lint_message = paste(
"Use sort(x, decreasing = TRUE) instead of rev(sort(x)).

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.

odd to see paste() but the string has the embedded newline, I reckon it's meant to be ", at the end of this line?

(Do we need paste anyway? It looks like it'll fit in 120 characters)

@MichaelChirico MichaelChirico 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.

Ready to merge after nit fix, thanks!

@Bisaloo
Bisaloo merged commit b8f1fda into main Jul 6, 2026
21 checks passed
@Bisaloo
Bisaloo deleted the rev-sort branch July 6, 2026 15:56
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.

Lint rev(sort(x)) pattern in sort_linter() in favour of the more efficient alternative

2 participants