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

Is it possible to cuddled if with related lines? #70

Closed
flw-cn opened this issue Feb 12, 2020 · 3 comments
Closed

Is it possible to cuddled if with related lines? #70

flw-cn opened this issue Feb 12, 2020 · 3 comments

Comments

@flw-cn
Copy link
Contributor

flw-cn commented Feb 12, 2020

For example:

	result, err := doSomeThing()

	if err != nil {
		return err
	}

In the above code, there is a blank line before the if statement, and I really want to remind developers to remove it. Is it possible to add a rule to give such a warning?

Thank you in advance.

@bombsimon
Copy link
Owner

I don't think it's possible to enforce cuddling every time something is related, the main purpose is to get people to add newlines. However since it's idiomatic to cuddle the error checking it was implemented in #65 (after #66 was created).

The feature is not merged to golangci-lint but if you build your own version or use wsl with --enforce-err-cuddling you can enforce what you're asking about regarding error checking.

@flw-cn
Copy link
Contributor Author

flw-cn commented Feb 12, 2020

That's true. I understand. I should use wsl on master.

@flw-cn flw-cn closed this as completed Feb 12, 2020
@bombsimon
Copy link
Owner

For now that's the best idea! I (or someone) will update the version in golangci-lint with a new release in the future. I've been lagging behind because I really want to find the time to implement a fixer before the next merge to golangci-lint. Sadly it seems like it will take longer than I thought so I might need to update golangci-lint anyway.

To build it locally is the only option right now I'm afraid.

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

No branches or pull requests

2 participants