Code style change: Replace clang-format off/on with TODO/TEST comments.#2600
Code style change: Replace clang-format off/on with TODO/TEST comments.#2600hoffie merged 2 commits intojamulussoftware:masterfrom
Conversation
There was a problem hiding this comment.
Yeah. Looks much better now.
Although it's a different idea to make the todo's stand out even more:
// // // TODO BEGIN \\ \\ \\
/* comment */
// // // TODO END \\ \\ \\
might be even more visible. I think my proposal - which you implemented here is somewhat ok, but arguably "standard-ish" and not that outstanding (after looking at the diff. Surely, this would loose the editor highlighting)
linux/sound.cpp
Outdated
| // TODO: BEGIN | ||
| /* do not call malloc in real-time callback | ||
| */ | ||
| // TODO: END |
There was a problem hiding this comment.
| // TODO: BEGIN | |
| /* do not call malloc in real-time callback | |
| */ | |
| // TODO: END | |
| // TODO: BEGIN | |
| /* do not call malloc in real-time callback */ | |
| // TODO: END |
There was a problem hiding this comment.
OK, so for single comments also the closing */ on the same line ?
But that is not according your proposal ;=))
Maybe have a second thought about that, since if we change this how consistent will it still be ?
If we place the comment closing at the end of line than multi line comment should be:
// TODO: BEGIN
/* some comments
and some more comment */
... code...
// TODO: END
to be really consistent.
There was a problem hiding this comment.
I know. But after seeing it in real code, it seemed very strange.
src/buffer.cpp
Outdated
| // TEST: BEGIN | ||
| /* | ||
| // TEST store important detection parameters in file for debugging | ||
| static FILE* pFile = fopen ( "test.dat", "w" ); | ||
| static int icnt = 0; | ||
| if ( icnt == 50 ) | ||
| { | ||
| fprintf ( pFile, "%d %e\n", iCurDecision, dCurIIRFilterResult ); | ||
| fflush ( pFile ); | ||
| icnt = 0; | ||
| } | ||
| else | ||
| { | ||
| icnt++; | ||
| } | ||
| */ | ||
| // TEST: END |
There was a problem hiding this comment.
Yup. After some thinking this looks quite good.
src/channel.cpp
Outdated
| // TODO: BEGIN | ||
| /* if we later do not fire vectors in the emits, we can remove this again | ||
| */ |
There was a problem hiding this comment.
| // TODO: BEGIN | |
| /* if we later do not fire vectors in the emits, we can remove this again | |
| */ | |
| // TODO: BEGIN | |
| /* if we later do not fire vectors in the emits, we can remove this again */ |
src/channel.h
Outdated
| /* TODO needed for compatibility to old servers >= 3.4.6 and <= 3.5.12 | ||
| */ |
src/client.cpp
Outdated
| // TODO: BEGIN | ||
| /* needed for compatibility to old servers >= 3.4.6 and <= 3.5.12 | ||
| */ | ||
| Channel.CreateReqChannelLevelListMes(); | ||
| // TODO: END |
src/main.cpp
Outdated
| // TEST: BEGIN | ||
| /* activate the following line to activate the test bench, | ||
| */ | ||
| // CTestbench Testbench ( "127.0.0.1", DEFAULT_PORT_NUMBER ); | ||
| // TEST: END |
There was a problem hiding this comment.
Previously this looked really nasty. Much better now.
src/protocol.cpp
Outdated
| // TEST: BEGIN | ||
| /* channel implementation: randomly delete protocol messages (50 % loss) | ||
| */ | ||
| // if ( rand() < ( RAND_MAX / 2 ) ) return false; | ||
| // TEST: END |
There was a problem hiding this comment.
Honestly, these tests should not be in the code but somewhere externally. But that's out of scope of this PR
Yes. CONTRIBUTING.md |
To be honest all those slashes and back-slashes make me dizzy, even nauseous if I look too long....
Not necessarily. For most highlighters the keywords are 'TODO:' and 'FIXME:' anywhere in any comment, so as long you keep it uppercase and directly followed by a colon, most highlighters will still work. |
|
I like /*** TODO: BEGIN ***/ since it looks standard-ish. However /### TODO: BEGIN ###/ stands out well too. Would you prefer |
Yes it stands out more, maybe we should combine them to make BEGIN stand out the most? |
|
I'd prefer the consistent approach. |
OK it will be then ? |
|
Yes. If the code already uses a specific multi line comment style this should be used. If not I'd go with your present proposal |
Well most of them use the repeated asterisk: But I think that's over-doing it here. |
|
If it's just "most" not all, I think we're fine with the lighter way — as long as clang-format is happy, I think it's ok. |
Another option is not using block comments at all: I don't like using block comment inside the code anyway, since you can't use block comment to comment out a piece of code containing a block comment. |
|
That's also possible |
ann0see
left a comment
There was a problem hiding this comment.
Great. Thanks. Looks good now.
Can the other PR with clang format be closed then?
| // clang-format off | ||
| // TODO compatibility to old version < 3.8.2 | ||
| if ( GetNumericIniSet ( IniXMLDocument, "server", "centservaddrtype", static_cast<int> ( AT_DEFAULT ), static_cast<int> ( AT_CUSTOM ), iValue ) ) | ||
| { | ||
| directoryType = static_cast<EDirectoryType> ( iValue ); | ||
| } | ||
| else | ||
| // clang-format on | ||
|
|
||
| //### TODO: BEGIN ###// | ||
| // compatibility to old version < 3.8.2 | ||
| if ( GetNumericIniSet ( IniXMLDocument, | ||
| "server", | ||
| "directorytype", | ||
| static_cast<int> ( AT_NONE ), | ||
| "centservaddrtype", | ||
| static_cast<int> ( AT_DEFAULT ), | ||
| static_cast<int> ( AT_CUSTOM ), | ||
| iValue ) ) | ||
| { | ||
| directoryType = static_cast<EDirectoryType> ( iValue ); | ||
| } | ||
| //### TODO: END ###// | ||
|
|
||
| else if ( GetNumericIniSet ( IniXMLDocument, | ||
| "server", | ||
| "directorytype", | ||
| static_cast<int> ( AT_NONE ), | ||
| static_cast<int> ( AT_CUSTOM ), | ||
| iValue ) ) | ||
| { | ||
| directoryType = static_cast<EDirectoryType> ( iValue ); | ||
| } |
There was a problem hiding this comment.
The diff looks a bit strange due to reformatting here, but I think it's ok.
There was a problem hiding this comment.
Yeah, I had too look 3 times too here...
Looks a bit strange because of the splitting up of if else.
If I remember well this was exactly the spot where also clang-format got confused ;=))
|
Note to maintainers: This should be squash merged. |
Yes. I will close it.. |
There was a problem hiding this comment.
Thanks! I've got one minor nit/question -- see inline review comment.
I guess one could bike-shed about the proper style here. The syntax looks non-natural to me, but I guess one can get used to it. In the end, it doesn't matter that much and if done consistently -- which seems to be the case -- it can easily be changed if wanted.
Ideally, such changes would be ok'ed by all maintainers, but that's rather hard right now as per #2617.
As the issue and this PR have been open for some time now, I guess it's ok to merge even without more maintainer acknowledgements.
@pgScorpio I've got two general remarks:
- If a commit and/or PR fixes an issue, you can use the "Fixes #0000" syntax in order to make Github link the PR to the Issue automatically. This will also auto-close the issue on PR-merge. I've done that manually here now.
- Our CHANGELOG helper currently only understands single lines, i.e. the actual content has to stay on the same line as the keyword for it to be used. I'm therefore re-mentioning it here with slight variation.
CHANGELOG: Code style: Use TODO and TEST comments instead of un-indenting with clang-format off/on
Note to maintainers:
- Should be squashed / commit message-edited
- Might want to cherry-pick the add-to-authors commit from one of the other PRs here.
I can do both once the PR is fully approved.
|
@hoffie @pgScorpio I think the last commit made clang-format fail??? |
|
@annosee
That's the other clang-format quirk again ! A 149 character long line on windows (CR/LF) is 150 chars long for clang-format ! Nothing I can do about that.... EDIT: I re- clang-formatted on linux, so it should be ok now. |
|
Sorry for the long delay to re-review. Sadly, there are conflicts by now, most likely due to the sound backend moving. Therefore, I'm not clicking "approve" although this should be fine to do once the conflicts are fixed. |
Yeah, the very disadvantage of waiting to long with merging PR's is the risk on conflicts ;=) |
hoffie
left a comment
There was a problem hiding this comment.
I haven't investigated why, but the diff of this PR looks really strange now.
On Github it appears to re-list changes from other PRs/commits and I can't tell why (e.g. .github/autobuild/android.sh).
On CLI, it looks less confusing but there are diff hunks which revert parts of another PR:
$ git diff upstream/master..pr2600 src/serverdlg.cpp
diff --git a/src/serverdlg.cpp b/src/serverdlg.cpp
index 968aa2f4..6aadcd28 100644
--- a/src/serverdlg.cpp
+++ b/src/serverdlg.cpp
@@ -175,16 +175,14 @@ CServerDlg::CServerDlg ( CServer* pNServP, CServerSettings* pNSetP, const bool b
pbtRecordingDir->setWhatsThis ( "<b>" + tr ( "Main Recording Directory" ) + ":</b> " +
tr ( "Click the button to open the dialog that allows the main recording directory to be selected. "
"The chosen value must exist and be writeable (allow creation of sub-directories "
- "by the user %1 is running as)." )
- .arg ( APP_NAME ) );
+ "by the user Jamulus is running as)." ) );
...
No idea what happened... I just did a rebase, and there was just one conflict in a comment. all other changes are by auto-merge... |
|
No. That's not normal. I've seen this quite often in the past and it always was a hint that this could lead to a huge screw up. What were the exact commands you were using? |
Just as usual: |
Maybe? The PR in this state is not mergable unfortunately. Can you try the rebasing again or cherry pick the commits on a new branch? |
I did a reset of the last commit... |
There was a problem hiding this comment.
Thanks @pgScorpio! Looks good now.
I've squashed the commits and cherry-picked your contributors list addition from another PR.
Will merge when CI is done/green.
Changes as discussed in issue #2591
Short description of changes
Replace clang-format off/on with TODO/TEST comments where applicable.
CHANGELOG: Internal: Code style: TODO and TEST comments instead of un-indenting with clang-format off/on
Context: Fixes an issue?
partly solves clang-format problems (#2587)
Does this change need documentation? What needs to be documented and how?
Maybe we should document this new coding-style rule somewhere?
Status of this Pull Request
Ready to merge
What is missing until this pull request can be merged?
Review
Checklist