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

Special case id/exceptions for NameFormatViolation #231

Closed
jakecraige opened this issue Nov 23, 2015 · 5 comments
Closed

Special case id/exceptions for NameFormatViolation #231

jakecraige opened this issue Nov 23, 2015 · 5 comments
Labels
enhancement Ideas for improvements of existing features and rules. rule-request Requests for a new rules.

Comments

@jakecraige
Copy link
Contributor

We tend to have properties called id on objects and we always get the NameFormatViolation error because of it. Generally I like this rule but it's annoying when it does it for ID. I'd propose 2 solutions, one temporary, one more permanent.

  1. Special case id so that it won't trigger this violation. It's a pretty common thing I'd assume and I haven't seen anyone take issue with something called id before.
  2. Add configuration for "exceptions" to this rule and the user could then add "id" to the list of exceptions.

screen shot 2015-11-23 at 16 04 26

Thoughts?

@jpsim jpsim added rule-request Requests for a new rules. enhancement Ideas for improvements of existing features and rules. labels Nov 23, 2015
@jpsim
Copy link
Collaborator

jpsim commented Nov 23, 2015

Those are interesting requests.

Special casing id makes sense to me, but then again it's a slippery slope and sets a dangerous precedent 😬.

I have trouble coming up with a nice way to provide "exceptions" via a configuration file.

Perhaps an array of exceptions, that's independently regex'd, and violations within those regex match ranges are filtered out?

exceptions:
  - "(var|let) id:"

@jakecraige
Copy link
Contributor Author

Agreed that special casing sets a dangerous precedent. There's also bound to be others that come up so it would be nicer to have a way for people to set whatever they want.

I was thinking more of exceptions for this specific rule rather than a global one, perhaps something like:

variable_name_permitted_names:
  - id

Going a little further, nesting config values would be nice, but I'm sure that's a larger change.

Ex:

variable_name:
  permitted_names:
    - id
  min_length:
    warning: 2
    error: 3

@arsonik
Copy link

arsonik commented Nov 24, 2015

Same remark for "Variable Name Violation (should start with lowercase)" would be great to have exception like :

func test(URL: NSURL) {

}

cause I know that in Cupertino you can do stuff like :

let request = NSURLRequest(URL: url)

@scottrhoyt
Copy link
Contributor

+1 For the config file exception route.

@qalandarov
Copy link

Thanks to this comment, this is what I came up with:

identifier_name:
  excluded: # excluded via string array
    - id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Ideas for improvements of existing features and rules. rule-request Requests for a new rules.
Projects
None yet
Development

No branches or pull requests

5 participants