Skip to content

Commit

Permalink
feat: add line length limit check
Browse files Browse the repository at this point in the history
  • Loading branch information
houseme committed Oct 7, 2024
1 parent 183395f commit c768d67
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ linters:
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
- gosimple # Linter for Go source code that specializes in simplifying code
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- lll # Reports long lines.
- misspell # Finds commonly misspelled English words in comments
- nolintlint # Reports ill-formed or insufficient nolint directives
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
Expand Down Expand Up @@ -80,6 +81,13 @@ linters-settings:
ignore-words:
- cancelled

# https://golangci-lint.run/usage/linters/#lll
lll:
# Max line length, lines longer will be reported.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option.
# Default: 120.
line-length: 80 # 一行的长度

# https://golangci-lint.run/usage/linters/#revive
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
revive:
Expand All @@ -89,11 +97,11 @@ linters-settings:
- name: atomic
- name: line-length-limit
severity: error
arguments: [ 380 ]
arguments: [ 80 ]
- name: unhandled-error
severity: warning
disabled: true
arguments: []
arguments: ["fmt.Printf", "myFunction", "log.Printf","fmt.Println","bytes.Buffer.WriteString"]
- name: var-naming
severity: warning
disabled: true
Expand Down
52 changes: 52 additions & 0 deletions revive.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.8
errorCode = 0
warningCode = 0

[[rule]]
name = "missing-method-doc"
severity = "error"
message = "Method is missing a documentation comment."

[rule.missing-method-doc]
match = '''
^\s*func\s+\w+\s*\(.*\)\s*\{$
'''

[rule.missing-method-doc.exclude]
expression = '''
^\s*func\s+\w+\s*\(.*\)\s*\{$
'''

[rule.blank-imports]
[rule.context-as-argument]
[rule.context-keys-type]
[rule.dot-imports]
[rule.error-return]
[rule.error-strings]
[rule.error-naming]
[rule.exported]
[rule.if-return]
[rule.increment-decrement]
[rule.line-length-limit]
severity = "error"
arguments = [80]
[rule.var-naming]
arguments = [["ID","URL","IP","HTTP","JSON","API","UID","Id","Api","Uid","Http","Json","Ip","Url"], ["VM"]]
[rule.var-declaration]
[rule.package-comments]
[rule.range]
[rule.receiver-naming]
[rule.time-naming]
[rule.unexported-return]
[rule.indent-error-flow]
[rule.errorf]
[rule.empty-block]
[rule.superfluous-else]
[rule.unused-parameter]
[rule.unreachable-code]
[rule.redefines-builtin-id]
[rule.waitgroup-by-value]
severity = "warning"
disable = false

0 comments on commit c768d67

Please sign in to comment.