bobuhiro11/gokvm

View on GitHub

Showing 15 of 29 total issues

Function _ has 219 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func _() {
    // An "invalid array index" compiler error signifies that the constant values have changed.
    // Re-run the stringer command to generate them again.
    var x [1]struct{}
    _ = x[CapIRQChip-0]
Severity: Major
Found in kvm/capability_string.go - About 7 hrs to fix

    Function KVMCapabilities has 63 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func KVMCapabilities() error {
        X86tests := []kvm.Capability{
            kvm.CapIRQChip,
            kvm.CapUserMemory,
            kvm.CapSetTSSAddr,
    Severity: Minor
    Found in probe/capabilities.go - About 1 hr to fix

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

      func ParsePVHEntry(fwimg io.ReaderAt, phdr *elf.Prog) (uint32, error) {
          node := elfNote{}
          off := int64(phdr.Off)
          readSize := 0
      
      
      Severity: Minor
      Found in pvh/pvhboot.go - About 1 hr to fix

        Function CheckPVH has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
        Open

        func CheckPVH(kern io.ReaderAt) (bool, error) {
            elfkern, err := elf.NewFile(kern)
            if err != nil {
                return false, nil //nolint:nilerr
            }
        Severity: Minor
        Found in pvh/pvhboot.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 ParsePVHEntry has 8 return statements (exceeds 4 allowed).
        Open

        func ParsePVHEntry(fwimg io.ReaderAt, phdr *elf.Prog) (uint32, error) {
            node := elfNote{}
            off := int64(phdr.Off)
            readSize := 0
        
        
        Severity: Major
        Found in pvh/pvhboot.go - About 50 mins to fix

          Function CheckPVH has 7 return statements (exceeds 4 allowed).
          Open

          func CheckPVH(kern io.ReaderAt) (bool, error) {
              elfkern, err := elf.NewFile(kern)
              if err != nil {
                  return false, nil //nolint:nilerr
              }
          Severity: Major
          Found in pvh/pvhboot.go - About 45 mins to fix

            Method PCI.PciConfDataIn has 7 return statements (exceeds 4 allowed).
            Open

            func (p *PCI) PciConfDataIn(port uint64, values []byte) error {
                // offset can be obtained from many source as below:
                //        (address from IO port 0xcf8) & 0xfc + (IO port address for Data) - 0xCFC
                // see pci_conf1_read in linux/arch/x86/pci/direct.c for more detail.
                offset := int(p.addr.getRegisterOffset() + uint32(port-0xCFC))
            Severity: Major
            Found in pci/pci.go - About 45 mins to fix

              Method Machine.Args has 7 return statements (exceeds 4 allowed).
              Open

              func (m *Machine) Args(cpu int, r *kvm.Regs, nargs int) ([]uintptr, error) {
                  // We must always validate the cpu number, even if we don't absolutely need it.
                  // i.e., for pure register args, the cpu is not needed, but it's
                  // best to validate it.
                  if _, err := m.CPUToFD(cpu); err != nil {
              Severity: Major
              Found in machine/debug_amd64.go - About 45 mins to fix

                Method MSRS.Bytes has 6 return statements (exceeds 4 allowed).
                Open

                func (m *MSRS) Bytes() ([]byte, error) {
                    var buf bytes.Buffer
                
                    if err := binary.Write(&buf, binary.LittleEndian, m.NMSRs); err != nil {
                        return nil, err
                Severity: Major
                Found in kvm/msr.go - About 40 mins to fix

                  Function New has 6 return statements (exceeds 4 allowed).
                  Open

                  func New(name string) (*Tap, error) {
                      var err error
                  
                      t := &Tap{}
                  
                  
                  Severity: Major
                  Found in tap/tap.go - About 40 mins to fix

                    Method VMM.Setup has 6 return statements (exceeds 4 allowed).
                    Open

                    func (v *VMM) Setup() error {
                        var initrd *os.File
                        // Kernel arg required to load kernel or firmware image
                        kern, err := os.Open(v.Kernel)
                        if err != nil {
                    Severity: Major
                    Found in vmm/vmm.go - About 40 mins to fix

                      Method PCI.PciConfDataOut has 6 return statements (exceeds 4 allowed).
                      Open

                      func (p *PCI) PciConfDataOut(port uint64, values []byte) error {
                          offset := int(p.addr.getRegisterOffset() + uint32(port-0xCFC))
                      
                          if !p.addr.isEnable() {
                              return nil
                      Severity: Major
                      Found in pci/pci.go - About 40 mins to fix

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

                        func NewCPUID(data []byte) (*CPUID, error) {
                            c := CPUID{}
                        
                            var buf bytes.Buffer
                            if err := binary.Write(&buf, binary.LittleEndian, data); err != nil && !errors.Is(err, io.EOF) {
                        Severity: Major
                        Found in kvm/cpuid.go - About 35 mins to fix

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

                          func NewIRQRouting(data []byte) (*IRQRouting, error) {
                              r := IRQRouting{}
                          
                              var buf bytes.Buffer
                              if err := binary.Write(&buf, binary.LittleEndian, data); err != nil && !errors.Is(err, io.EOF) {
                          Severity: Major
                          Found in kvm/irq.go - About 35 mins to fix

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

                            func NewMSRS(data []byte) (*MSRS, error) {
                                m := MSRS{}
                            
                                var buf bytes.Buffer
                                if err := binary.Write(&buf, binary.LittleEndian, data); err != nil && !errors.Is(err, io.EOF) {
                            Severity: Major
                            Found in kvm/msr.go - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language