https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112017-12-27T10:19:07ZRuby Issue Tracking SystemRuby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=690252017-12-27T10:19:07Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul></ul><p>I'm all for better consistency. I thought there were clear guidelines for Ruby, and (almost) everybody was following them. I didn't know it was that bad.</p>
<p>But fixing spacing will obscure where the code originally came from. I don't really like that.</p>
<p>To improve the situation, I have the following suggestions:</p>
<ol>
<li>
<p>Install an SVN bot that fixes indents on newly committed lines automatically. That would hopefully catch the attention of the committers.</p>
</li>
<li>
<p>Based on <code>svn blame</code>, get a picture of who is how good (or not) at following the guidelines, and gently nudge everybody in the right direction.</p>
</li>
</ol>
<p>[Somebody sooner or later will start discussion on what the best way of indenting should be. If you want to do this, please make it a separate issue. Please tag it as "joke" (because we don't have a "bikeshed" category).]</p> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=690302017-12-27T10:36:14Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/69030/diff?detail_id=47649">diff</a>)</li></ul> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=690342017-12-27T11:08:35Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p><a href="mailto:duerst@it.aoyama.ac.jp" class="email">duerst@it.aoyama.ac.jp</a> wrote:</p>
<blockquote>
<p>I'm all for better consistency. I thought there were clear<br>
guidelines for Ruby, and (almost) everybody was following<br>
them. I didn't know it was that bad.</p>
</blockquote>
<p>Right, I remember it being 4 spaces per-level, and use TAB<br>
whenever it's 8 spaces. AFAIK, that's the Emacs default and I've<br>
seen this in several other projects, so not uncommon..<br>
In vim, I use: :set ts=8 sw=4 sts=4 noexpandtab</p>
<blockquote>
<p>But fixing spacing will obscure where the code originally came<br>
from. I don't really like that.</p>
</blockquote>
<p>Agreed 100%. Noise makes code archaelogy harder, I don't like<br>
whitespace-only changes; but I'd be happy to see them if one is<br>
in the affected area and already changing code, and the proposed<br>
SVN bot might help with that...</p>
<p>I admit that I moved some existing all-space code not long ago<br>
and did not notice it, but nobu fixed it for me :x</p>
<blockquote>
<p>To improve the situation, I have the following suggestions:</p>
</blockquote>
<blockquote>
<ol>
<li>Install an SVN bot that fixes indents on newly committed<br>
lines automatically. That would hopefully catch the attention<br>
of the committers.</li>
</ol>
</blockquote>
<p>Instead of auto-fixing, it should email the committer;<br>
that ought to reduce future screwups.</p> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=690992017-12-30T13:29:12Zznz (Kazuhiro NISHIYAMA)
<ul></ul><p>I think that guidelines are <code>.editorconfig</code> for most editors, <code>misc/ruby-style.el</code> for <code>Emacs</code>, and <code>.indent.pro</code> for <code>indent</code>.</p> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=692342018-01-05T18:13:13Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<ul></ul><p>Let me quote Developers How-To <a href="https://bugs.ruby-lang.org/projects/ruby/wiki/DeveloperHowto" class="external">1</a>:</p>
<blockquote>
<ul>
<li>indent</li>
<li>4 for C</li>
<li>2 for Ruby</li>
<li>tab/space</li>
<li>Do not use TABs in ruby codes ruby-dev:19388</li>
<li>Use TAB instead of 8 SPs in C. (Emacs's default style)</li>
</ul>
</blockquote> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=692392018-01-05T20:46:26Znaruse (Yui NARUSE)naruse@airemix.jp
<ul></ul><p>Just FYI, there's a format tool named clang-format.<br>
<a href="https://clang.llvm.org/docs/ClangFormat.html" class="external">https://clang.llvm.org/docs/ClangFormat.html</a></p>
<p>I use following options:<br>
<a href="https://github.com/nurse/strptime/blob/master/.clang-format" class="external">https://github.com/nurse/strptime/blob/master/.clang-format</a></p> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=695722018-01-14T17:56:17Zgraywolf (Gray Wolf)
<ul></ul><p>As <a class="user active user-mention" href="https://bugs.ruby-lang.org/users/703">@vo.x (Vit Ondruch)</a> already pointed out, there are guidelines for the indentation. So based on the guidelines the 101 files are (probably) correctly indented and the 76 (10 + 66) files are (probably) wrongly indented.</p> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=695772018-01-15T02:26:26Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul></ul><p><a class="user active user-mention" href="https://bugs.ruby-lang.org/users/12262">@graywolf (Gray Wolf)</a> we are talking about C codes here. The "Do not use TABs" policy applies to non-C files.</p> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=695782018-01-15T02:37:48Zgraywolf (Gray Wolf)
<ul></ul><p>I can't count to 8 in</p>
<pre><code>xargs grep --files-with-match '^ '`
</code></pre>
<p>, sorry, just ignore me. :/</p> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=697442018-01-24T08:00:17Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul></ul><p>We discussed this issue in today's developer meeting.</p>
<ul>
<li>We agreed <em>not</em> to batch update the indents at once. Indents should become consistent over time.</li>
<li>Matz has no strong opinion on this topic.</li>
<li>We agreed to move to spaces only. Reasons behind this:
<ul>
<li>No contemporary advantage of mixing tabs and spaces today.</li>
<li>Emacs fans at the meeting could use ruby-style.el, and that style can be updated.</li>
</ul>
</li>
</ul>
<p>So the next action is:</p>
<ul>
<li>Modify ruby-style.el and other config files.</li>
<li>Use them.</li>
</ul> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=697992018-01-25T00:11:56ZAnonymous
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset trunk|r62033.</p>
<hr>
<p>.editorconfig: Use spaces instead of tab except Makefiles</p>
<p>ref [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Inconsistent C source code indentation (Closed)" href="https://bugs.ruby-lang.org/issues/14246">#14246</a>]<br>
[ci skip]</p> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=700772018-01-31T12:04:01Zznz (Kazuhiro NISHIYAMA)
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Open</i></li></ul><p>Re-open because accidentally closed.<br>
At least misc/ruby-style.el set to tabs.</p> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=710492018-03-17T02:37:54Zk0kubun (Takashi Kokubun)takashikkbn@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset trunk|r62789.</p>
<hr>
<p>misc/ruby-style.el: use spaces for indentation</p>
<p>instead of hard tabs.</p>
<p>[Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Inconsistent C source code indentation (Closed)" href="https://bugs.ruby-lang.org/issues/14246">#14246</a>]</p> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=808892019-08-21T13:25:24Zk0kubun (Takashi Kokubun)takashikkbn@gmail.com
<ul><li><strong>Related to</strong> <i><a class="issue tracker-5 status-5 priority-4 priority-default closed" href="/issues/16112">Misc #16112</a>: Reduce the possibility of "expand tabs" commit occurrences</i> added</li></ul> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=977562022-05-26T02:58:15Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p><a href="https://github.com/ruby/ruby/pull/5946" class="external">https://github.com/ruby/ruby/pull/5946</a> experiment with <code>clang-format</code>.</p> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=981972022-06-24T04:22:39Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>Does this policy apply to the formatting of default gems too?</p> Ruby master - Bug #14246: Inconsistent C source code indentationhttps://bugs.ruby-lang.org/issues/14246?journal_id=982032022-06-27T00:28:30Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul></ul><p>ioquatix (Samuel Williams) wrote in <a href="#note-16">#note-16</a>:</p>
<blockquote>
<p>Does this policy apply to the formatting of default gems too?</p>
</blockquote>
<p>I don't think so. One good thing about splitting things into gems is they can have their own policies (release timing etc.). I support each gems having distinct point of view as to what code is a beautiful code.</p>