The Welkin Suite Forum

'Format Code' sets incorrect indentation on single line IF statements



'Format Code' sets incorrect indentation on single line IF statements

  • Please log in to reply

#1
windows version welkinsuite

gtasker

    Posted 07 Mar 2021

    Given the following IF statement in Apex code:

    if (ctr > 10)
       failed = true;

    Format Code will change the Apex source into this, stripping the indentation:

    if (ctr > 10)
    failed = true;
    

    It should give one of the following, in this preferred order:

    • Keep the original indentation
      if (ctr > 10)
         failed = true;
    • Merge the two lines into a single line
      if (ctr > 10) failed = true;
    • Add curly braces
      if (ctr > 10) {
         failed = true;
      }

    My team inherited an application with hundreds of thousands of lines, and we cannot use Format Code on the source unless we modify every IF statement by hand, so the indentation is visually correct after formatting.
    If the template for Format Code was made available, I could fix it myself.  But apparently there is no way for you to expose the template...?




    0 replies to this topic



    Boost Your Productivity. Get Started Today

    Try Free Trial