Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/scripts: golangci-lint cleanup #11583

Merged
merged 1 commit into from
Dec 15, 2023
Merged

core/scripts: golangci-lint cleanup #11583

merged 1 commit into from
Dec 15, 2023

Conversation

jmank88
Copy link
Contributor

@jmank88 jmank88 commented Dec 14, 2023

chaincli/command/keeper/upkeep.go:90:9: shadow: declaration of "err" shadows declaration at line 85 (govet)
			rec, err := readCsvFile(path)
			     ^
vrfv2/testnet/v2scripts/super_scripts.go:22: File is not `goimports`-ed with -local github.com/smartcontractkit/chainlink (goimports)
	evmtypes "github.com/ethereum/go-ethereum/core/types"
vrfv2/testnet/v2scripts/super_scripts.go:300:17: `Transfering` is a misspelling of `Transferring` (misspell)
		fmt.Printf("\nTransfering ownership of coordinator: %v, VRF Owner %v\n", contractAddresses.CoordinatorAddress, vrfOwnerAddress.String())
		              ^
vrfv2/testnet/v2scripts/super_scripts.go:323:11: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
			} else {
				return common.HexToAddress("0x0").String()
			}
vrfv2/testnet/v2scripts/super_scripts.go:350:11: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
			} else {
				return common.HexToAddress("0x0").String()
			}
common/avalanche.go:83:10: Error return value of `sha.Read` is not checked (errcheck)
	sha.Read(hashbuf)
	        ^
common/avalanche.go:262:12: Error return value of `rlp.Encode` is not checked (errcheck)
	rlp.Encode(sha, x)
	          ^
common/avalanche.go:263:10: Error return value of `sha.Read` is not checked (errcheck)
	sha.Read(h[:])
	        ^
common/helpers.go:464:13: var-declaration: should omit type *big.Int from declaration of var offset; it will be inferred from the right-hand side (revive)
	var offset *big.Int = big.NewInt(0)
	           ^
common/helpers.go:398:14: shadow: declaration of "err" shadows declaration at line 388 (govet)
		estimated, err := e.Ec.EstimateGas(context.Background(), ethereum.CallMsg{
		           ^
common/helpers.go:478:4: shadow: declaration of "err" shadows declaration at line 460 (govet)
			err := env.Jc.CallContext(context.Background(), &h, "eth_getBlockByNumber", hexutil.EncodeBig(nextBlockNum), false)
			^
vrfv2plus/testnet/v2plusscripts/util.go:7: File is not `goimports`-ed with -local github.com/smartcontractkit/chainlink (goimports)
	"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_load_test_with_metrics"
vrfv2plus/testnet/v2plusscripts/super_scripts.go:217:9: superfluous-else: if block ends with call to panic function, so drop this else and outdent its block (revive)
	} else {
		fmt.Println("key hash registered:", hexutil.Encode(provingKeyRegisteredLog.KeyHash[:]))
	}
vrfv2plus/testnet/v2plusscripts/super_scripts.go:399:9: superfluous-else: if block ends with call to os.Exit function, so drop this else and outdent its block (revive)
	} else {
		fmt.Println("storeEarliest succeeded, checking BH is there")
		bh, err := bhs.GetBlockhash(nil, seReceipt.BlockNumber.Sub(seReceipt.BlockNumber, big.NewInt(256)))
		helpers.PanicErr(err)
		fmt.Println("blockhash stored by storeEarliest:", hexutil.Encode(bh[:]))
		anchorBlockNumber = seReceipt.BlockNumber
	}
vrfv2plus/testnet/v2plusscripts/super_scripts.go:420:9: superfluous-else: if block ends with call to os.Exit function, so drop this else and outdent its block (revive)
	} else {
		fmt.Println("store succeeded, checking BH is there")
		bh, err := bhs.GetBlockhash(nil, toStore)
		helpers.PanicErr(err)
		fmt.Println("blockhash stored by store:", hexutil.Encode(bh[:]))
	}
vrfv2plus/testnet/v2plusscripts/super_scripts.go:438:9: superfluous-else: if block ends with call to os.Exit function, so drop this else and outdent its block (revive)
	} else {
		fmt.Println("storeVerifyHeader succeeded, checking BH is there")
		bh, err := bhs.GetBlockhash(nil, toStore)
		helpers.PanicErr(err)
		fmt.Println("blockhash stored by storeVerifyHeader:", hexutil.Encode(bh[:]))
	}
vrfv2plus/testnet/v2plusscripts/super_scripts.go:715:11: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
			} else {
				return common.HexToAddress("0x0").String()
			}
vrfv2plus/testnet/v2plusscripts/super_scripts.go:736:11: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
			} else {
				return common.HexToAddress("0x0").String()
			}
vrfv2plus/testnet/v2plusscripts/super_scripts.go:205:8: shadow: declaration of "err" shadows declaration at line 80 (govet)
			var err error
			    ^
vrfv2plus/testnet/v2plusscripts/super_scripts.go:278:8: shadow: declaration of "err" shadows declaration at line 80 (govet)
			var err error
			    ^
vrfv2plus/testnet/v2plusscripts/super_scripts.go:401:7: shadow: declaration of "err" shadows declaration at line 384 (govet)
		bh, err := bhs.GetBlockhash(nil, seReceipt.BlockNumber.Sub(seReceipt.BlockNumber, big.NewInt(256)))
		    ^
vrfv2plus/testnet/v2plusscripts/super_scripts.go:422:7: shadow: declaration of "err" shadows declaration at line 384 (govet)
		bh, err := bhs.GetBlockhash(nil, toStore)
		    ^
vrfv2plus/testnet/v2plusscripts/super_scripts.go:270:6: ineffectual assignment to err (ineffassign)
	tx, err = consumer.RequestRandomWords(e.Owner, subID, 100_000, 3, 3, provingKeyRegisteredLog.KeyHash, false)
	    ^
vrfv2plus/testnet/v2plusscripts/super_scripts.go:504:2: ineffectual assignment to fundingAmount (ineffassign)
	fundingAmount := decimal.RequireFromString(*nodeSendingKeyFundingAmount).BigInt()
	^
chaincli/handler/keeper.go:734:11: superfluous-else: if block ends with call to log.Fatalf function, so drop this else and outdent its block (revive)
			} else {
				log.Printf("upkeep privilege config is set for %s", id.String())
			}
chaincli/handler/keeper.go:781:18: func `(*Keeper).createKeeperJobOnExistingNode` is unused (unused)
func (k *Keeper) createKeeperJobOnExistingNode(urlStr, email, password, registryAddr, nodeAddr string) error {
                 ^
chaincli/handler/report.go:93:14: type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)
		err, ok := txErr[i].(JsonError)
		           ^
chaincli/handler/report.go:278:9: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
	return fmt.Sprintf("%s", j)
	       ^
chaincli/handler/ocr2_config.go:57:24: S1004: should use bytes.Equal(tx.To()[:], addr[:]) instead (gosimple)
		if tx.To() != nil && bytes.Compare(tx.To()[:], addr[:]) == 0 {
		                     ^
chaincli/handler/handler.go:414:9: shadow: declaration of "err" shadows declaration at line 231 (govet)
			rdr, err := dockerClient.ContainerLogs(ctx, nodeContainerResp.ID, types.ContainerLogsOptions{
			     ^
chaincli/handler/keeper_launch.go:103:8: shadow: declaration of "err" shadows declaration at line 93 (govet)
			var err error
			    ^
chaincli/handler/keeper_launch.go:110:8: shadow: declaration of "err" shadows declaration at line 93 (govet)
			var err error
			    ^
chaincli/handler/keeper_launch.go:231:6: shadow: declaration of "err" shadows declaration at line 223 (govet)
		if err := k.waitTx(ctx, tx); err != nil {
		   ^
chaincli/handler/keeper_launch.go:239:6: shadow: declaration of "err" shadows declaration at line 223 (govet)
		if err := k.waitTx(ctx, tx); err != nil {
		   ^
chaincli/handler/keeper_launch.go:267:6: shadow: declaration of "err" shadows declaration at line 260 (govet)
		if err := k.waitTx(ctx, tx); err != nil {
		   ^
chaincli/handler/keeper_launch.go:275:6: shadow: declaration of "err" shadows declaration at line 260 (govet)
		if err := k.waitTx(ctx, tx); err != nil {
		   ^
chaincli/handler/keeper.go:742:9: ineffectual assignment to err (ineffassign)
			min, err := reg21.GetMinBalanceForUpkeep(nil, id)
			     ^
chaincli/handler/report.go:87:16: ineffectual assignment to err (ineffassign)
	txRes, txErr, err = getSimulationsForTxs(hdlr, simBatch)
	              ^
gateway/run_gateway.go:59:10: Error return value of `gw.Start` is not checked (errcheck)
	gw.Start(ctx)
	        ^
gateway/client/send_request.go:55:7: shadow: declaration of "err" shadows declaration at line 46 (govet)
		var err error
		    ^
gateway/client/send_request.go:73:14: shadow: declaration of "err" shadows declaration at line 46 (govet)
		signature, err := envelope.Sign(key)
		           ^
ocr2vrf/util.go:309:6: func `registerMigratableCoordinator` is unused (unused)
func registerMigratableCoordinator(e helpers.Environment, coordinatorAddress, migratableCoordinatorAddress string) {
     ^
ocr2vrf/util.go:333:6: func `setBeaconBilling` is unused (unused)
func setBeaconBilling(e helpers.Environment, vrfBeaconAddr string, maximumGasPrice, reasonableGasPrice, observationPayment,
     ^
ocr2vrf/util.go:342:6: func `setCoordinatorBilling` is unused (unused)
func setCoordinatorBilling(e helpers.Environment, vrfCoordinatorAddr string, useReasonableGasPrice bool, unusedGasPenaltyPercent uint8,
     ^
ocr2vrf/setup_ocr2vrf.go:235:3: S1011: should replace loop with `nodesToFund = append(nodesToFund, transmitters[1:]...)` (gosimple)
		for _, t := range transmitters[1:] {
		^
common/vrf/setup-envs/main.go:146:32: G601: Implicit memory aliasing in for loop. (gosec)
		client, app := connectToNode(&node.URL, output, node.CredsFile)
		                             ^
common/vrf/setup-envs/main.go:147:69: G601: Implicit memory aliasing in for loop. (gosec)
		ethKeys := createETHKeysIfNeeded(client, app, output, numEthKeys, &node.URL, maxGasPriceGwei)
		                                                                  ^
common/vrf/setup-envs/main.go:149:69: G601: Implicit memory aliasing in for loop. (gosec)
			vrfKeys := createVRFKeyIfNeeded(client, app, output, numVRFKeys, &node.URL)
			                                                                 ^
common/vrf/setup-envs/main.go:245:33: G601: Implicit memory aliasing in for loop. (gosec)
			client, app := connectToNode(&node.URL, output, node.CredsFile)
			                             ^
common/vrf/setup-envs/main.go:321:12: G306: Expect WriteFile permissions to be 0600 or less (gosec)
	if err := os.WriteFile("job-spec.toml", []byte(jobSpec), 0666); err != nil {
	          ^
common/vrf/setup-envs/main.go:335:12: G306: Expect WriteFile permissions to be 0600 or less (gosec)
	if err := os.WriteFile("vrf-key-password.txt", []byte("twochains"), 0666); err != nil {
	          ^
common/vrf/setup-envs/main.go:349:12: G306: Expect WriteFile permissions to be 0600 or less (gosec)
	if err := os.WriteFile("vrf-key-password.txt", []byte("twochains"), 0666); err != nil {
	          ^
common/vrf/setup-envs/main.go:53:2: var `infoEmoji` is unused (unused)
	infoEmoji      = "ℹ️"
	^
common/vrf/setup-envs/main.go:468:2: S1011: should replace loop with `allVRFKeys = append(allVRFKeys, vrfKeys...)` (gosimple)
	for _, vrfKey := range vrfKeys {
	^
common/vrf/setup-envs/main.go:471:2: S1011: should replace loop with `allVRFKeys = append(allVRFKeys, newKeys...)` (gosimple)
	for _, nk := range newKeys {
	^
common/vrf/setup-envs/main.go:529:2: S1011: should replace loop with `allETHKeysNode = append(allETHKeysNode, ethKeys...)` (gosimple)
	for _, ethKey := range ethKeys {
	^
common/vrf/setup-envs/main.go:532:2: S1011: should replace loop with `allETHKeysNode = append(allETHKeysNode, newKeys...)` (gosimple)
	for _, nk := range newKeys {
	^
vrfv2/testnet/main.go:1091:11: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
			} else {
				panic(err)
			}
functions/src/delete_jobs.go:65:18: Error return value of `client.ListJobs` is not checked (errcheck)
		client.ListJobs(cli.NewContext(app, fileFs, nil))
		               ^
functions/src/delete_jobs.go:76:14: Error return value of `set.Parse` is not checked (errcheck)
				set.Parse([]string{jobSpec.Id})
				         ^
functions/src/deploy_jobspecs_cmd.go:60:15: Error return value of `fileFs.Parse` is not checked (errcheck)
		fileFs.Parse([]string{tomlPath})
		            ^
functions/src/deploy_jobspecs_cmd.go:55:9: shadow: declaration of "err" shadows declaration at line 45 (govet)
		if _, err := os.Stat(tomlPath); err != nil {
		      ^
functions/src/fetching.go:71:3: shadow: declaration of "ocr2Bundle" shadows declaration at line 18 (govet)
		ocr2Bundle := ocr2Bundles[ocr2BundleIndex]
		^
functions/src/generate_ocr2_config_cmd.go:152:19: shadow: declaration of "err" shadows declaration at line 137 (govet)
		nodePublicKeys, err := json.MarshalIndent(nca, "", " ")
		                ^
functions/src/generate_ocr2_config_cmd.go:171:12: shadow: declaration of "err" shadows declaration at line 137 (govet)
		pkBytes, err := hex.DecodeString(n.OCR2OffchainPublicKey)
		         ^
functions/src/generate_ocr2_config_cmd.go:187:12: shadow: declaration of "err" shadows declaration at line 137 (govet)
		pkBytes, err := hex.DecodeString(n.OCR2ConfigPublicKey)
		         ^
common/vrf/model/model.go:24:2: field `jobSpec` is unused (unused)
	jobSpec                     string
	^
gateway/connector/run_connector.go:34:27: Error return value of `h.connector.SendToGateway` is not checked (errcheck)
	h.connector.SendToGateway(context.Background(), gatewayId, msg)
	                         ^
gateway/connector/run_connector.go:73:17: Error return value of `connector.Start` is not checked (errcheck)
	connector.Start(ctx)
	               ^
vrfv2plus/testnet/proofs.go:13: File is not `goimports`-ed with -local github.com/smartcontractkit/chainlink (goimports)
	"github.com/shopspring/decimal"
vrfv2plus/testnet/proofs.go:20:22: var-declaration: should omit type string from declaration of var vrfProofTemplate; it will be inferred from the right-hand side (revive)
var vrfProofTemplate string = `{
                     ^
vrfv2plus/testnet/proofs.go:45:16: var-declaration: should omit type string from declaration of var rcTemplate; it will be inferred from the right-hand side (revive)
var rcTemplate string = `{
               ^
vrfv2plus/testnet/main.go:1049:11: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
			} else {
				panic(err)
			}

Copy link
Contributor

I see that you haven't updated any CHANGELOG files. Would it make sense to do so?

@jmank88 jmank88 force-pushed the core-scripts-lint branch 4 times, most recently from 5b6f28e to 2cd9724 Compare December 15, 2023 00:08
@jmank88 jmank88 requested a review from a team December 15, 2023 00:08
@jmank88 jmank88 marked this pull request as ready for review December 15, 2023 00:11
@jmank88 jmank88 requested review from bolekk and a team as code owners December 15, 2023 00:11
@cl-sonarqube-production
Copy link

SonarQube Quality Gate

Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

No Coverage information No Coverage information
2.2% 2.2% Duplication

@jmank88 jmank88 requested a review from a team December 15, 2023 11:18
Copy link
Contributor

@shileiwill shileiwill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing all those, including keeper issues.

@jmank88 jmank88 added this pull request to the merge queue Dec 15, 2023
Merged via the queue into develop with commit 413ebe2 Dec 15, 2023
84 checks passed
@jmank88 jmank88 deleted the core-scripts-lint branch December 15, 2023 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants