Skip to content

Conversation

@vituri
Copy link
Contributor

@vituri vituri commented Feb 11, 2025

Issue #149

Duplicates on import should be linted.

Description

  • Added the function box_repeated_calls_linter that detects repetitions even when on different box::use calls;
  • Added a set of 14 tests with combinations of paths and libraries in tests/testthat/test-box_repeated_calls_linter.R;
  • Added box_repeated_calls_linter to rhino_default_linters;
  • Added docs and imports.

Definition of Done

  • The change is thoroughly documented.
  • The CI passes (R CMD check, linter, unit tests, spelling).
  • Any generated files have been updated (e.g. .Rd files with roxygen2::roxygenise())

@codecov
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.01%. Comparing base (320452b) to head (d3cbbc0).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
R/namespaced_function_calls.R 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #154      +/-   ##
==========================================
+ Coverage   96.92%   97.01%   +0.08%     
==========================================
  Files          24       25       +1     
  Lines        1172     1207      +35     
==========================================
+ Hits         1136     1171      +35     
  Misses         36       36              

☔ View full report in Codecov by Sentry.
📢 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.

@vituri

This comment was marked as resolved.

@vituri vituri linked an issue Feb 14, 2025 that may be closed by this pull request
@vituri vituri requested a review from jakubnowicki April 4, 2025 18:39
Copy link
Collaborator

@radbasa radbasa left a comment

Choose a reason for hiding this comment

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

The three-deep loop can/will be difficult to maintain and debug. As single XPath query or a series of XPath queries can be tested manually using a XPath query utility.

.Rproj.user
docs
inst/doc
box.linters.Rproj
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove. Don't gitignore Rproj file.

Comment on lines +113 to +131
for (call_node in box_use_calls) {
# Get all arguments (import specifications)
args <- xml2::xml_find_all(call_node, "./expr[position() > 1]")

# Process each argument
for (arg in args) {
# Handle alias assignments (like tbl = tibble)
target_nodes <- xml2::xml_find_all(arg, ".//node()")

#' Extract components before [ bracket
import_parts <- extract_import_parts(target_nodes)

# Combine parts to form full import specifier
import_text <- paste(import_parts, collapse = "")

# Store the import text and XML node
all_imports <- append(all_imports, list(list(text = import_text, node = arg)))
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Performance concern.

This is a three-deep nested loop with multiple xml searches which themselves are loops:

for
  xml_find_all()
  for
    xml_find_all()
    for # extract_import_parts()

O(n^3)

return(
lintr::Linter(function(source_expression) {
return(list())
list()
Copy link
Collaborator

@radbasa radbasa Jun 19, 2025

Choose a reason for hiding this comment

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

Don't change. This is addressed in PR #158

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_BUG]: duplicate package imports aren't linted

3 participants