encoder/encoder.go

Summary

Maintainability
A
0 mins
Test Coverage

File encoder.go has 1214 lines of code (exceeds 500 allowed). Consider refactoring.
Wontfix

// Copyright (c) 2020-2023 Ozan Hacıbekiroğlu.
// Use of this source code is governed by a MIT License
// that can be found in the LICENSE file.

package encoder
Severity: Major
Found in encoder/encoder.go - About 2 days to fix

    Function DecodeObject has a Cognitive Complexity of 60 (exceeds 20 allowed). Consider refactoring.
    Wontfix

    func DecodeObject(r io.Reader) (ugo.Object, error) {
        btype, err := readByteFrom(r)
        if err != nil {
            return nil, err
        }
    Severity: Minor
    Found in encoder/encoder.go - About 6 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

    Function DecodeObject has 138 lines of code (exceeds 50 allowed). Consider refactoring.
    Wontfix

    func DecodeObject(r io.Reader) (ugo.Object, error) {
        btype, err := readByteFrom(r)
        if err != nil {
            return nil, err
        }
    Severity: Major
    Found in encoder/encoder.go - About 4 hrs to fix

      Function DecodeObject has 33 return statements (exceeds 4 allowed).
      Wontfix

      func DecodeObject(r io.Reader) (ugo.Object, error) {
          btype, err := readByteFrom(r)
          if err != nil {
              return nil, err
          }
      Severity: Major
      Found in encoder/encoder.go - About 2 hrs to fix

        Method CompiledFunction.UnmarshalBinary has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
        Wontfix

        func (o *CompiledFunction) UnmarshalBinary(data []byte) error {
            if len(data) < 2 || data[0] != binCompiledFunctionV1 {
                return errors.New("invalid ugo.CompiledFunction data")
            }
        
        
        Severity: Minor
        Found in encoder/encoder.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 Bytecode.bytecodeV1Decoder has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
        Wontfix

        func (bc *Bytecode) bytecodeV1Decoder(r *bytes.Buffer) error {
            for {
                field, err := r.ReadByte()
                if err != nil {
                    if err == io.EOF {
        Severity: Minor
        Found in encoder/encoder.go - About 1 hr 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 CompiledFunction.UnmarshalBinary has 64 lines of code (exceeds 50 allowed). Consider refactoring.
        Wontfix

        func (o *CompiledFunction) UnmarshalBinary(data []byte) error {
            if len(data) < 2 || data[0] != binCompiledFunctionV1 {
                return errors.New("invalid ugo.CompiledFunction data")
            }
        
        
        Severity: Minor
        Found in encoder/encoder.go - About 1 hr to fix

          Method CompiledFunction.UnmarshalBinary has 11 return statements (exceeds 4 allowed).
          Wontfix

          func (o *CompiledFunction) UnmarshalBinary(data []byte) error {
              if len(data) < 2 || data[0] != binCompiledFunctionV1 {
                  return errors.New("invalid ugo.CompiledFunction data")
              }
          
          
          Severity: Major
          Found in encoder/encoder.go - About 1 hr to fix

            Method Bytecode.bytecodeV1Encoder has 10 return statements (exceeds 4 allowed).
            Wontfix

            func (bc *Bytecode) bytecodeV1Encoder(w io.Writer) (err error) {
                if err = putBytecodeHeader(w); err != nil {
                    return
                }
            
            
            Severity: Major
            Found in encoder/encoder.go - About 1 hr to fix

              Method Bytecode.bytecodeV1Decoder has 8 return statements (exceeds 4 allowed).
              Wontfix

              func (bc *Bytecode) bytecodeV1Decoder(r *bytes.Buffer) error {
                  for {
                      field, err := r.ReadByte()
                      if err != nil {
                          if err == io.EOF {
              Severity: Major
              Found in encoder/encoder.go - About 50 mins to fix

                Method Map.UnmarshalBinary has 8 return statements (exceeds 4 allowed).
                Wontfix

                func (o *Map) UnmarshalBinary(data []byte) error {
                    if len(data) < 2 || data[0] != binMapV1 {
                        return errors.New("invalid ugo.Map data")
                    }
                
                
                Severity: Major
                Found in encoder/encoder.go - About 50 mins to fix

                  Method SourceFile.UnmarshalBinary has 7 return statements (exceeds 4 allowed).
                  Wontfix

                  func (sf *SourceFile) UnmarshalBinary(data []byte) error {
                      rd := bytes.NewReader(data)
                  
                      obj, err := DecodeObject(rd)
                      if err != nil {
                  Severity: Major
                  Found in encoder/encoder.go - About 45 mins to fix

                    Method varintConv.read has 7 return statements (exceeds 4 allowed).
                    Wontfix

                    func (vi *varintConv) read() (value int64, err error) {
                        var n byte
                        n, err = vi.reader.ReadByte()
                        if err != nil {
                            return
                    Severity: Major
                    Found in encoder/encoder.go - About 45 mins to fix

                      Method Char.UnmarshalBinary has 7 return statements (exceeds 4 allowed).
                      Wontfix

                      func (o *Char) UnmarshalBinary(data []byte) error {
                          if len(data) < 2 || data[0] != binCharV1 {
                              return errors.New("invalid ugo.Char data")
                          }
                      
                      
                      Severity: Major
                      Found in encoder/encoder.go - About 45 mins to fix

                        Method Array.UnmarshalBinary has 7 return statements (exceeds 4 allowed).
                        Wontfix

                        func (o *Array) UnmarshalBinary(data []byte) error {
                            if len(data) < 2 || data[0] != binArrayV1 {
                                return errors.New("invalid ugo.Array data")
                            }
                        
                        
                        Severity: Major
                        Found in encoder/encoder.go - About 45 mins to fix

                          Method varintConv.readBytes has 7 return statements (exceeds 4 allowed).
                          Wontfix

                          func (vi *varintConv) readBytes(r io.Reader) (value int64, readBytes []byte, err error) {
                              var n byte
                              n, err = readByteFrom(r)
                              if err != nil {
                                  return
                          Severity: Major
                          Found in encoder/encoder.go - About 45 mins to fix

                            Method BuiltinFunction.UnmarshalBinary has 7 return statements (exceeds 4 allowed).
                            Wontfix

                            func (o *BuiltinFunction) UnmarshalBinary(data []byte) error {
                                if len(data) < 2 || data[0] != binBuiltinFunctionV1 {
                                    return errors.New("invalid ugo.BuiltinFunction data")
                                }
                            
                            
                            Severity: Major
                            Found in encoder/encoder.go - About 45 mins to fix

                              Method SourceFileSet.UnmarshalBinary has 7 return statements (exceeds 4 allowed).
                              Wontfix

                              func (sfs *SourceFileSet) UnmarshalBinary(data []byte) error {
                                  rd := bytes.NewReader(data)
                                  var vi varintConv
                                  vi.reader = rd
                                  v, err := vi.read()
                              Severity: Major
                              Found in encoder/encoder.go - About 45 mins to fix

                                Method Uint.UnmarshalBinary has 6 return statements (exceeds 4 allowed).
                                Wontfix

                                func (o *Uint) UnmarshalBinary(data []byte) error {
                                    if len(data) < 2 || data[0] != binUintV1 {
                                        return errors.New("invalid ugo.Uint data")
                                    }
                                
                                
                                Severity: Major
                                Found in encoder/encoder.go - About 40 mins to fix

                                  Method Float.UnmarshalBinary has 6 return statements (exceeds 4 allowed).
                                  Wontfix

                                  func (o *Float) UnmarshalBinary(data []byte) error {
                                      if len(data) < 2 || data[0] != binFloatV1 {
                                          return errors.New("invalid ugo.Float data")
                                      }
                                  
                                  
                                  Severity: Major
                                  Found in encoder/encoder.go - About 40 mins to fix

                                    Method Int.UnmarshalBinary has 6 return statements (exceeds 4 allowed).
                                    Wontfix

                                    func (o *Int) UnmarshalBinary(data []byte) error {
                                        if len(data) < 2 || data[0] != binIntV1 {
                                            return errors.New("invalid ugo.Int data")
                                        }
                                    
                                    
                                    Severity: Major
                                    Found in encoder/encoder.go - About 40 mins to fix

                                      Function toVarint has 5 return statements (exceeds 4 allowed).
                                      Wontfix

                                      func toVarint(data []byte) (value int64, offset int, err error) {
                                          size := int(data[0])
                                          if size == 0 {
                                              offset = 1
                                              return
                                      Severity: Major
                                      Found in encoder/encoder.go - About 35 mins to fix

                                        Method String.UnmarshalBinary has 5 return statements (exceeds 4 allowed).
                                        Wontfix

                                        func (o *String) UnmarshalBinary(data []byte) error {
                                            if len(data) < 2 || data[0] != binStringV1 {
                                                return errors.New("invalid ugo.String data")
                                            }
                                        
                                        
                                        Severity: Major
                                        Found in encoder/encoder.go - About 35 mins to fix

                                          Function readByteFrom has 5 return statements (exceeds 4 allowed).
                                          Wontfix

                                          func readByteFrom(r io.Reader) (byte, error) {
                                              if br, ok := r.(io.ByteReader); ok {
                                                  return br.ReadByte()
                                              }
                                          
                                          
                                          Severity: Major
                                          Found in encoder/encoder.go - About 35 mins to fix

                                            Method Bytes.UnmarshalBinary has 5 return statements (exceeds 4 allowed).
                                            Wontfix

                                            func (o *Bytes) UnmarshalBinary(data []byte) error {
                                                if len(data) < 2 || data[0] != binBytesV1 {
                                                    return errors.New("invalid ugo.Bytes data")
                                                }
                                            
                                            
                                            Severity: Major
                                            Found in encoder/encoder.go - About 35 mins to fix

                                              Method Function.UnmarshalBinary has 5 return statements (exceeds 4 allowed).
                                              Wontfix

                                              func (o *Function) UnmarshalBinary(data []byte) error {
                                                  if len(data) < 2 || data[0] != binFunctionV1 {
                                                      return errors.New("invalid ugo.Function data")
                                                  }
                                              
                                              
                                              Severity: Major
                                              Found in encoder/encoder.go - About 35 mins to fix

                                                Method Bytecode.bytecodeV1Encoder has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                                                Wontfix

                                                func (bc *Bytecode) bytecodeV1Encoder(w io.Writer) (err error) {
                                                    if err = putBytecodeHeader(w); err != nil {
                                                        return
                                                    }
                                                
                                                
                                                Severity: Minor
                                                Found in encoder/encoder.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

                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                Wontfix

                                                func (o *Uint) UnmarshalBinary(data []byte) error {
                                                    if len(data) < 2 || data[0] != binUintV1 {
                                                        return errors.New("invalid ugo.Uint data")
                                                    }
                                                
                                                
                                                Severity: Major
                                                Found in encoder/encoder.go and 1 other location - About 2 hrs to fix
                                                encoder/encoder.go on lines 487..511

                                                Duplicated Code

                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                Tuning

                                                This issue has a mass of 204.

                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                Refactorings

                                                Further Reading

                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                Wontfix

                                                func (o *Int) UnmarshalBinary(data []byte) error {
                                                    if len(data) < 2 || data[0] != binIntV1 {
                                                        return errors.New("invalid ugo.Int data")
                                                    }
                                                
                                                
                                                Severity: Major
                                                Found in encoder/encoder.go and 1 other location - About 2 hrs to fix
                                                encoder/encoder.go on lines 528..552

                                                Duplicated Code

                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                Tuning

                                                This issue has a mass of 204.

                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                Refactorings

                                                Further Reading

                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                Wontfix

                                                func (o *Function) MarshalBinary() ([]byte, error) {
                                                    s, err := String(o.Name).MarshalBinary()
                                                    if err != nil {
                                                        return nil, err
                                                    }
                                                Severity: Major
                                                Found in encoder/encoder.go and 1 other location - About 1 hr to fix
                                                encoder/encoder.go on lines 1057..1071

                                                Duplicated Code

                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                Tuning

                                                This issue has a mass of 162.

                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                Refactorings

                                                Further Reading

                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                Wontfix

                                                func (o *BuiltinFunction) MarshalBinary() ([]byte, error) {
                                                    // Note: use string name instead of index of builtin
                                                    s, err := String(o.Name).MarshalBinary()
                                                    if err != nil {
                                                        return nil, err
                                                Severity: Major
                                                Found in encoder/encoder.go and 1 other location - About 1 hr to fix
                                                encoder/encoder.go on lines 1108..1121

                                                Duplicated Code

                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                Tuning

                                                This issue has a mass of 162.

                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                Refactorings

                                                Further Reading

                                                Similar blocks of code found in 3 locations. Consider refactoring.
                                                Wontfix

                                                func (o Char) MarshalBinary() ([]byte, error) {
                                                    buf := make([]byte, 2+binary.MaxVarintLen32)
                                                    buf[0] = binCharV1
                                                    if o == 0 {
                                                        buf[1] = 0
                                                Severity: Major
                                                Found in encoder/encoder.go and 2 other locations - About 1 hr to fix
                                                encoder/encoder.go on lines 472..484
                                                encoder/encoder.go on lines 514..525

                                                Duplicated Code

                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                Tuning

                                                This issue has a mass of 136.

                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                Refactorings

                                                Further Reading

                                                Similar blocks of code found in 3 locations. Consider refactoring.
                                                Wontfix

                                                func (o Uint) MarshalBinary() ([]byte, error) {
                                                    buf := make([]byte, 2+binary.MaxVarintLen64)
                                                    buf[0] = binUintV1
                                                    if o == 0 {
                                                        buf[1] = 0
                                                Severity: Major
                                                Found in encoder/encoder.go and 2 other locations - About 1 hr to fix
                                                encoder/encoder.go on lines 472..484
                                                encoder/encoder.go on lines 555..566

                                                Duplicated Code

                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                Tuning

                                                This issue has a mass of 136.

                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                Refactorings

                                                Further Reading

                                                Similar blocks of code found in 3 locations. Consider refactoring.
                                                Wontfix

                                                func (o Int) MarshalBinary() ([]byte, error) {
                                                    buf := make([]byte, 2+binary.MaxVarintLen64)
                                                    buf[0] = binIntV1
                                                
                                                    if o == 0 {
                                                Severity: Major
                                                Found in encoder/encoder.go and 2 other locations - About 1 hr to fix
                                                encoder/encoder.go on lines 514..525
                                                encoder/encoder.go on lines 555..566

                                                Duplicated Code

                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                Tuning

                                                This issue has a mass of 136.

                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                Refactorings

                                                Further Reading

                                                Identical blocks of code found in 2 locations. Consider refactoring.
                                                Wontfix

                                                        if m := marshaler(v); m != nil {
                                                            d, err := m.MarshalBinary()
                                                            if err != nil {
                                                                return nil, err
                                                            }
                                                Severity: Minor
                                                Found in encoder/encoder.go and 1 other location - About 40 mins to fix
                                                encoder/encoder.go on lines 739..750

                                                Duplicated Code

                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                Tuning

                                                This issue has a mass of 111.

                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                Refactorings

                                                Further Reading

                                                Identical blocks of code found in 2 locations. Consider refactoring.
                                                Wontfix

                                                        if m := marshaler(v); m != nil {
                                                            d, err := m.MarshalBinary()
                                                            if err != nil {
                                                                return nil, err
                                                            }
                                                Severity: Minor
                                                Found in encoder/encoder.go and 1 other location - About 40 mins to fix
                                                encoder/encoder.go on lines 813..824

                                                Duplicated Code

                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                Tuning

                                                This issue has a mass of 111.

                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                Refactorings

                                                Further Reading

                                                There are no issues that match your filters.

                                                Category
                                                Status