vorteil/vorteil

View on GitHub

Showing 207 of 546 total issues

Function runFirecracker has 70 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func runFirecracker(pkgReader vpkg.Reader, cfg *vcfg.VCFG, name, diskOutput string) error {
    var err error
    if runtime.GOOS != "linux" {
        return errors.New("firecracker is only available on linux")
    }
Severity: Minor
Found in pkg/cli/virtualizers.go - About 1 hr to fix

    Method Virtualizer.RemoveEntry has 69 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (v *Virtualizer) RemoveEntry() error {
        env, err := os.UserHomeDir()
        if err != nil {
            return err
        }
    Severity: Minor
    Found in pkg/virtualizers/vmware/virtualizer.go - About 1 hr to fix

      Function StatImageFile has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
      Open

      func StatImageFile(vorteilImagePath string, imageFilePath string, seekOS bool) (StatFileReport, error) {
          var statOut StatFileReport
          vorteilImage, err := vdecompiler.Open(vorteilImagePath)
          if err != nil {
              return statOut, err
      Severity: Minor
      Found in pkg/imagetools/stat.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 Provisioner.Provision has 65 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (p *Provisioner) Provision(args *provisioners.ProvisionArgs) error {
          var err error
          var imageID *string
          p.args = *args
      
      
      Severity: Minor
      Found in pkg/provisioners/amazon/amazon.go - About 1 hr to fix

        Function DUImageFile has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
        Open

        func DUImageFile(vorteilImage *vdecompiler.IO, imageFilePath string, calcFreeSpace bool, maxDepth int, all bool) (DUImageReport, error) {
            var duOut DUImageReport
            var depth = 0
        
            var recurse func(*ext.Inode, string) (int, error)
        Severity: Minor
        Found in pkg/imagetools/du.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 CLIRemoteManager.get has 17 return statements (exceeds 4 allowed).
        Open

        func (mgr *CLIRemoteManager) get(version CalVer) error {
        
            prog := mgr.log.NewProgress(fmt.Sprintf("Fetching kernel: %s", version.String()), "", 0)
            defer prog.Finish(false)
        
        
        Severity: Major
        Found in pkg/vkern/cli.go - About 1 hr to fix

          Function DUImageFile has 64 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func DUImageFile(vorteilImage *vdecompiler.IO, imageFilePath string, calcFreeSpace bool, maxDepth int, all bool) (DUImageReport, error) {
              var duOut DUImageReport
              var depth = 0
          
              var recurse func(*ext.Inode, string) (int, error)
          Severity: Minor
          Found in pkg/imagetools/du.go - About 1 hr to fix

            Method Provisioner.Provision has 16 return statements (exceeds 4 allowed).
            Open

            func (p *Provisioner) Provision(args *provisioners.ProvisionArgs) error {
                var err error
            
                // report that the 'description' flag is ignored if using this provisioner
                if args.Description != "" {
            Severity: Major
            Found in pkg/provisioners/vcenter/vcenter.go - About 1 hr to fix

              Function BindPort has 62 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func BindPort(netType, protocol, port string) (string, string, error) {
                  var (
                      bind     string
                      netRoute string
                      isBound  bool
              Severity: Minor
              Found in pkg/virtualizers/util.go - About 1 hr to fix

                Function decompileImageRecursive has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func decompileImageRecursive(vorteilImage *vdecompiler.IO, report DecompileReport, symlinkCallbacks []func() error, ino int, rpath string, dpath string) (DecompileReport, []func() error, error) {
                    var entries []*vdecompiler.DirectoryEntry
                
                    inode, err := vorteilImage.ResolveInode(ino)
                    if err != nil {
                Severity: Minor
                Found in pkg/imagetools/decompile.go - About 1 hr to fix

                  Function StatImageFile has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func StatImageFile(vorteilImagePath string, imageFilePath string, seekOS bool) (StatFileReport, error) {
                      var statOut StatFileReport
                      vorteilImage, err := vdecompiler.Open(vorteilImagePath)
                      if err != nil {
                          return statOut, err
                  Severity: Minor
                  Found in pkg/imagetools/stat.go - About 1 hr to fix

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

                    func main() {
                    
                        defer cli.HandleErrors()
                    
                        // Init FOSS COMMANDS
                    Severity: Minor
                    Found in cmd/vorteil/main.go - About 1 hr to fix

                      Method Virtualizer.Close has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (v *Virtualizer) Close(force bool) error {
                          v.logger.Debugf("Deleting VM")
                          if force && v.state != virtualizers.Ready {
                              err := v.ForceStop()
                              if err != nil {
                      Severity: Minor
                      Found in pkg/virtualizers/vmware/virtualizer.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 decompileImageRecursive has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func decompileImageRecursive(vorteilImage *vdecompiler.IO, report DecompileReport, symlinkCallbacks []func() error, ino int, rpath string, dpath string) (DecompileReport, []func() error, error) {
                          var entries []*vdecompiler.DirectoryEntry
                      
                          inode, err := vorteilImage.ResolveInode(ino)
                          if err != nil {
                      Severity: Minor
                      Found in pkg/imagetools/decompile.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 compiler.precompile has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (c *compiler) precompile(ctx context.Context) error {
                      
                          var err error
                      
                          // alloc group sizes
                      Severity: Minor
                      Found in pkg/xfs/xfs.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 CLIRemoteManager.get has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (mgr *CLIRemoteManager) get(version CalVer) error {
                      
                          prog := mgr.log.NewProgress(fmt.Sprintf("Fetching kernel: %s", version.String()), "", 0)
                          defer prog.Finish(false)
                      
                      
                      Severity: Minor
                      Found in pkg/vkern/cli.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 runHyperV has 60 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func runHyperV(pkgReader vpkg.Reader, cfg *vcfg.VCFG, name, diskOutput string) error {
                          if runtime.GOOS != "windows" {
                              return errors.New("hyper-v is only available on windows system")
                          }
                          if !hyperv.Allocator.IsAvailable() {
                      Severity: Minor
                      Found in pkg/cli/virtualizers.go - About 1 hr to fix

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

                        func GenerateVMX(cores, memory, disk, name, dir string, numberOfNetworkCards int, networkType string, id string) string {
                            replace := func(in, replace, with string) string {
                                return strings.Replace(in, replace, with, -1)
                            }
                        
                        
                        Severity: Minor
                        Found in pkg/virtualizers/vmware/util.go - About 1 hr to fix

                          Method Compiler.setPrecompileConstants has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (c *Compiler) setPrecompileConstants(size, minDataBlocks, minInodes, minInodesPer64 int64) error {
                          
                              c.size = size
                              blocks := c.size / BlockSize
                              groups := divide(blocks, BlocksPerGroup)
                          Severity: Minor
                          Found in pkg/ext4/layout.go - About 1 hr to fix

                            Method Provisioner.Provision has 14 return statements (exceeds 4 allowed).
                            Open

                            func (p *Provisioner) Provision(args *provisioners.ProvisionArgs) error {
                            
                                authHeader := fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", p.cfg.Username, p.cfg.Password))))
                                if args.Description != "" {
                                    p.log.Warnf(`The 'description' field is ignored by Nutanix provision operation`)
                            Severity: Major
                            Found in pkg/provisioners/nutanix/nutanix.go - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language