Skip to content

Commit d298e85

Browse files
committed
fixing golint ./... warnings & copyright year
1 parent 3bc1788 commit d298e85

31 files changed

+88
-58
lines changed

.link-checker-service.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2021 Siemens AG
1+
# Copyright 2020-2022 Siemens AG
22
# This file is not subject to the MPLv2 license, and can be edited freely.
33

44
# proxy = "http://<some-proxy>:<port>"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ some URL check services exist, albeit not open source (as of 02.09.2020)
288288
## License
289289

290290
```text
291-
Copyright 2020-2021 Siemens AG and contributors as noted in the AUTHORS file.
291+
Copyright 2020-2022 Siemens AG and contributors as noted in the AUTHORS file.
292292
293293
This Source Code Form is subject to the terms of the Mozilla Public
294294
License, v. 2.0. If a copy of the MPL was not distributed with this

cmd/check.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package cmd
78

89
import (

cmd/root.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package cmd
78

89
import (

cmd/serve.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package cmd
78

89
import (

cmd/version.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package cmd
78

89
import (

infrastructure/cache.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package infrastructure
78

89
import (
910
"encoding/json"
11+
"time"
12+
1013
"github.com/dgraph-io/ristretto"
1114
"github.com/patrickmn/go-cache"
12-
"time"
1315
)
1416

1517
type resultCache interface {

infrastructure/cached_url_checker.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package infrastructure
78

89
import (

infrastructure/cc_limited_url_checker.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package infrastructure
78

89
import (

infrastructure/domain_rate_limited_checker.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package infrastructure
78

89
import (

infrastructure/stats_collector.go

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package infrastructure
78

89
import "sync"
@@ -12,7 +13,7 @@ type Stats struct {
1213
IncomingRequests int64
1314
OutgoingRequests int64
1415
IncomingStreamRequests int64
15-
DnsResolutionsFailed int64
16+
DNSResolutionsFailed int64
1617
LinkChecksErrored int64
1718
LinkChecksOk int64
1819
LinkChecksBroken int64
@@ -22,15 +23,16 @@ type Stats struct {
2223
CacheMisses int64
2324
}
2425

25-
type statsState struct {
26+
// StatsState is the protected instance of the Stats object
27+
type StatsState struct {
2628
sync.RWMutex
2729
s Stats
2830
}
2931

3032
var globalStatsState = newStatsState()
3133

3234
// GlobalStats returns the global handler to the stats collector
33-
func GlobalStats() *statsState {
35+
func GlobalStats() *StatsState {
3436
return globalStatsState
3537
}
3638

@@ -40,89 +42,89 @@ func ResetGlobalStats() {
4042
}
4143

4244
// OnIncomingRequest call on incoming request
43-
func (stats *statsState) OnIncomingRequest() {
45+
func (stats *StatsState) OnIncomingRequest() {
4446
stats.Lock()
4547
stats.s.IncomingRequests++
4648
stats.Unlock()
4749
}
4850

4951
// OnIncomingStreamRequest called on an incoming stream request
50-
func (stats *statsState) OnIncomingStreamRequest() {
52+
func (stats *StatsState) OnIncomingStreamRequest() {
5153
stats.Lock()
5254
stats.s.IncomingStreamRequests++
5355
stats.Unlock()
5456
}
5557

5658
// OnOutgoingRequest called on outgoing request
57-
func (stats *statsState) OnOutgoingRequest() {
59+
func (stats *StatsState) OnOutgoingRequest() {
5860
stats.Lock()
5961
stats.s.OutgoingRequests++
6062
stats.Unlock()
6163
}
6264

63-
// OnDnsResolutionFailed called on dns resolution failure
64-
func (stats *statsState) OnDnsResolutionFailed() {
65+
// OnDNSResolutionFailed called on dns resolution failure
66+
func (stats *StatsState) OnDNSResolutionFailed() {
6567
stats.Lock()
66-
stats.s.DnsResolutionsFailed++
68+
stats.s.DNSResolutionsFailed++
6769
stats.Unlock()
6870
}
6971

7072
// OnLinkErrored called on link check error
71-
func (stats *statsState) OnLinkErrored() {
73+
func (stats *StatsState) OnLinkErrored() {
7274
stats.Lock()
7375
stats.s.LinkChecksErrored++
7476
stats.Unlock()
7577
}
7678

7779
// OnLinkOk called on link check ok
78-
func (stats *statsState) OnLinkOk() {
80+
func (stats *StatsState) OnLinkOk() {
7981
stats.Lock()
8082
stats.s.LinkChecksOk++
8183
stats.Unlock()
8284
}
8385

8486
// OnLinkBroken called on link check broken
85-
func (stats *statsState) OnLinkBroken() {
87+
func (stats *StatsState) OnLinkBroken() {
8688
stats.Lock()
8789
stats.s.LinkChecksBroken++
8890
stats.Unlock()
8991
}
9092

9193
// OnLinkDropped called on link check dropped
92-
func (stats *statsState) OnLinkDropped() {
94+
func (stats *StatsState) OnLinkDropped() {
9395
stats.Lock()
9496
stats.s.LinkChecksDropped++
9597
stats.Unlock()
9698
}
9799

98100
// OnLinkSkipped called on link check skipped
99-
func (stats *statsState) OnLinkSkipped() {
101+
func (stats *StatsState) OnLinkSkipped() {
100102
stats.Lock()
101103
stats.s.LinkChecksSkipped++
102104
stats.Unlock()
103105
}
104106

105107
// OnCacheHit called when the result is taken from the cache
106-
func (stats *statsState) OnCacheHit() {
108+
func (stats *StatsState) OnCacheHit() {
107109
stats.Lock()
108110
stats.s.CacheHits++
109111
stats.Unlock()
110112
}
111113

112114
// OnCacheMiss called when the requested URL wasn't found in the cache
113-
func (stats *statsState) OnCacheMiss() {
115+
func (stats *StatsState) OnCacheMiss() {
114116
stats.Lock()
115117
stats.s.CacheMisses++
116118
stats.Unlock()
117119
}
118120

119121
// GetStats returns a copy of the stats
120-
func (stats *statsState) GetStats() Stats {
122+
func (stats *StatsState) GetStats() Stats {
121123
stats.RLock()
122124
defer stats.RUnlock()
123125
return stats.s // a copy
124126
}
125127

126-
func newStatsState() *statsState {
127-
return &statsState{}
128+
func newStatsState() *StatsState {
129+
return &StatsState{}
128130
}

infrastructure/stats_collector_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package infrastructure
78

89
import (
9-
"github.com/stretchr/testify/assert"
1010
"sync"
1111
"testing"
12+
13+
"github.com/stretchr/testify/assert"
1214
)
1315

1416
func TestCollectingFromSeveralGoroutines(t *testing.T) {
@@ -22,7 +24,7 @@ func TestCollectingFromSeveralGoroutines(t *testing.T) {
2224
IncomingRequests: expectedCount,
2325
OutgoingRequests: expectedCount,
2426
IncomingStreamRequests: expectedCount,
25-
DnsResolutionsFailed: expectedCount,
27+
DNSResolutionsFailed: expectedCount,
2628
LinkChecksErrored: expectedCount,
2729
LinkChecksOk: expectedCount,
2830
LinkChecksBroken: expectedCount,
@@ -47,7 +49,7 @@ func addStats(numGoroutines int, count int) {
4749
s.OnIncomingStreamRequest()
4850
s.OnLinkBroken()
4951
s.OnLinkDropped()
50-
s.OnDnsResolutionFailed()
52+
s.OnDNSResolutionFailed()
5153
s.OnLinkErrored()
5254
s.OnLinkOk()
5355
s.OnLinkSkipped()

infrastructure/strings.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package infrastructure
78

89
import "strings"

infrastructure/strings_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package infrastructure
78

89
import (
9-
"github.com/stretchr/testify/assert"
1010
"strings"
1111
"testing"
12+
13+
"github.com/stretchr/testify/assert"
1214
)
1315

1416
func TestSanitizingUserLogInputForNewlines(t *testing.T) {

infrastructure/url_checker.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package infrastructure
78

89
import (
@@ -455,7 +456,7 @@ func (c *URLCheckerClient) checkURL(ctx context.Context, urlToCheck string, clie
455456
},
456457
DNSDone: func(info httptrace.DNSDoneInfo) {
457458
if remoteAddr == "" {
458-
GlobalStats().OnDnsResolutionFailed()
459+
GlobalStats().OnDNSResolutionFailed()
459460
// this may not be as precise as ConnectDone, thus skipping caching
460461
remoteAddr = getDNSAddressesAsString(info.Addrs)
461462
}
@@ -529,7 +530,7 @@ func (c *URLCheckerClient) resolveAndCacheTCPAddr(network string, err error, add
529530
remoteAddr = addr.String()
530531
c.dnsCache.Set(addrToResolve, remoteAddr, defaultCacheExpirationInterval)
531532
} else {
532-
GlobalStats().OnDnsResolutionFailed()
533+
GlobalStats().OnDNSResolutionFailed()
533534
c.dnsCache.Set(addrToResolve, "DNS resolution failed", defaultRetryFailedAfter)
534535
log.Printf("ERROR in resolveAndCacheTCPAddr: %v", err)
535536
}

infrastructure/url_checker_plugin.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package infrastructure
78

89
import "context"

infrastructure/url_checker_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package infrastructure
78

89
import (

infrastructure/urlcheckstatus.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
66
//go:generate go get github.com/alvaroloes/enumer
77
//go:generate enumer -type=URLCheckStatus -json -text -transform=lower
8+
89
package infrastructure
910

1011
//run go generate to generate enum serialization code

infrastructure/version.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2020-2021 Siemens AG
1+
// Copyright 2020-2022 Siemens AG
22
// This Source Code Form is subject to the terms of the Mozilla Public
33
// License, v. 2.0. If a copy of the MPL was not distributed with this
44
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
// SPDX-License-Identifier: MPL-2.0
6+
67
package infrastructure
78

89
import "runtime/debug"

0 commit comments

Comments
 (0)