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

lint_package returns early when no package is found #776

Merged
merged 10 commits into from
Mar 12, 2021
Merged

Conversation

MichaelChirico
Copy link
Collaborator

On HEAD this gives me a funny error:

lintr::lint_package("/")
# Error in paths[rel_path] <- file.path(root, paths[rel_path]) : 
#   replacement has length zero

Should we issue a warning here?

@AshesITR
Copy link
Collaborator

Shouldn't this be an error condition?

@MichaelChirico
Copy link
Collaborator Author

An error seems harsh, though maybe the return should just be NULL?

Ran into this trying to create a test for #702 -- easiest test is to make sure a DESCRIPTION directory is skipped and then no package is found at all.

@AshesITR
Copy link
Collaborator

AshesITR commented Mar 11, 2021

I would return NULL for find_package but lint_package() run non-interactively IMO should definitely error if there was no package, no?

If not, a warning ("No package was found at '/path'."?) with NULL instead of an empty lints list seems more correct.
Maybe even something like NA such that length(lint_package()) will be different from the lint-free state. WDYT?

@MichaelChirico
Copy link
Collaborator Author

I'm still happy with warn + return NULL. Don't really like NA -- the warning should be enough to distinguish from lint-free right?

Also it's NULL whereas lint-free is list().

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. Please add a NEWS bullet.

@AshesITR AshesITR merged commit 46f0eb1 into master Mar 12, 2021
@AshesITR AshesITR deleted the lint-non-package branch March 12, 2021 10:52
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.

2 participants