
{"id":2176,"date":"2016-12-23T23:43:50","date_gmt":"2016-12-24T04:43:50","guid":{"rendered":"http:\/\/www.ikriv.com\/blog\/?p=2176"},"modified":"2016-12-23T23:45:41","modified_gmt":"2016-12-24T04:45:41","slug":"the-procrustean-bed-of-resharper-formatting","status":"publish","type":"post","link":"https:\/\/ikriv.com\/blog\/?p=2176","title":{"rendered":"The Procrustean bed of Resharper formatting"},"content":{"rendered":"<p>I was playing with some Javascript in Visual Studio, and I found that it gets annoyingly reformatted every time I end a statement or a block. Visual Studio formatting options have a choice of disabling auto-format, but Resharper is not that generous. All I get to choose is <i>how<\/i> the code will be auto-formatted, but there is no option to leave the formatting alone. This applies to any language, not just Javacsript.<\/p>\n<p>E.g., consider this piece of code:<\/p>\n<p><code>return (sorted[len\/2-1] + sorted[len\/2]) \/ 2;<\/code><\/p>\n<p>I like it the way it is, but with Resharper the only options I get is no spaces around binary operators, i.e.<\/p>\n<p><code>return (sorted[len\/2-1]+sorted[len\/2])\/2;<\/code><\/p>\n<p>or spaces around <b>every<\/b> binary operator:<\/p>\n<p><code>return (sorted[len \/ 2 - 1] + sorted[len \/ 2]) \/ 2;<\/code><\/p>\n<p>I like neither: the first one is too terse, the second one is too sparse, but that&#8217;s the only two choices I get if Resharper is installed. Quick googling reveals that &#8216;leave my code alone&#8217; option has been requested several times in the past, but JetBrains insists that uniform formatting is good for your health. <a href=\"https:\/\/resharper-support.jetbrains.com\/hc\/en-us\/community\/posts\/206050679-Resharper-C-space-formatting\">This thread<\/a> is a typical example:<\/p>\n<p><b>User<\/b>: <i>I have my assignments neatly formatted and don&#8217;t want Resharper to ruin it.<\/i><br \/>\n<b>JetBrains<\/b>: <i>The main problem with such formatting style is that it is EXTEMELY hard to maintain<\/i><\/p>\n<p>That is, they decided that they know better how to format your code, and you all you can do is to pick a party line and stick to it. Fooling around is not allowed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was playing with some Javascript in Visual Studio, and I found that it gets annoyingly reformatted every time I end a statement or a block. Visual Studio formatting options <a href=\"https:\/\/ikriv.com\/blog\/?p=2176\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[4],"tags":[],"class_list":["entry","author-ikriv","post-2176","post","type-post","status-publish","format-standard","category-hack"],"_links":{"self":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2176"}],"version-history":[{"count":7,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2176\/revisions"}],"predecessor-version":[{"id":2183,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2176\/revisions\/2183"}],"wp:attachment":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}