ekristen/aws-nuke

View on GitHub

Showing 50 of 54 total issues

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

func execute(c *cli.Context) error {
    defaultRegion := c.String("default-region")
    creds := nuke.ConfigureCreds(c)

    if err := creds.Validate(); err != nil {
Severity: Minor
Found in pkg/commands/account/account.go - About 1 hr to fix

    Method Credentials.rootConfig has 57 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (c *Credentials) rootConfig(ctx context.Context) (*aws.Config, error) {
        if c.cfg != nil {
            return c.cfg, nil
        }
    
    
    Severity: Minor
    Found in pkg/awsutil/config.go - About 1 hr to fix

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

      func init() {
          flags := []cli.Flag{
              &cli.PathFlag{
                  Name:    "config",
                  Aliases: []string{"c"},
      Severity: Minor
      Found in pkg/commands/account/account.go - About 1 hr to fix

        Method BatchDelete.Delete has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
        Open

        func (d *BatchDelete) Delete(ctx context.Context, iter BatchDeleteIterator, opts ...func(input *s3.DeleteObjectsInput)) error {
            var errs []Error
            var objects []BatchDeleteObject
            var input *s3.DeleteObjectsInput
        
        
        Severity: Minor
        Found in pkg/awsmod/batch.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 ECSTaskLister.List has 56 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (l *ECSTaskLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
            opts := o.(*nuke.ListerOpts)
        
            resources := make([]resource.Resource, 0)
        
        
        Severity: Minor
        Found in resources/ecs-task.go - About 1 hr to fix

          Method IoTSiteWiseDashboardLister.List has 56 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (l *IoTSiteWiseDashboardLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
              opts := o.(*nuke.ListerOpts)
          
              svc := iotsitewise.New(opts.Session)
              resources := make([]resource.Resource, 0)
          Severity: Minor
          Found in resources/iotsitewise-dashboard.go - About 1 hr to fix

            Method AppMeshRouteLister.List has 56 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (l *AppMeshRouteLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
                opts := o.(*nuke.ListerOpts)
                svc := appmesh.New(opts.Session)
                var resources []resource.Resource
            
            
            Severity: Minor
            Found in resources/appmesh-route.go - About 1 hr to fix

              Method AppMeshGatewayRouteLister.List has 56 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (l *AppMeshGatewayRouteLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
                  opts := o.(*nuke.ListerOpts)
                  svc := appmesh.New(opts.Session)
                  var resources []resource.Resource
              
              
              Severity: Minor
              Found in resources/appmesh-gatewayroute.go - About 1 hr to fix

                Method EKSFargateProfileLister.List has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (l *EKSFargateProfileLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
                    opts := o.(*nuke.ListerOpts)
                    svc := eks.New(opts.Session)
                    var clusterNames []*string
                    var resources []resource.Resource
                Severity: Minor
                Found in resources/eks-fargate-profile.go - About 1 hr to fix

                  Method IAMRolePolicyAttachmentLister.List has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (l *IAMRolePolicyAttachmentLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
                      opts := o.(*nuke.ListerOpts)
                  
                      svc := iam.New(opts.Session)
                      roleParams := &iam.ListRolesInput{}
                  Severity: Minor
                  Found in resources/iam-role-policy-attachments.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 IAMRolePolicyLister.List has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (l *IAMRolePolicyLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
                      opts := o.(*nuke.ListerOpts)
                  
                      svc := iam.New(opts.Session)
                      roleParams := &iam.ListRolesInput{}
                  Severity: Minor
                  Found in resources/iam-role-policy.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 CloudWatchLogsLogGroupLister.List has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (l *CloudWatchLogsLogGroupLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
                      opts := o.(*nuke.ListerOpts)
                  
                      svc := cloudwatchlogs.New(opts.Session)
                      resources := make([]resource.Resource, 0)
                  Severity: Minor
                  Found in resources/cloudwatchlogs-loggroups.go - About 1 hr to fix

                    Method Credentials.NewSession has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (c *Credentials) NewSession(region, serviceType string) (*session.Session, error) {
                        log.Debugf("creating new session in %s for %s", region, serviceType)
                    
                        global := false
                    
                    
                    Severity: Minor
                    Found in pkg/awsutil/session.go - About 1 hr to fix

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                          if defaultRegion != "" {
                              awsutil.DefaultRegionID = defaultRegion
                      
                              partition, ok := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), defaultRegion)
                              if !ok {
                      Severity: Minor
                      Found in pkg/commands/account/account.go and 1 other location - About 55 mins to fix
                      pkg/commands/nuke/nuke.go on lines 89..104

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 126.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                          if defaultRegion != "" {
                              awsutil.DefaultRegionID = defaultRegion
                      
                              partition, ok := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), defaultRegion)
                              if !ok {
                      Severity: Minor
                      Found in pkg/commands/nuke/nuke.go and 1 other location - About 55 mins to fix
                      pkg/commands/account/account.go on lines 40..55

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 126.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Function execute has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func execute(c *cli.Context) error { //nolint:funlen,gocyclo
                          var regs registry.Registrations
                      
                          if c.String("resource") == "all" {
                              regs = registry.GetRegistrations()
                      Severity: Minor
                      Found in tools/generate-docs/docs.go - About 55 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 S3ObjectLister.List has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (l *S3ObjectLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) {
                          opts := o.(*nuke.ListerOpts)
                          svc := s3.NewFromConfig(*opts.Config)
                      
                          resources := make([]resource.Resource, 0)
                      Severity: Minor
                      Found in resources/s3-objects.go - About 55 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

                      Avoid deeply nested control flow statements.
                      Open

                                              if awsError.Code() == "AccessDeniedException" {
                                                  inaccessibleKeys = true
                                                  logrus.WithError(err).Debug("unable to list tags")
                                                  continue
                                              } else {
                      Severity: Major
                      Found in resources/kms-key.go - About 45 mins to fix

                        Method IoTTwinMakerComponentTypeLister.List has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (l *IoTTwinMakerComponentTypeLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
                            opts := o.(*nuke.ListerOpts)
                            resources := make([]resource.Resource, 0)
                        
                            if !l.IsSupportedRegion(opts.Region.Name) {
                        Severity: Minor
                        Found in resources/iottwinmaker-component-type.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

                        Avoid deeply nested control flow statements.
                        Open

                                } else if _, err := cfs.svc.DeleteStack(&cloudformation.DeleteStackInput{
                                    StackName: cfs.stack.StackName,
                                }); err != nil {
                                    return err
                                } else if err := cfs.svc.WaitUntilStackDeleteComplete(&cloudformation.DescribeStacksInput{
                        Severity: Major
                        Found in resources/cloudformation-stack.go - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language