Skip to content

fix: nakedret and exhaustive config #199

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

fix: nakedret and exhaustive config #199

wants to merge 3 commits into from

Conversation

caarlos0
Copy link
Member

I propose we give it a bit more lines before it starts complaining.

@caarlos0 caarlos0 self-assigned this Mar 25, 2025
@caarlos0 caarlos0 requested a review from aymanbagabas as a code owner March 25, 2025 12:10
@caarlos0 caarlos0 marked this pull request as draft March 25, 2025 12:11
@caarlos0 caarlos0 marked this pull request as ready for review March 25, 2025 12:18
@caarlos0 caarlos0 added the enhancement New feature or request label Mar 25, 2025
@caarlos0 caarlos0 changed the title fix: nakedret config fix: nakedret and exhaustive config Mar 25, 2025
max-func-lines: 60
exhaustive:
# Default: false
default-signifies-exhaustive: true
Copy link
Member Author

Choose a reason for hiding this comment

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

this one I'm not so sure about though...

on one hand, most of the times we do use default, it really is meant to cover all other options

but some times, the proper way might be to cover all the options, and make default error (as in, someone somehow provided an unsupported option)

not sure how common the later is, but I have seen the first in our codebase quite a few times

Copy link
Member

Choose a reason for hiding this comment

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

I like this lint tbh, I feel skip default when good mapped cases are settled is better. It's the pattern in many languages that prefer explicity over implicity (Python, Rust, ...). Since can lead to mistakes obscure case switchs

linters-settings:
nakedret:
# Default: 30
max-func-lines: 60
Copy link
Member Author

Choose a reason for hiding this comment

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

this one makes sense to me

we could also forbid naked returns 🤔

Copy link
Member

Choose a reason for hiding this comment

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

I think this is a good middle ground, personally.

@@ -1,3 +1,5 @@
# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.v1.jsonschema.json
Copy link
Member Author

Choose a reason for hiding this comment

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

there's a v2 now, this prevents the editor from complaining about it

Copy link
Member

@aymanbagabas aymanbagabas 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 ok with both changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants