-
New linters:
expect_s3_class_linter()(@trevorld, #110)expect_s4_class_linter()(@trevorld, #109)nzchar_linter()(@trevorld, #102)vector_logic_linter()(@trevorld, #111)
-
New vignette "Tips and tricks" that lists some solutions for problems one may encounter when writing new rules (#94).
-
When using external rules with the
with-<pkg>syntax, if the YAML file contains several rules separated by "---", thenflirwould only use the first one. This is now fixed (#95). -
list_linters()now usespath = "."by default (#99). -
lint_text()andfix_text()now work correctly with custom rules when the working directory is neither an R package nor an RStudio project (#119).
expect_type_linter()now has less false positives for non-typeis.*()functions and also provides more fixes (@trevorld, #110).
This is the first CRAN release.
-
add_new_rule()now errors if the file already exists (#87). -
In all functions that create or modify files (
fix(),setup_flir(), etc.), the argumentpathhas to be specified. Linting functions keep using the default path".". This is due to the CRAN policy that a package cannot modify the user file system (#79).
-
Most
fix_*()functions have a new argumentinteractive(FALSEby default). When set toTRUE, it opens a Shiny app in the Viewer so that the user can review fixes that would be applied to a file. It is therefore possible to accept or skip fixes on a file-by-file basis (#76). -
In R packages, it is now possible to create a list of rules that will be available to the users of the package. This can be useful to provide automatic fixes for deprecated or superseded functions, for example. More information is available in the vignette "Sharing rules across packages". Thanks to @maelle and @Bisaloo for the suggestion and early feedback on the implementation (#78, #84).
-
add_new_rule()now accepts severalnames at once (#88).
-
unreachable_codeis deactivated by default. It can still be activated with the argumentlintersor inflir/config.ymlafter runningsetup_flir()(#75). -
T_and_F_symboldo not detect anymore the use ofFandTwhen those are used in the:operation (#81). -
semicolon_linteris no longer used. It is a linter related to code formatting only and therefore isn't in the scope offlir(and the current implementation was buggy). It is also handled by theAirformatter (#93).
lint_*()andfix_*()now work with relative paths to YAML files, for examplelint(linters = "my_rule.yml")(#92).
- Linters related to
testthat(such asexpect_named) are ignored if the files that are parsed belong to a package that doesn't have atests/testthatfolder (for instance if you usetinytestinstead). (#74)
-
Changes were still directly applied to files that are unstaged in Git while there should have been a warning. This is now fixed.
-
Properly skip changes in the user picks "No" in the menu about modifying unstaged files in Git.
setup_flir()no longer imports all built-in rules in theflir/rulesfolder. Those are now directly read from the folder wherefliris installed. Consequently,update_flir()has been removed as it has no purpose anymore (#66).
- New function
add_new_rule()to create the template for a new rule inflir/rules/custom(#67).
- Fix error in replacement in rule
sample_int-4.
-
BREAKING:
flintis renamedflirto avoid namespace conflict with the recentflintpackage on CRAN. Thanks to Mikael Jagan for the warning (#63).Consequences:
setup_flint()is renamedsetup_flir()and creates a folder namedflirinstead offlint;setup_flint_gha()is renamedsetup_flir_gha()and creates a YAML file namedflir.ymlinstead offlint.yml;update_flint()is renamedupdate_flir();- ignoring specific lines now requires
flir-ignoreinstead offlint-ignore; - the environment variable
FLINT_ERROR_ON_LINTis renamedFLIR_ERROR_ON_LINT; - if
flintwas used in a package,.Rbuildignoremust be updated to ignore the folderflirinstead offlint.
- New environment variable
FLINT_ERROR_ON_LINTto determine whetherflintshould error if some lints were found.
-
No longer error about unavailable sourceMarkers when running
lint()in Positron. -
Better detection of
flint/config.ymlwhen using runningflinton a package or a directory. -
The cache used after
setup_flir()is now invalidated if the rules used change. -
Do not print "empty data.table(...)" when no lints are detected.
-
New linter
stopifnot_all_linter()to detect calls tostopifnot(all(...))since theall()is unnecessary. This has an automatic fix available. -
New linter
list_comparison_linter()to detect a comparison with a list, e.g.lapply(x, sum) > 10. No automatic fix available. -
Line breaks are removed from multi-line messages reported by
lint*functions. -
matrix_apply_linternow detects when1Land2Lare used in theMARGINargument. -
any_is_na_linternow reports cases likeNA %in% x, and can fix them to beanyNA(x)instead.
-
library_call_linterno longer reports cases wherelibrary()calls are wrapped insuppressPackageStartupMessages(). -
Nested fixes no longer overlap. The
fix*()functions now run several times on the files containing nested fixes until there are no more fixes to apply. This can be deactivated to run only once per file by addingrerun = FALSE(#61). -
any_is_na_linterwrongly reported cases likeany(is.na(x), y). Those are no longer reported. -
No longer lint and fix
expect_equal(length(x), length(y)), which is more readable thanexpect_length(x, length(y)). -
No longer lint and fix
expect_equal(names(x), names(y)), which is more readable thanexpect_named(x, names(y)).
sample(n, m)is now reported and can be rewritten assample.int(n, m)whennis a literal integer.
-
Rule names have been harmonized to use a dash instead of underscore, e.g.
any_duplicated-1instead ofany_duplicated_1. -
Replacement of
redundant_ifelse_linterof the formifelse(cond, FALSE, TRUE)now works (#57). -
absolute_path_linterwas deactivated in 0.0.5 but was still reported. It is now properly ignored. -
Code like
expect_equal(typeof(x), 'class')was modified twice byexpect_identical_linterandexpect_type_linter, which lead to a wrong rewrite. It is now replaced byexpect_type(x, 'class').
-
fix()andlint()now work correctly when several paths are passed. -
fix_package()andlint_package()used all R files present from the root path, even those in folders that are not typical of an R package. -
fix_dir()andfix_package()now have the argumentsforceandverbose, likefix().
- New linters:
rep_len_linter(),sample_int_linter()andwhich_grepl_linter(). - Add a menu or an error if
fix()and its variants would change some unstaged files. update_flint()now updates all rules and doesn't only add new rules anymore.
- New linters:
condition_message_linter()andexpect_identical_linter(). - Rewrote vignette on adding new rules.
setup_flir()now puts built-in rules inflint/rules/builtin.
- New linters:
expect_comparison_linterandpackage_hooks_linter. - Add argument
verbosetolint_package()andlint_dir(). - Better message when no lints can be fixed.
- Add one case in
seq_linterwhereseq_len(x)is faster thanseq(1, x). - Better handling of
exclude_path.
- Set up the Github Actions workflow for
flint(#22). - New linters
function_return_linterandtodo_comment_linter. - Better support for
library_call_linter. - Add argument
overwritetosetup_flir_gha().
- New linter
redundant_equals_linter. - Better support for
matrix_apply_linter.
- Deactivated
absolute_path_linterin default use as there are too many false positives. - New linter
unnecessary_nesting_linter. - Add messages for
lint()andfix()showing the number of files checked, lints found and/or fixed.
- More robust detection of allowed usage of
TandFin formulas. - Use the pipe in the replacement for
lengths_linterif it was already present in code.
- Add links to
lintrdocumentation in the manual pages.
- New linters:
for_loop_index,missing_argument. fix()has a new argumentforce(FALSEby default). This is useful if Git was not detected,fix()would modify several files, and it is run in a non-interactive context. In this situation, setforce = TRUEto apply the fixes anyway.- Add
climessages informing how many files are checked, and how many contain lints (forlint_*functions) or were modified (forfix_*functions). - Better coverage of the
length_testlinter.
- Allow usage of
TandFin formulas (#33).
- New linters:
absolute_path,duplicate_argument,empty_assignment,expect_length,expect_not,expect_null,expect_true_false,expect_type,literal_coercion,nested_ifelse,sort,undesirable_operator. - Added a contributing guide.
- Better docs for
fix()and its variants. - Using
fix()on several files without using Git now opens an interactive menu so that the user confirms they want to runfix(). In case of non-interactive use, this errors. - Ignore lines following
# nolintfor compatibility withlintr.
- Fix a few false positives (#23, #24, #27).
-
New linters:
expect_named,numeric_leading_zero,outer_negation,redundant_ifelse,undesirable_function,unreachable_code. -
fix_dir(),fix_package(),lint_dir(),lint_package()now have arguments to exclude paths, linters, and use cache. -
Removed
browserlinter (it is now part ofundesriable_function). -
Add support for a
flint/config.ymlfile that contains the list of linters to use so that one doesn't need to constantly specify them inlint()orfix().
- Do not lint for
x %in% class(y)wherexis not a string as this is not equivalent in some cases. Thanks Vincent Arel-Bundock for spotting this.
- First Github release.