chainlink icon indicating copy to clipboard operation
chainlink copied to clipboard

core/services/chainlink/config.go: merge RawConfigs using expected fields

Open cfal opened this issue 1 year ago • 4 comments

cfal avatar Sep 14 '24 21:09 cfal

Quality Gate failed Quality Gate failed

Failed conditions
7 New Major Issues (required ≤ 5)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

AER Report: CI Core

aer_workflow , commit , Detect Changes , Clean Go Tidy & Generate , lint , Core Tests (go_core_tests) , Core Tests (go_core_ccip_deployment_tests) , Core Tests (go_core_race_tests) , Core Tests (go_core_fuzz) , SonarQube Scan

1. Error return value not checked: [Golang Lint]

Source of Error:
core/services/chainlink/config.go:66:17: Error return value of `(github.com/smartcontractkit/chainlink/v2/core/services/chainlink.RawConfig).SetFrom` is not checked (errcheck)
			rs[i].SetFrom(config)
			 ^
**Why**: The function `SetFrom` returns an error that is not being checked. Ignoring error return values can lead to unhandled exceptions and unexpected behavior.

Suggested fix: Add error handling for the SetFrom function call to ensure any errors are properly managed.

2. Variable naming issues: [Golang Lint]

Source of Error:
core/services/chainlink/config.go:60:3: var-naming: var chainId should be chainID (revive)
		chainId := config.ChainID()
		^

core/services/chainlink/config.go:62:4: var-naming: var otherChainId should be otherChainID (revive)
			otherChainId := r.ChainID()
			^

core/services/chainlink/config.go:82:2: var-naming: var chainIds should be chainIDs (revive)
	chainIds := commonconfig.UniqueStrings{}
	^

core/services/chainlink/config.go:84:3: var-naming: var chainId should be chainID (revive)
		chainId := config.ChainID()
		^

core/services/chainlink/config.go:112:2: var-naming: var chainId should be chainID (revive)
	chainId := c.ChainID()
	^
**Why**: The variable names do not follow the Go naming conventions, which prefer `ID` over `Id` for consistency and readability.

Suggested fix: Rename the variables from chainId, otherChainId, and chainIds to chainID, otherChainID, and chainIDs respectively.

3. Redundant nil check: [Golang Lint]

Source of Error:
core/services/chainlink/config.go:117:5: S1009: should omit nil check; len() for []string is defined as zero (gosimple)
	if nodeNames == nil || len(nodeNames) == 0 {
	 ^
**Why**: Checking for `nil` before checking the length of a slice is redundant because `len()` on a `nil` slice returns zero.

Suggested fix: Remove the nil check and only check the length of the slice: if len(nodeNames) == 0 {.

AER Report: Operator UI CI ran successfully :white_check_mark:

aer_workflow , commit

github-actions[bot] avatar Oct 17 '24 21:10 github-actions[bot]

AER Report: CI Core ran successfully :white_check_mark:

aer_workflow , commit

AER Report: Operator UI CI ran successfully :white_check_mark:

aer_workflow , commit

github-actions[bot] avatar Oct 21 '24 09:10 github-actions[bot]

@cfal can you clean up this PR and get it merged please? Aptos staging got affected by some config reorgs and I believe this will fix it.

bolekk avatar Oct 29 '24 21:10 bolekk

Hey @cfal, please do not worry about this failing job. This is unrelated to your PR and will be fixed soon.

lukaszcl avatar Oct 30 '24 16:10 lukaszcl