-
Notifications
You must be signed in to change notification settings - Fork 1
feat: adding uber style guidelines (WIP) #48
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
base: main
Are you sure you want to change the base?
Conversation
I added |
Ok, I was checking what else to add, and to be honest, I don't know if more rules can be covered, any idea @ccoVeille ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are your homework
- [Local Variable Declarations](https://github.com/uber-go/guide/blob/master/style.md#local-variable-declarations) | ||
- [nil is a valid slice](https://github.com/uber-go/guide/blob/master/style.md#nil-is-a-valid-slice) | ||
- [Reduce Scope of Variables](https://github.com/uber-go/guide/blob/master/style.md#reduce-scope-of-variables) | ||
- [Avoid Naked Parameters](https://github.com/uber-go/guide/blob/master/style.md#avoid-naked-parameters) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something was discussed lately in nakedreturn linter I think
- [nil is a valid slice](https://github.com/uber-go/guide/blob/master/style.md#nil-is-a-valid-slice) | ||
- [Reduce Scope of Variables](https://github.com/uber-go/guide/blob/master/style.md#reduce-scope-of-variables) | ||
- [Avoid Naked Parameters](https://github.com/uber-go/guide/blob/master/style.md#avoid-naked-parameters) | ||
- [Use Raw String Literals to Avoid Escaping](https://github.com/uber-go/guide/blob/master/style.md#use-raw-string-literals-to-avoid-escaping) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one, I plan to create a linter.
There is one rule in staticcheck, but only for regexp
- [Omit Zero Value Fields in Structs](https://github.com/uber-go/guide/blob/master/style.md#omit-zero-value-fields-in-structs) | ||
- [Use `var` for Zero Value Structs](https://github.com/uber-go/guide/blob/master/style.md#use-var-for-zero-value-structs) | ||
- [Initializing Struct References](https://github.com/uber-go/guide/blob/master/style.md#initializing-struct-references) | ||
- [Initializing Maps](https://github.com/uber-go/guide/blob/master/style.md#initializing-maps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is something for this
maybe revive.enforce-slice-style
- [Initializing Struct References](https://github.com/uber-go/guide/blob/master/style.md#initializing-struct-references) | ||
- [Initializing Maps](https://github.com/uber-go/guide/blob/master/style.md#initializing-maps) | ||
- [Format Strings outside Printf](https://github.com/uber-go/guide/blob/master/style.md#format-strings-outside-printf) | ||
- [Naming Printf-style Functions](https://github.com/uber-go/guide/blob/master/style.md#naming-printf-style-functions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is something for this in revive, go vet, or go-critic
- [Package Names](https://github.com/uber-go/guide/blob/master/style.md#package-names) | ||
- [Function Names](https://github.com/uber-go/guide/blob/master/style.md#function-names) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revive.var-naming does that for packages and function
- [Wait for goroutines to exit](https://github.com/uber-go/guide/blob/master/style.md#wait-for-goroutines-to-exit) | ||
- [No goroutines in `init()`](https://github.com/uber-go/guide/blob/master/style.md#no-goroutines-in-init) | ||
- [Performance](https://github.com/uber-go/guide/blob/master/style.md#performance) | ||
- [x] [Prefer strconv over fmt](https://github.com/uber-go/guide/blob/master/style.md#prefer-strconv-over-fmt) - Style applied through `perfsprint` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mention the name of the option
- [Prefer Specifying Container Capacity](https://github.com/uber-go/guide/blob/master/style.md#prefer-specifying-container-capacity) | ||
- [Style](https://github.com/uber-go/guide/blob/master/style.md#style) | ||
- [x] [Avoid overly long lines](https://github.com/uber-go/guide/blob/master/style.md#avoid-overly-long-lines) - Style applied through `lll` | ||
- [Be Consistent](https://github.com/uber-go/guide/blob/master/style.md#be-consistent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe revive.enforce-slice-style make sense here
- [Avoid Naked Parameters](https://github.com/uber-go/guide/blob/master/style.md#avoid-naked-parameters) | ||
- [Use Raw String Literals to Avoid Escaping](https://github.com/uber-go/guide/blob/master/style.md#use-raw-string-literals-to-avoid-escaping) | ||
- [Initializing Structs](https://github.com/uber-go/guide/blob/master/style.md#initializing-structs) | ||
- [Use Field Names to Initialize Structs](https://github.com/uber-go/guide/blob/master/style.md#use-field-names-to-initialize-structs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is something for this
Try to find it with daredevil
- [Use `var` for Zero Value Structs](https://github.com/uber-go/guide/blob/master/style.md#use-var-for-zero-value-structs) | ||
- [Initializing Struct References](https://github.com/uber-go/guide/blob/master/style.md#initializing-struct-references) | ||
- [Initializing Maps](https://github.com/uber-go/guide/blob/master/style.md#initializing-maps) | ||
- [Format Strings outside Printf](https://github.com/uber-go/guide/blob/master/style.md#format-strings-outside-printf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfsprint here maybe, this one might be about str-concat option
- [Function Names](https://github.com/uber-go/guide/blob/master/style.md#function-names) | ||
- [Import Aliasing](https://github.com/uber-go/guide/blob/master/style.md#import-aliasing) | ||
- [x] [Function Grouping and Ordering](https://github.com/uber-go/guide/blob/master/style.md#function-grouping-and-ordering) - Style applied through linter `funcorder`. | ||
- [Reduce Nesting](https://github.com/uber-go/guide/blob/master/style.md#reduce-nesting) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is revive.max-control-nesting and revive.cyclomatic
But also everything listed in #48 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nestif linter also
Skeleton to create a
.golangci-lint.yml
with Uber Style Guidelines.