Skip to content

Double indentation on C++ initialization arguments #1268

Closed

Description

@mihaipopescu
        floatNx3 randomRotationMatrices[3];
        if (rotationRandomnessX > epsilon() || rotationRandomnessY > epsilon())
        {
            floatNx3 rotationEuler = floatNx3(
                    (GenerateRandom(randomSeed + intN(kParticleSystemExternalForcesRotationRandomnessXId)) * 2 - 1) * rotationRandomnessX,
                    (GenerateRandom(randomSeed + intN(kParticleSystemExternalForcesRotationRandomnessYId)) * 2 - 1) * rotationRandomnessY,
                    floatN(ZERO));
            eulerToMatrix(rotationEuler, randomRotationMatrices);

            toForce = mul(randomRotationMatrices, toForce);
        }

Expected versus output diff:

diff --git "a/C:\\work\\external\\uncrustify\\tests\\output\\staging\\60022-UNI-18439.cpp" "b/C:\\work\\external\\uncrustify\\tests\\results\\staging\\60022-UNI-18439.cpp"
index 8d467c6..446501d 100644
--- "a/C:\\work\\external\\uncrustify\\tests\\output\\staging\\60022-UNI-18439.cpp"
+++ "b/C:\\work\\external\\uncrustify\\tests\\results\\staging\\60022-UNI-18439.cpp"
@@ -1,12 +1,12 @@
 floatNx3 randomRotationMatrices[3];
 if (rotationRandomnessX > epsilon() || rotationRandomnessY > epsilon())
 {
 // Parameters are being double indented.
     floatNx3 rotationEuler = floatNx3(
-        (GenerateRandom(randomSeed + intN(kParticleSystemExternalForcesRotationRandomnessXId)) * 2 - 1) * rotationRandomnessX,
-        (GenerateRandom(randomSeed + intN(kParticleSystemExternalForcesRotationRandomnessYId)) * 2 - 1) * rotationRandomnessY,
-        floatN(ZERO));
+            (GenerateRandom(randomSeed + intN(kParticleSystemExternalForcesRotationRandomnessXId)) * 2 - 1) * rotationRandomnessX,
+            (GenerateRandom(randomSeed + intN(kParticleSystemExternalForcesRotationRandomnessYId)) * 2 - 1) * rotationRandomnessY,
+            floatN(ZERO));
     eulerToMatrix(rotationEuler, randomRotationMatrices);
 
     toForce = mul(randomRotationMatrices, toForce);
 }

Debug support files:

60022-UNI-18439.cpp
60022-UNI-18439.cpp.log
60022-UNI-18439.cpp.unc
Uncrustify.Cpp.cfg
UNI-18439.cpp

Disclaimer:

Note: This is a generated issue from our internal issue tracker.
Expect a dry description which could be insufficient to properly understand the issue.
On the other hand, the support files should be sufficient to easily reproduce and debug the issue,
but please comment if it's still unclear and I will get back with clarifications.
See main discussion thread here #1223.

Activity

  1. CDanU commented on Jul 11, 2017

    @CDanU
    Collaborator

    I haven't gone through all issues yet but it seems a bunch of them is related to indentions.
    While tying to solve #1218 I made this branch: code_width. Contrary to the name the goal was to fix the width for func call params. The solution works somewhat better but fights with the rest of the code inside indent.cpp (mainly everything that gets done by uncrustify.cpp - indent_text() - L1890-L1907)

  2. mihaipopescu commented on Jul 11, 2017

    @mihaipopescu
    CollaboratorAuthor

    Yes, a quite a few are double indentation related but they are different. We're not using code_width at all. You think it's the same code that deals with width of func call params ? What is the option for that ?

  3. CDanU commented on Jul 11, 2017

    @CDanU
    Collaborator

    Ohh ok, I saw the function call and thought of the the code I wrote. No the changes I had made are only triggered when code_width is violated. But the problems here most likely are still caused by indent_text() (it is also called a few lines above the mentioned ones).

  4. guy-maurel commented on Jul 13, 2017

    @guy-maurel
    Contributor

    Please push Uncrustify.Common-Cpp.cfg

  5. guy-maurel commented on Jul 13, 2017

    @guy-maurel
    Contributor

    Should it be controlled by the option use_indent_continue_only_once = true ?

  6. CDanU commented on Jul 13, 2017

    @CDanU
    Collaborator
  7. mihaipopescu commented on Jul 13, 2017

    @mihaipopescu
    CollaboratorAuthor

    Yeah, I noticed that they're missing and I started to reduce the configs but didn't finished that so I pushed it like this. But, as mentioned in the main discussion thread #1223 the config can be extracted from the dump .unc file.

  8. CDanU commented on Jul 14, 2017

    @CDanU
    Collaborator

    Caused by:

    # Align continued statements at the '='. Default=True
    # If False or the '=' is followed by a newline, the next line is indent one tab.
    indent_align_assign             = false    # false/true
  9. mihaipopescu commented on Jul 14, 2017

    @mihaipopescu
    CollaboratorAuthor

    Cool! Are you finding these with the option reducer ?

  10. CDanU commented on Jul 14, 2017

    @CDanU
    Collaborator

    No, I just paste the config in my webtool, manually reduce the config in halve and check the output until I find the problem. I could use the option reducer as a prefilter, but I am faster just copy and pasting it.
    Most of the config can be removed if I already know that the problem is not about spaces or newlines.

  11. added a commit that references this issue on Oct 25, 2017
  12. gmaurel commented on Jan 22, 2018

    @gmaurel
    Collaborator

    Fixed at 2c412d8, Dec 17 18:33:16 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions