-
Notifications
You must be signed in to change notification settings - Fork 56
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
add forbidden regex #377
base: main
Are you sure you want to change the base?
add forbidden regex #377
Conversation
Co-authored-by: Brujo Benavides <[email protected]>
Co-authored-by: Brujo Benavides <[email protected]>
dddb8af
to
40edae8
Compare
Co-authored-by: Brujo Benavides <[email protected]>
But what's the problem with |
The implicit specification for Taking advantage of an optimization to mess up with the expected semantics of an expression is not a great thing to do. First of all, nothing prevents the OTP team from changing that behaviour in the future and crash if the second part is not a boolean (that would be semantically correct, anyway). But more importantly… for developers reading that code… finding something that's not a boolean there is unexpected and surprising future devs is not usually a good thing in terms of maintainability. |
I'll leave the PR open for another day so @paulo-ferraz-oliveira can review… and if he doesn't request changes by then, I'll merge it. |
src/elvis_style.erl
Outdated
"The function ~p is written in a forbidden format" | ||
"defined by the regular expression '~p'."). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these should refer "name" instead of format, because function format is odd to read. I'll probably not be able to comment on the other warnings because they're outside the scope of the pull request, but you could change them all to e.g. "Function ~p's name does not...", "Variable ~p's name, on line ~p, does not...", etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally approving, but did comment on a few things that could be improved.
Thank you for this explanation. I truly appreciate these "small"(but important) things that I can't learn anywhere else. Thanks again for the effort you put into these reviews! |
@bormilan, it's also one of the reasons behind https://github.com/inaka/elvis_core/blob/main/doc_rules/elvis_style/no_block_expressions.md. I was seeing (and writing, since Erlang didn't forbid me) code like: Connected andalso begin
NumberOfEvents = num_events(...)
NumberOfEvents > 10 orelse log(...)
end While that works, it's generally messy to maintain. |
Thank you for the hint and all the reviews, too! |
Co-authored-by: Paulo F. Oliveira <[email protected]>
Co-authored-by: Paulo F. Oliveira <[email protected]>
Co-authored-by: Paulo F. Oliveira <[email protected]>
Co-authored-by: Paulo F. Oliveira <[email protected]>
If it's okay, I will rebase it to prepare for the merge. |
Description
I added the `forbidden_regex' to all "naming_convention" rules.
I made tests for a simple case about making numbers forbidden.
I can't decide in these situations that making a "case in case" is a good implementation. I feel that moving these into another function is not much cleaner, and maybe reading is more frustrating if you need to look into another function just for another case. What do you think about it?
Closes #151.