Package: flint 0.1.0

flint: Find and Fix Lints in R Code

Lints are code patterns that are not optimal because they are inefficient, forget corner cases, or less readable. 'flint' provides a small set of functions to detect those lints and automatically fix them. It builds on 'astgrepr', which itself uses the Rust crate 'ast-grep' to parse and navigate R code.

Authors:Etienne Bacher [aut, cre, cph]

flint_0.1.0.tar.gz
flint_0.1.0.zip(r-4.5)flint_0.1.0.zip(r-4.4)flint_0.1.0.zip(r-4.3)
flint_0.1.0.tgz(r-4.4-any)flint_0.1.0.tgz(r-4.3-any)
flint_0.1.0.tar.gz(r-4.5-noble)flint_0.1.0.tar.gz(r-4.4-noble)
flint_0.1.0.tgz(r-4.4-emscripten)flint_0.1.0.tgz(r-4.3-emscripten)
flint.pdf |flint.html
flint/json (API)
NEWS

# Install 'flint' in R:
install.packages('flint', repos = c('https://etiennebacher.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/etiennebacher/flint/issues

On CRAN:

5.44 score 42 stars 2 scripts 60 exports 11 dependencies

Last updated 1 months agofrom:02ae2d21d9 (on v0.1.1). Checks:OK: 7. Indexed: yes.

TargetResultDate
Doc / VignettesOKNov 14 2024
R-4.5-winOKNov 14 2024
R-4.5-linuxOKNov 14 2024
R-4.4-winOKNov 14 2024
R-4.4-macOKNov 14 2024
R-4.3-winOKNov 14 2024
R-4.3-macOKNov 14 2024

Exports:any_duplicated_linterany_is_na_linterclass_equals_lintercondition_message_linterdouble_assignment_linterduplicate_argument_linterempty_assignment_linterequal_assignment_linterequals_na_linterexpect_comparison_linterexpect_identical_linterexpect_length_linterexpect_named_linterexpect_not_linterexpect_null_linterexpect_true_false_linterexpect_type_linterfixfix_dirfix_packagefix_textfor_loop_index_linterfunction_return_linterimplicit_assignment_linteris_numeric_linterlength_levels_linterlength_test_linterlengths_linterlibrary_call_linterlintlint_dirlint_packagelint_textlist_lintersliteral_coercion_lintermatrix_apply_lintermissing_argument_linternested_ifelse_linternumeric_leading_zero_linterouter_negation_linterpackage_hooks_linterpaste_linterredundant_equals_linterredundant_ifelse_linterrep_len_linterright_assignment_lintersample_int_lintersemicolon_linterseq_lintersetup_flintsetup_flint_ghasort_linterT_and_F_symbol_lintertodo_comment_linterundesirable_function_linterundesirable_operator_linterunnecessary_nesting_linterunreachable_code_linterupdate_flintwhich_grepl_linter

Dependencies:astgreprbackportscheckmateclicrayondata.tabledigestfsgit2rrrapplyyaml

Adding new rules

Rendered fromadding_rules.Rmdusingknitr::rmarkdownon Nov 14 2024.

Last update: 2024-10-07
Started: 2024-07-01

Readme and manuals

Help Manual

Help pageTopics
Require usage of 'anyDuplicated(x) > 0' over 'any(duplicated(x))'any_duplicated_linter
Require usage of 'anyNA(x)' over 'any(is.na(x))'any_is_na_linter
Block comparison of class with '=='class_equals_linter
Block usage of 'paste()' and 'paste0()' with messaging functions using '...'condition_message_linter
double_assignmentdouble_assignment_linter
Duplicate argument linterduplicate_argument_linter
empty_assignmentempty_assignment_linter
equal_assignmentequal_assignment_linter
Equality check with NA linterequals_na_linter
Require usage of 'expect_gt(x, y)' over 'expect_true(x > y)' (and similar)expect_comparison_linter
Require usage of 'expect_identical(x, y)' where appropriateexpect_identical_linter
Require usage of 'expect_length(x, n)' over 'expect_equal(length(x), n)'expect_length_linter
Require usage of 'expect_named(x, n)' over 'expect_equal(names(x), n)'expect_named_linter
Require usage of 'expect_false(x)' over 'expect_true(!x)'expect_not_linter
Require usage of 'expect_null' for checking 'NULL'expect_null_linter
Require usage of 'expect_true(x)' over 'expect_equal(x, TRUE)'expect_true_false_linter
Require usage of 'expect_type(x, type)' over 'expect_equal(typeof(x), type)'expect_type_linter
Automatically replace lintsfix fix_dir fix_package fix_text
Block usage of for loops directly overwriting the indexing variablefor_loop_index_linter
Lint common mistakes/style issues cropping up from return statementsfunction_return_linter
implicit_assignmentimplicit_assignment_linter
Redirect 'is.numeric(x) || is.integer(x)' to just use 'is.numeric(x)'is_numeric_linter
Require usage of nlevels over length(levels(.))length_levels_linter
Check for a common mistake where length is applied in the wrong placelength_test_linter
Require usage of 'lengths()' where possiblelengths_linter
Library call linterlibrary_call_linter
List all lints in a file or a directorylint lint_dir lint_package lint_text
Get the list of linters in 'flint'list_linters
Require usage of correctly-typed literals over literal coercionsliteral_coercion_linter
Require usage of 'colSums(x)' or 'rowSums(x)' over 'apply(x, ., sum)'matrix_apply_linter
Missing argument lintermissing_argument_linter
Block usage of nested 'ifelse()' callsnested_ifelse_linter
Require usage of a leading zero in all fractional numericsnumeric_leading_zero_linter
Require usage of '!any(x)' over 'all(!x)', '!all(x)' over 'any(!x)'outer_negation_linter
Package hooks linterpackage_hooks_linter
Raise lints for several common poor usages of 'paste()'paste_linter
Block usage of '==', '!=' on logical vectorsredundant_equals_linter
Prevent 'ifelse()' from being used to produce 'TRUE'/'FALSE' or '1'/'0'redundant_ifelse_linter
Require usage of rep_len(x, n) over rep(x, length.out = n)rep_len_linter
right_assignmentright_assignment_linter
Require usage of sample.int(n, m, ...) over sample(1:n, m, ...)sample_int_linter
Semicolon lintersemicolon_linter
Sequence linterseq_linter
Setup flintsetup_flint
Create a Github Actions workflow for 'flint'setup_flint_gha
Check for common mistakes around sorting vectorssort_linter
'T' and 'F' symbol linterT_and_F_symbol_linter
TODO comment lintertodo_comment_linter
Undesirable function linterundesirable_function_linter
Undesirable operator linterundesirable_operator_linter
Block instances of unnecessary nestingunnecessary_nesting_linter
Block unreachable code and comments following return statementsunreachable_code_linter
Update the 'flint' setupupdate_flint
Require usage of grep over which(grepl(.))which_grepl_linter