-
-
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
Apply clang-format #6323
Apply clang-format #6323
Conversation
🤖 Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! 🎩
Linux
Windows
macOS🤖{"platform_name_to_artifacts": {"Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://output.circle-artifacts.com/output/job/f8fdeafb-b9cd-4229-8c48-73bb7be732de/artifacts/0/lmms-1.3.0-alpha.1.185+g9c49e78c4-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/16614?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "Windows": [{"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://output.circle-artifacts.com/output/job/511c5315-e9f8-46c1-8175-fac414decf64/artifacts/0/lmms-1.3.0-alpha.1.185+g9c49e78c4-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/16610?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://output.circle-artifacts.com/output/job/a66c729e-287e-4c12-a6b1-53fb597396ad/artifacts/0/lmms-1.3.0-alpha.1.185+g9c49e78c4-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/16612?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/1avf797ms690wya6/artifacts/build/lmms-1.3.0-alpha-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/43398151"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/5shx66gtuim4e77t/artifacts/build/lmms-1.3.0-alpha-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/43398151"}], "macOS": [{"artifact": {"title": {"title": "", "platform_name": "macOS"}, "link": {"link": "https://output.circle-artifacts.com/output/job/5f139266-c005-4dde-9854-6365b97e0966/artifacts/0/lmms-1.3.0-alpha.1.185+g9c49e78c4-mac10.14.dmg"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/16611?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}]}, "commit_sha": "25bc6f40eba4b2c8ce611bcec1beea642c0fed80"} |
I added a github action (see build number 15). |
include/BandLimitedWave.h
Outdated
if (table % 2 == 0) { | ||
return m_data[TLENS[table] + ph]; | ||
} else { | ||
if (table % 2 == 0) { return m_data[TLENS[table] + ph]; } |
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.
The if
is on a single line, but the else
is not. It looks inconsistent.
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.
Putting the else completely into one line seems impossible (possibly a bug or limitation to AllowShortIfStatementsOnASingleLine
). As soon as I turn this else
into an if
, it works.
I can only change it to
if (table % 2 == 0) { return m_data[TLENS[table] + ph]; }
else {
return m_data3[TLENS[table] + ph];
}
Is that better or worse?
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.
This looks better:
if (table % 2 == 0)
{
return m_data[TLENS[table] + ph];
}
else
{
return m_data3[TLENS[table] + ph];
}
A ternary if is even better:
return (table % 2 == 0) ? m_data[TLENS[table] + ph] : m_data3[TLENS[table] + ph];
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 know, but the coding rules said If the block can fit on one line, it is acceptable
. I think we must live with the bad else.
Using a ternary is nice, but clang-format can't do that.
src/gui/editors/PianoRoll.cpp
Outdated
{ | ||
note->setLength(bound); | ||
} | ||
if (constrainMax ? note->length() > bound : note->length() < bound) { note->setLength(bound); } |
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.
It's in 1 line now and fits the 120 columns, so the tool does what we requested, but I'm not sure if it got more readable.
General impressions:
|
@allejok96 Thanks for your review.
Yes, I added
Obscured in what way? Can you please point out which exact line you mean, or paste a code snipped? |
It might be very rare but in this case it feels like the break gets hidden (from PianoRoll's paint event)
|
Indeed, I did not even see this when scrolling through it. Patching clang-format like -AllowShortCaseLabelsOnASingleLine: true
+AllowShortCaseLabelsOnASingleLine: false fixed it. Of course then, some I'm rather for disabling one-line-cases, any opinions? |
@allejok96 , what do you think? |
Glancing over the use of switch statements there are some places where you've got lot of things crammed into one line: case 1: w = (float)fabs(2.0f*(float)sin(fmod(0.5f*ph,TwoPi)))-1.f; break; //sine^2 Or you do this horrible whitespace thing: case Base::UserVST : loc = ConfigManager::inst()->userVstDir(); break; I'd rather see each statement on a separate line.
In theory this would be a problem, but currently the only such switch statement (>20 cases) in non-third-party code is in So my opinion is 👍 @JohannesLorenz |
This adds `.clang-format` and `.clang-tidy` files to check the code (partially) against the [LMMS coding conventions](https://github.com/LMMS/lmms/wiki/Coding-conventions).
f5c4d51
to
25bc6f4
Compare
Thanks @allejok96 ! |
This code here should be the same as in #5948 . Asking for final review.
A good "playground" might be src/gui/editors/PianoRoll.cpp (>5000 lines).
Note: The review can also end with "Let's better not take clang-format", that is also OK.