Cooomma/ksm-golang

View on GitHub

Showing 6 of 8 total issues

Function main has 73 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func main() {
    // Setting Echo
    e := echo.New()

    e.Use(middleware.Logger())
Severity: Minor
Found in api/api.go - About 1 hr to fix

    Function parseTLLVs has 72 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func parseTLLVs(spcPayload []byte) map[uint64]TLLVBlock {
        var m map[uint64]TLLVBlock
        m = make(map[uint64]TLLVBlock)
    
        for currentOffset := 0; currentOffset < len(spcPayload); {
    Severity: Minor
    Found in ksm/ksm.go - About 1 hr to fix

      Method Ksm.GenCKC has 70 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (k *Ksm) GenCKC(playback []byte) ([]byte, error) {
          spcv1, err := ParseSPCV1(playback, k.Pub, k.Pri)
          if err != nil {
              return nil, err
          }
      Severity: Minor
      Found in ksm/ksm.go - About 1 hr to fix

        Method Ksm.GenCKC has 13 return statements (exceeds 4 allowed).
        Open

        func (k *Ksm) GenCKC(playback []byte) ([]byte, error) {
            spcv1, err := ParseSPCV1(playback, k.Pub, k.Pri)
            if err != nil {
                return nil, err
            }
        Severity: Major
        Found in ksm/ksm.go - About 1 hr to fix

          Function main has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
          Open

          func main() {
              // Setting Echo
              e := echo.New()
          
              e.Use(middleware.Logger())
          Severity: Minor
          Found in api/api.go - About 45 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

          Method DFunction.Compute has 5 return statements (exceeds 4 allowed).
          Open

          func (d DFunction) Compute(R2 []byte, ask []byte) ([]byte, error) {
          
              if hex.EncodeToString(ask) == APPLE_TESTING_ASk {
                  return hex.DecodeString(APPLE_TESTING_ASk)
              }
          Severity: Major
          Found in ksm/d_function.go - About 35 mins to fix
            Severity
            Category
            Status
            Source
            Language