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

[WIP] Bugfix/missing lintr action #139

Merged
merged 30 commits into from
Feb 26, 2024
Merged

Conversation

annakrystalli
Copy link
Member

@annakrystalli annakrystalli commented Feb 15, 2024

For some reason, on the packages I upgraded last friday, the linting workflow was missed off (probably used an earlier installed version oh hubDevs I use put the wrong hubDevs configuration function in my upgrade issue template 🤦‍♀️)

Adding the missing workflow here as well as updating R CMD CHECK & codecov worklfows with newer versions.

Also fixing linting issues and cleaning up in preparation for package split.

Also reverts somenolint comments by using function(x) calls in purrr instead of ~ (as dicsussed in #141 and https://github.com/orgs/Infectious-Disease-Modeling-Hubs/discussions/3#discussioncomment-8477805)

Copy link

github-actions bot commented Feb 15, 2024

Copy link

@bsweger bsweger left a comment

Choose a reason for hiding this comment

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

Looks good! I left a few questions, but nothing that would hold up a merge.

# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
Copy link

Choose a reason for hiding this comment

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

Do we also want to lint when someone pushes a feature branch (so devs get earlier feedback if something should be fixed)?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the standard lintr workflow maintained by r-lib and I feel it should be good enough for our purposes. I imaging folks will get in the habit of linting before pushing just as we normally test and chack locally before pushing too.

@@ -19,7 +34,7 @@ check_input <- function(input, property, parent_schema,
return()
}
}
if (!is.atomic(input) | is.pairlist(input)) {
if (!is.atomic(input) || is.pairlist(input)) {
Copy link

Choose a reason for hiding this comment

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

In case there are other newish R folks following along, I found an explanation of | vs || here: https://stat.ethz.ch/R-manual/R-devel/library/base/html/Logic.html

@@ -24,9 +26,9 @@ load_model_metadata <- function(hub_path, model_ids = NULL) {
UseMethod("load_model_metadata")
}


# cyclomatic complexity of 17 instead of 15 acceptable
Copy link

Choose a reason for hiding this comment

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

Is this something worth putting in the common .lintr file, or is the increased complexity of 17 specific to this file? (e.g., cyclocomp_linter(complexity_limit = 17L))

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think 15L is particularly meaningful or that 17L would be more appropriate. I think the particular linter is useful to bring attention to extra cyclomatic complexity but also ok for the developer to ignore if they feel it's warranted

@@ -36,7 +36,7 @@
model_id_merge <- function(tbl, sep = "-") {
# check all required columns present
if (!all(c("model_abbr", "team_abbr") %in% names(tbl))) {
missing_cols <- c("model_abbr", "team_abbr")[
missing_cols <- c("model_abbr", "team_abbr")[ # nolint: object_usage_linter
Copy link

Choose a reason for hiding this comment

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

Another question about the hubverse's common .lintr... I see object_usage_linter in several of this PR's nolint directives. Is this something we want to ignore globally, or is it specific to hubUtils?

If the latter is true, would it be worth supplying a project-specific set of configs to this repo (mostly as a convenience in case people forget to add the exception when coding)?

Copy link
Member Author

Choose a reason for hiding this comment

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

There's discussion regarding this here: https://github.com/orgs/Infectious-Disease-Modeling-Hubs/discussions/3#discussioncomment-8477805 & #141

In short, it's useful to not turn off the linter completely but it is problematic with cli messages while purrr calls can avoid triggering false linter positives by switching out formula expressions

@annakrystalli
Copy link
Member Author

Thanks @bsweger ! Added responses in comments

@annakrystalli annakrystalli merged commit 4da82df into main Feb 26, 2024
10 checks passed
@annakrystalli annakrystalli deleted the bugfix/missing-lintr-action branch February 26, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Replace ~ with \(x) in purrr calls that trigger object_usage_linter errors
2 participants