Skip to content

User experience improvements - #245

Merged
AshesITR merged 25 commits into
masterfrom
linter_class
Feb 8, 2021
Merged

AshesITR merged 25 commits into
masterfrom
linter_class

Conversation

@fangly

@fangly fangly commented May 18, 2017

Copy link
Copy Markdown
Contributor

Hi Jim,

Please have a look at the code in this branch. My main objective was to ensure a consistence interface to the different linters because the situation is currently confusing; some linters have to be called with an argument while other must just be identified by name. My proposed solution is to have all linters written so that they need to be called.

Before:

  • semicolon_terminator_linter(semicolon = "compound")
  • T_and_F_symbol_linter

After:

  • semicolon_terminator_linter(semicolon = "compound")
  • T_and_F_symbol_linter() # takes no argument

An advantage of this change is that we can later decide to add optional arguments to any linter without breaking compatibility with prior versions of lintr. So, we introduce an incompatible change now for better user experience and will be able to introduce fewer incompatible changes in the future.

I also gave all the linters the "linter" class and check in lint() that the 'linters' argument only contains objects of class 'linter'. This is to warn users early when they use the 'linters' argument wrongly and prevent them from encountering obscure error messages.

To support these changes, I have added two deprecation messages and work-arounds in lint(). The users are thus informed of the changes but the code should continue to work as before.

Thoughts on the idea or implementation? Cheers,

Florent

fangly added 8 commits May 11, 2017 14:38
+ linters are of the 'linter' class
+ lint checks that the 'linters' argument contains 'linter' objects
1/ when using linters of class 'function' instead of 'linter'
2/ when using linter variables (old interface) instead of calling the linter (new consistent interface)
@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #245 into master will decrease coverage by 0.6%.
The diff coverage is 97.8%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #245      +/-   ##
==========================================
- Coverage   86.13%   85.52%   -0.61%     
==========================================
  Files          39       39              
  Lines        2178     2204      +26     
==========================================
+ Hits         1876     1885       +9     
- Misses        302      319      +17
Impacted Files Coverage Δ
R/zzz.R 0% <ø> (ø) ⬆️
R/expect_lint.R 76.27% <ø> (-7.94%) ⬇️
R/pipe_continuation_linter.R 100% <100%> (ø) ⬆️
R/open_curly_linter.R 100% <100%> (ø) ⬆️
R/spaces_left_parentheses_linter.R 100% <100%> (ø) ⬆️
R/object_name_linters.R 100% <100%> (ø) ⬆️
R/path_linters.R 97.5% <100%> (ø) ⬆️
R/undesirable_operator_linter.R 100% <100%> (ø) ⬆️
R/line_length_linter.R 100% <100%> (ø) ⬆️
R/spaces_inside_linter.R 100% <100%> (ø) ⬆️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b48702b...91b53ac. Read the comment docs.

@fangly

fangly commented Jun 16, 2017

Copy link
Copy Markdown
Contributor Author

Jim, I'd be interested to read what you think of this branch.
Cheers,
Flroent

@jimhester

Copy link
Copy Markdown
Member

I think the ideas here are good, unfortunately it is now pretty far diverged from the current master :(

Would be great if @fangly or someone else would be able to update the code in this PR to merge cleanly with the current lintr codebase.

@AshesITR

Copy link
Copy Markdown
Collaborator

By now, this has diverged even more.
IMO we should add a compatibility layer for old .lintr files to automagically call the linter functions if they have no arguments and issue a warning.

Let me know if you're still interested in this change and I'll try to get the PR going again.

# Conflicts:
#	DESCRIPTION
#	R/T_and_F_symbol_linter.R
#	R/closed_curly_linter.R
#	R/commas_linter.R
#	R/comment_linters.R
#	R/deprecated.R
#	R/expect_lint.R
#	R/extraction_operator_linter.R
#	R/function_left_parentheses.R
#	R/line_length_linter.R
#	R/no_tab_linter.R
#	R/object_name_linters.R
#	R/object_usage_linter.R
#	R/path_linters.R
#	R/pipe_continuation_linter.R
#	R/seq_linter.R
#	R/single_quotes_linter.R
#	R/spaces_inside_linter.R
#	R/spaces_left_parentheses_linter.R
#	R/undesirable_function_linter.R
#	R/undesirable_operator_linter.R
#	R/unneeded_concatenation_linter.R
#	R/zzz.R
#	man/default_linters.Rd
#	man/expect_lint.Rd
#	man/linters.Rd
#	tests/testthat/test-T_and_F_symbol_linter.R
#	tests/testthat/test-absolute_path_linter.R
#	tests/testthat/test-assignment_linter.R
#	tests/testthat/test-cache.R
#	tests/testthat/test-closed_curly_linter.R
#	tests/testthat/test-commas_linter.R
#	tests/testthat/test-error.R
#	tests/testthat/test-extraction_operator_linter.R
#	tests/testthat/test-function_left_parentheses_linter.R
#	tests/testthat/test-infix_spaces_linter.R
#	tests/testthat/test-line_length_linter.R
#	tests/testthat/test-no_tab_linter.R
#	tests/testthat/test-nonportable_path_linter.R
#	tests/testthat/test-object_length_linter.R
#	tests/testthat/test-object_name_linter.R
#	tests/testthat/test-object_usage_linter.R
#	tests/testthat/test-open_curly_linter.R
#	tests/testthat/test-pipe_continuation_linter.R
#	tests/testthat/test-semicolon_terminator_linter.R
#	tests/testthat/test-seq_linter.R
#	tests/testthat/test-single_quotes_linter.R
#	tests/testthat/test-spaces_inside_linter.R
#	tests/testthat/test-spaces_left_parentheses_linter.R
#	tests/testthat/test-todo_comment_linter.R
#	tests/testthat/test-trailing_blank_lines_linter.R
#	tests/testthat/test-trailing_whitespace_linter.R
#	tests/testthat/test-undesirable_function_linter.R
#	tests/testthat/test-undesirable_operator_linter.R
#	tests/testthat/test-unneeded_concatenation_linter.R
#	vignettes/creating_linters.Rmd
@AshesITR

AshesITR commented Feb 4, 2021

Copy link
Copy Markdown
Collaborator

This changeset is absolutely huge.

I merged all R/ files by hand, ported newer linters added since 2017 to the Linter() interface and then fixed all tests that started failing.

I also updated the deprecation note @fangly added to 2.0.1.9001.

Comment thread NEWS.md Resolved
@MichaelChirico

MichaelChirico commented Feb 6, 2021 •

Copy link
Copy Markdown
Collaborator

This changeset is absolutely huge.

FWIW highly recommend viewing the diff with whitespace diffs off in the UI. A lot more manageable:

https://github.com/jimhester/lintr/pull/245/files?diff=unified&w=1

Comment thread R/assignment_linter.R Resolved
Comment thread R/lint.R Resolved
Comment thread R/utils.R Resolved
Comment thread vignettes/creating_linters.Rmd Resolved

@MichaelChirico MichaelChirico left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree it's good to be more consistent about forcing () on the calls.

Mostly minor changes, I'll have another look at the NEWS file once that's cleaned up -- we'll definitely want to surface this high as a breaking change.

And with that, changing to 3.0.0 is definitely warranted (wasn't 100% sure before).

@AshesITR

AshesITR commented Feb 7, 2021

Copy link
Copy Markdown
Collaborator

Yep. NB the compatibility layer issues a warning for the old style, so at least lintr configurations and core linting functions shouldn't break.

Comment thread R/lint.R Resolved
Comment thread R/lint.R Resolved
Comment thread R/utils.R Resolved
MichaelChirico
MichaelChirico previously approved these changes Feb 8, 2021
@AshesITR
AshesITR merged commit 2d76469 into master Feb 8, 2021
@AshesITR
AshesITR deleted the linter_class branch February 8, 2021 19:53
@AshesITR AshesITR linked an issue Feb 8, 2021 that may be closed by this pull request
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.

Unified linter function interface

5 participants