Method Handler.UnmarshalCaddyfile
has a Cognitive Complexity of 94 (exceeds 20 allowed). Consider refactoring.
func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
config := getDefaultConfig()
for d.Next() {
Similar blocks of code found in 2 locations. Consider refactoring.
package distributed
import (
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
)
Similar blocks of code found in 2 locations. Consider refactoring.
package influxlog
import "github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
const (
Method Handler.UnmarshalCaddyfile
has 23 return statements (exceeds 4 allowed).
func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
config := getDefaultConfig()
for d.Next() {
Method Handler.ServeHTTP
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {
start := time.Now()
upstreamDuration := time.Duration(0)
Method Handler.UnmarshalCaddyfile
has 126 lines of code (exceeds 100 allowed). Consider refactoring.
func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
config := getDefaultConfig()
for d.Next() {
Method Handler.ServeHTTP
has 14 return statements (exceeds 4 allowed).
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {
start := time.Now()
upstreamDuration := time.Duration(0)
Function getCacheStatus
has 7 return statements (exceeds 4 allowed).
func getCacheStatus(req *http.Request, response *Response, config *Config) (bool, time.Time) {
if response.Code == http.StatusPartialContent || response.snapHeader.Get("Content-Range") != "" {
return false, now().Add(config.LockTimeout)
}
Function judgeResponseShouldCacheOrNot
has 7 return statements (exceeds 4 allowed).
func judgeResponseShouldCacheOrNot(req *http.Request,
statusCode int,
respHeaders http.Header,
privateCache bool) ([]cacheobject.Reason, time.Time, []cacheobject.Warning, *cacheobject.Object, error) {
Method Storage.Delete
has 5 return statements (exceeds 4 allowed).
func (s *Storage) Delete(ctx context.Context, key string) error {
kv, _, err := s.KV.Get(s.generateKey(key), &api.QueryOptions{RequireConsistent: true})
if err != nil {
return fmt.Errorf("unable to get data: %s, key: %s", err.Error(), s.generateKey(key))
}
Similar blocks of code found in 2 locations. Consider refactoring.
case keyCacheMaxMemorySize:
if len(args) != 1 {
return d.Err(fmt.Sprintf("Invalid usage of %s in cache config.", keyCacheMaxMemorySize))
}
num, err := strconv.Atoi(args[0])
Similar blocks of code found in 2 locations. Consider refactoring.
case keyCacheBucketsNum:
if len(args) != 1 {
return d.Err(fmt.Sprintf("Invalid usage of %s in cache config.", keyCacheBucketsNum))
}
num, err := strconv.Atoi(args[0])
type name will be used as distributed.DistributedLock by other packages, and that stutters; consider calling this Lock
type DistributedLock struct {
exported var LogUTCTimeFormat should have comment or be unexported
var LogUTCTimeFormat = "2006/01/02 15:04:05"