1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
File: RUBOCOP
— Documentation by YARD 0.9.37
</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "RUBOCOP";
relpath = '';
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="file_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="_index.html">Index</a> »
<span class="title">File: RUBOCOP</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><div id='filecontents'><h1 id="rubocop-usage-guide">RuboCop Usage Guide</h1>
<h2 id="overview">Overview</h2>
<p>A tale of two RuboCop plugin gems.</p>
<h3 id="rubocop-gradual">RuboCop Gradual</h3>
<p>This project uses <code>rubocop_gradual</code> instead of vanilla RuboCop for code style checking. The <code>rubocop_gradual</code> tool allows for gradual adoption of RuboCop rules by tracking violations in a lock file.</p>
<h3 id="rubocop-lts">RuboCop LTS</h3>
<p>This project uses <code>rubocop-lts</code> to ensure, on a best-effort basis, compatibility with Ruby >= 1.9.2.<br>
RuboCop rules are meticulously configured by the <code>rubocop-lts</code> family of gems to ensure that a project is compatible with a specific version of Ruby. See: https://rubocop-lts.gitlab.io for more.</p>
<h2 id="checking-rubocop-violations">Checking RuboCop Violations</h2>
<p>To check for RuboCop violations in this project, always use:</p>
<pre class="code language-bash"><code class="language-bash">bundle exec rake rubocop_gradual:check
</code></pre>
<p><strong>Do not use</strong> the standard RuboCop commands like:</p>
<ul>
<li><code>bundle exec rubocop</code></li>
<li><code>rubocop</code></li>
</ul>
<h2 id="understanding-the-lock-file">Understanding the Lock File</h2>
<p>The <code>.rubocop_gradual.lock</code> file tracks all current RuboCop violations in the project. This allows the team to:</p>
<ol>
<li>Prevent new violations while gradually fixing existing ones</li>
<li>Track progress on code style improvements</li>
<li>Ensure CI builds don’t fail due to pre-existing violations</li>
</ol>
<h2 id="common-commands">Common Commands</h2>
<ul>
<li>
<strong>Check violations</strong>
<ul>
<li><code>bundle exec rake rubocop_gradual</code></li>
<li><code>bundle exec rake rubocop_gradual:check</code></li>
</ul>
</li>
<li>
<strong>(Safe) Autocorrect violations, and update lockfile if no new violations</strong>
<ul>
<li><code>bundle exec rake rubocop_gradual:autocorrect</code></li>
</ul>
</li>
<li>
<strong>Force update the lock file (w/o autocorrect) to match violations present in code</strong>
<ul>
<li><code>bundle exec rake rubocop_gradual:force_update</code></li>
</ul>
</li>
</ul>
<h2 id="workflow">Workflow</h2>
<ol>
<li>Before submitting a PR, run <code>bundle exec rake rubocop_gradual:autocorrect</code><br>
a. or just the default <code>bundle exec rake</code>, as autocorrection is a pre-requisite of the default task.</li>
<li>If there are new violations, either:
<ul>
<li>Fix them in your code</li>
<li>Run <code>bundle exec rake rubocop_gradual:force_update</code> to update the lock file (only for violations you can’t fix immediately)</li>
</ul>
</li>
<li>Commit the updated <code>.rubocop_gradual.lock</code> file along with your changes</li>
</ol>
<h2 id="never-add-inline-rubocop-disables">Never add inline RuboCop disables</h2>
<p>Do not add inline <code>rubocop:disable</code> / <code>rubocop:enable</code> comments anywhere in the codebase (including specs, except when following the few existing <code>rubocop:disable</code> patterns for a rule already being disabled elsewhere in the code). We handle exceptions in two supported ways:</p>
<ul>
<li>Permanent/structural exceptions: prefer adjusting the RuboCop configuration (e.g., in <code>.rubocop.yml</code>) to exclude a rule for a path or file pattern when it makes sense project-wide.</li>
<li>Temporary exceptions while improving code: record the current violations in <code>.rubocop_gradual.lock</code> via the gradual workflow:
<ul>
<li>
<code>bundle exec rake rubocop_gradual:autocorrect</code> (preferred; will autocorrect what it can and update the lock only if no new violations were introduced)</li>
<li>If needed, <code>bundle exec rake rubocop_gradual:force_update</code> (as a last resort when you cannot fix the newly reported violations immediately)</li>
</ul>
</li>
</ul>
<p>In general, treat the rules as guidance to follow; fix violations rather than ignore them. For example, RSpec conventions in this project expect <code>described_class</code> to be used in specs that target a specific class under test.</p>
<h2 id="benefits-of-rubocop_gradual">Benefits of rubocop_gradual</h2>
<ul>
<li>Allows incremental adoption of code style rules</li>
<li>Prevents CI failures due to pre-existing violations</li>
<li>Provides a clear record of code style debt</li>
<li>Enables focused efforts on improving code quality over time</li>
</ul>
</div></div>
<div id="footer">
Generated on Mon Sep 15 21:28:40 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
</div>
</body>
</html>
|