ipfs/ipfs-cluster

View on GitHub
api/types.go

Summary

Maintainability
B
5 hrs
Test Coverage

File types.go has 1006 lines of code (exceeds 500 allowed). Consider refactoring.
Wontfix

// Package api holds declarations for types used in ipfs-cluster APIs to make
// them re-usable across differen tools. This include RPC API "Serial[izable]"
// versions for types. The Go API uses natives types, while RPC API,
// REST APIs etc use serializable types (i.e. json format). Conversion methods
// exists between types.
Severity: Major
Found in api/types.go - About 1 day to fix

    Method PinOptions.FromQuery has a Cognitive Complexity of 32 (exceeds 15 allowed). Consider refactoring.
    Open

    func (po *PinOptions) FromQuery(q url.Values) error {
        po.Name = q.Get("name")
    
        po.Mode = PinModeFromString(q.Get("mode"))
    
    
    Severity: Minor
    Found in api/types.go - About 3 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 PinOptions.Equals has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring.
    Open

    func (po PinOptions) Equals(po2 PinOptions) bool {
        if po.Name != po2.Name {
            return false
        }
    
    
    Severity: Minor
    Found in api/types.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 PinOptions.Equals has 12 return statements (exceeds 10 allowed).
    Open

    func (po PinOptions) Equals(po2 PinOptions) bool {
        if po.Name != po2.Name {
            return false
        }
    
    
    Severity: Major
    Found in api/types.go - About 40 mins to fix

      Method Pin.ProtoUnmarshal has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
      Open

      func (pin *Pin) ProtoUnmarshal(data []byte) error {
          pbPin := pb.Pin{}
          err := proto.Unmarshal(data, &pbPin)
          if err != nil {
              return err
      Severity: Minor
      Found in api/types.go - About 35 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

      FIXME found
      Confirmed

      // FIXME include maxdepth
      Severity: Minor
      Found in api/types.go by fixme

      FIXME found
      Confirmed

              // FIXME: when we know how ipfs returns partial pins.
      Severity: Minor
      Found in api/types.go by fixme

      FIXME found
      Confirmed

              // FIXME: Maxdepth?
      Severity: Minor
      Found in api/types.go by fixme

      There are no issues that match your filters.

      Category
      Status