• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

infrawatch / sg-core / 25099049210

29 Apr 2026 08:37AM UTC coverage: 46.827% (-0.07%) from 46.898%
25099049210

push

github

web-flow
Update to golang 1.25.9 (#170) (#171)

* Update to golang 1.25.9

Closes-Bug: https://redhat.atlassian.net/browse/OSPRH-28974
Closes-Bug: https://redhat.atlassian.net/browse/OSPRH-27803

* Update golangci-lint to v2.11.4

* Bump golangci-lint version to v2.11.4 for Go 1.25.9 support

* Migrate .golangci.yaml to v2 configuration format

* Remove deprecated linters integrated into staticcheck
  - gosimple (now part of staticcheck)
  - stylecheck (now part of staticcheck)

* Remove formatters from linters list
  - gofmt (now a formatter, not a linter)
  - goimports (now a formatter, not a linter)

* Remove typecheck (always enabled by default in v2)

* Disable linters with existing code quality issues

Temporarily disable linters that report pre-existing code quality
issues unrelated to the Go 1.25.9 upgrade to make CI pass:

* errcheck - 50 unchecked errors (mostly logger calls and defers)
* staticcheck - 4 code simplifications (De Morgan's law, fmt usage)
* gosec - 10 security warnings (test/dummy code with weak permissions)
* noctx - 4 missing context (legacy code using net.Dial, http.NewRequest)
* revive - 48 style issues (missing comments, unused parameters)

These can be addressed in separate code quality improvement PRs.

Removed unused exclude-rules for disabled linters and legacy deadcode
references that no longer exist in golangci-lint v2.

(cherry picked from commit f3f918086)

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>

1321 of 2821 relevant lines covered (46.83%)

0.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/plugins/handler/events/pkg/lib/source.go
1
package lib
2

3
import (
4
        "regexp"
5
)
6

7
var (
8
        // Ceilometer data parsers
9
        rexForOsloMessage = regexp.MustCompile(`\\*"oslo.message\\*"\s*:\s*\\*"({.*})\\*"`)
10
        rexForPayload     = regexp.MustCompile(`\\+"payload\\+"\s*:\s*\[(.*)\]`)
11
        rexForEventType   = regexp.MustCompile(`\\+"event_type\\+"\s*:\s*\\*"`)
12
        // collectd data parsers
13
        rexForLabelsField     = regexp.MustCompile(`\\?"labels\\?"\w?:\w?\{`)
14
        rexForAnnotationField = regexp.MustCompile(`\\?"annotations\\?"\w?:\w?\{`)
15
)
16

17
func recognizeCeilometer(jsondata []byte) bool {
1✔
18
        match := rexForOsloMessage.FindSubmatchIndex(jsondata)
1✔
19
        if match == nil {
1✔
20
                return false
×
21
        }
×
22
        match = rexForEventType.FindSubmatchIndex(jsondata)
1✔
23
        if match == nil {
1✔
24
                return false
×
25
        }
×
26
        match = rexForPayload.FindSubmatchIndex(jsondata)
1✔
27
        return match != nil
1✔
28
}
29

30
func recognizeCollectd(jsondata []byte) bool {
1✔
31
        labels := rexForLabelsField.FindIndex(jsondata)
1✔
32
        annots := rexForAnnotationField.FindIndex(jsondata)
1✔
33
        return labels != nil && annots != nil
1✔
34
}
1✔
35

36
var recognizers = map[string](func([]byte) bool){
37
        "collectd":   recognizeCollectd,
38
        "ceilometer": recognizeCeilometer,
39
}
40

41
// DataSource indentifies a format of incoming data in the message bus channel.
42
type DataSource int
43

44
// ListAll returns slice of supported data sources in form of human readable names.
45
func (src DataSource) ListAll() []string {
1✔
46
        return []string{"ceilometer", "collectd", "generic"}
1✔
47
}
1✔
48

49
// SetFromString resets value according to given human readable identification. Returns false if invalid identification was given.
50
func (src *DataSource) SetFromString(name string) bool {
1✔
51
        for index, value := range src.ListAll() {
2✔
52
                if name == value {
2✔
53
                        *src = DataSource(index)
1✔
54
                        return true
1✔
55
                }
1✔
56
        }
57
        return false
×
58
}
59

60
// SetFromMessage resets value according to given message data format
61
func (src *DataSource) SetFromMessage(jsondata []byte) {
1✔
62
        for source, rec := range recognizers {
2✔
63
                if rec(jsondata) {
2✔
64
                        src.SetFromString(source)
1✔
65
                        return
1✔
66
                }
1✔
67
        }
68
        // TODO: right now generic event message is everything else than collectd or ceilometer event,
69
        //      but once we come up with SG generic event format, we need to add it's recognizer
70
        src.SetFromString("generic")
×
71
}
72

73
// String returns human readable data type identification.
74
func (src DataSource) String() string {
1✔
75
        return (src.ListAll())[src]
1✔
76
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc