nilaway icon indicating copy to clipboard operation
nilaway copied to clipboard

The method encapsulates nil detection but cannot recognize it

Open fidding opened this issue 1 year ago • 0 comments

golang code:


// HasOrg 是否有机构
func (o *InfoOutput) HasOrg() bool {
	if o == nil {
		return false
	}
	if o.OrgInfo == nil {
		return false
	}
	if o.OrgInfo.Id == "" {
		return false
	}
	return true
}

func (o *InfoOutput) GetOrgName() string {
	if !o.HasOrg() {
		return ""
	}
	return o.OrgInfo.Name
}

but:

  • org_user/info.go:45:9: field OrgInfo accessed field Id

fidding avatar Jun 25 '24 06:06 fidding