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

Extend naming conventions with things to avoid #151

Open
elbrujohalcon opened this issue Aug 7, 2020 · 3 comments
Open

Extend naming conventions with things to avoid #151

elbrujohalcon opened this issue Aug 7, 2020 · 3 comments
Milestone

Comments

@elbrujohalcon
Copy link
Member

Currently, our naming convention rules only allow for a single regex that identifies what is permitted/valid.
It would be nice to add an additional forbidden regex to identify things that are not valid, like function names starting with do_.

Ref: WhatsApp/erlfmt#91

@paulo-ferraz-oliveira
Copy link
Collaborator

For semantics purposes, a forbidden keyword might make sense... but then you'd always have to have an order in evaluation: if you accept and negate a given string, which one is valid?

Have you considered negative lookaheads, like ^(?!(^do_)).*$?

> {ok,RE} = re:compile("^(?!do_).*$").
{ok,{re_pattern,0,0,0,
                <<69,82,67,80,87,0,0,0,16,0,0,0,1,128,0,0,255,255,255,
                  255,255,255,...>>}}
> re:run("ado_", RE).                        
{match,[{0,4}]}
> re:run("do_", RE). 
nomatch

@elbrujohalcon
Copy link
Member Author

HA! I didn't know about negative lookaheads.
I still think that a forbidden regex would be clearer and the usual semantics is "allow everything that matches with regex except if it matches forbidden regex". I would go with that, with the default for forbidden being none.

@paulo-ferraz-oliveira
Copy link
Collaborator

with the default for forbidden being none.

It could even be undefined :-)

@elbrujohalcon elbrujohalcon transferred this issue from inaka/elvis Jan 7, 2021
@elbrujohalcon elbrujohalcon added this to the 2.0.0 milestone May 26, 2022
@elbrujohalcon elbrujohalcon modified the milestones: 4.1.0, 4.0.0 Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants