ipfs/ipfs-cluster

View on GitHub

Showing 105 of 124 total issues

Connector has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

type Connector struct {
    // struct alignment! These fields must be up-front.
    updateMetricCount uint64
    ipfsPinCount      int64

Severity: Minor
Found in ipfsconn/ipfshttp/ipfshttp.go - About 3 hrs to fix

    File methods.go has 535 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package client
    
    import (
        "bytes"
        "context"
    Severity: Minor
    Found in api/rest/client/methods.go - About 2 hrs to fix

      defaultClient has 25 methods (exceeds 20 allowed). Consider refactoring.
      Open

      func (c *defaultClient) ID(ctx context.Context) (api.ID, error) {
          ctx, span := trace.StartSpan(ctx, "client/ID")
          defer span.End()
      
          var id api.ID
      Severity: Minor
      Found in api/rest/client/methods.go - About 2 hrs to fix

        File raft.go has 525 lines of code (exceeds 500 allowed). Consider refactoring.
        Open

        package raft
        
        import (
            "context"
            "errors"
        Severity: Minor
        Found in consensus/raft/raft.go - About 2 hrs to fix

          API has 23 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type API struct {
              ctx    context.Context
              cancel func()
          
              config *Config
          Severity: Minor
          Found in api/common/api.go - About 2 hrs to fix

            Function runCmd has a Cognitive Complexity of 27 (exceeds 15 allowed). Consider refactoring.
            Open

            func runCmd(c *cli.Context) error {
                clusterName := c.String(clusterNameFlag)
            
                if cfgURL := c.String("init"); cfgURL != "" {
                    err := initCluster(c, true, cfgURL)
            Severity: Minor
            Found in cmd/ipfs-cluster-follow/commands.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 Cluster.Shutdown has a Cognitive Complexity of 27 (exceeds 15 allowed). Consider refactoring.
            Open

            func (c *Cluster) Shutdown(ctx context.Context) error {
                ctx, span := trace.StartSpan(ctx, "cluster/Shutdown")
                defer span.End()
            
                c.shutdownLock.Lock()
            Severity: Minor
            Found in cluster.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 Monitor.logFromPubsub has a Cognitive Complexity of 27 (exceeds 15 allowed). Consider refactoring.
            Open

            func (mon *Monitor) logFromPubsub() {
                ctx, span := trace.StartSpan(mon.ctx, "monitor/pubsub/logFromPubsub")
                defer span.End()
            
                decodeWarningPrinted := false
            Severity: Minor
            Found in monitor/pubsubmon/pubsubmon.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

            Function main has 111 lines of code (exceeds 80 allowed). Consider refactoring.
            Open

            func main() {
                app := cli.NewApp()
                app.Name = programName
                app.Usage = "IPFS Cluster Follower"
                app.UsageText = fmt.Sprintf("%s [global options] <clusterName> [subcommand]...", programName)
            Severity: Major
            Found in cmd/ipfs-cluster-follow/main.go - About 2 hrs to fix

              Method Server.pinLsHandler has a Cognitive Complexity of 26 (exceeds 15 allowed). Consider refactoring.
              Open

              func (proxy *Server) pinLsHandler(w http.ResponseWriter, r *http.Request) {
                  proxy.setHeaders(w.Header(), r)
              
                  arg := r.URL.Query().Get("arg")
              
              
              Severity: Minor
              Found in api/ipfsproxy/ipfsproxy.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 Tracker.StatusAll has a Cognitive Complexity of 26 (exceeds 15 allowed). Consider refactoring.
              Open

              func (spt *Tracker) StatusAll(ctx context.Context, filter api.TrackerStatus, out chan<- api.PinInfo) error {
                  ctx, span := trace.StartSpan(ctx, "tracker/stateless/StatusAll")
                  defer span.End()
              
                  ipfsid := spt.getIPFSID(ctx)
              Severity: Minor
              Found in pintracker/stateless/stateless.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 Cluster.globalPinInfoStream has a Cognitive Complexity of 25 (exceeds 15 allowed). Consider refactoring.
              Open

              func (c *Cluster) globalPinInfoStream(ctx context.Context, comp, method string, inChan interface{}, out chan<- api.GlobalPinInfo) error {
                  defer close(out)
              
                  ctx, span := trace.StartSpan(ctx, "cluster/globalPinInfoStream")
                  defer span.End()
              Severity: Minor
              Found in cluster.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 Connector.Pin has a Cognitive Complexity of 24 (exceeds 15 allowed). Consider refactoring.
              Open

              func (ipfs *Connector) Pin(ctx context.Context, pin api.Pin) error {
                  ctx, span := trace.StartSpan(ctx, "ipfsconn/ipfshttp/Pin")
                  defer span.End()
              
                  hash := pin.Cid
              Severity: Minor
              Found in ipfsconn/ipfshttp/ipfshttp.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

              Function main has 25 return statements (exceeds 10 allowed).
              Open

              func main() {
                  ctx := context.Background()
              
                  app := cli.NewApp()
                  app.Name = programName
              Severity: Major
              Found in cmd/ipfs-cluster-ctl/main.go - About 1 hr to fix

                Method Server.pinLsHandler has 98 lines of code (exceeds 80 allowed). Consider refactoring.
                Open

                func (proxy *Server) pinLsHandler(w http.ResponseWriter, r *http.Request) {
                    proxy.setHeaders(w.Header(), r)
                
                    arg := r.URL.Query().Get("arg")
                
                
                Severity: Major
                Found in api/ipfsproxy/ipfsproxy.go - About 1 hr to fix

                  Method Tracker.StatusAll has 97 lines of code (exceeds 80 allowed). Consider refactoring.
                  Open

                  func (spt *Tracker) StatusAll(ctx context.Context, filter api.TrackerStatus, out chan<- api.PinInfo) error {
                      ctx, span := trace.StartSpan(ctx, "tracker/stateless/StatusAll")
                      defer span.End()
                  
                      ipfsid := spt.getIPFSID(ctx)
                  Severity: Major
                  Found in pintracker/stateless/stateless.go - About 1 hr to fix

                    Method Cluster.globalPinInfoCid has 96 lines of code (exceeds 80 allowed). Consider refactoring.
                    Open

                    func (c *Cluster) globalPinInfoCid(ctx context.Context, comp, method string, h api.Cid) (api.GlobalPinInfo, error) {
                        ctx, span := trace.StartSpan(ctx, "cluster/globalPinInfoCid")
                        defer span.End()
                    
                        // The object we will return
                    Severity: Major
                    Found in cluster.go - About 1 hr to fix

                      Method Cluster.globalPinInfoStream has 95 lines of code (exceeds 80 allowed). Consider refactoring.
                      Open

                      func (c *Cluster) globalPinInfoStream(ctx context.Context, comp, method string, inChan interface{}, out chan<- api.GlobalPinInfo) error {
                          defer close(out)
                      
                          ctx, span := trace.StartSpan(ctx, "cluster/globalPinInfoStream")
                          defer span.End()
                      Severity: Major
                      Found in cluster.go - About 1 hr to fix

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

                        func (lo *ListOptions) FromQuery(q url.Values) error {
                            cidq := q.Get("cid")
                            if len(cidq) > 0 {
                                for _, cstr := range strings.Split(cidq, ",") {
                                    c, err := types.DecodeCid(cstr)
                        Severity: Minor
                        Found in api/pinsvcapi/pinsvc/pinsvc.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

                        Function createCluster has 93 lines of code (exceeds 80 allowed). Consider refactoring.
                        Open

                        func createCluster(
                            ctx context.Context,
                            c *cli.Context,
                            cfgHelper *cmdutils.ConfigHelper,
                            host host.Host,
                        Severity: Major
                        Found in cmd/ipfs-cluster-service/daemon.go - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language