Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-112878

qmlfomater improvements

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P2: Important
    • Some future release
    • 5.15, 6.5.0
    • QML: Tooling
    • None
    • All

    Description

      The qmlformat tool removes the curly brackets and adds a semi-colon at the end of function calls.

       

      • The first one is a serious safety issue, is documented as why if/else statements should always have curly brackets.
      • The second one is subjective but i don't remember the last time that any mainstream javascript formatter added semi-colons instead of removing them.

      Original function:

      function getSafe(fn, defaultVal) {
          try {
              return fn()
          } catch (e) {
              if (typeof defaultVal === "undefined") {
                  defaultVal = null
              }
              return defaultVal
          }
      }
      
      

         Formatted function

          function getSafe(fn, defaultVal) {
              try {
                  return fn();
              } catch (e) {
                  if (typeof defaultVal === "undefined")
                      defaultVal = null;
                  return defaultVal;
              }
          }
      

      the curly brackets from the if were removed, and a semicolon was added at the end of each expression. 

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtqmlteam Qt Qml Team User
            ErnestoCO Ernesto Cruz-Olivera
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes