lib / pq

Pure Go Postgres driver for database/sql
https://pkg.go.dev/github.com/lib/pq
MIT License
8.86k stars 908 forks source link

Reduced the complexity of handlePgpass #1101

Closed JCPrice0024 closed 1 year ago

JCPrice0024 commented 1 year ago

The complexity of handlePgpass was 30 and most of it seemed unnecessary as there was an anonymous func that was used like a named function and the for loop for scanner.Scan added at least 15 points of complexity alone. So I broke out the anonymous function and made the for loop run through a function with the same functionality as the original loop. I was unable to test the changes however, the complexity of all three has been reduced to under 15 and is ready to be tested. Here is the before and after sonar reports:

image Web capture_30-11-2022_103312_localhost