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

lll: skip imports #3288

Merged
merged 5 commits into from
Oct 15, 2022
Merged

lll: skip imports #3288

merged 5 commits into from
Oct 15, 2022

Conversation

ibez92
Copy link
Contributor

@ibez92 ibez92 commented Oct 9, 2022

Skip long line check on imports.

Fixes #3251

@boring-cyborg
Copy link

boring-cyborg bot commented Oct 9, 2022

Hey, thank you for opening your first Pull Request !

@CLAassistant
Copy link

CLAassistant commented Oct 9, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@bombsimon bombsimon left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

I added some suggestions about simplifying the code and also a question about correctness. Maybe worth adding a unit test for this?

Also I'm curious if we should set lineNumber := 0 and do lineNumber++ on line 96. That way you don't need to do that in every new branch you create and just call continue since we should always increment the number on each line we scan.

pkg/golinters/lll.go Outdated Show resolved Hide resolved
pkg/golinters/lll.go Outdated Show resolved Hide resolved
@ldez ldez changed the title lll skip imports lll: skip imports Oct 10, 2022
@ldez ldez added enhancement New feature or improvement linter: update Update the linter implementation inside golangci-lint labels Oct 10, 2022
@ibez92
Copy link
Contributor Author

ibez92 commented Oct 10, 2022

Thanks for the PR!

I added some suggestions about simplifying the code and also a question about correctness. Maybe worth adding a unit test for this?

Also I'm curious if we should set lineNumber := 1 and do lineNumber++ on line 96. That way you don't need to do that in every new branch you create and just call continue since we should always increment the number on each line we scan.

Thank you for your reply!

I will try to fix all comments.

One question: could you please guide me where should I put unit test for lll? I don't see any *_test file in the golinters directory. Should I put it there?

@ldez
Copy link
Member

ldez commented Oct 10, 2022

@ibez92 you have to sign the CLA

#3288 (comment)

@ibez92 ibez92 force-pushed the lll-skip-imports-setting branch from d3309e7 to 9ad980b Compare October 10, 2022 04:00
@ibez92
Copy link
Contributor Author

ibez92 commented Oct 10, 2022

Yeah, missed my email in commit, sry.

Now it's signed

@bombsimon
Copy link
Member

Thanks for the PR!

I added some suggestions about simplifying the code and also a question about correctness. Maybe worth adding a unit test for this?

Also I'm curious if we should set lineNumber := 1 and do lineNumber++ on line 96. That way you don't need to do that in every new branch you create and just call continue since we should always increment the number on each line we scan.

Thank you for your reply!

I will try to fix all comments.

One question: could you please guide me where should I put unit test for lll? I don't see any *_test file in the golinters directory. Should I put it there?

Have a look at testdata. You can probably just set max lengt in the config to something very short and import any internal package.

@ibez92
Copy link
Contributor Author

ibez92 commented Oct 11, 2022

Thank you!

I added 2 tests for single and multi import

@ibez92 ibez92 marked this pull request as ready for review October 11, 2022 07:06
@ibez92 ibez92 requested review from bombsimon and removed request for bombsimon October 11, 2022 07:11
pkg/golinters/lll.go Outdated Show resolved Hide resolved
@ibez92 ibez92 requested review from ldez and bombsimon and removed request for ldez and bombsimon October 11, 2022 12:22
@ibez92 ibez92 requested a review from ldez October 11, 2022 12:24
Copy link
Member

@bombsimon bombsimon left a comment

Choose a reason for hiding this comment

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

LGTM but can we also add the change to lineNumber to avoid the incrementation at three different places? Basically:

  • Set lineNumber := 0 on line 87
  • Do lineNumber++ on line 92
  • Remove lineNumber++ in all branches (line 97, 106 and 121)

That way we can add any logic and rely on line numbers getting incremented even if we do a continue in a branch.

@ibez92
Copy link
Contributor Author

ibez92 commented Oct 12, 2022

Nice point, thank you!

Did as you suggested

Copy link
Member

@bombsimon bombsimon left a comment

Choose a reason for hiding this comment

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

LGTM, not merging until you've updated your review status @ldez to avoid miscommunication.

Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

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

LGTM

@ldez ldez merged commit 8a1cf90 into golangci:master Oct 15, 2022
SeigeC pushed a commit to SeigeC/golangci-lint that referenced this pull request Apr 4, 2023
@ldez ldez added this to the v1.50 milestone Mar 6, 2024
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: update Update the linter implementation inside golangci-lint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

silence lll linter for imports
4 participants