Skip to content

chore: upgrade .golangci.yml and workflow to v2 #6924

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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

mohammed90
Copy link
Member

I also ran golangci-lint fmt, which formats all files including tests. It found a couple issues, which is good.

run `golangci-lint fmt`

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
@mohammed90 mohammed90 added under review 🧐 Review is pending before merging CI/CD 🔩 Automated tests, releases labels Mar 25, 2025
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
@mohammed90 mohammed90 requested a review from WeidiDeng March 25, 2025 20:29
@mohammed90
Copy link
Member Author

mohammed90 commented Mar 25, 2025

@WeidiDeng, please take a look. The linter complaints included code lines in the listener management, and those parts of the code scare me. I already introduced and fixed one bug of infinite recursion. I'm afraid I did something else 👀

if !quoted && !(heredoc != heredocClosed || heredocEscaped) &&
if !quoted && (heredoc == heredocClosed && !heredocEscaped) &&
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this one is a valuable change, I think there's a usefulness behind this condition. But maybe it's better to extract this out to a var with a clearer name. I dunno.

Copy link
Member Author

Choose a reason for hiding this comment

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

I honestly struggled to read the former form 😅 How would you read it? It'll help me find a suitable variable name. The new form is read in my head as:

If not quoted, and heredoc is closed and not escaped.

if !(quoted || btQuoted) && !(inHeredoc || heredocEscaped) &&
if (!quoted && !btQuoted) && (!inHeredoc && !heredocEscaped) &&
Copy link
Member

Choose a reason for hiding this comment

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

This one is okay I think, but both are easy enough to read I think.

@francislavoie
Copy link
Member

I'm glad fmt easily fixes the imports order now, very nice addition. We should maybe add that to the contribution doc to mention how to run it

@WeidiDeng
Copy link
Member

The changes regarding listeners are unreasonable. Those embedded fields are explicitly referred to so it's clear whose methods or fields we are using. Because of the way caddy usage pool is designed, there are many cases of struct embedding.

I see the new linter shortens many these types of embedding, and to be fair, I don't like it. Rather, I'd like for the linter to expand some of the embedding to its full form or not care about it at all.

@mohammed90
Copy link
Member Author

The changes regarding listeners are unreasonable. Those embedded fields are explicitly referred to so it's clear whose methods or fields we are using. Because of the way caddy usage pool is designed, there are many cases of struct embedding.

I see the new linter shortens many these types of embedding, and to be fair, I don't like it. Rather, I'd like for the linter to expand some of the embedding to its full form or not care about it at all.

Noted. I'll figure out which linting rule triggers this and disable it.

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
@WeidiDeng
Copy link
Member

Embeds in several other parts are shortened when it's better to leave them as they're, such as headers and response writers.

I think the linter should be run on the unmodified source before this bump.

@mohammed90 mohammed90 marked this pull request as draft April 15, 2025 22:01
@mohammed90
Copy link
Member Author

Changing it to draft until I resolve the review points. It might take me some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/CD 🔩 Automated tests, releases under review 🧐 Review is pending before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants