From 63cc3823228629ab04812fb741cf81222b6e6115 Mon Sep 17 00:00:00 2001 From: zzzk1 Date: Fri, 17 Jan 2025 11:33:02 +0800 Subject: [PATCH 1/2] [chore] Remove incorrect usage of nolint:gosec --- .chloggen/remove-nolint-usage-wrong.yaml | 25 +++++++++++++++++++ .../iruntime/total_memory_linux.go | 1 - pdata/pcommon/timestamp.go | 2 -- pdata/pcommon/timestamp_test.go | 1 - pdata/pcommon/value.go | 2 -- .../memorylimiter_test.go | 1 - service/internal/graph/node.go | 1 - .../proctelemetry/process_telemetry.go | 5 ---- 8 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 .chloggen/remove-nolint-usage-wrong.yaml diff --git a/.chloggen/remove-nolint-usage-wrong.yaml b/.chloggen/remove-nolint-usage-wrong.yaml new file mode 100644 index 00000000000..01d062eaf46 --- /dev/null +++ b/.chloggen/remove-nolint-usage-wrong.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: processor, service, pdata + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove incorrect usage of nolint:gosec introduced by PR #10935 + +# One or more tracking issues or pull requests related to the change +issues: [11425] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [api] diff --git a/internal/memorylimiter/iruntime/total_memory_linux.go b/internal/memorylimiter/iruntime/total_memory_linux.go index 526fefbb191..2380f5e16e0 100644 --- a/internal/memorylimiter/iruntime/total_memory_linux.go +++ b/internal/memorylimiter/iruntime/total_memory_linux.go @@ -49,6 +49,5 @@ func TotalMemory() (uint64, error) { return totalMem, nil } - // nolint:gosec return uint64(memoryQuota), nil } diff --git a/pdata/pcommon/timestamp.go b/pdata/pcommon/timestamp.go index 666f86f43f6..5fd1758b1be 100644 --- a/pdata/pcommon/timestamp.go +++ b/pdata/pcommon/timestamp.go @@ -13,13 +13,11 @@ type Timestamp uint64 // NewTimestampFromTime constructs a new Timestamp from the provided time.Time. func NewTimestampFromTime(t time.Time) Timestamp { - // nolint:gosec return Timestamp(uint64(t.UnixNano())) } // AsTime converts this to a time.Time. func (ts Timestamp) AsTime() time.Time { - // nolint:gosec return time.Unix(0, int64(ts)).UTC() } diff --git a/pdata/pcommon/timestamp_test.go b/pdata/pcommon/timestamp_test.go index 3fa5ffbc5b1..dea8cbfa468 100644 --- a/pdata/pcommon/timestamp_test.go +++ b/pdata/pcommon/timestamp_test.go @@ -12,7 +12,6 @@ import ( func TestUnixNanosConverters(t *testing.T) { t1 := time.Date(2020, 3, 24, 1, 13, 23, 789, time.UTC) - // nolint:gosec tun := Timestamp(t1.UnixNano()) assert.EqualValues(t, uint64(1585012403000000789), tun) diff --git a/pdata/pcommon/value.go b/pdata/pcommon/value.go index ad2e1c7ae47..0948555cd34 100644 --- a/pdata/pcommon/value.go +++ b/pdata/pcommon/value.go @@ -148,7 +148,6 @@ func (v Value) FromRaw(iv any) error { case int64: v.SetInt(tv) case uint: - // nolint:gosec v.SetInt(int64(tv)) case uint8: v.SetInt(int64(tv)) @@ -157,7 +156,6 @@ func (v Value) FromRaw(iv any) error { case uint32: v.SetInt(int64(tv)) case uint64: - // nolint:gosec v.SetInt(int64(tv)) case float32: v.SetDouble(float64(tv)) diff --git a/processor/memorylimiterprocessor/memorylimiter_test.go b/processor/memorylimiterprocessor/memorylimiter_test.go index e6ac7da5819..b195513790e 100644 --- a/processor/memorylimiterprocessor/memorylimiter_test.go +++ b/processor/memorylimiterprocessor/memorylimiter_test.go @@ -52,7 +52,6 @@ func TestNoDataLoss(t *testing.T) { runtime.ReadMemStats(&ms) // Set the limit to current usage plus expected increase. This means initially we will not be limited. - // nolint:gosec cfg.MemoryLimitMiB = uint32(ms.Alloc/(1024*1024) + expectedMemoryIncreaseMiB) cfg.MemorySpikeLimitMiB = 1 diff --git a/service/internal/graph/node.go b/service/internal/graph/node.go index 0d1c329c68e..0e17bb74bf5 100644 --- a/service/internal/graph/node.go +++ b/service/internal/graph/node.go @@ -17,6 +17,5 @@ func (n nodeID) ID() int64 { func newNodeID(parts ...string) nodeID { h := fnv.New64a() h.Write([]byte(strings.Join(parts, "|"))) - // nolint:gosec return nodeID(h.Sum64()) } diff --git a/service/internal/proctelemetry/process_telemetry.go b/service/internal/proctelemetry/process_telemetry.go index de60d4518ed..0fe58d5d694 100644 --- a/service/internal/proctelemetry/process_telemetry.go +++ b/service/internal/proctelemetry/process_telemetry.go @@ -68,7 +68,6 @@ func RegisterProcessMetrics(cfg component.TelemetrySettings, opts ...RegisterOpt ctx = context.WithValue(ctx, common.EnvKey, common.EnvMap{common.HostProcEnvKey: set.hostProc}) } pm.context = ctx - // nolint:gosec pm.proc, err = process.NewProcessWithContext(pm.context, int32(os.Getpid())) if err != nil { return err @@ -94,7 +93,6 @@ func (pm *processMetrics) updateAllocMem() int64 { pm.mu.Lock() defer pm.mu.Unlock() pm.readMemStatsIfNeeded() - // nolint:gosec return int64(pm.ms.Alloc) } @@ -102,7 +100,6 @@ func (pm *processMetrics) updateTotalAllocMem() int64 { pm.mu.Lock() defer pm.mu.Unlock() pm.readMemStatsIfNeeded() - // nolint:gosec return int64(pm.ms.TotalAlloc) } @@ -110,7 +107,6 @@ func (pm *processMetrics) updateSysMem() int64 { pm.mu.Lock() defer pm.mu.Unlock() pm.readMemStatsIfNeeded() - // nolint:gosec return int64(pm.ms.Sys) } @@ -129,7 +125,6 @@ func (pm *processMetrics) updateRSSMemory() int64 { if err != nil { return 0 } - // nolint:gosec return int64(mem.RSS) } From de2573553cd3d912b34b3516951a71d70c35cba3 Mon Sep 17 00:00:00 2001 From: zzzk1 Date: Fri, 17 Jan 2025 12:41:41 +0800 Subject: [PATCH 2/2] changelog no need --- .chloggen/remove-nolint-usage-wrong.yaml | 25 ------------------------ 1 file changed, 25 deletions(-) delete mode 100644 .chloggen/remove-nolint-usage-wrong.yaml diff --git a/.chloggen/remove-nolint-usage-wrong.yaml b/.chloggen/remove-nolint-usage-wrong.yaml deleted file mode 100644 index 01d062eaf46..00000000000 --- a/.chloggen/remove-nolint-usage-wrong.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Use this changelog template to create an entry for release notes. - -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: breaking - -# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) -component: processor, service, pdata - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Remove incorrect usage of nolint:gosec introduced by PR #10935 - -# One or more tracking issues or pull requests related to the change -issues: [11425] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: - -# Optional: The change log or logs in which this entry should be included. -# e.g. '[user]' or '[user, api]' -# Include 'user' if the change is relevant to end users. -# Include 'api' if there is a change to a library API. -# Default: '[user]' -change_logs: [api]