Showing 59 of 92 total issues

Method Platform.Prune has 57 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (p *Platform) Prune(region, stage string, versions int) error {
    p.events.Emit("prune", nil)

    if err := p.createRole(); err != nil {
        return errors.Wrap(err, "creating iam role")
Severity: Minor
Found in platform/lambda/prune.go - About 1 hr to fix

    Method Platform.createCerts has 57 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (p *Platform) createCerts() error {
        s := session.New(aws.NewConfig().WithRegion("us-east-1"))
        a := acm.New(s)
        var domains []string
    
    
    Severity: Minor
    Found in platform/lambda/lambda.go - About 1 hr to fix

      Function init has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
      Open

      func init() {
          cmd := root.Command("upgrade", "Install the latest or specified version of Up.")
          cmd.Example(`up upgrade`, "Upgrade to the latest version available.")
          cmd.Example(`up upgrade -t 0.4.4`, "Upgrade to the specified version.")
          target := cmd.Flag("target", "Target version for upgrade.").Short('t').String()
      Severity: Minor
      Found in internal/cli/upgrade/upgrade.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 subscribe has 10 return statements (exceeds 4 allowed).
      Open

      func subscribe(cmd *kingpin.Cmd) {
          c := cmd.Command("subscribe", "Subscribe to the Pro plan.")
      
          c.Action(func(_ *kingpin.ParseContext) error {
              t, err := userconfig.Require()
      Severity: Major
      Found in internal/cli/team/team.go - About 1 hr to fix

        Method Platform.updateFunction has 10 return statements (exceeds 4 allowed).
        Open

        func (p *Platform) updateFunction(c *lambda.Lambda, a *apigateway.APIGateway, up *s3manager.Uploader, region string, d up.Deploy) (version string, err error) {
            b := aws.String(p.getS3BucketName(region))
            k := aws.String(p.getS3Key(d.Stage))
        
            // upload
        Severity: Major
        Found in platform/lambda/lambda.go - About 1 hr to fix

          Function deploy has 10 return statements (exceeds 4 allowed).
          Open

          func deploy(stage string, build bool) error {
          retry:
              c, p, err := root.Init()
          
              // missing up.json non-interactive
          Severity: Major
          Found in internal/cli/deploy/deploy.go - About 1 hr to fix

            Function init has 9 return statements (exceeds 4 allowed).
            Open

            func init() {
                cmd := root.Command("upgrade", "Install the latest or specified version of Up.")
                cmd.Example(`up upgrade`, "Upgrade to the latest version available.")
                cmd.Example(`up upgrade -t 0.4.4`, "Upgrade to the specified version.")
                target := cmd.Flag("target", "Target version for upgrade.").Short('t').String()
            Severity: Major
            Found in internal/cli/upgrade/upgrade.go - About 55 mins to fix

              Function init has 9 return statements (exceeds 4 allowed).
              Open

              func init() {
                  cmd := root.Command("build", "Build zip file.")
                  cmd.Example(`up build`, "Build archive and save to ./out.zip")
                  cmd.Example(`up build > /tmp/out.zip`, "Build archive and output to file via stdout.")
                  cmd.Example(`up build --size`, "Build archive and list files by size.")
              Severity: Major
              Found in internal/cli/build/build.go - About 55 mins to fix

                Method Config.Load has 8 return statements (exceeds 4 allowed).
                Open

                func (c *Config) Load() error {
                    path, err := c.path()
                    if err != nil {
                        return errors.Wrap(err, "getting path")
                    }
                Severity: Major
                Found in internal/userconfig/userconfig.go - About 50 mins to fix

                  Function init has 7 return statements (exceeds 4 allowed).
                  Open

                  func init() {
                      cmd := root.Command("start", "Start development server.")
                      cmd.Example(`up start`, "Start development server on port 3000.")
                      cmd.Example(`up start -o`, "Start development server and open in the browser.")
                      cmd.Example(`up start --address :5000`, "Start development server on port 5000.")
                  Severity: Major
                  Found in internal/cli/start/start.go - About 45 mins to fix

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

                    func init() {
                        cmd := root.Command("build", "Build zip file.")
                        cmd.Example(`up build`, "Build archive and save to ./out.zip")
                        cmd.Example(`up build > /tmp/out.zip`, "Build archive and output to file via stdout.")
                        cmd.Example(`up build --size`, "Build archive and list files by size.")
                    Severity: Minor
                    Found in internal/cli/build/build.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 Stack.Plan has 7 return statements (exceeds 4 allowed).
                    Open

                    func (s *Stack) Plan(versions resources.Versions) error {
                        c := s.config
                        tmpl := s.template(versions)
                        name := c.Name
                    
                    
                    Severity: Major
                    Found in platform/lambda/stack/stack.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                      } else if v := e.String("version"); v != "" {
                                          s += " (version " + v + ")"
                                      }
                      Severity: Major
                      Found in reporter/text/text.go - About 45 mins to fix

                        Function login has 7 return statements (exceeds 4 allowed).
                        Open

                        func login(cmd *kingpin.Cmd) {
                            c := cmd.Command("login", "Sign in to your account.")
                            c.Example(`up team login`, "Sign in or create account with interactive prompt.")
                            c.Example(`up team login --team apex-software`, "Sign in to a team using your existing email.")
                            c.Example(`up team login --email tj@example.com --team apex-software`, "Sign in to a team with email.")
                        Severity: Major
                        Found in internal/cli/team/team.go - About 45 mins to fix

                          Function add has 7 return statements (exceeds 4 allowed).
                          Open

                          func add(cmd *kingpin.Cmd) {
                              c := cmd.Command("add", "Add a new team.")
                              name := c.Arg("name", "Name of the team.").Required().String()
                          
                              c.Action(func(_ *kingpin.ParseContext) error {
                          Severity: Major
                          Found in internal/cli/team/team.go - About 45 mins to fix

                            Method Platform.createRole has 7 return statements (exceeds 4 allowed).
                            Open

                            func (p *Platform) createRole() error {
                                s := session.New(aws.NewConfig())
                                c := iam.New(s)
                            
                                name := p.roleName()
                            Severity: Major
                            Found in platform/lambda/lambda.go - About 45 mins to fix

                              Method Platform.Prune has 6 return statements (exceeds 4 allowed).
                              Open

                              func (p *Platform) Prune(region, stage string, versions int) error {
                                  p.events.Emit("prune", nil)
                              
                                  if err := p.createRole(); err != nil {
                                      return errors.Wrap(err, "creating iam role")
                              Severity: Major
                              Found in platform/lambda/prune.go - About 40 mins to fix

                                Function status has 6 return statements (exceeds 4 allowed).
                                Open

                                func status(cmd *kingpin.Cmd) {
                                    c := cmd.Command("status", "Status of your account.").Default()
                                
                                    c.Action(func(_ *kingpin.ParseContext) error {
                                        var config userconfig.Config
                                Severity: Major
                                Found in internal/cli/team/team.go - About 40 mins to fix

                                  Function unsubscribe has 6 return statements (exceeds 4 allowed).
                                  Open

                                  func unsubscribe(cmd *kingpin.Cmd) {
                                      c := cmd.Command("unsubscribe", "Unsubscribe from the Pro plan.")
                                  
                                      c.Action(func(_ *kingpin.ParseContext) error {
                                          config, err := userconfig.Require()
                                  Severity: Major
                                  Found in internal/cli/team/team.go - About 40 mins to fix

                                    Method Platform.Deploy has 6 return statements (exceeds 4 allowed).
                                    Open

                                    func (p *Platform) Deploy(d up.Deploy) error {
                                        regions := p.config.Regions
                                        var g errgroup.Group
                                    
                                        if err := p.createRole(); err != nil {
                                    Severity: Major
                                    Found in platform/lambda/lambda.go - About 40 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language