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

Avoid using equality checks / %in% on class() #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MichaelChirico
Copy link

@MichaelChirico MichaelChirico commented Mar 17, 2024

Just started with the package so thought I'd try and contribute back some code quality fixes as a token of thanks.

Found with lintr::class_equals_linter(). Some of the changes (noted in a comment) require more context than I have to execute completely correctly, so feedback welcome on things that need more fine-tuning.

There are many other changes found with lintr::lint_package(linters = lintr::all_linters()); many of them are stylistic but others have implications for correctness, too.

@@ -424,12 +424,12 @@ otp_parse_missing <- function(x){

otp_clean_input <- function(imp, imp_name) {
# For single point inputs
if (all(class(imp) == "numeric")) {
if (!is.matrix(imp) && is.double(imp)) {
Copy link
Author

Choose a reason for hiding this comment

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

this test looked to me like "non-matrix numeric vector", which matches the new test. CMIIW.

expect_true(nrow(r3) == 1)
expect_true("leg_elevation" %in% names(r3))
expect_true(class(r3$leg_elevation) == "list")
expect_true(is.list(r3$leg_elevation))
Copy link
Author

Choose a reason for hiding this comment

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

this could also be expect_type(., "list")

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.

1 participant