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

Implemented an object_name_linter #194

Closed
fangly opened this issue Jan 12, 2017 · 3 comments
Closed

Implemented an object_name_linter #194

fangly opened this issue Jan 12, 2017 · 3 comments

Comments

@fangly
Copy link
Contributor

fangly commented Jan 12, 2017

Hi,

I have written a new linter, called object_name_linter, which includes the features of the existing name
linters (camel_case_linter, snake_case_linter and mutiple_dots_linter) and adds new ones.

Features of object_name_linter:

  • A single linter is needed to check for naming style (instead of several currently). Just specify the style to use and all others will be linted (including unrecognized styles, e.g. in a name like "my_inconsistentStyle").
  • Possibility to enforce new styles: "alllowercase" and "UPPERCASE".
  • The camelcase style is split into "UpperCamelCase" and "lowerCamelCase"
  • The linters are digit-aware, i.e. digits count as both lowercase or uppercase and a name such as "html5Parser" is thus valid "lowerCamelCase" (in contrast with camel_case_linter).
  • Style checking is turned off for names from functions that seem to extend known generics (even
    those that contain mutiple dots such as as.data.frame.data.frame), and this without having to load
    or require any packages.
  • Private objects (with a name starting with one or multiple dots) are supported. Thus, ".my_var" is
    valid "snake_case".
  • Quoted functions and operators are properly handled, i.e. backticks are removed and operators like %in% are not subjected to a style check.
  • Only newly-defined object are submitted to style checking. This prevents imported functions (and other objects) to trigger lints.

This work partially derives from discussions at:
#108
#182
#183
#191

In my opinion, object_name_linter could effectively replace the existing name linters.

Best,

Florent

PS/ Not having the ability to contribute code directly through Github, I am attaching my code and unit tests here: object_name_linter.zip

@jimhester
Copy link
Member

Florent, I think you have since worked around the issues you were having and can now contribute code directly. Could you open a PR for this contribution?

@fangly
Copy link
Contributor Author

fangly commented Mar 6, 2017

If you are referring to my github.com issues, this is a no, since the access is blocked from my workplace.
I have ten or so linters that have been working well for my purpose (including this object_name_linter). The best I could do is to make a patch for each of them against the latest master version of lintr.

fangly added a commit to fangly/lintr that referenced this issue Mar 8, 2017
* features of the linter described at r-lib#194
* default_linters() changed accordingly (enforce lowerCamelCase)
* refactored make_object_linter() since it returned too many objects that were out of the scope, and failed to return some that were
@fangly
Copy link
Contributor Author

fangly commented Mar 13, 2017

Fixed in #214

@fangly fangly closed this as completed Mar 13, 2017
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

No branches or pull requests

2 participants