|
| 1 | +# Clarifying Questions for Linter Auto-fix Feature |
| 2 | + |
| 3 | +## 🤔 Questions for Implementation |
| 4 | + |
| 5 | +Please answer these questions by editing this file directly. Add your answers after each question. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +### 1. **Scope - Which Linters Get Auto-fix?** |
| 10 | + |
| 11 | +Based on the research, I identified these linters with auto-fix: |
| 12 | + |
| 13 | +- ✅ **markdown**: `npx markdownlint-cli --fix` |
| 14 | +- ✅ **yaml**: Should we use `prettier --write` or is there another tool? |
| 15 | +- ✅ **clippy**: `cargo clippy --fix --allow-dirty --allow-staged` |
| 16 | +- ✅ **rustfmt**: Already auto-formats (no change needed) |
| 17 | +- ✅ **taplo**: `taplo fmt` for TOML files |
| 18 | +- ❌ **shellcheck**: No auto-fix (skip) |
| 19 | +- ❌ **cspell**: No auto-fix (skip) |
| 20 | + |
| 21 | +**Questions:** |
| 22 | + |
| 23 | +- Is this the correct list of linters? |
| 24 | +- For YAML, should we use `prettier` or another tool? (I see prettier might not be installed) |
| 25 | +- Are there any other linters I'm missing? |
| 26 | + |
| 27 | +**Your Answer:** |
| 28 | + |
| 29 | +- Is this the correct list of linters? |
| 30 | + |
| 31 | +Yes, it is. |
| 32 | + |
| 33 | +- For YAML, should we use `prettier` or another tool? (I see prettier might not be installed) |
| 34 | + |
| 35 | +We can use [yamlfmt](https://github.com/google/yamlfmt) if it's compatible with the YAML linter we are using. |
| 36 | + |
| 37 | +- Are there any other linters I'm missing? |
| 38 | + |
| 39 | +No, there are no other linters to add. |
| 40 | + |
| 41 | +### 2. **Fix Behavior - What Gets Fixed?** |
| 42 | + |
| 43 | +When running `cargo run --bin linter all --fix`, should we: |
| 44 | + |
| 45 | +- **Option A**: Fix ALL files in the project (even those not staged/modified) |
| 46 | +- **Option B**: Only fix files that the linter would check anyway (current linter behavior) |
| 47 | +- **Option C**: Only fix staged files (git staged files only) |
| 48 | + |
| 49 | +**My assumption:** Option B (same scope as current linting) - is that correct? |
| 50 | + |
| 51 | +**Your Answer:** |
| 52 | + |
| 53 | +Yes, you are right. Option B is the correct one. |
| 54 | + |
| 55 | +### 3. **Output Verbosity and Logging** |
| 56 | + |
| 57 | +You mentioned: |
| 58 | + |
| 59 | +- "We only need to provide the remaining errors. Developers can check what was changed with git." |
| 60 | +- "The output should follow the current pattern. We are only using logging as output (tracing crate)." |
| 61 | +- "Logs can be nested using tracing instrumentation (spans) to group events related to one linter." |
| 62 | + |
| 63 | +**Confirmed approach:** |
| 64 | + |
| 65 | +- Use `tracing` crate for all output (consistent with current implementation) |
| 66 | +- Use tracing spans to group operations per linter (optional enhancement) |
| 67 | +- Log auto-fix operations at INFO level |
| 68 | +- Only show errors that remain after auto-fix |
| 69 | +- Maintain current logging targets (e.g., `target: "markdown"`) |
| 70 | + |
| 71 | +**Example with tracing:** |
| 72 | + |
| 73 | +```rust |
| 74 | +#[tracing::instrument(name = "markdown", skip_all)] |
| 75 | +pub fn run_markdown_linter_with_fix(fix: bool) -> Result<()> { |
| 76 | + if fix { |
| 77 | + info!("Applying auto-fix..."); |
| 78 | + // Run fix command |
| 79 | + } |
| 80 | + info!("Scanning markdown files..."); |
| 81 | + // Run check |
| 82 | + // ... |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +**Question:** Do you want tracing spans for grouping linter operations, or is the current flat logging with targets sufficient? |
| 87 | + |
| 88 | +**Your Answer:** |
| 89 | + |
| 90 | +The current flat logging with targets is sufficient. Regarding "Log auto-fix operations at INFO level", we should not be too verbose. We can show only a summary of the number of files fixed per linter. |
| 91 | + |
| 92 | +### 4. **Exit Code Behavior** |
| 93 | + |
| 94 | +What should the exit code be in these scenarios? |
| 95 | + |
| 96 | +- All linters pass without fixes needed: **0** ✅ |
| 97 | +- Some files auto-fixed, all linters pass after fix: **0** ✅ |
| 98 | +- Some files auto-fixed, but errors remain: **non-zero** ✅ |
| 99 | +- Auto-fix fails (command error): **non-zero** ✅ |
| 100 | + |
| 101 | +**Question:** Is this correct? |
| 102 | + |
| 103 | +**Your Answer:** |
| 104 | + |
| 105 | +Yes, it's correct. |
| 106 | + |
| 107 | +### 5. **Git Integration** |
| 108 | + |
| 109 | +Should we: |
| 110 | + |
| 111 | +- **Option A**: Just run fix commands, let git track changes naturally (unstaged) |
| 112 | +- **Option B**: Automatically stage fixed files |
| 113 | +- **Option C**: Show git diff after fixes |
| 114 | + |
| 115 | +**My assumption:** Option A (just fix, don't auto-stage) - correct? |
| 116 | + |
| 117 | +**Your Answer:** |
| 118 | + |
| 119 | +Yes, it's correct. |
| 120 | + |
| 121 | +### 6. **Error Handling** |
| 122 | + |
| 123 | +If auto-fix command fails (e.g., `npx` not found, network error): |
| 124 | + |
| 125 | +- **Option A**: Fail immediately, don't continue with other linters |
| 126 | +- **Option B**: Log error, skip that linter's auto-fix, continue with checking |
| 127 | +- **Option C**: Log error, skip that linter entirely (no fix or check) |
| 128 | + |
| 129 | +**My suggestion:** Option B (log error, still run check) - agree? |
| 130 | + |
| 131 | +**Your Answer:** |
| 132 | + |
| 133 | +I want a different option: **Option D - Auto-install missing tools**. Automatically install the missing tool (e.g., npm package) if it's not found, the same way we do for the linters. After installation, proceed with auto-fix and checking. |
| 134 | + |
| 135 | +### 7. **Definition of Done - Testing** |
| 136 | + |
| 137 | +What level of testing do you expect? |
| 138 | + |
| 139 | +- Unit tests for CLI parsing? ✅ |
| 140 | +- Integration tests for each linter? ✅ |
| 141 | +- E2E test with actual broken files that get fixed? ✅ |
| 142 | +- Manual testing checklist? ✅ |
| 143 | + |
| 144 | +**Question:** Is this sufficient? |
| 145 | + |
| 146 | +**Your Answer:** |
| 147 | + |
| 148 | +Yes, that should be enough. |
| 149 | + |
| 150 | +### 8. **Documentation Updates** |
| 151 | + |
| 152 | +Which documents need updating? |
| 153 | + |
| 154 | +- `docs/contributing/commit-process.md` - Pre-commit checklist ✅ |
| 155 | +- `docs/contributing/linting.md` - Linting documentation ✅ |
| 156 | +- `README.md` - Main readme (if it mentions linting) ✅ |
| 157 | +- Any others? |
| 158 | + |
| 159 | +**Your Answer:** |
| 160 | + |
| 161 | +No, that's enough. |
| 162 | + |
| 163 | +### 9. **Backward Compatibility** |
| 164 | + |
| 165 | +Should the behavior without `--fix` remain **exactly** the same as current? |
| 166 | + |
| 167 | +- Same output format? ✅ |
| 168 | +- Same exit codes? ✅ |
| 169 | +- Same file paths checked? ✅ |
| 170 | + |
| 171 | +**Question:** Confirm this is correct? |
| 172 | + |
| 173 | +**Your Answer:** |
| 174 | + |
| 175 | +Yes, that's correct. |
| 176 | + |
| 177 | +### 10. **Timeline & Priority** |
| 178 | + |
| 179 | +Should we implement this as: |
| 180 | + |
| 181 | +- **Option A**: Implement all linters at once |
| 182 | +- **Option B**: Start with markdown only, iterate with others |
| 183 | +- **Option C**: Core infrastructure first, then add linters incrementally |
| 184 | + |
| 185 | +**My suggestion:** Option A (all at once, it's not that complex) - agree? |
| 186 | + |
| 187 | +**Your Answer:** |
| 188 | + |
| 189 | +Yes, we can do it all at once. However, during the implementation, I want to work on one linter at a time so we can test each one properly and commit the changes incrementally. |
| 190 | + |
| 191 | +## 📋 Summary of Assumptions |
| 192 | + |
| 193 | +Based on your feedback, here are my assumptions (please confirm or correct): |
| 194 | + |
| 195 | +1. ✅ Add `--fix` flag to existing `cargo run --bin linter` binary |
| 196 | +2. ✅ Fix same files that linter checks (project-wide) |
| 197 | +3. ✅ **UPDATED**: Show only remaining errors after fix, not what was fixed |
| 198 | +4. ✅ Exit 0 only if all errors resolved (fixed or none) |
| 199 | +5. ✅ Don't auto-stage files, just fix them (developers use git to see changes) |
| 200 | +6. ✅ If fix command fails, log error and continue with check |
| 201 | +7. ✅ Implement all linters with auto-fix support at once |
| 202 | +8. ✅ Comprehensive testing (unit + integration + manual) |
| 203 | +9. ✅ Update documentation in commit-process and linting guides |
| 204 | + |
| 205 | +**Your Confirmation:** |
| 206 | + |
| 207 | +Regarding point 6: It's OK, but if the command fails because the tool is missing, I want it to be installed automatically (same as we do for linters). |
| 208 | + |
| 209 | +Regarding point 7: Yes, but during the implementation, I want to work on one linter at a time so we can test each one properly and commit the changes incrementally. |
| 210 | + |
| 211 | +### 11. **Parallel Execution (Moved to Separate Feature)** |
| 212 | + |
| 213 | +**Note**: Parallel execution has been moved to a separate feature specification. |
| 214 | + |
| 215 | +**See**: [Parallel Linter Execution Feature](../linter-parallel-execution/specification.md) |
| 216 | + |
| 217 | +**Decision for auto-fix feature**: Use sequential execution (current approach) |
| 218 | + |
| 219 | +**Rationale**: |
| 220 | + |
| 221 | +- Current performance (~13s) is acceptable for pre-commit workflow |
| 222 | +- Parallel execution is a separate optimization that can be added later |
| 223 | +- Auto-fix works correctly with sequential execution |
| 224 | +- Focus on implementing auto-fix functionality first (higher priority) |
| 225 | + |
| 226 | +**Compatibility**: Auto-fix will work correctly with parallel execution if that feature is implemented in the future. |
| 227 | + |
| 228 | +--- |
| 229 | + |
| 230 | +## 🚀 Next Steps |
| 231 | + |
| 232 | +Once you've answered these questions: |
| 233 | + |
| 234 | +1. I'll update the specification based on your answers |
| 235 | +2. Create a detailed implementation plan |
| 236 | +3. You'll review the plan |
| 237 | +4. Commit the documentation |
| 238 | +5. Start implementing the feature |
0 commit comments