rubocounsel 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3839fdb133937bd743490942d358cadb5ec5b03380b20755150f1e06ffdc8cf3
4
+ data.tar.gz: 618b43fadb08f8896de3f9b70e4638eaac8169c981614f3dc474007db314e44c
5
+ SHA512:
6
+ metadata.gz: 563a253cd41f2ab816aed6a7241ebb68ab3c4ac12df4fa12c804e6f5b415f228d54004710289201a065cd09c7b6fc74dd313af8de45162b5d9a08a7fc605912f
7
+ data.tar.gz: 8c9be74c4d2c0bf342e05e4dfb9cc8aad6c26ab7899e31aef24c7600d5901dcca0dcd7d4b8f5c9a5e5f7e762593bb3e35ce27319dfd232ed25fe48e223073cb8
data/.claude/CLAUDE.md ADDED
@@ -0,0 +1,11 @@
1
+ # RuboCounsel Project Guidelines
2
+
3
+ ## Code Style
4
+
5
+ - Never use blank `puts` for empty lines. Use a heredoc or include `\n` in the previous string instead.
6
+
7
+ ## Testing
8
+
9
+ - Consolidate simple accessor/property tests into a single test when they're straightforward
10
+ - Avoid creating multiple tests for trivial variations of the same behavior (e.g., testing `#type` for each possible value type)
11
+ - Group related assertions in one test to reduce noise while still maintaining clear test intent
@@ -0,0 +1,22 @@
1
+ {
2
+ "permissions": {
3
+ "ask": [
4
+ "Bash(gh api -X:*)"
5
+ ],
6
+ "allow": [
7
+ "Bash(bin/test:*)",
8
+ "Bash(bin/style:*)",
9
+ "Bash(bin/console:*)",
10
+ "Bash(bundle install:*)",
11
+ "Bash(gh api :*)",
12
+ "Bash(gh pr create:*)",
13
+ "Bash(gh pr list:*)",
14
+ "Bash(gh pr view:*)",
15
+ "Bash(gh pr close:*)",
16
+ "Bash(git add:*)",
17
+ "Bash(git commit:*)",
18
+ "Bash(git checkout -b:*)",
19
+ "Bash(git push -u:*)"
20
+ ]
21
+ }
22
+ }
data/.rubocounsel.yml ADDED
@@ -0,0 +1,3 @@
1
+ ---
2
+ Style/StringLiterals:
3
+ EnforcedStyle: double_quotes
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-10-26
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/FEEDBACK.md ADDED
@@ -0,0 +1,67 @@
1
+ # User Feedback
2
+
3
+ ## From initial testing (2026-02-03)
4
+
5
+ ### 1. Show default value in choice options
6
+ When presenting choice options (e.g., `EnforcedStyle`), mark which one is the default so users know the recommended value.
7
+
8
+ Example: Instead of showing:
9
+ ```
10
+ > single_quotes
11
+ double_quotes
12
+ ```
13
+
14
+ Show:
15
+ ```
16
+ > single_quotes (default)
17
+ double_quotes
18
+ ```
19
+
20
+ ### 2. "Show examples" option for attributes
21
+ Add a "Show examples" option when prompting for attribute values. When selected, display the examples and then return to the choice prompt.
22
+
23
+ Current flow:
24
+ 1. Show examples automatically
25
+ 2. Prompt for choice
26
+
27
+ Requested flow:
28
+ 1. Prompt for choice with "Show examples" as an option
29
+ 2. If "Show examples" selected, display examples and return to step 1
30
+ 3. Otherwise, use the selected value
31
+
32
+ This gives users control over when to see examples rather than always showing them upfront.
33
+
34
+ **Context:** Tested on `Bundler/OrderedGems` with `ConsiderPunctuation` attribute.
35
+
36
+ ### 3. Skip non-style attributes like Include/Exclude
37
+ Attributes like `Include` and `Exclude` are file glob patterns, not style decisions. Prompting for them:
38
+ - Slows down the process
39
+ - Isn't the core value prop (helping decide on code style)
40
+ - Users would typically configure these separately if needed
41
+
42
+ **Suggestion:** Filter out certain attributes from interactive prompts. Candidates:
43
+ - `Include`
44
+ - `Exclude`
45
+ - Possibly others that are "configuration" rather than "style"
46
+
47
+ **Open question:** Should there be a way to access these if users want them? Maybe an "advanced" mode or separate command?
48
+
49
+ ### 4. Progress is lost if you quit early
50
+ Config is only written at the very end. If you quit partway through (or hit a bug), all your choices are lost.
51
+
52
+ **Options:**
53
+ - Write after each cop decision (incremental) ✓ DONE
54
+ - Save progress to a temp file and resume
55
+ - At minimum, warn users that quitting will lose progress
56
+
57
+ ### 5. Some examples aren't visually distinct
58
+ Example: `TreatCommentsAsGroupSeparators` shows nearly identical code for `true` and `false` - the only difference is the `# good` vs `# bad` comment label. This is how RuboCop writes their documentation, so not much we can control, but it can be confusing.
59
+
60
+ **Possible mitigation:** Add explanatory text above examples describing what the setting does, not just showing code.
61
+
62
+ ### 6. Some attributes have no examples at all
63
+ Example: `ConsiderPunctuation` for `Bundler/OrderedGems` has no "Show examples" option because RuboCop's source doesn't include `@example` tags for it.
64
+
65
+ **Possible mitigations:**
66
+ - Show a message like "No examples available" instead of hiding the option
67
+ - Link to RuboCop documentation URL for the cop
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 John DeWyze
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/PLAN.md ADDED
@@ -0,0 +1,346 @@
1
+ # RuboCounsel Implementation Plan
2
+
3
+ ## Vision
4
+
5
+ RuboCounsel is an interactive CLI tool that transforms the RuboCop experience from "fix these errors" to "let's decide on your team's style together." Instead of dumping a wall of offenses, it walks developers through each failing cop, explains what it does, shows real code examples, and helps them make informed decisions that get written to `.rubocop.yml`.
6
+
7
+ The end result: a rubocop configuration that reflects conscious choices, not cargo-culted defaults.
8
+
9
+ ---
10
+
11
+ ## The Problem with the Current Approach
12
+
13
+ The `first_attempt` branch uses YARD to discover cops by parsing all RuboCop source files, then filtering for classes that inherit from `RuboCop::Cop::Base`. This works, but it's solving a problem that RuboCop already solved.
14
+
15
+ ### Issues
16
+
17
+ 1. **Reinventing the Registry**: RuboCop maintains `RuboCop::Cop::Registry.global` specifically for programmatic access to all cops. Using YARD to discover cops is like scraping a website when there's a perfectly good API.
18
+
19
+ 2. **Fragile Gem Path Resolution**: The current code does `Gem::Specification.find_by_name("rubocop").gem_dir` and then globs for Ruby files. This is indirect—we're finding the gem just to parse its source, when we could just ask RuboCop directly what cops exist.
20
+
21
+ 3. **Mixing Concerns**: The `Store` class does cop discovery AND example loading in the same pass through YARD. These are separate concerns—cop discovery is structural (what cops exist?), while example loading is documentary (what do the docs say about them?).
22
+
23
+ 4. **Duplicate Code**: `rubocop_config` is defined twice in `store.rb` (lines 39-40 and 68-69). Small symptom of rushed exploration.
24
+
25
+ 5. **Incomplete Interactive Flow**: The `Runner` has empty option handlers and a leftover `debugger` call. The flow from "cop fired" to "config generated" isn't complete.
26
+
27
+ ### What's Actually Good
28
+
29
+ - **The YARD example parsing works**: The `Example` class correctly parses `@example EnforcedStyle: single_quotes (default)` into structured data (attribute, value, default flag).
30
+
31
+ - **The Runner hook is clever**: Subclassing `RuboCop::Runner` and overriding `file_finished` to collect offending cops is a clean integration point.
32
+
33
+ - **The attribute detection logic is sound**: Recognizing that `EnforcedStyle` maps to `SupportedStyles` is correct.
34
+
35
+ ---
36
+
37
+ ## The Hybrid Approach
38
+
39
+ Use RuboCop's Registry for cop discovery (it's authoritative and stable), but keep YARD for extracting documentation examples (there's no other way to get them).
40
+
41
+ ### Why This Split Makes Sense
42
+
43
+ **Cop Discovery via Registry**
44
+
45
+ The Registry is RuboCop's official answer to "what cops exist?" It's:
46
+ - Stable across versions (public API)
47
+ - Complete (includes all registered cops)
48
+ - Provides cop classes directly (no string-to-class conversion needed)
49
+ - Includes metadata like `cop_name`, `department`, `support_autocorrect?`
50
+
51
+ Using it is one line: `RuboCop::Cop::Registry.global.each { |cop| ... }`
52
+
53
+ **Examples via YARD**
54
+
55
+ There's no runtime API in RuboCop to get example code. The examples live in YARD `@example` tags in the source comments. YARD is the only way to extract them, so we keep it—but scoped to just example loading, not cop discovery.
56
+
57
+ This separation means:
58
+ - If YARD parsing fails for some cop, we still have the cop (just without examples)
59
+ - We can cache/lazy-load examples separately from cops
60
+ - The code is easier to test in isolation
61
+
62
+ ---
63
+
64
+ ## Architecture
65
+
66
+ ### Data Flow
67
+
68
+ ```
69
+ ┌─────────────────────────────────────────────────────────────────┐
70
+ │ RuboCop Gem │
71
+ ├─────────────────────────────────────────────────────────────────┤
72
+ │ Registry.global default.yml YARD @example │
73
+ │ (cop classes) (config values) (documentation) │
74
+ └────────┬─────────────────────────┬─────────────────────┬────────┘
75
+ │ │ │
76
+ ▼ ▼ ▼
77
+ ┌─────────────────┐ ┌─────────────────────┐ ┌──────────────┐
78
+ │ Cop Classes │ │ Configuration │ │ Examples │
79
+ │ (from Reg.) │ │ (from Config) │ │ (from YARD) │
80
+ └────────┬────────┘ └──────────┬──────────┘ └──────┬───────┘
81
+ │ │ │
82
+ └────────────┬───────────┴─────────────────────┘
83
+
84
+ ┌───────────────┐
85
+ │ CopCatalog │
86
+ │ (unified) │
87
+ └───────┬───────┘
88
+
89
+ ┌────────────┴────────────┐
90
+ ▼ ▼
91
+ ┌─────────────────┐ ┌─────────────────────┐
92
+ │ Runner │ │ Counselor (CLI) │
93
+ │ (runs rubocop, │──────▶│ (interactive │
94
+ │ tracks cops) │ │ walkthrough) │
95
+ └─────────────────┘ └──────────┬──────────┘
96
+
97
+
98
+ ┌─────────────────────┐
99
+ │ ConfigWriter │
100
+ │ (generates YAML) │
101
+ └─────────────────────┘
102
+ ```
103
+
104
+ ### Component Responsibilities
105
+
106
+ **CopCatalog** (replaces `Store`)
107
+
108
+ The central repository of cop information. Responsibilities:
109
+ - Load all cops from Registry
110
+ - Load examples from YARD (via ExampleLoader)
111
+ - Associate examples with cops
112
+ - Provide lookup by cop name
113
+
114
+ Why "Catalog" instead of "Store"? A store implies persistence/mutation. This is more like a catalog—a comprehensive listing you can browse and query.
115
+
116
+ **ExampleLoader**
117
+
118
+ Focused concern: extract `@example` tags from YARD and parse them into structured data.
119
+
120
+ Why separate from CopCatalog?
121
+ - Single responsibility: YARD parsing is finicky and worth isolating
122
+ - Testability: can test example parsing without loading the full catalog
123
+ - Fallback: if YARD fails, cops still load (just without examples)
124
+
125
+ **CopEntry** (replaces `CopStore`)
126
+
127
+ Represents a single cop with its configuration and examples. Contains:
128
+ - The cop class (from Registry)
129
+ - Its configuration (from ConfigLoader)
130
+ - Its examples (from ExampleLoader)
131
+ - Computed configurable attributes
132
+
133
+ Why "Entry" instead of "CopStore"? Each cop isn't a store—it's an entry in the catalog. The name should reflect its role as a data object, not a container.
134
+
135
+ **ConfigurableAttribute** (keep, mostly unchanged)
136
+
137
+ Represents one configurable aspect of a cop (e.g., `EnforcedStyle`). Computes:
138
+ - Default value
139
+ - Available options (for choice-type attributes)
140
+ - Value type (boolean, integer, string, array, choice)
141
+
142
+ **Example** (simplify to hash or keep as lightweight class)
143
+
144
+ Parsed `@example` tag data:
145
+ - Attribute name (e.g., "EnforcedStyle")
146
+ - Value (e.g., "single_quotes")
147
+ - Whether it's the default
148
+ - The code text
149
+
150
+ The current `Example` class is fine. Could be a plain hash, but the class provides clarity.
151
+
152
+ **Runner** (keep, complete the implementation)
153
+
154
+ Subclass of `RuboCop::Runner` that:
155
+ - Runs RuboCop normally
156
+ - Hooks `file_finished` to track which cops fired
157
+ - Provides the list of offending cops to the Counselor
158
+
159
+ **Counselor** (new, replaces the inline CLI code in Runner)
160
+
161
+ The interactive CLI experience. Responsibilities:
162
+ - Walk through each offending cop
163
+ - Display cop information and examples
164
+ - Collect user choices via cli-ui prompts
165
+ - Pass choices to ConfigWriter
166
+
167
+ Why separate from Runner? The Runner is about RuboCop integration. The Counselor is about user interaction. Different concerns, different classes.
168
+
169
+ **ConfigWriter** (new)
170
+
171
+ Generates `.rubocop.yml` content from user choices. Responsibilities:
172
+ - Convert choices to YAML structure
173
+ - Handle merging with existing config (future)
174
+ - Write to file or output to stdout
175
+
176
+ Why separate? Config generation is its own concern. Keeping it separate makes it testable and allows different output strategies (write file, print to stdout, return string).
177
+
178
+ ---
179
+
180
+ ## Key Decisions
181
+
182
+ ### Decision: Use Registry, Keep YARD
183
+
184
+ **Alternative considered**: Parse everything from YARD (current approach)
185
+
186
+ **Why Registry wins**: It's the authoritative source. RuboCop uses it internally. It's a stable API. Using YARD for cop discovery is indirect—we're parsing documentation to learn structure, when structure is already exposed programmatically.
187
+
188
+ **Why keep YARD for examples**: There's no alternative. Examples are documentation, not structure. They exist only in source comments. YARD is the right tool for extracting documentation.
189
+
190
+ ### Decision: Subclass RuboCop::Runner
191
+
192
+ **Alternative considered**: Run `rubocop` as subprocess, parse output
193
+
194
+ **Why subclassing wins**:
195
+ - Direct access to offense objects (not parsed strings)
196
+ - Can hook multiple points in the execution lifecycle
197
+ - Stays in-process (faster, no serialization)
198
+ - Can reuse RuboCop's configuration loading
199
+
200
+ **Risk**: Coupling to RuboCop internals. The `file_finished` callback is documented behavior, but internals can change.
201
+
202
+ **Mitigation**: Stick to documented hooks. If RuboCop changes significantly, we adapt—but this is true of any integration.
203
+
204
+ ### Decision: Separate Counselor from Runner
205
+
206
+ **Alternative considered**: Keep CLI code in Runner (current approach)
207
+
208
+ **Why separation wins**:
209
+ - Runner is about "run RuboCop, track offenses"
210
+ - Counselor is about "guide user through choices"
211
+ - Mixing them makes both harder to test
212
+ - Different change frequencies: CLI UX will evolve faster than RuboCop integration
213
+
214
+ ### Decision: Generate Config Per-Cop (Incremental Saves)
215
+
216
+ **Alternative considered**: Batch all choices and write at the end
217
+
218
+ **Why per-cop wins**:
219
+ - User doesn't lose progress if they quit mid-session
220
+ - Immediate feedback: config file reflects each choice as it's made
221
+ - No need for a separate "save progress" feature
222
+
223
+ ### Decision: Focus on Offending Cops Only
224
+
225
+ **Alternative considered**: Walk through ALL cops (full configuration wizard)
226
+
227
+ **Why offending-only wins**:
228
+ - Immediate value: address what's actually failing
229
+ - Manageable scope: 5-10 cops vs 500+
230
+ - Progressive disclosure: deal with issues as they arise
231
+ - User already knows they have these offenses (ran RuboCop)
232
+
233
+ **Future extension**: Could add a "full audit" mode that walks through all cops, but that's a different workflow.
234
+
235
+ ---
236
+
237
+ ## What Changes
238
+
239
+ | Current File | Action | Notes |
240
+ |--------------|--------|-------|
241
+ | `store.rb` | Rewrite | Becomes CopCatalog, uses Registry |
242
+ | `cop_store.rb` | Rewrite | Becomes CopEntry, simpler |
243
+ | `configurable_attribute.rb` | Modify | Add `example_for(value)` method |
244
+ | `configurable_option.rb` | Keep or Remove | May not be needed if attributes handle options |
245
+ | `example.rb` | Keep | Works correctly |
246
+ | `runner.rb` | Clean up | Remove debugger, fix empty handlers |
247
+ | `util.rb` | Evaluate | May not be needed |
248
+ | `rubocounsel.rb` | Update | Wire up new components |
249
+ | (new) `example_loader.rb` | Create | Focused YARD parsing |
250
+ | (new) `counselor.rb` | Create | Interactive CLI flow |
251
+ | (new) `config_writer.rb` | Create | YAML generation |
252
+
253
+ ---
254
+
255
+ ## Testing Strategy
256
+
257
+ ### Unit Tests
258
+
259
+ - **ExampleLoader**: Given YARD source, extracts examples correctly
260
+ - **CopEntry**: Given cop class + config + examples, computes attributes correctly
261
+ - **ConfigurableAttribute**: Given config hash, determines type and options correctly
262
+ - **ConfigWriter**: Given choices hash, generates correct YAML
263
+
264
+ ### Integration Tests
265
+
266
+ - **CopCatalog**: Loads real cops from RuboCop, count is reasonable (500+)
267
+ - **Runner**: Running on a file with known offenses captures those cop names
268
+
269
+ ### Manual Testing
270
+
271
+ - **Full flow**: Run on a real project, walk through prompts, verify generated config
272
+
273
+ ---
274
+
275
+ ## Resolved Questions
276
+
277
+ 1. **Merging with existing .rubocop.yml**: Deep merge. Implemented — doesn't clobber existing cop keys.
278
+
279
+ 2. **Cops without configurable attributes**: Enable/Disable/Skip is sufficient. Working as implemented.
280
+
281
+ 3. **Cops with many attributes**: Walk through each. Works fine in practice.
282
+
283
+ 4. **Saving progress**: Moot — we save after each cop decision (incremental writes).
284
+
285
+ 5. **Non-interactive mode**: Dropped. Accepting all defaults is equivalent to not configuring, since RuboCop already uses its defaults. `rubocop --auto-gen-config` covers the "just suppress everything" use case.
286
+
287
+ ---
288
+
289
+ ## Implementation Order (Phase 1 — Complete)
290
+
291
+ All 7 steps implemented. 66 tests passing. Installable as a gem via `rake install`.
292
+
293
+ 1. ~~ExampleLoader~~
294
+ 2. ~~CopCatalog~~
295
+ 3. ~~CopEntry~~
296
+ 4. ~~ConfigWriter~~
297
+ 5. ~~Counselor~~
298
+ 6. ~~Runner cleanup~~
299
+ 7. ~~CLI entry point~~
300
+
301
+ ---
302
+
303
+ ## Backlog
304
+
305
+ ### ~~1. "No examples available" message~~
306
+
307
+ ~~When an attribute has no YARD `@example` tags, the "Show examples" option is silently hidden. Instead, show a message like "No examples available for this attribute" so the user knows it's not a bug.~~
308
+
309
+ Done in PR #9. Message displayed before the prompt for choice/boolean attributes when no examples exist.
310
+
311
+ ### ~~2. Sort cops alphabetically~~
312
+
313
+ ~~Currently cops are walked through in file-discovery order. Default to alphabetical (or by department).~~
314
+
315
+ Done in PR #10. Cops are now sorted alphabetically by default (within their department grouping).
316
+
317
+ ### ~~3. Array attribute awareness~~
318
+
319
+ ~~Currently all array-type attributes (Include, Exclude, AllowedMethods, AllowedPatterns, etc.) are silently skipped. Improve this:~~
320
+
321
+ ~~- **Include/Exclude**: Continue to skip silently (file-targeting config, not style choices)~~
322
+ ~~- **Other array attributes** (AllowedMethods, AllowedPatterns, CountAsOne, etc.): Show an informational message listing them and suggesting the user configure these directly in `.rubocop.yml`~~
323
+
324
+ ~~These attributes are "list the specific things in your codebase to exempt" — not a good fit for interactive prompts.~~
325
+
326
+ Done in PR #11. Non-file-targeting array attributes now display a green informational message suggesting users configure them directly in .rubocop.yml.
327
+
328
+ ### ~~4. Verify extension gem support~~
329
+
330
+ ~~Quick investigation: if rubocop-rails, rubocop-rspec, etc. are in the project's bundle, their cops should appear in `Registry.global`. Verify that rubocounsel already handles these correctly (Runner catches offenses, CopCatalog finds them, ExampleLoader finds their YARD docs). May already work with no changes.~~
331
+
332
+ Done in PR #12. Investigation found that cop discovery (Registry), offense collection (Runner), and configuration data (CopEntry) all worked out of the box. ExampleLoader needed a fix — it was hardcoded to only parse the core rubocop gem's source files. Updated to discover all loaded `rubocop-*` gems so extension cops get YARD examples and docstrings too.
333
+
334
+ ### ~~5. Clean up README.md~~
335
+
336
+ ~~Replace template TODO placeholders with real content: gem description, installation instructions, usage examples.~~
337
+
338
+ Done. Replaced bundler template boilerplate with real gem description, installation instructions, usage walkthrough, and extension gem note.
339
+
340
+ ---
341
+
342
+ ## Non-Goals
343
+
344
+ - Full configuration wizard for all cops (500+ cops is not a useful walkthrough)
345
+ - Custom cop support (uses Registry, so custom cops would need to register themselves)
346
+ - GUI or web interface