type/encoding/encoding.go

Summary

Maintainability
D
2 days
Test Coverage
D
69%

Method qiDecoder.value has a Cognitive Complexity of 44 (exceeds 20 allowed). Consider refactoring.
Open

func (q qiDecoder) value(v reflect.Value) error {
    switch v.Kind() {
    case reflect.Interface:
        i := v.Interface()
        b, ok := i.(BinaryDecoder)
Severity: Minor
Found in type/encoding/encoding.go - About 4 hrs 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

Method qiDecoder.value has 112 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (q qiDecoder) value(v reflect.Value) error {
    switch v.Kind() {
    case reflect.Interface:
        i := v.Interface()
        b, ok := i.(BinaryDecoder)
Severity: Major
Found in type/encoding/encoding.go - About 3 hrs to fix

    Method qiEncoder.value has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
    Open

    func (q qiEncoder) value(v reflect.Value) error {
        switch v.Kind() {
        case reflect.Interface:
            i := v.Interface()
            w, ok := i.(BinaryEncoder)
    Severity: Minor
    Found in type/encoding/encoding.go - About 2 hrs 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

    Method qiDecoder.value has 21 return statements (exceeds 4 allowed).
    Open

    func (q qiDecoder) value(v reflect.Value) error {
        switch v.Kind() {
        case reflect.Interface:
            i := v.Interface()
            b, ok := i.(BinaryDecoder)
    Severity: Major
    Found in type/encoding/encoding.go - About 1 hr to fix

      Method qiEncoder.value has 71 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (q qiEncoder) value(v reflect.Value) error {
          switch v.Kind() {
          case reflect.Interface:
              i := v.Interface()
              w, ok := i.(BinaryEncoder)
      Severity: Minor
      Found in type/encoding/encoding.go - About 1 hr to fix

        Method qiDecoder.Decode has 13 return statements (exceeds 4 allowed).
        Open

        func (q qiDecoder) Decode(x interface{}) (err error) {
            switch v := x.(type) {
            case CustomDecoder:
                return v.Decode(q)
            case BinaryDecoder:
        Severity: Major
        Found in type/encoding/encoding.go - About 1 hr to fix

          Method qiDecoder.Decode has 55 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (q qiDecoder) Decode(x interface{}) (err error) {
              switch v := x.(type) {
              case CustomDecoder:
                  return v.Decode(q)
              case BinaryDecoder:
          Severity: Minor
          Found in type/encoding/encoding.go - About 1 hr to fix

            Method qiEncoder.value has 10 return statements (exceeds 4 allowed).
            Open

            func (q qiEncoder) value(v reflect.Value) error {
                switch v.Kind() {
                case reflect.Interface:
                    i := v.Interface()
                    w, ok := i.(BinaryEncoder)
            Severity: Major
            Found in type/encoding/encoding.go - About 1 hr to fix

              Method qiDecoder.mapValue has 8 return statements (exceeds 4 allowed).
              Open

              func (q qiDecoder) mapValue(v reflect.Value) error {
                  length, err := basic.ReadInt32(q.r)
                  if err != nil {
                      return fmt.Errorf("failed to read vector size: %w", err)
                  }
              Severity: Major
              Found in type/encoding/encoding.go - About 50 mins to fix

                Method qiDecoder.sliceValue has 8 return statements (exceeds 4 allowed).
                Open

                func (q qiDecoder) sliceValue(v reflect.Value) error {
                    length, err := basic.ReadInt32(q.r)
                    if err != nil {
                        return fmt.Errorf("failed to read vector size: %w", err)
                    }
                Severity: Major
                Found in type/encoding/encoding.go - About 50 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if err != nil {
                                  return fmt.Errorf("read %v: %w",
                                      v.Type().Name(), err)
                              }
                  Severity: Major
                  Found in type/encoding/encoding.go - About 45 mins to fix

                    Method qiDecoder.readValue has 5 return statements (exceeds 4 allowed).
                    Open

                    func (q qiDecoder) readValue(typ reflect.Type) (v reflect.Value, err error) {
                        if typ.Kind() == reflect.Interface {
                            // not much we can do here. let's handle the
                            // special case of value.Value
                            if typ.Name() == "Value" {
                    Severity: Major
                    Found in type/encoding/encoding.go - About 35 mins to fix

                      exported type Decoder should have comment or be unexported
                      Open

                      type Decoder interface {
                      Severity: Minor
                      Found in type/encoding/encoding.go by golint

                      if block ends with a return statement, so drop this else and outdent its block
                      Open

                              } else {
                      Severity: Minor
                      Found in type/encoding/encoding.go by golint

                      exported type BinaryDecoder should have comment or be unexported
                      Open

                      type BinaryDecoder interface {
                      Severity: Minor
                      Found in type/encoding/encoding.go by golint

                      exported type Writer should have comment or be unexported
                      Open

                      type Writer interface {
                      Severity: Minor
                      Found in type/encoding/encoding.go by golint

                      exported type BinaryEncoder should have comment or be unexported
                      Open

                      type BinaryEncoder interface {
                      Severity: Minor
                      Found in type/encoding/encoding.go by golint

                      exported type Encoder should have comment or be unexported
                      Open

                      type Encoder interface {
                      Severity: Minor
                      Found in type/encoding/encoding.go by golint

                      exported function NewEncoder should have comment or be unexported
                      Open

                      func NewEncoder(c Capability, w io.Writer) Encoder {
                      Severity: Minor
                      Found in type/encoding/encoding.go by golint

                      exported type CustomDecoder should have comment or be unexported
                      Open

                      type CustomDecoder interface {
                      Severity: Minor
                      Found in type/encoding/encoding.go by golint

                      exported type CustomEncoder should have comment or be unexported
                      Open

                      type CustomEncoder interface {
                      Severity: Minor
                      Found in type/encoding/encoding.go by golint

                      exported function NewDecoder should have comment or be unexported
                      Open

                      func NewDecoder(c Capability, r io.Reader) Decoder {
                      Severity: Minor
                      Found in type/encoding/encoding.go by golint

                      There are no issues that match your filters.

                      Category
                      Status