Skip to content

Code bug: should return a error but return a nil value error #2762

@alingse

Description

@alingse

Environment

  • Server:
  • Client:
  • Protocol:
  • Registry:

Issue description

code 1
https://github.com/apache/dubbo-go/blob/main/config/tls_config.go#L88

	caBytes, err := os.ReadFile(opt.CACertFile)
	if err != nil {
		return nil, err
	}
	if ok := ca.AppendCertsFromPEM(caBytes); !ok {
		return nil, err
	}

the err is nil in line 88, here should define an error to return

code 2

https://github.com/apache/dubbo-go/blob/main/protocol/triple/internal/client/common/client.go#L68

https://github.com/apache/dubbo-go/blob/main/protocol/triple/internal/client/common/client.go#L92

	if sendErr := stream.Send(&greet.GreetStreamRequest{Name: "triple"}); sendErr != nil {
		return err
	}

should return sendErr but return a nil value err

I create a linter to detect code that returns a non-relevant nilness error bug. I checked the top 1000 GitHub Go repositories and found this, all result listed in alingse/sundrylint#4

Logs

Click me to check logs
Copy logs to here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions