Showing 26 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"
Further reading
type name will be used as cache.CacheBackend by other packages, and that stutters; consider calling this Backend Open
Open
type CacheBackend interface {
- Exclude checks
exported method RedisBackend.WithContext should have comment or be unexported Open
Open
func (rb *RedisBackend) WithContext(ctx context.Context) CacheBackend {
- Exclude checks
2: cannot find package "github.com/dimkr/dohli/pkg/cache" in any of: Open
Open
"github.com/dimkr/dohli/pkg/cache"
- Exclude checks
exported method MemoryBackend.Connect should have comment or be unexported Open
Open
func (mb *MemoryBackend) Connect() error {
- Exclude checks
exported method HostsBlacklist.IsBad should have comment or be unexported Open
Open
func (hb *HostsBlacklist) IsBad(_ context.Context, msg *queue.DomainAccessMessage) bool {
- Exclude checks
exported method RedisBackend.Connect should have comment or be unexported Open
Open
func (rb *RedisBackend) Connect() error {
- Exclude checks
exported method Client.Connect should have comment or be unexported Open
Open
func (client *Client) Connect() error {
- Exclude checks
exported method MemoryBackend.Set should have comment or be unexported Open
Open
func (mb *MemoryBackend) Set(key string, value []byte, expiry int) {
- Exclude checks
type name will be used as hosts.HostsBlacklist by other packages, and that stutters; consider calling this Blacklist Open
Open
type HostsBlacklist struct{}
- Exclude checks
exported method MemoryBackend.Get should have comment or be unexported Open
Open
func (mb *MemoryBackend) Get(key string) []byte {
- Exclude checks
exported method HostsBlacklist.Connect should have comment or be unexported Open
Open
func (hb *HostsBlacklist) Connect() error {
- Exclude checks
exported method Client.IsBad should have comment or be unexported Open
Open
func (client *Client) IsBad(parent context.Context, msg *queue.DomainAccessMessage) bool {
- Exclude checks
exported method HostsBlacklist.IsAsync should have comment or be unexported Open
Open
func (hb *HostsBlacklist) IsAsync() bool {
- Exclude checks