Showing 59 of 92 total issues
Method Platform.Prune
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
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")
Method Platform.createCerts
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p *Platform) createCerts() error {
s := session.New(aws.NewConfig().WithRegion("us-east-1"))
a := acm.New(s)
var domains []string
Function init
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
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()
- Read upRead up
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
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()
Method Platform.updateFunction
has 10 return statements (exceeds 4 allowed). Open
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
Function deploy
has 10 return statements (exceeds 4 allowed). Open
Open
func deploy(stage string, build bool) error {
retry:
c, p, err := root.Init()
// missing up.json non-interactive
Function init
has 9 return statements (exceeds 4 allowed). Open
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()
Function init
has 9 return statements (exceeds 4 allowed). Open
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.")
Method Config.Load
has 8 return statements (exceeds 4 allowed). Open
Open
func (c *Config) Load() error {
path, err := c.path()
if err != nil {
return errors.Wrap(err, "getting path")
}
Function init
has 7 return statements (exceeds 4 allowed). Open
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.")
Function init
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
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.")
- Read upRead up
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
Open
func (s *Stack) Plan(versions resources.Versions) error {
c := s.config
tmpl := s.template(versions)
name := c.Name
Avoid deeply nested control flow statements. Open
Open
} else if v := e.String("version"); v != "" {
s += " (version " + v + ")"
}
Function login
has 7 return statements (exceeds 4 allowed). Open
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.")
Function add
has 7 return statements (exceeds 4 allowed). Open
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 {
Method Platform.createRole
has 7 return statements (exceeds 4 allowed). Open
Open
func (p *Platform) createRole() error {
s := session.New(aws.NewConfig())
c := iam.New(s)
name := p.roleName()
Method Platform.Prune
has 6 return statements (exceeds 4 allowed). Open
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")
Function status
has 6 return statements (exceeds 4 allowed). Open
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
Function unsubscribe
has 6 return statements (exceeds 4 allowed). Open
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()
Method Platform.Deploy
has 6 return statements (exceeds 4 allowed). Open
Open
func (p *Platform) Deploy(d up.Deploy) error {
regions := p.config.Regions
var g errgroup.Group
if err := p.createRole(); err != nil {