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

Add linters #2403

Merged
merged 1 commit into from
Feb 6, 2025
Merged

Add linters #2403

merged 1 commit into from
Feb 6, 2025

Conversation

AnkushinDaniil
Copy link
Contributor

This pull request includes multiple changes aimed at improving the codebase by optimizing loops and adding new linters. The most significant changes include replacing traditional for loops with range loops, adding new linters to the configuration, and optimizing array initialization.

Loop Optimization:

Linter Configuration:

  • .golangci.yaml: Added new linters prealloc, makezero, and intrange to the configuration.

Array Initialization:

Copy link

codecov bot commented Jan 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.56%. Comparing base (daeb674) to head (0537486).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2403      +/-   ##
==========================================
- Coverage   74.60%   74.56%   -0.05%     
==========================================
  Files         113      113              
  Lines       13052    13051       -1     
==========================================
- Hits         9738     9732       -6     
- Misses       2583     2586       +3     
- Partials      731      733       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@weiihann
Copy link
Contributor

makezero and prealloc seems good to me.

For intrange, I'm not sure if it actually helps. Personally, it does not help with improving code readability. For example, I'd prefer to see for i := 0; i < len(something); i++ since it's clear to me that it starts at 0 and ends at len(something) - 1. For for i := range len(something), I still have to think about what it actually starts from. Performance wise, I think both are the same? Not super against adding it, but I don't see the benefit of it for now.

* prealloc
* makezero
* intrange
@AnkushinDaniil
Copy link
Contributor Author

Performance wise, I think both are the same?

I've just done some simple benchmarks and range version is about 17% more efficient.

Copy link
Contributor

@rodrigo-pino rodrigo-pino left a comment

Choose a reason for hiding this comment

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

I agree with these changes.

In case of int range, I prefer the new way as well. It is syntactic sugar for the same thing, and avoids the need to write the same old for i =0; etc ... .

@AnkushinDaniil AnkushinDaniil merged commit 6255436 into main Feb 6, 2025
14 checks passed
@AnkushinDaniil AnkushinDaniil deleted the daniil/add-linters branch February 6, 2025 03:01
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

Successfully merging this pull request may close these issues.

3 participants