vorteil/vorteil

View on GitHub

Showing 207 of 546 total issues

Function Open has 5 return statements (exceeds 4 allowed).
Open

func Open(path string) (File, error) {
    fi, err := os.Lstat(path)
    if err != nil {
        return nil, err
    }
Severity: Major
Found in pkg/vio/file.go - About 35 mins to fix

    Method operation.setVMDetails has 5 return statements (exceeds 4 allowed).
    Open

    func (o *operation) setVMDetails(size string) error {
        // set vm memory
        cmd := exec.Command(virtualizers.Powershell, "Set-VMMemory", "-VMName", o.name, "-DynamicMemoryEnabled", "0", "-StartupBytes", size)
        output, err := o.execute(cmd)
        if err != nil {
    Severity: Major
    Found in pkg/virtualizers/hyperv/virtualizer.go - About 35 mins to fix

      Function BindPort has 5 return statements (exceeds 4 allowed).
      Open

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

        Method ContainerConverter.downloadInformationRemote has 5 return statements (exceeds 4 allowed).
        Open

        func (cc *ContainerConverter) downloadInformationRemote(config *registryConfig) error {
        
            if config == nil || config.url == "" {
                return fmt.Errorf("config is nil or URL is empty")
            }
        Severity: Major
        Found in pkg/vconvert/remote.go - About 35 mins to fix

          Method Writer.writeL1Table has 5 return statements (exceeds 4 allowed).
          Open

          func (w *Writer) writeL1Table() error {
          
              l2Capacity := w.clusterSize * (w.clusterSize / 8)
          
              buf := new(bytes.Buffer)
          Severity: Major
          Found in pkg/qcow2/qcow2.go - About 35 mins to fix

            Method Virtualizer.GenerateScript has 5 return statements (exceeds 4 allowed).
            Open

            func (v *Virtualizer) GenerateScript(source string) error {
                var err error
            
                // look up full path to qemu
                v.command.Args[0], err = exec.LookPath(v.command.Args[0])
            Severity: Major
            Found in pkg/virtualizers/qemu/virtualizer_windows.go - About 35 mins to fix

              Method Virtualizer.GenerateScript has 5 return statements (exceeds 4 allowed).
              Open

              func (v *Virtualizer) GenerateScript(source string) error {
                  var err error
              
                  name := filepath.Base(v.folder)
                  err = os.MkdirAll(filepath.Join(source), 0777)
              Severity: Major
              Found in pkg/virtualizers/qemu/virtualizer_notwindows.go - About 35 mins to fix

                Method tree.Close has 5 return statements (exceeds 4 allowed).
                Open

                func (t *tree) Close() error {
                
                    t.lock.Lock()
                    defer t.lock.Unlock()
                    if t.closed {
                Severity: Major
                Found in pkg/vio/tree.go - About 35 mins to fix

                  Method Size.String has 5 return statements (exceeds 4 allowed).
                  Open

                  func (x Size) String() string {
                      sign := ""
                      if int(x) < 0 {
                          sign = "+"
                      }
                  Severity: Major
                  Found in pkg/vcfg/types.go - About 35 mins to fix

                    Function build has 5 return statements (exceeds 4 allowed).
                    Open

                    func build(ctx context.Context, w io.WriteSeeker, cfg *vcfg.VCFG, args *BuildArgs) error {
                    
                        log := args.Logger
                    
                        fsCompiler, err := NewFilesystemCompiler(string(cfg.System.Filesystem), log, args.PackageReader.FS(), nil)
                    Severity: Major
                    Found in pkg/vdisk/build.go - About 35 mins to fix

                      Method writeSeeker.Seek has 5 return statements (exceeds 4 allowed).
                      Open

                      func (ws *writeSeeker) Seek(offset int64, whence int) (int64, error) {
                          switch whence {
                          case io.SeekCurrent:
                              if ws.s == nil {
                                  if offset < 0 {
                      Severity: Major
                      Found in pkg/vio/writeseeker.go - About 35 mins to fix

                        Method Virtualizer.Start has 5 return statements (exceeds 4 allowed).
                        Open

                        func (v *Virtualizer) Start() error {
                            v.logger.Debugf("Starting VM")
                            switch v.State() {
                            case "ready":
                                v.state = virtualizers.Changing
                        Severity: Major
                        Found in pkg/virtualizers/virtualbox/virtualizer.go - About 35 mins to fix

                          Method StreamOptimizedWriter.Write has 5 return statements (exceeds 4 allowed).
                          Open

                          func (w *StreamOptimizedWriter) Write(p []byte) (int, error) {
                          
                              if w.cursor >= w.h.Size() {
                                  return 0, io.EOF
                              }
                          Severity: Major
                          Found in pkg/vmdk/stream-optimized.go - About 35 mins to fix

                            Method MonitoringOptions.preprocess has 5 return statements (exceeds 4 allowed).
                            Open

                            func (opts *MonitoringOptions) preprocess(b Builder) error {
                                if opts.PreProcessCompleteCallback == nil {
                                    return nil
                                }
                            
                            
                            Severity: Major
                            Found in pkg/vpkg/package.go - About 35 mins to fix

                              Method Virtualizer.initializeNetworkCards has 5 return statements (exceeds 4 allowed).
                              Open

                              func (v *Virtualizer) initializeNetworkCards() ([]string, error) {
                                  v.logger.Debugf("Initializing Network Cards")
                                  var nicArgs string
                                  var err error
                                  var nr string
                              Severity: Major
                              Found in pkg/virtualizers/qemu/virtualizer.go - About 35 mins to fix

                                Method precompiler.setBlockSize has 5 return statements (exceeds 4 allowed).
                                Open

                                func (p *precompiler) setBlockSize(size int64) error {
                                
                                    if size == 0 {
                                        p.exponents.blockSize = 12 // 4 KiB
                                        return nil
                                Severity: Major
                                Found in pkg/xfs/xfs.go - About 35 mins to fix

                                  Method Virtualizer.handlePorts has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (v *Virtualizer) handlePorts(args []string, route virtualizers.NetworkInterface, protocol string, i int) ([]string, bool, error) {
                                      var err error
                                      var nr string
                                      var hasDefinedPorts bool
                                      for j, port := range route.HTTP {
                                  Severity: Major
                                  Found in pkg/virtualizers/virtualbox/virtualizer.go - About 35 mins to fix

                                    Method ContainerConverter.createVCFG has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                                    Open

                                    func (cc *ContainerConverter) createVCFG(config v1.Config, targetDir string) error {
                                    
                                        if _, err := os.Stat(targetDir); err != nil {
                                            return fmt.Errorf("directory %s does not exist", targetDir)
                                        }
                                    Severity: Minor
                                    Found in pkg/vconvert/vconvert.go - About 35 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

                                    Function treeImageFileRecurse has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                                    Open

                                    func treeImageFileRecurse(vorteilImage *vdecompiler.IO, ino int, name string) (TreeReport, error) {
                                        var treeOut TreeReport = TreeReport{
                                            Name:     name,
                                            Children: make([]TreeReport, 0),
                                        }
                                    Severity: Minor
                                    Found in pkg/imagetools/tree.go - About 35 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 builder.MergeVCFG has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func (b *builder) MergeVCFG(cfg *vcfg.VCFG) error {
                                    
                                        v, err := vcfg.LoadFile(b.vcfg)
                                        if err != nil {
                                            return err
                                    Severity: Major
                                    Found in pkg/vpkg/package.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language