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

Add variable names rule #283

Merged
merged 8 commits into from
Oct 20, 2015
Merged

Conversation

harenson
Copy link
Member

No description provided.

{
elvis_style,
variable_naming_convention,
#{regex => "^([A-Z][0-9a-zA-Z]*)*$", ignore => []}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need the external star, i.e. you can get the same results with just [A-Z][0-9a-zA-Z]*.
I'm also pretty sure your regex will render _ThisTotallyValidVariable as invalid.
I think the proper default value should be along the lines of ^_?[A-Z][0-9a-zA-Z]*$ or maybe better we should ignore the leading _ when matching regexes in code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right, let me change it.

@elbrujohalcon
Copy link
Member

Don't forget to add the new rule to the wiki

nomatch ->
Msg = ?VARIABLE_NAMING_CONVENTION_MSG,
Info = [VariableNameStr, Regex],
Result = elvis_result:new(item, Msg, Info, 1),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide the location of the variable in the error message so that it is easier to find. You can check the following code here to know how to extract the location information from a node.

@elbrujohalcon elbrujohalcon self-assigned this Oct 14, 2015
Msg = ?VARIABLE_NAMING_CONVENTION_MSG,
{Line, _} = ktn_code:attr(location, Variable),
Info = [VariableNameStr, Line, Regex],
Result = elvis_result:new(item, Msg, Info, 1),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use Line here, instead of 1

@jfacorro
Copy link
Contributor

@harenson Since another PR was merged before this one, it is necessary to synchronize this branch with the master branch by either merging or rebasing, before we can merge the PR. Thanks!

@harenson
Copy link
Member Author

@jfacorro Ok, I will take care of it in a while.

@harenson
Copy link
Member Author

@jfacorro @elbrujohalcon Thanks for your reviews 👍

jfacorro added a commit that referenced this pull request Oct 20, 2015
@jfacorro jfacorro merged commit 227c30d into inaka:master Oct 20, 2015
@jfacorro
Copy link
Contributor

@harenson Merged! 🎉

@harenson
Copy link
Member Author

🎉

@harenson harenson deleted the issue187-variable-names branch October 20, 2015 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants