nats-io / natscli

The NATS Command Line Interface
Apache License 2.0
480 stars 95 forks source link

Clean up consumer code #1084

Open diorcety opened 3 months ago

diorcety commented 3 months ago

Proposed change

Code at line https://github.com/nats-io/natscli/blob/main/cli/consumer_command.go#L1006 is not reachable

At line 1003 c.consumer is always != "" due to conditon at line 1002.

What is the expected behaviour?

Use case

Fix or remove dead code

Contribution

No response

ripienaar commented 2 months ago

Sorry, not sure which code you refer to, when linking to code its best to use permalinks then the links stay valid and shows your code even as the code changes.

Will close for now.

diorcety commented 2 months ago

@ripienaar this code https://github.com/nats-io/natscli/blob/d55fe64dc973939785e520e5dccfeddca546e605/cli/consumer_command.go#L1264

        if cfg.Durable != "" && c.consumer != "" && cfg.Durable != c.consumer {
            if c.consumer != "" {
                cfg.Durable = c.consumer
            } else {
                                // Never reached
                return cfg, fmt.Errorf("durable consumer name in %s does not match CLI consumer name %s", c.inputFile, c.consumer)
            }
        }
ripienaar commented 2 months ago

indeed thats dead code, do you want to send a PR to fix?

diorcety commented 2 months ago

I fall on that issue during a modification I made in order to read a field "stream_name" from configuration file in order to create a consumer only from a json file cf (https://github.com/diorcety/natscli/commit/78fc5a477f8b684b4a675a0207e0d3f7069f0714) But for this dead code, I can't figure what was the wanted behavior

ripienaar commented 2 months ago

It's probably just old code from a previous edit left over by accident