Showing 207 of 546 total issues
Method precompiler.setBlockSize
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *precompiler) setBlockSize(size int64) error {
if size == 0 {
p.exponents.blockSize = 12 // 4 KiB
return nil
Method Writer.writeL1Table
has 5 return statements (exceeds 4 allowed). Open
Open
func (w *Writer) writeL1Table() error {
l2Capacity := w.clusterSize * (w.clusterSize / 8)
buf := new(bytes.Buffer)
Method Virtualizer.GenerateScript
has 5 return statements (exceeds 4 allowed). Open
Open
func (v *Virtualizer) GenerateScript(source string) error {
var err error
name := filepath.Base(v.folder)
err = os.MkdirAll(filepath.Join(source), 0777)
Method ContainerConverter.downloadInformationRemote
has 5 return statements (exceeds 4 allowed). Open
Open
func (cc *ContainerConverter) downloadInformationRemote(config *registryConfig) error {
if config == nil || config.url == "" {
return fmt.Errorf("config is nil or URL is empty")
}
Method builder.MergeVCFG
has 5 return statements (exceeds 4 allowed). Open
Open
func (b *builder) MergeVCFG(cfg *vcfg.VCFG) error {
v, err := vcfg.LoadFile(b.vcfg)
if err != nil {
return err
Method Virtualizer.createAndConfigure
has 5 return statements (exceeds 4 allowed). Open
Open
func (v *Virtualizer) createAndConfigure(diskpath string) error {
cVMArgs := createVM(v.folder, v.name)
cmd := exec.Command("VBoxManage", cVMArgs...)
err := v.execute(cmd)
if err != nil {
Function checkIfNewVRepo
has 5 return statements (exceeds 4 allowed). Open
Open
func checkIfNewVRepo(src string) (string, error) {
urlo, err := url.Parse(src)
if err != nil {
return "", err
}
Method Virtualizer.GenerateScript
has 5 return statements (exceeds 4 allowed). Open
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])
Method Virtualizer.initializeNetworkCards
has 5 return statements (exceeds 4 allowed). Open
Open
func (v *Virtualizer) initializeNetworkCards() ([]string, error) {
v.logger.Debugf("Initializing Network Cards")
var nicArgs string
var err error
var nr string
Method operation.setVMDetails
has 5 return statements (exceeds 4 allowed). Open
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 {
Method DynamicWriter.writeHeader
has 5 return statements (exceeds 4 allowed). Open
Open
func (w *DynamicWriter) writeHeader() error {
// sparse drive header
cxsparse := uint64(0x6378737061727365)
header := &header{
Cookie: cxsparse,
Method compiler.buildBitmap
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (c *compiler) buildBitmap() {
c.allocGroupFreeBlocks = make([]int64, c.allocGroups)
c.allocGroupFreeInodes = make([]int64, c.allocGroups)
for i := int64(0); i < c.allocGroups; i++ {
- 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
Method writeSeeker.Seek
has 5 return statements (exceeds 4 allowed). Open
Open
func (ws *writeSeeker) Seek(offset int64, whence int) (int64, error) {
switch whence {
case io.SeekCurrent:
if ws.s == nil {
if offset < 0 {
Method Virtualizer.handlePorts
has 5 return statements (exceeds 4 allowed). Open
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 {
Method Size.String
has 5 return statements (exceeds 4 allowed). Open
Open
func (x Size) String() string {
sign := ""
if int(x) < 0 {
sign = "+"
}
Function BindPort
has 5 return statements (exceeds 4 allowed). Open
Open
func BindPort(netType, protocol, port string) (string, string, error) {
var (
bind string
netRoute string
isBound bool
Method Builder.validateOSArgs
has 5 return statements (exceeds 4 allowed). Open
Open
func (b *Builder) validateOSArgs(ctx context.Context) error {
b.linuxArgs = b.vcfg.System.KernelArgs
b.determineKernelTags()
Method tree.Close
has 5 return statements (exceeds 4 allowed). Open
Open
func (t *tree) Close() error {
t.lock.Lock()
defer t.lock.Unlock()
if t.closed {
Function Open
has 5 return statements (exceeds 4 allowed). Open
Open
func Open(path string) (File, error) {
fi, err := os.Lstat(path)
if err != nil {
return nil, err
}
Function NewBuilderFromReader
has 5 return statements (exceeds 4 allowed). Open
Open
func NewBuilderFromReader(rdr Reader) (Builder, error) {
var err error
b := NewBuilder()
b.(*builder).closeFunc = rdr.Close