Showing 247 of 615 total issues
Method Unarchive.copyFile
has 5 return statements (exceeds 4 allowed). Open
Open
func (u *Unarchive) copyFile(from, to string) error {
src, err := os.Open(from)
if err != nil {
return err
}
Method Preparer.Prepare
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Preparer) Prepare(ctx context.Context, render resource.Renderer) (resource.Task, error) {
if p.UID != nil && *p.UID == math.MaxUint32 {
// the maximum uid on linux is MaxUint32 - 1
return nil, fmt.Errorf("user \"uid\" parameter out of range")
}
Method User.DiffAdd
has 5 return statements (exceeds 4 allowed). Open
Open
func (u *User) DiffAdd(status *resource.Status) (*AddUserOptions, error) {
options := new(AddUserOptions)
// if a group exists with the same name as the user being added, a groupname
// must also be indicated so the user may be added to that group
Function newSliceTypePropertiesFromMap
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func newSliceTypePropertiesFromMap(m map[string]interface{}) *SliceTypeProperties {
s := &SliceTypeProperties{}
if val, ok := m["BlockIOAccounting"]; ok {
s.BlockIOAccounting = val.(bool)
- 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 resourceLV.Apply
has 5 return statements (exceeds 4 allowed). Open
Open
func (r *resourceLV) Apply(context.Context) (resource.TaskStatus, error) {
status := &Status{}
if _, err := r.checkVG(true); err != nil {
return nil, err
}
Function getParams
has 5 return statements (exceeds 4 allowed). Open
Open
func getParams(g *graph.Graph, id string, node *parse.Node) (out []string, err error) {
var nodeStrings []string
nodeStrings, err = node.GetStrings()
if err != nil {
return nil, err
Method pipelineGen.maybeRunFinalCheck
has 5 return statements (exceeds 4 allowed). Open
Open
func (g *pipelineGen) maybeRunFinalCheck(ctx context.Context, resultI interface{}) (interface{}, error) {
result, ok := resultI.(*Result)
if !ok {
return nil, fmt.Errorf("expected *Result but got %T", resultI)
}
Function HTTP
has 5 return statements (exceeds 4 allowed). Open
Open
func HTTP(ctx context.Context, loc string) ([]byte, error) {
var client http.Client
req, err := http.NewRequest("GET", loc, nil)
if err != nil {
return nil, err
Method resourceFS.Check
has 5 return statements (exceeds 4 allowed). Open
Open
func (r *resourceFS) Check(context.Context, resource.Renderer) (resource.TaskStatus, error) {
status := &resource.Status{}
if err := r.lvm.CheckFilesystemTools(r.mount.Type); err != nil {
return nil, errors.Wrapf(err, "filesystem prerequisites for %s", r.mount.Type)
Method resourceVG.Check
has 5 return statements (exceeds 4 allowed). Open
Open
func (r *resourceVG) Check(context.Context, resource.Renderer) (resource.TaskStatus, error) {
status := &resource.Status{}
if err := r.lvm.Check(); err != nil {
return nil, errors.Wrap(err, "lvm.volumegroup")
Method Printer.drawEdges
has 5 return statements (exceeds 4 allowed). Open
Open
func (p Printer) drawEdges(g *graph.Graph) (Renderable, error) {
edgePrinter, epOK := p.pp.(EdgePrinter)
edgeSectionPrinter, espOK := p.pp.(EdgeSectionPrinter)
if !epOK && !espOK {
Method Printer.DrawNode
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Printer) DrawNode(g *graph.Graph, id string) (pp.Renderable, error) {
type printerNode struct {
ID string
*resource.HealthStatus
}
Method Graph.IsNibling
has 5 return statements (exceeds 4 allowed). Open
Open
func (g *Graph) IsNibling(fst, snd string) bool {
sndID, sndHasParent := g.GetParentID(snd)
if !sndHasParent {
return false
}
Function getXrefs
has 5 return statements (exceeds 4 allowed). Open
Open
func getXrefs(g *graph.Graph, id string, node *parse.Node) (out []string, err error) {
var nodeStrings []string
var calls []string
nodeRefs := make(map[string]struct{})
nodeStrings, err = node.GetStrings()
Function execPipeline
has 5 return statements (exceeds 4 allowed). Open
Open
func execPipeline(ctx context.Context, in *graph.Graph, pipelineF MkPipelineF, renderingPlant *render.Factory, notify *graph.Notifier) (*graph.Graph, error) {
var hasErrors error
out, err := in.Transform(ctx,
notify.Transform(func(meta *node.Node, out *graph.Graph) error {
Function ParseSize
has 5 return statements (exceeds 4 allowed). Open
Open
func ParseSize(sizeToParse string) (*LvmSize, error) {
var err error
size := &LvmSize{}
if m := pctRE.FindStringSubmatch(sizeToParse); m != nil {
size.Relative = true
Function RenderPredicate
has 5 return statements (exceeds 4 allowed). Open
Open
func RenderPredicate(meta *node.Node, renderFunc func(string, string) (string, error)) (string, error) {
rendered, ok := meta.LookupMetadata(MetaRenderedPredicate)
if ok {
return rendered.(string), nil
}
Method Keystore.CheckSignature
has 5 return statements (exceeds 4 allowed). Open
Open
func (ks *Keystore) CheckSignature(signed, signature io.Reader) error {
if ks.keyring == nil {
keyring, err := loadKeyring(ks)
if err != nil {
return errors.Wrap(err, "error loading keyring")
Method Content.Check
has 5 return statements (exceeds 4 allowed). Open
Open
func (t *Content) Check(context.Context, resource.Renderer) (resource.TaskStatus, error) {
diffs := make(map[string]resource.Diff)
contentDiff := resource.TextDiff{Values: [2]string{"", t.Content}}
stat, err := os.Stat(t.Destination)
if os.IsNotExist(err) {
Function getParentSubgraph
has 5 return statements (exceeds 4 allowed). Open
Open
func getParentSubgraph(subgraphs SubgraphMap, thisSubgraph SubgraphID, id string) SubgraphID {
parent := graph.ParentID(id)
if thisSubgraph == SubgraphBottomID {
return SubgraphBottomID
}