New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 721911 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Nov 27
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: ----
Type: Bug

Blocked on:
issue 768586



Sign in to add a comment

clang-format places multiple array literal elements on the same line

Project Member Reported by isherman@chromium.org, May 12 2017

Issue description

clang-format produced code that (choose all that apply): 
- Doesn't match Chromium style
- Doesn't match blink style
x Riles my finely honed stylistic dander
- No sane human would ever choose

Here's the code before formatting:
  const std::string patterns[] = {
      // Queries with path "/search" need to have the query parameter in either
      // the url parameter or the hash fragment.
      "%s://www.google.com/search?%s=something",
      "%s://www.google.com/search#%s=something",
      "%s://www.google.com/search?name=bob&%s=something",
      "%s://www.google.com/search?name=bob#%s=something",
      "%s://www.google.com/search?name=bob#age=24&%s=thng",
      "%s://www.google.co.uk/search?%s=something",
      // It's actually valid for both to have the query parameter.
      "%s://www.google.com/search?%s=something#q=other",

      // Queries with path "/webhp", "/" or "" need to have the query parameter
      // in the hash fragment.
      "%s://www.google.com/webhp#%s=something",
      "%s://www.google.com/webhp#name=bob&%s=something",
      "%s://www.google.com/webhp?name=bob#%s=something",
      "%s://www.google.com/webhp?name=bob#age=24&%s=thing",

      "%s://www.google.com/#%s=something",
      "%s://www.google.com/#name=bob&%s=something",
      "%s://www.google.com/?name=bob#%s=something",
      "%s://www.google.com/?name=bob#age=24&%s=something",

      "%s://www.google.com#%s=something",
      "%s://www.google.com#name=bob&%s=something",
      "%s://www.google.com?name=bob#%s=something",
      "%s://www.google.com?name=bob#age=24&%s=something",

      // Google subdomain queries.
      "%s://ipv4.google.com/search?%s=something",
      "%s://ipv4.google.com#name=bob&%s=something",
      "%s://ipv6.google.com?name=bob#%s=something",
      "%s://ipv6.google.com?name=bob#age=24&%s=something",

      // Trailing dots in the hosts.
      "%s://www.google.com./#%s=something",
      "%s://www.google.de./#%s=something",
      "%s://ipv4.google.com./#%s=something",
      "%s://ipv6.google.com./#%s=something",
  };

Here's the code after formatting:
  const std::string patterns[] = {
      // Queries with path "/search" need to have the query parameter in either
      // the url parameter or the hash fragment.
      "%s://www.google.com/search?%s=something",
      "%s://www.google.com/search#%s=something",
      "%s://www.google.com/search?name=bob&%s=something",
      "%s://www.google.com/search?name=bob#%s=something",
      "%s://www.google.com/search?name=bob#age=24&%s=thng",
      "%s://www.google.co.uk/search?%s=something",
      // It's actually valid for both to have the query parameter.
      "%s://www.google.com/search?%s=something#q=other",

      // Queries with path "/webhp", "/" or "" need to have the query parameter
      // in the hash fragment.
      "%s://www.google.com/webhp#%s=something",
      "%s://www.google.com/webhp#name=bob&%s=something",
      "%s://www.google.com/webhp?name=bob#%s=something",
      "%s://www.google.com/webhp?name=bob#age=24&%s=thing",

      "%s://www.google.com/#%s=something",
      "%s://www.google.com/#name=bob&%s=something",
      "%s://www.google.com/?name=bob#%s=something",
      "%s://www.google.com/?name=bob#age=24&%s=something",

      "%s://www.google.com#%s=something",
      "%s://www.google.com#name=bob&%s=something",
      "%s://www.google.com?name=bob#%s=something",
      "%s://www.google.com?name=bob#age=24&%s=something",

      // Google subdomain queries.
      "%s://ipv4.google.com/search?%s=something",
      "%s://ipv4.google.com#name=bob&%s=something",
      "%s://ipv6.google.com?name=bob#%s=something",
      "%s://ipv6.google.com?name=bob#age=24&%s=something",

      // Trailing dots in the hosts.
      "%s://www.google.com./#%s=something", "%s://www.google.de./#%s=something",
      "%s://ipv4.google.com./#%s=something",
      "%s://ipv6.google.com./#%s=something",
  };

Here's how it ought to look:
  I think the before case is better.  I understand that we're unifying {} and () initializer syntax, but I would have expected the trailing comma to also mean "one per line".  It does for JS clang formatting, at least within google3.

Code review link for full files/context:
https://codereview.chromium.org/2861183002/diff/100001/components/google/core/browser/google_util_unittest.cc

(Related to  bug 721496 , where I forgot to call out this additional point of frustration.)
 
Components: Tools
Blockedon: 768586
Labels: clang-format
Status: Fixed (was: Assigned)
int main() {
  const std::string patterns[] = {
      // Queries with path "/search" need to have the query parameter in either
      // the url parameter or the hash fragment.
      "%s://www.google.com/search?%s=something",
      "%s://www.google.com/search#%s=something",
      "%s://www.google.com/search?name=bob&%s=something",
      "%s://www.google.com/search?name=bob#%s=something",
      "%s://www.google.com/search?name=bob#age=24&%s=thng",
      "%s://www.google.co.uk/search?%s=something",
      // It's actually valid for both to have the query parameter.
      "%s://www.google.com/search?%s=something#q=other",

      // Queries with path "/webhp", "/" or "" need to have the query parameter
      // in the hash fragment.
      "%s://www.google.com/webhp#%s=something",
      "%s://www.google.com/webhp#name=bob&%s=something",
      "%s://www.google.com/webhp?name=bob#%s=something",
      "%s://www.google.com/webhp?name=bob#age=24&%s=thing",

      "%s://www.google.com/#%s=something",
      "%s://www.google.com/#name=bob&%s=something",
      "%s://www.google.com/?name=bob#%s=something",
      "%s://www.google.com/?name=bob#age=24&%s=something",

      "%s://www.google.com#%s=something",
      "%s://www.google.com#name=bob&%s=something",
      "%s://www.google.com?name=bob#%s=something",
      "%s://www.google.com?name=bob#age=24&%s=something",

      // Google subdomain queries.
      "%s://ipv4.google.com/search?%s=something",
      "%s://ipv4.google.com#name=bob&%s=something",
      "%s://ipv6.google.com?name=bob#%s=something",
      "%s://ipv6.google.com?name=bob#age=24&%s=something",

      // Trailing dots in the hosts.
      "%s://www.google.com./#%s=something",
      "%s://www.google.de./#%s=something",
      "%s://ipv4.google.com./#%s=something",
      "%s://ipv6.google.com./#%s=something",
  };
}

Sign in to add a comment