Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: add file-length-limit rule #1072

Merged
merged 3 commits into from
Oct 26, 2024

Conversation

alexandear
Copy link
Contributor

@alexandear alexandear commented Oct 24, 2024

This PR adds a new rule file-length-limit.
The rule is inspired on the eslint rule max-length.

This rule has options:

  • max (default 0) enforces a maximum number of lines in a file, 0 means the rule is disabled;
  • skipBlankLines (default false) if true ignore lines made up purely of whitespace;
  • skipComments (default false) if true ignore lines containing just comments.

@alexandear alexandear force-pushed the feat/file-length-limit branch from 8e4a158 to a2eb931 Compare October 24, 2024 22:25
@alexandear alexandear marked this pull request as ready for review October 24, 2024 22:30
@alexandear alexandear force-pushed the feat/file-length-limit branch 4 times, most recently from 4713d65 to d33cc0e Compare October 24, 2024 22:44
@alexandear alexandear force-pushed the feat/file-length-limit branch from d33cc0e to f74c8fe Compare October 24, 2024 22:53
@ccoVeille
Copy link
Contributor

For record, archives and context

The following linter made by @DanilXO has been merged into golangci-lint

https://github.com/DanilXO/filen

It also was discussed here
golangci/golangci-lint#2881

@DanilXO
Copy link

DanilXO commented Oct 25, 2024

SkipBlankLines is an interesting addition. I'll add it to my linter too. I was thinking about revive as a place to add this, but I liked the idea of ​​golangci-lint with little disabling linters better.

Copy link
Collaborator

@chavacava chavacava left a comment

Choose a reason for hiding this comment

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

Thanks @alexandear. I've left some comments. Please also add documentation to the Name method to remove the lint warn.

@chavacava
Copy link
Collaborator

IMO the default max must be -1 meaning the rule is not activated. That way we will not pollute the results of those who activate all rules.

@alexandear
Copy link
Contributor Author

alexandear commented Oct 26, 2024

IMO the default max must be -1 meaning the rule is not activated. That way we will not pollute the results of those who activate all rules.

@chavacava Resolved your comments. But I choose 0 in max to disable the rule. This is for consistency with the function-length rule.

@alexandear alexandear requested a review from chavacava October 26, 2024 09:59
@alexandear alexandear force-pushed the feat/file-length-limit branch from 568deb5 to d92f14d Compare October 26, 2024 10:00
@alexandear alexandear force-pushed the feat/file-length-limit branch from d92f14d to 2008ca4 Compare October 26, 2024 10:01
@chavacava chavacava merged commit 3bead6f into mgechev:master Oct 26, 2024
4 checks passed
@alexandear alexandear deleted the feat/file-length-limit branch October 26, 2024 18:17
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants