Showing 7 of 26 total issues
Function handleDNSQuery
has 9 return statements (exceeds 4 allowed). Open
Open
func handleDNSQuery(w http.ResponseWriter, r *http.Request) {
var body []byte
var err error
switch r.Method {
Method Client.IsBad
has 8 return statements (exceeds 4 allowed). Open
Open
func (client *Client) IsBad(parent context.Context, msg *queue.DomainAccessMessage) bool {
ctx, cancel := context.WithTimeout(parent, timeout)
defer cancel()
request, err := http.NewRequestWithContext(ctx, "POST", url+"/v1/host", bytes.NewBuffer([]byte("host="+msg.Domain)))
Function resolve
has 7 return statements (exceeds 4 allowed). Open
Open
func resolve(ctx context.Context, question dnsmessage.Question, request []byte) []byte {
if err := sem.Acquire(ctx, 1); err != nil {
return nil
}
defer sem.Release(1)
Function resolve
has 7 return statements (exceeds 4 allowed). Open
Open
func resolve(ctx context.Context, request []byte) []byte {
post, err := http.NewRequestWithContext(ctx, "POST", server, bytes.NewBuffer(request))
if err != nil {
log.Println("Resolving failed: ", err)
return nil
Method Cache.Set
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (c *Cache) Set(ctx context.Context, domain string, requestType dnsmessage.Type, response []byte, expiry int) {
Function ReplaceTTLInResponse
has 5 return statements (exceeds 4 allowed). Open
Open
func ReplaceTTLInResponse(response []byte, TTL uint32) ([]byte, error) {
var p dnsmessage.Parser
header, err := p.Start(response)
if err != nil {
Function main
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func main() {
flag.StringVar(&server, "server", "https://dohli.herokuapp.com/dns-query", "DoH server to use")
flag.Parse()
l, err := net.ListenPacket("udp4", ":53")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"