{"id":1115,"date":"2019-09-30T21:19:50","date_gmt":"2019-10-01T05:19:50","guid":{"rendered":"https:\/\/accretiondisc.com\/blog\/?p=1115"},"modified":"2019-11-19T16:01:48","modified_gmt":"2019-11-20T01:01:48","slug":"rubocop-and-rufo","status":"publish","type":"post","link":"https:\/\/accretiondisc.com\/blog\/2019\/09\/30\/rubocop-and-rufo\/","title":{"rendered":"rubocop and rufo"},"content":{"rendered":"\n<p>I&#8217;ve been writing in the Ruby language since sometime in 2002, but if I was looking for a job, I don&#8217;t know enough to call myself a ruby programmer. I don&#8217;t know rails or anything of the other cool things people do with ruby. I&#8217;ve learned to use gems, but haven&#8217;t bothered to learn how to write them myself.<\/p>\n\n\n\n<p>But I&#8217;m not opposed to learning. I just haven&#8217;t gotten around to it yet.<\/p>\n\n\n\n<p>Or so I thought. Then I ran into <a href=\"https:\/\/github.com\/rubocop-hq\/rubocop\">rubocop<\/a>, which is a sort of linter and style cop. Those can be helpful, so I thought I&#8217;d give it a try. And it&#8217;s mostly good. Except it&#8217;s opinionated, and some of <a href=\"https:\/\/github.com\/rubocop-hq\/ruby-style-guide\">their opinions<\/a> are wrong. For example:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>the indentation should be four spaces, not two as they suggest <\/li><li>parallel assignment is the bomb, despite what they say<\/li><li>I use double quotes (<code>\"<\/code>) pretty much everywhere I&#8217;m not forced to use single quotes (<code>'<\/code>). They want to save time for the compiler, I guess.<\/li><li>You <em>need<\/em> space inside parentheses (although I will grant the extra whitespace is less important with syntax highlighting than without it). <\/li><li>And if I&#8217;m declaring a RE that&#8217;s so complicated I&#8217;m using \/x flag, then don&#8217;t tell me to use <code>\/...\/<\/code> instead of <code>%r&lt;...><\/code>.<\/li><li>And speaking of which, go ahead and use <code>$1<\/code> and <code>$'<\/code> when retrieving the results of an RE match. (In moderation.) Honestly, this is a tie. Go ahead and use named groups if you want to.<\/li><\/ul>\n\n\n\n<p>But you can&#8217;t fight city hall. If some younglings want to make Ruby over in the style of Python, well, that&#8217;s a crying shame. Ruby is supposed to occupy the perfect spot between Perl and Python. But these kids today! If they&#8217;re on your lawn, you might as well go along with their misguided project. And that brings us to <a href=\"https:\/\/github.com\/ruby-formatter\/rufo\">rufo<\/a>, the ruby reformatter. You can use it to do like 10% of the things that rubocop whinges about.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been writing in the Ruby language since sometime in 2002, but if I was looking for a job, I don&#8217;t know enough to call myself a ruby programmer. I don&#8217;t know rails or anything of the other cool things people do with ruby. I&#8217;ve learned to use gems, but haven&#8217;t bothered to learn how [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[52],"tags":[1052,200],"class_list":["post-1115","post","type-post","status-publish","format-standard","hentry","category-technology","tag-rubocop","tag-ruby-2"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paRqpr-hZ","_links":{"self":[{"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/posts\/1115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/comments?post=1115"}],"version-history":[{"count":0,"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/posts\/1115\/revisions"}],"wp:attachment":[{"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/media?parent=1115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/categories?post=1115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/tags?post=1115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}