Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom binaries with custom linters #4427

Closed
firelizzard18 opened this issue Feb 28, 2024 · 7 comments · Fixed by #4437
Closed

Allow custom binaries with custom linters #4427

firelizzard18 opened this issue Feb 28, 2024 · 7 comments · Fixed by #4437
Assignees
Labels
enhancement New feature or improvement linter: custom About custom/private linters

Comments

@firelizzard18
Copy link
Contributor

Your feature request related to a problem? Please describe.

Adding a custom linter is a massive headache.

Describe the solution you'd like.

Provide a mechanism for creating wrapper binaries that register custom linters.

Describe alternatives you've considered.

  • Loading custom linters as plugins. This is a massive headache.
  • Create a custom wrapper that uses hacks to register a custom linter. I did this, and it works but it's a horrible hack relying on unsafe and it breaks with the latest version.

Additional context.

I already implemented this. If this issue is received positively I will submit a PR.

@firelizzard18 firelizzard18 added the enhancement New feature or improvement label Feb 28, 2024
@ldez ldez self-assigned this Feb 28, 2024
@ldez
Copy link
Member

ldez commented Feb 28, 2024

Hello,

It's fun because I'm currently working on a system to simplify the plugin system 😄

Your implementation doesn't fit with my design expectations.

I will share my POC in a few days.

@firelizzard18
Copy link
Contributor Author

To be clear the "massive headache" I was referring to is Go's plugin system. I don't see that there's anything you can do to make that much better.

The only thing I care about is that I can install custom linters (probably in a custom binary) without having to use Go's plugin system.

@ldez
Copy link
Member

ldez commented Mar 1, 2024

When I said "simplify the plugin system" I didn't talk about Go's plugin system 😉

I'm waiting for the merge of one PR, and once it's done you will see that my POC will, I hope, fit your needs.

You are not alone in complaining about this, the idea of improving the extensibility of golangci-lint is a topic that I have thought about for a long time.

I made important changes recently to the design of some pieces of golangci-lint.
The users will not see them because it's internal things but those changes will improve a lot the maintainability and allow new things.

@ldez ldez added the linter: custom About custom/private linters label Mar 1, 2024
@ldez
Copy link
Member

ldez commented Mar 2, 2024

@firelizzard18 #4437

@firelizzard18
Copy link
Contributor Author

@ldez That looks good to me, I agree it closes this issue

@ldez
Copy link
Member

ldez commented Mar 3, 2024

Can I ask you to give me more information about your usage of custom linters?

example:

  • What kind of custom linters are you using?
  • Is it related to an internal company usage?
  • how do you share them? (if you share them)

@firelizzard18
Copy link
Contributor Author

It's internal company usage in the sense that they are built specifically for linting rules I wanted to apply to our codebase. But it's 100% open source so anyone who wanted to could copy them, I just don't advertise/publish them, mostly because they're just good enough for my purposes and not polished.

rangevarref detects code that captures a reference to a range variable (the bug that lead to the loopvar changes). I discovered exportloopref after the fact, which may serve the same purpose, but I've never bothered to check since my version works well enough.

The other two, nodebug and noprint, could probably be replaced by forbidigo but again my version works well enough. nodebug detects var debugFoo = true to prevent debug-enable flags from being merged. noprint forbids print statements in the majority of the code base since we use logging libraries instead for output (in most places).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement linter: custom About custom/private linters
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants