Skip to content

chore: fix with {flir} 💅 #1871

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

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft

chore: fix with {flir} 💅 #1871

wants to merge 13 commits into from

Conversation

maelle
Copy link
Contributor

@maelle maelle commented Jun 10, 2025

I'm not sure we need distinct PRs. 👀

Easy to re-recreate:

linters <- flir::list_linters()
# https://github.com/etiennebacher/flir/issues/80
linters <- setdiff(linters, "T_and_F_symbol")

use_linter <- function(linter) {
  cli::cli_alert_info(linter)
  flir::fix_dir("R", linters = linter)
  flir::fix_dir("tests", linters = linter)
  try(gert::git_commit_all(sprintf("chore: apply linter %s from {flir}", linter)), silent = TRUE)
}

purrr::walk(linters, use_linter)

@@ -805,7 +805,7 @@ print.igraphHRG <- function(x, type = c("auto", "tree", "plain"),
level = 3, ...) {
type <- igraph.match.arg(type)
if (type == "auto") {
type <- if (length(x$left <= 100)) "tree" else "plain"
type <- if (length(x$left) <= 100) "tree" else "plain"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ouch this is probably wrong

@@ -1338,7 +1338,7 @@ print.igraph.vs <- function(x,
":\n"
cat(title)

if (is_single_index(x) && !is.null(graph) && length(vertex_attr_names(graph) > 0)) {
if (is_single_index(x) && !is.null(graph) && length(vertex_attr_names(graph)) > 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

check this as well

@@ -599,7 +599,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) {
on.exit(.Call(R_igraph_finalizer))
tmp <- .Call(
R_igraph_vs_adj, graph, x, as_igraph_es(graph, e) - 1,
as.numeric(3)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this might actually be important here, check others in this commit

@maelle maelle changed the title chore: apply linter any_duplicated from {flir} chore: fix with {flir} 💅 Jun 10, 2025
@krlmlr krlmlr requested a review from Copilot June 12, 2025 08:44
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR applies automated stylistic updates from the {flir} linter across the codebase to improve consistency and leverage newer R primitives.

  • Replaced rep(..., length.out = ...) with rep_len(...) for concise vector recycling.
  • Swapped any(is.na(x)) / any(!is.na(x)) patterns with anyNA(x) / !all(is.na(x)).
  • Used lengths() instead of sapply(..., length) and seq_len() / seq_along() over 1:n.

Reviewed Changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated no comments.

Show a summary per file
File Description
R/plot.common.R rep → rep_len, anyNA pattern
R/plot.R rep → rep_len, numeric literals, anyNA
R/other.R anyNA replacement
R/operators.R anyDuplicated, !all, inherits → inherits, rep_len replacements
R/make.R anyNA replacements
R/layout.R lengths, seq_len, seq_along, anyNA / !all usage, stopifnot tweaks
R/iterators.R anyNA replacements
R/indexing.R lengths, anyNA replacements
R/import-standalone-types-check.R anyNA replacement
R/import-standalone-purrr.R lengths, stopifnot tweaks
R/hrg.R seq_len loops, seq_len for height
R/glet.R anyNA / !all usage, seq_along loops
R/games.R rep_len for list & vector
R/epi.R lengths, rep_len
R/conversion.R lengths, anyNA replacements
R/community.R seq_len, !all usage
R/cohesive.blocks.R lengths usage
R/centrality.R anyNA / !all usage, rowSums
R/attributes.R lengths, anyNA / anyDuplicated usage
R/aaa-auto.R anyNA / !all usage

@maelle
Copy link
Contributor Author

maelle commented Jun 24, 2025

We can re-create the whole PR during the hackathon so you two will see how fast flir is @krlmlr @schochastics 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant