portainer/portainer

View on GitHub
api/cmd/portainer/main.go

Summary

Maintainability
D
1 day
Test Coverage

Function buildServer has 188 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func buildServer(flags *portainer.CLIFlags) portainer.Server {
    shutdownCtx, shutdownTrigger := context.WithCancel(context.Background())

    if flags.FeatureFlags != nil {
        featureflags.Parse(*flags.FeatureFlags, portainer.SupportedFeatureFlags)
Severity: Major
Found in api/cmd/portainer/main.go - About 6 hrs to fix

    Function buildServer has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
    Open

    func buildServer(flags *portainer.CLIFlags) portainer.Server {
        shutdownCtx, shutdownTrigger := context.WithCancel(context.Background())
    
        if flags.FeatureFlags != nil {
            featureflags.Parse(*flags.FeatureFlags, portainer.SupportedFeatureFlags)
    Severity: Minor
    Found in api/cmd/portainer/main.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

    File main.go has 521 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package main
    
    import (
        "context"
        "crypto/sha256"
    Severity: Minor
    Found in api/cmd/portainer/main.go - About 2 hrs to fix

      Function initDataStore has 61 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func initDataStore(flags *portainer.CLIFlags, secretKey []byte, fileService portainer.FileService, shutdownCtx context.Context) dataservices.DataStore {
          connection, err := database.NewDatabase("boltdb", *flags.Data, secretKey)
          if err != nil {
              log.Fatal().Err(err).Msg("failed creating database connection")
          }
      Severity: Minor
      Found in api/cmd/portainer/main.go - About 1 hr to fix

        Function initKubernetesDeployer has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func initKubernetesDeployer(kubernetesTokenCacheManager *kubeproxy.TokenCacheManager, kubernetesClientFactory *kubecli.ClientFactory, dataStore dataservices.DataStore, reverseTunnelService portainer.ReverseTunnelService, signatureService portainer.DigitalSignatureService, proxyManager *proxy.Manager, assetsPath string) portainer.KubernetesDeployer {
        Severity: Major
        Found in api/cmd/portainer/main.go - About 50 mins to fix

          Function initSwarmStackManager has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              assetsPath string,
              configPath string,
              signatureService portainer.DigitalSignatureService,
              fileService portainer.FileService,
              reverseTunnelService portainer.ReverseTunnelService,
          Severity: Minor
          Found in api/cmd/portainer/main.go - About 45 mins to fix

            Function initSnapshotService has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                snapshotIntervalFromFlag string,
                dataStore dataservices.DataStore,
                dockerClientFactory *dockerclient.ClientFactory,
                kubernetesClientFactory *kubecli.ClientFactory,
                shutdownCtx context.Context,
            Severity: Minor
            Found in api/cmd/portainer/main.go - About 45 mins to fix

              There are no issues that match your filters.

              Category
              Status