-
Notifications
You must be signed in to change notification settings - Fork 1k
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 Credo to Elixir test suite #1769
Conversation
Here is a rationale of this PR. I added Credo to the Mix project, then I disabled some "not so useful" checks. They are:
Then, I added Credo to the Makefile and Makefile.win with a proper goal, and I added that goal to The only check I maintained but I changed its exit code to @wohali I think your eyes could be useful here 🙂 |
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.
Overall this looks good, a few minor comments.
I'm eager to get ahead of any code style issues, as our Erlang code base uses a style that presently doesn't have a formal checker (@davisp is working on one...someday...)
Perhaps it's time for me to add black
for our Python code, too... :)
+1 after addressing my small comments
test/elixir/test/test_helper.exs
Outdated
@@ -1,3 +1,5 @@ | |||
# credo:disable-for-this-file Credo.Check.Consistency.ParameterPatternMatching |
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.
Why wouldn't we disable this globally, or fix the problem in this one file? Keep in mind I am new to Elixir, but not to linting and formatting...exceptions in a single file are usually bad news.
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.
Totally agree with @wohali on this one lets avoid file/line specific exemptions unless absolutely necessary.
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.
@dottorblaster This still needs addressing before I can approve this PR.
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.
Done! Sorry, I missed it 🙇
I have a general question about max line length. This commit explicitly sets the max line length to 120, up from its default of 96. For Erlang code, the current consensus (and also @davisp's emelio) appears to be 80, for which there is ample precedent. Because it forces you to write more concise code, and it’s great being able to have two code windows open side by side (on a 15" laptop), I hope we also adopt 80 for Elixir code. But I'm curious to what others think it should be. |
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.
I am totally on board with adding this. Though I also agree with Jay that the 120 line length seems awfully long. I personally prefer 80 but if there's a community consensus around a specific width then I'd of course defer to the existing language consensus.
test/elixir/test/test_helper.exs
Outdated
@@ -1,3 +1,5 @@ | |||
# credo:disable-for-this-file Credo.Check.Consistency.ParameterPatternMatching |
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.
Totally agree with @wohali on this one lets avoid file/line specific exemptions unless absolutely necessary.
@jaydoane After having been an 80-column adherent for 30 years now (I started on VT-52 terminals connected to a PDP-11/34A), I'm growing more in love with slightly longer line length. I want to propose Black for our Python code, which adopts an 88-character limit. They have a researched answer as to why 90-ish is probably better than 80, complete with YouTube video. Over in apache/couchdb-documentation, due to limitations of the ReStructuredText parser and some very long URL references we can't line wrap without breaking the syntax, we've had to recently relax line length from 80 to 90 for similar reasons. |
@jaydoane also, as to your comment on "two code windows open side by side (on a 15" laptop)" is highly variable. I use a 15" laptop and often get 3 or 4 code windows open side by side, with >80 characters each. Resolution and font size (and your own visual acuity!) enter into it a lot :) |
@wohali I much prefer 90 to 120. And you are right about numerous variables factoring into how many characters are comfortable to squeeze on a screen and read easily over long time periods. Hmm, I'm not sure I find it more readable with all the additional vertical space it uses in some places going from 120 to 90. |
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.
Two major changes that need to be addressed, see comments.
@jaydoane Hrm, I don't mind it... |
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.
Another (to-me) mandatory change occurred to me as I was working on my Python code formatting PR.
Some comments on the above discussion:
Enforcing a 90 columns format will cause almost all of our tests to be reformatted. @wohali et al. do you want me to go further or do we want to do that in another subsequent PR? |
Reformatting all the lines that require it to pass a |
@davisp thanks! I'm going further then |
Hi all! Not long ago we also added checking elixir code format with Here is formatter options, In that case |
@dottorblaster sorry, looks like you are going to add |
@van-mronov yeah |
@wohali @davisp @jaydoane @van-mronov I added two more commits for that, gonna edit the Makefile soon, can you provide me feedbacks? @van-mronov I still prefer to maintain max length checks in Credo too because it's more developer friendly. I enforced the value formatter-side as well. |
c8283b5
to
5019b6c
Compare
5019b6c
to
91a58cc
Compare
@wohali just rebased this branch against the recent |
0fd651b
to
6886959
Compare
6886959
to
0e2a0d8
Compare
+1 LGTM |
Overview
This PR adds Credo as the static code analysis tool of choice for the Elixir test suite.
Testing recommendations
Just issue
make elixir-credo
first, thenmake elixir
Related Issues or Pull Requests
#1756
Checklist