Skip to content

[MAINT] Create custom golangci-lint to integrate tfproviderlint#3254

Open
deiga wants to merge 20 commits intointegrations:mainfrom
F-Secure-web:use-custom-golangci-lint-for-tfproviderlint
Open

[MAINT] Create custom golangci-lint to integrate tfproviderlint#3254
deiga wants to merge 20 commits intointegrations:mainfrom
F-Secure-web:use-custom-golangci-lint-for-tfproviderlint

Conversation

@deiga
Copy link
Copy Markdown
Collaborator

@deiga deiga commented Mar 4, 2026

Before the change?

  • Not able to use tfproviderlint as part of golangci-lint

After the change?

  • Capable to use tfproviderlint as part of golangci-lint
  • Capable of adding new checks for the terraform provider schema
    • Example: tools/tfproviderlint/checks/L001/L001.go
  • Add 3 custom linter rules
    • L001: Instructs to use ValidateDiagFunc instead of ValidateFunc
    • L002: Instructs to use Context-aware CRUD functions
    • L003: Instructs to not call any CRUD functions directly
  • Enable all tfproviderlint checks, which seem sensible and don't require fixes right now
  • Add make lint-new to run stricter linters on only code since main
  • Refactor ci.yaml workflow, to run linters in parallel using golangci-lint-action
    • This enables inline linter complaints in PRs

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 4, 2026

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@deiga deiga force-pushed the use-custom-golangci-lint-for-tfproviderlint branch from cec47f0 to 7f284d2 Compare March 4, 2026 22:21
@deiga deiga force-pushed the use-custom-golangci-lint-for-tfproviderlint branch from 4e23dc1 to 82c95b3 Compare March 15, 2026 18:38
@deiga deiga marked this pull request as ready for review March 15, 2026 18:38
Copy link
Copy Markdown
Collaborator

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

I'm sorry but I'm not currently onboard with this change as it stands. It's a long way away from the principle of least surprise and changes standard patterns I'd expect to see in a TF provider codebase. Is there a reason why we can't run tfproviderlint as a separate job so at least the complexity is kept away from the other more standard linting?

@deiga
Copy link
Copy Markdown
Collaborator Author

deiga commented Mar 16, 2026

@stevehipwell I don't think I understand your objection. The PR forces no changes on existing code and provides a stable way, with oversight, to have all new changes linted with a stricter ruleset.

It basically already does exactly what you're asking for: running the new linter rules in a separate job. While also providing seamless integration into the linting landscape I use.

These changes would reduce a big part of review comments we currently have to type out manually.

Could you elaborate what the problem with these changes is, so that I could understand better?

@stevehipwell
Copy link
Copy Markdown
Collaborator

@deiga you've changed how CI and the local default linting works, neither of which is desirable. I'm keen to have advanced checks but not at the cost of slowdown for local development or changing the fast feedback loop and understandability of the CI job.

Why not run tfproviderlint as a standalone?

@deiga
Copy link
Copy Markdown
Collaborator Author

deiga commented Mar 17, 2026

Why not run tfproviderlint as a standalone?

  • We'd need to use a custom golangci-lint or revive (not investigated) to enable adding our own linter rules.
    • And to get the GitHub Actions tie-in
    • And IMO the custom rules here are the most important part of this change

you've changed how CI and the local default linting works

In some ways, yes. The linter is now fully dependent on make, or at least for the necessary targets to have been run once. After that, one could call the ./bin/custom-gcl directly. BUT it doesn't really change how default linting works IMO. It still uses the same logic for linting and the same ruleset. It just runs a few more rules now.

but not at the cost of slowdown for local development or changing the fast feedback loop and understandability of the CI job.

I haven't measured it, but there should not be any major slowdown locally. Only the first run after each of these forces a recompile: updated golangci-lint version or updated go (non-test) files in ./tools/. Neither of which happen too often, unless you're developing new linters.

If there is an impact on the understandability of the CI job, that has not been intentional and needs to be addressed. Please point to this degradation

@deiga deiga force-pushed the use-custom-golangci-lint-for-tfproviderlint branch from a112dd5 to 97c8e01 Compare March 17, 2026 19:46
@deiga deiga requested a review from stevehipwell March 19, 2026 17:18
@deiga deiga added Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR Needs Discussion This issue/PR needs maintainers to discuss and decide on a course of action. labels Apr 19, 2026
deiga added 16 commits April 24, 2026 11:01
To enable adding `tfproviderlint` as a plugin

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
deiga added 3 commits April 24, 2026 11:01
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
@deiga deiga force-pushed the use-custom-golangci-lint-for-tfproviderlint branch from a6d7d10 to dc392ec Compare April 24, 2026 08:04
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Discussion This issue/PR needs maintainers to discuss and decide on a course of action. Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants