Showing 59 of 92 total issues

Method parser.Init has a Cognitive Complexity of 2639 (exceeds 20 allowed). Consider refactoring.
Open

func (p *parser) Init(options ...func(*parser) error) error {
    var (
        max                  token32
        position, tokenIndex uint32
        buffer               []rune
Severity: Minor
Found in internal/logs/parser/grammar.peg.go - About 1 mo 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 parser.Init has 2833 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (p *parser) Init(options ...func(*parser) error) error {
    var (
        max                  token32
        position, tokenIndex uint32
        buffer               []rune
Severity: Major
Found in internal/logs/parser/grammar.peg.go - About 2 wks to fix

    File grammar.peg.go has 3337 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package parser
    
    // Code generated by peg -inline -switch grammar.peg DO NOT EDIT
    
    import (
    Severity: Major
    Found in internal/logs/parser/grammar.peg.go - About 1 wk to fix

      File lambda.go has 793 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      // Package lambda implements the API Gateway & AWS Lambda platform.
      package lambda
      
      import (
          "bytes"
      Severity: Major
      Found in platform/lambda/lambda.go - About 1 day to fix

        Method reporter.Start has a Cognitive Complexity of 59 (exceeds 20 allowed). Consider refactoring.
        Open

        func (r *reporter) Start() {
            tick := time.NewTicker(150 * time.Millisecond)
            defer tick.Stop()
        
            render := term.Renderer()
        Severity: Minor
        Found in reporter/text/text.go - About 6 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 reporter.Start has 156 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (r *reporter) Start() {
            tick := time.NewTicker(150 * time.Millisecond)
            defer tick.Stop()
        
            render := term.Renderer()
        Severity: Major
        Found in reporter/text/text.go - About 5 hrs to fix

          Platform has 39 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type Platform struct {
              config  *up.Config
              handler string
              zip     *bytes.Buffer
              events  event.Events
          Severity: Minor
          Found in platform/lambda/lambda.go - About 5 hrs to fix

            Method parser.Init has 46 return statements (exceeds 4 allowed).
            Open

            func (p *parser) Init(options ...func(*parser) error) error {
                var (
                    max                  token32
                    position, tokenIndex uint32
                    buffer               []rune
            Severity: Major
            Found in internal/logs/parser/grammar.peg.go - About 4 hrs to fix

              File team.go has 561 lines of code (exceeds 500 allowed). Consider refactoring.
              Open

              package team
              
              import (
                  "context"
                  "encoding/base64"
              Severity: Minor
              Found in internal/cli/team/team.go - About 3 hrs to fix

                Function subscribe has 83 lines of code (exceeds 50 allowed). Consider refactoring.
                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 2 hrs to fix

                  Function login has 78 lines of code (exceeds 50 allowed). Consider refactoring.
                  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 2 hrs to fix

                    Function init has 75 lines of code (exceeds 50 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 2 hrs to fix

                      Method Stack.Plan has 75 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

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

                        Method parser.Execute has 74 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (p *parser) Execute() {
                            buffer, _buffer, text, begin, end := p.Buffer, p.buffer, "", 0, 0
                            for _, token := range p.Tokens() {
                                switch token.pegRule {
                        
                        
                        Severity: Minor
                        Found in internal/logs/parser/grammar.peg.go - About 1 hr to fix

                          Function login has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
                          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: Minor
                          Found in internal/cli/team/team.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 deploy has 65 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

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

                            Method Platform.updateFunction has 61 lines of code (exceeds 50 allowed). Consider refactoring.
                            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: Minor
                            Found in platform/lambda/lambda.go - About 1 hr to fix

                              Function subscribe has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                              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: Minor
                              Found in internal/cli/team/team.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 init has 60 lines of code (exceeds 50 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 1 hr to fix

                                Function init has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func init() {
                                    cmd := root.Command("logs", "Show log output.")
                                    cmd.Example(`up logs`, "Show logs from the past hour.")
                                    cmd.Example(`up logs -S 30m`, "Show logs from the past 30 minutes.")
                                    cmd.Example(`up logs -S 5h`, "Show logs from the past 5 hours.")
                                Severity: Minor
                                Found in internal/cli/logs/logs.go - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language