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

Non ascii operators are rejected by identifier_name for not starting with a lowercase letter. #1762

Closed
ryanbooker opened this issue Aug 10, 2017 · 14 comments · Fixed by #5362
Labels

Comments

@ryanbooker
Copy link
Contributor

ryanbooker commented Aug 10, 2017

While ["/", "=", "-", "+", "!", "*", "|", "^", "~", "?", ".", "%", "<", ">", "&"] are specifically allowed as the first character of operators, anything else is rejected.

e.g. using as the compose operator or § as function application is relatively common and useful. Including them in allowed_symbols doesn't circumvent this behaviour. Should it? The isOperator function seems otherwise very narrow in its permissiveness.

I don't really want to disable the entire feature just to allow these functions.

@marcelofabri
Copy link
Collaborator

Including them in allowed_symbols doesn't circumvent this behaviour. Should it?

I think so.


Also, I think there's another bug in the implementation currently:

let containsAllowedSymbol = configuration.allowedSymbols.contains(where: name.contains)
                if !containsAllowedSymbol &&
                    !CharacterSet.alphanumerics.isSuperset(ofCharactersIn: name) 

This doesn't seem to guarantee that all non-alphanumeric characters in name are in configuration.allowedSymbols.

@ryanbooker
Copy link
Contributor Author

OK. Cheers. I'll work on something for this in the next couple of days.

@dcutting
Copy link

dcutting commented Nov 8, 2017

Was there any progress on this? I'm trying to permit variables/functions that begin with underscores.

@SDGGiesbrecht
Copy link
Contributor

@dcutting, this comment in the related pull request describes the current state of things.

@weakfl
Copy link

weakfl commented Apr 3, 2018

In #2134 @marcelofabri wrote:

SwiftLint started validating local variables with Xcode 9.3.

This has quite an impact on this issue, because now all local variables that start with an underscore are flagged as errors and since allowed_symbols does not work, there's no option to prevent this.

Also looks like a regression of #628, unless the default behaviour has been changed on purpose.

@mylemans
Copy link

We are running in the same issue.

@ryanbooker
Copy link
Contributor Author

I don't think I ended up pushing anything. I got sidetracked onto work. :\

@Sajjon
Copy link

Sajjon commented Jun 20, 2018

We are running in the same issue.

@endogenesis
Copy link

allowed_symbols not works for enum cases

@aklowther
Copy link

has anyone been able to give this attention?

@stale
Copy link

stale bot commented Nov 8, 2020

This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!

@stale stale bot added the wontfix label Nov 8, 2020
@stale stale bot closed this as completed Nov 15, 2020
@colbad2
Copy link

colbad2 commented Jan 17, 2021

Still an issue

@jpsim jpsim reopened this Feb 23, 2021
@jpsim jpsim removed the wontfix label Feb 23, 2021
@billburgess
Copy link

This seems like a huge issue that hasn't been fixed in over 5 years. What the heck?! It seems like allowing characters in your variable, types, etc is a huge oversight. This rule is unusable which means you can't even enforce simple length checks on variables.

@SimplyDanny
Copy link
Collaborator

The original issue has been fixed by supporting a new option additional_operators in the rule's configuration. Just add the symbols you want to have considered as operators to the list and the rule will keep silence on them.

Furthermore, the rule has completely been rewritten so that a few false positives or configuration issues should have been fixed as well. For anything more, that doesn't work as you expect, please create separate issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.