Skip to content

Ensure attached box objects have unique labels #177

@radbasa

Description

@radbasa

Lint on duplicated attached package, module, function, alias names/labels.

Definition of a box object:

  • A package name. Use case: box::use(package); package$function()
  • A module sans the path: Use case: box::use(path/to/module); module$function()
  • A function name. Use case: box::use(package[function]); function() or the module equivalent
  • A ... attachment. Use case: box::use(package[...]); function() or the module equivalent
  • A package alias: Use case: box::use(alias = package); alias$function() or the module equivalent
  • A function alias: Use case; box::use(package[alias = function]; alias()` or the module equivalent

Related issues and PRs

Issue #149
PR #154
PR #174

This issue effectively replaces the above issue and PRs.

SHOULD lint

In the examples given below, only packages are used. However, it should be noted that the same rules apply for modules. For modules, the significant label or name is the final name. The path to the module is not considered part of the module name. For example, path/A/module and path/B/module would both be loaded as module and would be considered a duplicate.

# lint on dplyr

box::use(
  dplyr,
)

box::use(
  dplyr,
)
# lint on dplyr

box::use(
  dplyr,
  dplyr,
)
# lint on dplyr

box::use(
  dplyr,
  dplyr = stats
)

# contrived but it's an example for box aliases
# lint on duplicate
box::use(
  duplicate = dplyr,
  duplicate = stats,
)
# lint on filiter

box::use(
  stats[filter],
  dplyr[filter],
)
# lint on duplicate
box::use(
  stats[duplicate = filter],
  dplyr[duplicate = filter],
)
# lint on duplicate
box::use(
  duplicate = stats,
  dplyr[duplicate = filter],
)
# lint on filter, lag, select

box::use(
  dplyr[...],
  stats[...],
)

SHOULD NOT lint

box::use(
  dplyr,
  dplyr[filter]
)
box::use(
  stats[s_filter = filter],
  dplyr[d_filter = filter],
)
box::use(
  path_a/module_name[function_A],
  path_b/module_name[function_B],
)

Notes

  • Is {stats} loaded in a {box} environment? Will dplyr[filter] lint against stats::filter?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions