Showing 26 of 26 total issues

Function handleDNSQuery has 9 return statements (exceeds 4 allowed).
Open

func handleDNSQuery(w http.ResponseWriter, r *http.Request) {
    var body []byte
    var err error

    switch r.Method {
Severity: Major
Found in cmd/web/main.go - About 55 mins to fix

    Method Client.IsBad has 8 return statements (exceeds 4 allowed).
    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)))
    Severity: Major
    Found in pkg/urlhaus/api.go - About 50 mins to fix

      Function resolve has 7 return statements (exceeds 4 allowed).
      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)
      Severity: Major
      Found in cmd/web/main.go - About 45 mins to fix

        Function resolve has 7 return statements (exceeds 4 allowed).
        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
        Severity: Major
        Found in cmd/stub/main.go - About 45 mins to fix

          Method Cache.Set has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func (c *Cache) Set(ctx context.Context, domain string, requestType dnsmessage.Type, response []byte, expiry int) {
          Severity: Minor
          Found in pkg/cache/cache.go - About 35 mins to fix

            Function ReplaceTTLInResponse has 5 return statements (exceeds 4 allowed).
            Open

            func ReplaceTTLInResponse(response []byte, TTL uint32) ([]byte, error) {
                var p dnsmessage.Parser
            
                header, err := p.Start(response)
                if err != nil {
            Severity: Major
            Found in pkg/dns/ttl.go - About 35 mins to fix

              Function main has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
              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")
              Severity: Minor
              Found in cmd/stub/main.go - About 25 mins to fix

              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

              type CacheBackend interface {
              Severity: Minor
              Found in pkg/cache/backend.go by golint

              exported method RedisBackend.WithContext should have comment or be unexported
              Open

              func (rb *RedisBackend) WithContext(ctx context.Context) CacheBackend {
              Severity: Minor
              Found in pkg/cache/redis_backend.go by golint

              2: cannot find package "github.com/dimkr/dohli/pkg/cache" in any of:
              Open

                  "github.com/dimkr/dohli/pkg/cache"
              Severity: Minor
              Found in cmd/stub/main.go by govet

              exported method MemoryBackend.Connect should have comment or be unexported
              Open

              func (mb *MemoryBackend) Connect() error {
              Severity: Minor
              Found in pkg/cache/memory_backend.go by golint

              exported method HostsBlacklist.IsBad should have comment or be unexported
              Open

              func (hb *HostsBlacklist) IsBad(_ context.Context, msg *queue.DomainAccessMessage) bool {
              Severity: Minor
              Found in pkg/hosts/hosts.go by golint

              exported method RedisBackend.Connect should have comment or be unexported
              Open

              func (rb *RedisBackend) Connect() error {
              Severity: Minor
              Found in pkg/cache/redis_backend.go by golint

              exported method Client.Connect should have comment or be unexported
              Open

              func (client *Client) Connect() error {
              Severity: Minor
              Found in pkg/urlhaus/api.go by golint

              exported method MemoryBackend.Set should have comment or be unexported
              Open

              func (mb *MemoryBackend) Set(key string, value []byte, expiry int) {
              Severity: Minor
              Found in pkg/cache/memory_backend.go by golint

              type name will be used as hosts.HostsBlacklist by other packages, and that stutters; consider calling this Blacklist
              Open

              type HostsBlacklist struct{}
              Severity: Minor
              Found in pkg/hosts/hosts.go by golint

              exported method MemoryBackend.Get should have comment or be unexported
              Open

              func (mb *MemoryBackend) Get(key string) []byte {
              Severity: Minor
              Found in pkg/cache/memory_backend.go by golint

              exported method HostsBlacklist.Connect should have comment or be unexported
              Open

              func (hb *HostsBlacklist) Connect() error {
              Severity: Minor
              Found in pkg/hosts/hosts.go by golint

              exported method Client.IsBad should have comment or be unexported
              Open

              func (client *Client) IsBad(parent context.Context, msg *queue.DomainAccessMessage) bool {
              Severity: Minor
              Found in pkg/urlhaus/api.go by golint

              exported method HostsBlacklist.IsAsync should have comment or be unexported
              Open

              func (hb *HostsBlacklist) IsAsync() bool {
              Severity: Minor
              Found in pkg/hosts/hosts.go by golint
              Severity
              Category
              Status
              Source
              Language