johnsonjh/gfcp

View on GitHub
gfcp_fec.go

Summary

Maintainability
D
1 day
Test Coverage

Method FecDecoder.Decode has a Cognitive Complexity of 55 (exceeds 20 allowed). Consider refactoring.
Open

func (
    dec *FecDecoder,
) Decode(
    in FecPacket,
) (
Severity: Minor
Found in gfcp_fec.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

Method FecDecoder.Decode has 142 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (
    dec *FecDecoder,
) Decode(
    in FecPacket,
) (
Severity: Major
Found in gfcp_fec.go - About 4 hrs to fix

    Method FecEncoder.Encode has 53 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (
        enc *FecEncoder,
    ) Encode(
        b []byte,
    ) (
    Severity: Minor
    Found in gfcp_fec.go - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                      if numshard == 1 {
                          first = i
                      }
      Severity: Major
      Found in gfcp_fec.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if !shardsflag[k] {
                                recovered = append(
                                    recovered,
                                    shards[k],
                                )
        Severity: Major
        Found in gfcp_fec.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          } else if k < dec.dataShards {
                              shards[k] = KxmitBuf.Get().([]byte)[:0]
                          }
          Severity: Major
          Found in gfcp_fec.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            if dec.rx[i].flag() == KTypeData {
                                numDataShard++
                            }
            Severity: Major
            Found in gfcp_fec.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                              if len(
                                  dec.rx[i].data(),
                              ) > maxlen {
                                  maxlen = len(
                                      dec.rx[i].data(),
              Severity: Major
              Found in gfcp_fec.go - About 45 mins to fix

                TODO found
                Open

                        // TODO(jhj): Switch to pointer to avoid allocation.
                Severity: Minor
                Found in gfcp_fec.go by fixme

                There are no issues that match your filters.

                Category
                Status