Skip to content

Conversation

bendrucker
Copy link
Member

@bendrucker bendrucker commented Aug 8, 2025

Extends the JSON formatter to include information about whether issues are fixable or have been fixed, addressing the feature request in #2354.

Changes

  • fixable: Set to true when an issue can be automatically fixed
  • fixed: Set to true when an issue is fixable AND the --fix flag is used
  • Test Updates: Updated all JSON test expectation files to include the new fields

Testing

  • Unit tests for different fixable/fixed combinations
  • Integration tests for autofix scenarios
  • Manual verification with the example from the issue

Example Output

Before

{
  "issues": [{
    "rule": {"name": "terraform_comment_syntax", "severity": "warning"},
    "message": "Single line comments should begin with #",
    "range": {...},
    "callers": []
  }]
}

After

{
  "issues": [{
    "rule": {"name": "terraform_comment_syntax", "severity": "warning"}, 
    "message": "Single line comments should begin with #",
    "range": {...},
    "callers": [],
    "fixable": true,
    "fixed": false
  }]
}

With --fix:

{
  "issues": [{
    "rule": {"name": "terraform_comment_syntax", "severity": "warning"},
    "message": "Single line comments should begin with #", 
    "range": {...},
    "callers": [],
    "fixable": true,
    "fixed": true
  }]
}

Closes #2354

- Add 'fixable' bool field to JSONIssue struct indicating if issue can be auto-fixed
- Add 'fixed' bool field to JSONIssue struct indicating if issue was fixed (fixable && --fix flag)
- Update all test expectation files with new fields
- Maintain backwards compatibility with existing JSON consumers

Resolves #2354
@bendrucker bendrucker changed the title feat: add fixable and fixed fields to JSON output json: add fixed, fixable Aug 8, 2025
Add fixable and fixed fields to bundled integration test result files
to match the new JSON output format.
Updates the expected fixable field values in bundled integration test
result.json files to match the actual behavior of terraform rules:

- terraform_unused_declarations: fixable=true
- terraform_empty_list_equality: fixable=true
- terraform_deprecated_interpolation: fixable=true
- Other rules remain fixable=false as expected

These changes ensure the bundled integration tests pass with the new
fixable and fixed fields in the JSON formatter output.
Fixes Windows integration tests by restoring backslash path separators
in result_windows.json files. On Windows, file paths use backslashes
and the test expectations must match the actual output format.
@bendrucker bendrucker requested a review from wata727 August 8, 2025 03:10
Copy link
Member

@wata727 wata727 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bendrucker bendrucker merged commit 25bbc1f into master Aug 10, 2025
19 checks passed
@bendrucker bendrucker deleted the json-fixable-fields branch August 10, 2025 03:53
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Sep 12, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [tflint](https://github.com/terraform-linters/tflint) | minor | `0.58.1` -> `0.59.1` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>terraform-linters/tflint (tflint)</summary>

### [`v0.59.1`](https://github.com/terraform-linters/tflint/releases/tag/v0.59.1)

[Compare Source](terraform-linters/tflint@v0.59.0...v0.59.1)

#### What's Changed

##### Enhancements

- build(deps): Bump github.com/terraform-linters/tflint-ruleset-terraform from 0.12.0 to 0.13.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2351](terraform-linters/tflint#2351)
- json: add fixed, fixable by [@&#8203;bendrucker](https://github.com/bendrucker) in [#&#8203;2355](terraform-linters/tflint#2355)

##### Bug Fixes

- format(sarif): Add `tflint-errors` rules for errors by [@&#8203;wata727](https://github.com/wata727) in [#&#8203;2373](terraform-linters/tflint#2373)

##### Chores

- build(deps): Bump github.com/sigstore/sigstore-go from 1.0.0 to 1.1.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2343](terraform-linters/tflint#2343)
- build(deps): Bump golang.org/x/net from 0.41.0 to 0.42.0 in the go-x group across 1 directory by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2346](terraform-linters/tflint#2346)
- build(deps): Bump sigstore/cosign-installer from 3.9.1 to 3.9.2 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2347](terraform-linters/tflint#2347)
- workflow: validate issues by [@&#8203;bendrucker](https://github.com/bendrucker) in [#&#8203;2348](terraform-linters/tflint#2348)
- build(deps): Bump google.golang.org/grpc from 1.73.0 to 1.74.2 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2349](terraform-linters/tflint#2349)
- build(deps): Bump docker/login-action from 3.4.0 to 3.5.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2350](terraform-linters/tflint#2350)
- build(deps): Bump mislav/bump-homebrew-formula-action from 3.4 to 3.5 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2353](terraform-linters/tflint#2353)
- dependabot: allow actions writes by [@&#8203;bendrucker](https://github.com/bendrucker) in [#&#8203;2356](terraform-linters/tflint#2356)
- build(deps): Bump docker/metadata-action from 5.7.0 to 5.8.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2352](terraform-linters/tflint#2352)
- build(deps): Bump actions/checkout from 4.2.2 to 5.0.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2357](terraform-linters/tflint#2357)
- build(deps): Bump the go-x group with 3 updates by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2358](terraform-linters/tflint#2358)
- build(deps): Bump github.com/sigstore/sigstore-go from 1.1.0 to 1.1.1 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2359](terraform-linters/tflint#2359)
- build(deps): Bump github.com/hashicorp/go-plugin from 1.6.3 to 1.7.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2360](terraform-linters/tflint#2360)
- build(deps): Bump goreleaser/goreleaser-action from 6.3.0 to 6.4.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2361](terraform-linters/tflint#2361)
- build(deps): Bump golang from 1.24-alpine3.21 to 1.25-alpine3.21 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2362](terraform-linters/tflint#2362)
- build(deps): Bump github.com/go-viper/mapstructure/v2 from 2.3.0 to 2.4.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2363](terraform-linters/tflint#2363)
- build(deps): Bump github.com/hashicorp/go-getter from 1.7.8 to 1.7.9 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2364](terraform-linters/tflint#2364)
- build(deps): Bump google.golang.org/grpc from 1.74.2 to 1.75.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2365](terraform-linters/tflint#2365)
- build(deps): Bump github.com/zclconf/go-cty from 1.16.3 to 1.16.4 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2366](terraform-linters/tflint#2366)
- build(deps): Bump github.com/ulikunitz/xz from 0.5.12 to 0.5.14 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2371](terraform-linters/tflint#2371)
- Add support for Terraform v1.13 by [@&#8203;wata727](https://github.com/wata727) in [#&#8203;2372](terraform-linters/tflint#2372)
- deps: Bump Go version to 1.25 by [@&#8203;wata727](https://github.com/wata727) in [#&#8203;2374](terraform-linters/tflint#2374)
- Bump github.com/ulikunitz/xz to v0.5.15 by [@&#8203;wata727](https://github.com/wata727) in [#&#8203;2375](terraform-linters/tflint#2375)

**Full Changelog**: <terraform-linters/tflint@v0.58.1...v0.59.1>

### [`v0.59.0`](terraform-linters/tflint@v0.58.1...v0.59.0)

[Compare Source](terraform-linters/tflint@v0.58.1...v0.59.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS45OC4xIiwidXBkYXRlZEluVmVyIjoiNDEuOTguMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

JSON: include autofix information
2 participants