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

Run common checks for every single solution; Add common check for snake_case #102

Merged
merged 18 commits into from
Jul 10, 2021

Conversation

angelikatyborska
Copy link
Member

@angelikatyborska angelikatyborska commented Jul 9, 2021

This is my attempt at adding common checks that will be done on every single solution, as suggested in #97

For starters, I'm adding two checks that were pretty easy to implement:

  • module attribute names should be snake_case
  • function names should be snake_case

I can also see that it should be relatively easy to implement a check for PascalCase module names. It might be a bit more difficult to check for snake_case variable names, but still worth it.

I would also want to later add a check for not using tabs for indentation, but only as a informative comment not to be too annoying.

Some checks can be "stolen" from Credo :)

Website copy PR: exercism/website-copy#2019

@angelikatyborska
Copy link
Member Author

@jiegillet your review would also be much appreciated!

Base automatically changed from refactoring to main July 10, 2021 01:55
end

defp to_snake_case(name) do
# Macro.underscore is good enough because a module attribute name must be a valid Elixir identifier anyway
Copy link
Contributor

Choose a reason for hiding this comment

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

100% agree, despite the warning on the function not to use, I see it used everywhere in non-core code :P

Comment on lines 18 to 25
if names == [] do
[]
else
wrong_name =
names
|> Enum.reverse()
|> hd()
|> to_string()
Copy link
Contributor

Choose a reason for hiding this comment

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

Same simplification could be done here

@angelikatyborska
Copy link
Member Author

I'll merge to see it in action and add more checks in new PR(s)

@angelikatyborska angelikatyborska merged commit 1b24399 into main Jul 10, 2021
@angelikatyborska angelikatyborska deleted the camel-case-checks branch July 10, 2021 07:00
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.

2 participants