Description, because “alt text” can’t show it well:

			{
				emit differentFiles (ckFile.absoluteFilePath(),
					otherFile.absoluteFilePath(),
					FileCompareWorker::FileComparisonParams{FileComparisonParams::FileNameMatch,
						(ckFile.size() > otherFile.size()) ? FileComparisonParams::File1IsLarger
							: FileComparisonParams::File2IsLarger});
			}

After Alignment

			{
				emit differentFiles (ckFile.absoluteFilePath(),
					otherFile.absoluteFilePath(),
					FileCompareWorker::FileComparisonParams{FileComparisonParams::FileNameMatch,
						(ckFile.size() > otherFile.size()) ? FileComparisonParams::File1IsLarger
														   : FileComparisonParams::File2IsLarger});
			}
    • ulterno@programming.devOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 years ago

      I am noone to say no to your preferences. and you can set your config that way.
      I want the “before” in my project.


      Also, consider the case where the thing after the : were longer and it would be using another line.

  • Eager Eagle@lemmy.world
    link
    fedilink
    English
    arrow-up
    8
    ·
    2 years ago

    is it my lack of go skills, or they’re both really awful to read? It takes me multiple seconds to match the first parenthesis opened and it seems the code could really use a refactoring, but both formatting options suck.

    • ulterno@programming.devOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 years ago

      Honestly, I’d prefer all curly’s in a new line, indented according to the previous one and in some cases, even parentheses in new lines.

      But if I had a problem with that, I would just go ahead and break the line down (that’s a single statement, I consider it 1 line of code) into multiple, with the arguments put into variables.

  • Lucien [he/him]@mander.xyz
    link
    fedilink
    arrow-up
    7
    arrow-down
    1
    ·
    2 years ago

    Like the other commented said, this isn’t random, but also I’d add that your first ternary option, the ?, should be on the next line; it would make the alignment make more sense to you then, and it would make the block more legible.

    • ulterno@programming.devOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      2 years ago

      I think I’d rather go with the ? being on the same line as the ‘condition’ and the rest can go on the other line.

      Otherwise, I’d be looking one line downwards and then coming back up after realising that it is a (cond)?ex:ex operator.


      And I get that it’s not random, just that I asked for it at as many places as possible to not do alignment.
      And from what I can recall, I had managed to make stuff work with the older clang-formats…
      Or maybe not. Maybe this kind of code never went through it.

  • ulterno@programming.devOP
    link
    fedilink
    English
    arrow-up
    2
    ·
    2 years ago

    BTW, I changed my code to avoid the formatting:

    {
    	if (ckFile.size() > otherFile.size())
    	{
    		emit differentFiles (ckFile.absoluteFilePath(),
    			otherFile.absoluteFilePath(),
    			FileCompareWorker::FileComparisonParams{
    				FileComparisonParams::FileNameMatch, FileComparisonParams::File1IsLarger});
    	}
    	else
    	{
    		emit differentFiles (ckFile.absoluteFilePath(),
    			otherFile.absoluteFilePath(),
    			FileCompareWorker::FileComparisonParams{
    				FileComparisonParams::FileNameMatch, FileComparisonParams::File2IsLarger});
    	}
    }
    

    BTW, here is my .clang-format in case you are interested

  • MNByChoice@midwest.social
    link
    fedilink
    arrow-up
    1
    ·
    2 years ago

    Seems like a lot of work, when the font I use will mess it up. And compiler/interpreter won’t care.

    But if it makes you happy, go for it.