Showing 15 of 29 total issues
Function _
has 219 lines of code (exceeds 50 allowed). Consider refactoring. Open
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]
Function KVMCapabilities
has 63 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func KVMCapabilities() error {
X86tests := []kvm.Capability{
kvm.CapIRQChip,
kvm.CapUserMemory,
kvm.CapSetTSSAddr,
Function ParsePVHEntry
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func ParsePVHEntry(fwimg io.ReaderAt, phdr *elf.Prog) (uint32, error) {
node := elfNote{}
off := int64(phdr.Off)
readSize := 0
Function CheckPVH
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
Open
func CheckPVH(kern io.ReaderAt) (bool, error) {
elfkern, err := elf.NewFile(kern)
if err != nil {
return false, nil //nolint:nilerr
}
- 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 ParsePVHEntry
has 8 return statements (exceeds 4 allowed). Open
Open
func ParsePVHEntry(fwimg io.ReaderAt, phdr *elf.Prog) (uint32, error) {
node := elfNote{}
off := int64(phdr.Off)
readSize := 0
Function CheckPVH
has 7 return statements (exceeds 4 allowed). Open
Open
func CheckPVH(kern io.ReaderAt) (bool, error) {
elfkern, err := elf.NewFile(kern)
if err != nil {
return false, nil //nolint:nilerr
}
Method PCI.PciConfDataIn
has 7 return statements (exceeds 4 allowed). Open
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))
Method Machine.Args
has 7 return statements (exceeds 4 allowed). Open
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 {
Method MSRS.Bytes
has 6 return statements (exceeds 4 allowed). Open
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
Function New
has 6 return statements (exceeds 4 allowed). Open
Open
func New(name string) (*Tap, error) {
var err error
t := &Tap{}
Method VMM.Setup
has 6 return statements (exceeds 4 allowed). Open
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 {
Method PCI.PciConfDataOut
has 6 return statements (exceeds 4 allowed). Open
Open
func (p *PCI) PciConfDataOut(port uint64, values []byte) error {
offset := int(p.addr.getRegisterOffset() + uint32(port-0xCFC))
if !p.addr.isEnable() {
return nil
Function NewCPUID
has 5 return statements (exceeds 4 allowed). Open
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) {
Function NewIRQRouting
has 5 return statements (exceeds 4 allowed). Open
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) {
Function NewMSRS
has 5 return statements (exceeds 4 allowed). Open
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) {