Skip to content

Commit 2434291

Browse files
committed
add gocyclo and godot linters plus associated fixes
1 parent ba4db90 commit 2434291

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

.golangci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ linters:
2828
- gci
2929
- goconst
3030
- gocritic
31+
- gocyclo
32+
- godot
3133
- gofmt
3234
- goheader
3335
- gosec
@@ -93,6 +95,33 @@ linters-settings:
9395
exclude-functions:
9496
- (*bytes.Buffer).WriteString # WriteString is documented as always returning a nil error
9597

98+
gocyclo:
99+
# Minimal code complexity to report.
100+
# Default: 30
101+
min-complexity: 10
102+
103+
godot:
104+
# Comments to be checked: `declarations`, `toplevel`, or `all`.
105+
# Default: declarations
106+
scope: toplevel
107+
# List of regexps for excluding particular comment lines from check.
108+
# Default: []
109+
exclude:
110+
# Exclude todo and fixme comments.
111+
- "^fixme:"
112+
- "^todo:"
113+
- "601"
114+
- "Config-Item:"
115+
- "Message:"
116+
- "Last-Modified:"
117+
- "URI:"
118+
# Check that each sentence ends with a period.
119+
# Default: true
120+
period: true
121+
# Check that each sentence starts with a capital letter.
122+
# Default: false
123+
capital: true
124+
96125
gci:
97126
sections:
98127
- standard # Standard section: captures all standard packages.

message/message.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ func parseFields(lines []string) []*Field {
167167
func parseField(line string) *Field {
168168
tokens := strings.Split(strings.TrimSpace(line), ":")
169169

170-
// the line may have additional colons, so the value needs to be any tokens
171-
// after the first joined with a colon
170+
// The line may have additional colons, so the value needs to be any tokens
171+
// after the first joined with a colon.
172172
valueTkns := make([]string, len(tokens[1:]))
173173
for idx, valueTkn := range tokens[1:] {
174174
valueTkns[idx] = strings.TrimSpace(valueTkn)

method/method.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (m *Method) waitForConfiguration() {
226226
}
227227
}
228228

229-
// A objectLocation wraps details about the requested items location in S3
229+
// A objectLocation wraps details about the requested items location in S3.
230230
type objectLocation struct {
231231
uri *url.URL
232232
bucket string
@@ -241,15 +241,15 @@ func newLocation(value, s3Hostname string) (objectLocation, error) {
241241
if uri.Host == s3Hostname {
242242
tokens := strings.Split(uri.Path, "/")
243243

244-
// splitting "/bucket/this/is/a/path" on "/" produces
244+
// Splitting "/bucket/this/is/a/path" on "/" produces
245245
// ["", "bucket", "this", "is", "a", "path"]
246246
// Note the initial empty string
247247
if len(tokens) < 3 {
248248
return objectLocation{}, errLocMissingRequiredTokens
249249
}
250250

251-
// the first non-zero length string is assumed to be the bucket. the rest are
252-
// concatenated back together as the path to the object in the bucket
251+
// The first non-zero length string is assumed to be the bucket. The rest are
252+
// concatenated back together as the path to the object in the bucket.
253253
return objectLocation{
254254
uri: uri,
255255
bucket: tokens[1],
@@ -272,7 +272,7 @@ func newLocation(value, s3Hostname string) (objectLocation, error) {
272272
}, nil
273273
}
274274

275-
// replace any forward slashes in access key and secret
275+
// Replace any forward slashes in access key and secret.
276276
func preProcessURL(url string) string {
277277
idx := strings.Index(url, "@")
278278
if idx < 0 {

method/method_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Pipeline: true
2727
Single-Instance: yes
2828
`
2929

30-
// The trailing blank line is intentional
30+
// The trailing blank line is intentional.
3131
acqMsg = `600 URI Acquire
3232
URI: s3://fake-access-key-id:fake-access-key-secret@s3.amazonaws.com/apt-repo-bucket/apt/generic/python-bernhard_0.2.3-1_all.deb
3333
Filename: /tmp/python-bernhard_0.2.3-1_all.deb
@@ -38,7 +38,7 @@ Filename: /tmp/riemann-sumd_0.7.2-1_all.deb
3838
3939
`
4040

41-
// The trailing blank line is intentional
41+
// The trailing blank line is intentional.
4242
configMsg = `601 Configuration
4343
Config-Item: Dir::Log=var/log/apt
4444
Config-Item: Dir::Log::Terminal=term.log

0 commit comments

Comments
 (0)