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

chore: remove unused heightsByQuery function #998

Merged

Conversation

rach-id
Copy link
Member

@rach-id rach-id commented Apr 17, 2023

Description

Please add a description of the changes that this PR introduces and the files that
are the most critical to review.

If this PR is non-trivial/large/complex, please ensure that you have either
created an issue that the team's had a chance to respond to, or had some
discussion with the team prior to submitting substantial pull requests. The team
can be reached via GitHub Discussions or the Cosmos Network Discord server in
the #cometbft channel. GitHub Discussions is preferred over Discord as it
allows us to keep track of conversations topically.
https://github.com/cometbft/cometbft/discussions

If the work in this PR is not aligned with the team's current priorities, please
be advised that it may take some time before it is merged - especially if it has
not yet been discussed with the team.

See the project board for the team's current priorities:
https://github.com/orgs/cometbft/projects/1

-->


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use
    unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments

@rach-id rach-id added the C:rpc Component: RPC label Apr 17, 2023
@rach-id rach-id self-assigned this Apr 17, 2023
@rach-id rach-id removed the C:rpc Component: RPC label Apr 17, 2023
Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

are we not running a filter to catch unused code?

@rach-id
Copy link
Member Author

rach-id commented Apr 17, 2023

Not in core. We're doing it in app. But what I suspect is that if the code is used in a comment, it will consider it as a usage and won't complain

@rootulp
Copy link
Collaborator

rootulp commented Apr 17, 2023

[non-blocking] golangci-lint has unused which should be enabled by default. It is explicitly enabled here. This unused function is flagged along with a bunch of other lint warnings if we run lint with an increased timeout:

$ golangci-lint run --timeout 10m
state/execution_test.go:624:21: Error return value of `eventBus.Stop` is not checked (errcheck)
	defer eventBus.Stop()
	                   ^
mempool/cat/cache.go:125: File is not `gofmt`-ed with `-s` (gofmt)
			peers: map[uint16]struct{}{peer: struct{}{}},
pkg/trace/flags.go:7:2: G101: Potential hardcoded credentials (gosec)
	FlagInfluxDBTokenDescription = "Token to use when writing to the InfluxDB instance. Must be specified if 'influxdb-url' is specified"
	^
mempool/cat/reactor.go:323:27: G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec)
	time.Sleep(time.Duration(rand.Intn(10)*10) * time.Millisecond)
	                         ^
types/block_test.go:895:3: `descripton` is a misspelling of `description` (misspell)
		descripton string
		^
node/node.go:839:48: `arbitary` is a misspelling of `arbitrary` (misspell)
	// create an optional influxdb client to send arbitary data to a remote
	                                              ^
libs/pubsub/query/empty.go:8:22: unused-parameter: parameter 'tags' seems to be unused, consider removing or renaming it as _ (revive)
func (Empty) Matches(tags map[string][]string) (bool, error) {
                     ^
libs/autofile/cmd/logjack.go:81:11: superfluous-else: if block ends with call to os.Exit function, so drop this else and outdent its block (revive)
			} else {
				fmt.Println("logjack errored")
				os.Exit(1)
			}
p2p/upnp/upnp.go:384:68: unused-parameter: parameter 'internalPort' seems to be unused, consider removing or renaming it as _ (revive)
func (n *upnpNAT) DeletePortMapping(protocol string, externalPort, internalPort int) (err error) {
                                                                   ^
rpc/jsonrpc/test/main.go:18:17: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func HelloWorld(ctx *rpctypes.Context, name string, num int) (Result, error) {
                ^
libs/clist/clist.go:255:2: redefines-builtin-id: redefinition of the built-in function len (revive)
	len := l.len
	^
libs/strings/string.go:41:26: empty-block: this block is empty, you can remove it (revive)
		if 32 <= b && b <= 126 {
			// good
		} else {
libs/rand/random_test.go:77:31: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
func TestRngConcurrencySafety(t *testing.T) {
                              ^
libs/rand/random.go:165:11: superfluous-else: if block ends with a continue statement, so drop this else and outdent its block (revive)
			} else {
				chars = append(chars, strChars[v])
				if len(chars) == length {
					break MAIN_LOOP
				}
				val >>= 6
			}
libs/cli/setup.go:141:45: empty-block: this block is empty, you can remove it (revive)
	if err := viper.ReadInConfig(); err == nil {
		// stderr, so if we redirect output to json file, this doesn't appear
		// fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
	} else if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
libs/cli/setup.go:128:45: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
func bindFlagsLoadViper(cmd *cobra.Command, args []string) error {
                                            ^
libs/cli/setup.go:151:21: unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive)
func validateOutput(cmd *cobra.Command, args []string) error {
                    ^
p2p/conn/secret_connection_test.go:312:30: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
func createGoldenTestVectors(t *testing.T) string {
                             ^
p2p/conn/connection.go:660:2: empty-block: this block is empty, you can remove it (revive)
	for range c.pong {
		// Drain
	}
rpc/jsonrpc/server/http_json_handler_test.go:198:11: superfluous-else: if block ends with a continue statement, so drop this else and outdent its block (revive)
			} else {
				// we were expecting an error here, so let's unmarshal a single response
				var response types.RPCResponse
				err = json.Unmarshal(blob, &response)
				if err != nil {
					t.Errorf("#%d: expected successful parsing of an RPCResponse\nblob: %s", i, blob)
					continue
				}
				// have a single-element result
				responses = []types.RPCResponse{response}
			}
libs/json/helpers_test.go:48:35: unused-parameter: parameter 'bz' seems to be unused, consider removing or renaming it as _ (revive)
func (c *CustomPtr) UnmarshalJSON(bz []byte) error {
                                  ^
libs/json/helpers_test.go:63:36: unused-parameter: parameter 'bz' seems to be unused, consider removing or renaming it as _ (revive)
func (c CustomValue) UnmarshalJSON(bz []byte) error {
                                   ^
libs/bits/bit_array_test.go:146:16: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
func TestBytes(t *testing.T) {
               ^
libs/bits/bit_array_test.go:191:28: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
func TestUpdateNeverPanics(t *testing.T) {
                           ^
libs/bits/bit_array_test.go:213:45: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
func TestNewBitArrayNeverCrashesOnNegatives(t *testing.T) {
                                            ^
rpc/jsonrpc/jsonrpc_test.go:74:17: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func EchoResult(ctx *types.Context, v string) (*ResultEcho, error) {
                ^
rpc/jsonrpc/jsonrpc_test.go:78:19: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func EchoWSResult(ctx *types.Context, v string) (*ResultEcho, error) {
                  ^
rpc/jsonrpc/jsonrpc_test.go:82:20: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func EchoIntResult(ctx *types.Context, v int) (*ResultEchoInt, error) {
                   ^
rpc/jsonrpc/jsonrpc_test.go:86:22: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func EchoBytesResult(ctx *types.Context, v []byte) (*ResultEchoBytes, error) {
                     ^
rpc/jsonrpc/jsonrpc_test.go:90:26: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func EchoDataBytesResult(ctx *types.Context, v cmtbytes.HexBytes) (*ResultEchoDataBytes, error) {
                         ^
rpc/jsonrpc/jsonrpc_test.go:94:22: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func EchoWithDefault(ctx *types.Context, v *int) (*ResultEchoWithDefault, error) {
                     ^
p2p/mock/reactor.go:23:27: unused-parameter: parameter 'peer' seems to be unused, consider removing or renaming it as _ (revive)
func (r *Reactor) AddPeer(peer p2p.Peer)                             {}
                          ^
p2p/mock/reactor.go:24:30: unused-parameter: parameter 'peer' seems to be unused, consider removing or renaming it as _ (revive)
func (r *Reactor) RemovePeer(peer p2p.Peer, reason interface{})      {}
                             ^
p2p/mock/peer.go:46:33: unused-parameter: parameter 'e' seems to be unused, consider removing or renaming it as _ (revive)
func (mp *Peer) TrySendEnvelope(e p2p.Envelope) bool { return true }
                                ^
p2p/mock/peer.go:47:30: unused-parameter: parameter 'e' seems to be unused, consider removing or renaming it as _ (revive)
func (mp *Peer) SendEnvelope(e p2p.Envelope) bool    { return true }
                             ^
p2p/mock/reactor.go:25:35: unused-parameter: parameter 'e' seems to be unused, consider removing or renaming it as _ (revive)
func (r *Reactor) ReceiveEnvelope(e p2p.Envelope)                    {}
                                  ^
p2p/mock/reactor.go:26:27: unused-parameter: parameter 'chID' seems to be unused, consider removing or renaming it as _ (revive)
func (r *Reactor) Receive(chID byte, peer p2p.Peer, msgBytes []byte) {}
                          ^
p2p/peer_set_test.go:22:37: unused-parameter: parameter 'e' seems to be unused, consider removing or renaming it as _ (revive)
func (mp *mockPeer) TrySendEnvelope(e Envelope) bool { return true }
                                    ^
p2p/switch_test.go:68:32: unused-parameter: parameter 'peer' seems to be unused, consider removing or renaming it as _ (revive)
func (tr *TestReactor) AddPeer(peer Peer) {}
                               ^
p2p/peer_set_test.go:23:34: unused-parameter: parameter 'e' seems to be unused, consider removing or renaming it as _ (revive)
func (mp *mockPeer) SendEnvelope(e Envelope) bool    { return true }
                                 ^
p2p/switch_test.go:70:35: unused-parameter: parameter 'peer' seems to be unused, consider removing or renaming it as _ (revive)
func (tr *TestReactor) RemovePeer(peer Peer, reason interface{}) {}
                                  ^
p2p/switch_test.go:110:21: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
func MakeSwitchPair(t testing.TB, initSwitch func(int, *Switch) *Switch) (*Switch, *Switch) {
                    ^
p2p/switch_test.go:116:21: unused-parameter: parameter 'i' seems to be unused, consider removing or renaming it as _ (revive)
func initSwitchFunc(i int, sw *Switch) *Switch {
                    ^
p2p/switch_test.go:722:33: unused-parameter: parameter 'c' seems to be unused, consider removing or renaming it as _ (revive)
func (et errorTransport) Accept(c peerConfig) (Peer, error) {
                                ^
p2p/switch_test.go:771:34: unused-parameter: parameter 'peer' seems to be unused, consider removing or renaming it as _ (revive)
func (r *mockReactor) RemovePeer(peer Peer, reason interface{}) {
                                 ^
p2p/base_reactor.go:84:29: unused-parameter: parameter 'peer' seems to be unused, consider removing or renaming it as _ (revive)
func (*BaseReactor) AddPeer(peer Peer)                             {}
                            ^
p2p/base_reactor.go:85:32: unused-parameter: parameter 'peer' seems to be unused, consider removing or renaming it as _ (revive)
func (*BaseReactor) RemovePeer(peer Peer, reason interface{})      {}
                               ^
p2p/base_reactor.go:86:37: unused-parameter: parameter 'e' seems to be unused, consider removing or renaming it as _ (revive)
func (*BaseReactor) ReceiveEnvelope(e Envelope)                    {}
                                    ^
p2p/base_reactor.go:87:29: unused-parameter: parameter 'chID' seems to be unused, consider removing or renaming it as _ (revive)
func (*BaseReactor) Receive(chID byte, peer Peer, msgBytes []byte) {}
                            ^
p2p/test_util.go:34:39: unused-parameter: parameter 'other' seems to be unused, consider removing or renaming it as _ (revive)
func (ni mockNodeInfo) CompatibleWith(other NodeInfo) error { return nil }
                                      ^
p2p/test_util.go:186:2: unused-parameter: parameter 'network' seems to be unused, consider removing or renaming it as _ (revive)
	network, version string,
	^
p2p/test_util.go:299:56: unused-parameter: parameter 'src' seems to be unused, consider removing or renaming it as _ (revive)
func (book *AddrBookMock) AddAddress(addr *NetAddress, src *NetAddress) error {
                                                       ^
test/fuzz/p2p/pex/reactor_receive.go:83:34: unused-parameter: parameter 'e' seems to be unused, consider removing or renaming it as _ (revive)
func (fp *fuzzPeer) SendEnvelope(e p2p.Envelope) bool    { return true }
                                 ^
test/fuzz/p2p/pex/reactor_receive.go:84:37: unused-parameter: parameter 'e' seems to be unused, consider removing or renaming it as _ (revive)
func (fp *fuzzPeer) TrySendEnvelope(e p2p.Envelope) bool { return true }
                                    ^
p2p/pex/pex_reactor.go:221:38: unused-parameter: parameter 'reason' seems to be unused, consider removing or renaming it as _ (revive)
func (r *Reactor) RemovePeer(p Peer, reason interface{}) {
                                     ^
abci/types/application.go:48:29: unused-parameter: parameter 'req' seems to be unused, consider removing or renaming it as _ (revive)
func (BaseApplication) Info(req RequestInfo) ResponseInfo {
                            ^
types/block_test.go:200:5: var `emptyBytes` is unused (unused)
var emptyBytes = []byte{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8,
    ^
rpc/core/blocks.go:474:6: func `heightsByQuery` is unused (unused)
func heightsByQuery(ctx *rpctypes.Context, query string) ([]int64, error) {
     ^
light/proxy/routes.go:112:6: type `rpcSignedBlockFunc` is unused (unused)
type rpcSignedBlockFunc func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultSignedBlock, error)
     ^
light/proxy/routes.go:114:6: func `makeSignedBlockFunc` is unused (unused)
func makeSignedBlockFunc(c *lrpc.Client) rpcSignedBlockFunc {
     ^
light/proxy/routes.go:144:6: type `rpcDataCommitmentFunc` is unused (unused)
type rpcDataCommitmentFunc func(
     ^
light/proxy/routes.go:150:6: type `rpcDataRootInclusionProofFunc` is unused (unused)
type rpcDataRootInclusionProofFunc func(
     ^
light/proxy/routes.go:157:6: func `makeDataCommitmentFunc` is unused (unused)
func makeDataCommitmentFunc(c *lrpc.Client) rpcDataCommitmentFunc {
     ^
light/proxy/routes.go:167:6: func `makeDataRootInclusionProofFunc` is unused (unused)
func makeDataRootInclusionProofFunc(c *lrpc.Client) rpcDataRootInclusionProofFunc {
     ^
mempool/cat/store_test.go:94:4: S1000: should use for range instead of for { select {} } (gosimple)
			for {
			^
mempool/cat/pool_test.go:730:5: testinggoroutine: call to (*T).Fatalf from a non-test goroutine (govet)
				t.Fatalf("failed to receive all txs (got %d/%d)", i+1, txs)
				^
rpc/core/events.go:49:5: SA4023: this comparison is never true (staticcheck)
	if sub == nil {
	   ^
rpc/core/events.go:45:2: SA4023(related information): the lhs of the comparison is the 1st return value of this function call (staticcheck)
	sub, err := env.EventBus.Subscribe(subCtx, addr, q, env.Config.SubscriptionBufferSize)
	^
types/event_bus.go:75:20: SA4023(related information): (*github.com/tendermint/tendermint/types.EventBus).Subscribe never returns a nil interface value (staticcheck)
func (b *EventBus) Subscribe(
                   ^
mempool/cat/pool_test.go:725:2: SA2002: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (staticcheck)
	go func() {
	^
mempool/cat/reactor.go:285:7: SA1019: p2p.SendEnvelopeShim is deprecated: Will be removed in v0.37. (staticcheck)
			if p2p.SendEnvelopeShim(e.Src, p2p.Envelope{
			   ^
mempool/cat/reactor.go:341:3: SA1019: peer.Send is deprecated: entities looking to act as peers should implement SendEnvelope instead. Send will be removed in v0.37. (staticcheck)
		peer.Send(MempoolStateChannel, bz)
		^
mempool/cat/reactor.go:374:6: SA1019: peer.Send is deprecated: entities looking to act as peers should implement SendEnvelope instead. Send will be removed in v0.37. (staticcheck)
		if peer.Send(mempool.MempoolChannel, bz) {
		   ^
mempool/cat/reactor.go:398:13: SA1019: peer.Send is deprecated: entities looking to act as peers should implement SendEnvelope instead. Send will be removed in v0.37. (staticcheck)
	success := peer.Send(MempoolStateChannel, bz)
	           ^
state/execution_test.go:6:2: SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)
	"io/ioutil"
	^

@rootulp rootulp mentioned this pull request Apr 17, 2023
@rach-id rach-id merged commit d23c70f into celestiaorg:v0.34.x-celestia Apr 17, 2023
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