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

fangly opened this issue Jan 12, 2017 · 3 comments

Implemented an object_name_linter #194

fangly opened this issue Jan 12, 2017 · 3 comments


Copy link

fangly commented Jan 12, 2017


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, 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:

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



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

Copy link

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?

Copy link
Contributor Author

fangly commented Mar 6, 2017

If you are referring to my 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
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
None yet
None yet

No branches or pull requests

2 participants