Showing 247 of 615 total issues
Function testDrawNodesCustomPrinter
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func testDrawNodesCustomPrinter(t *testing.T, h *human.Printer, id string, in Printable, out string) {
Function newMockOS
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func newMockOS(ownedFiles []ownershipRecord,
users []*user.User,
groups []*user.Group,
defaultUser *user.User,
defaultGroup *user.Group,
Function simpleApplyFailure
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func simpleApplyFailure(t *testing.T, lvm lowlevel.LVM, group string, name string, size *lowlevel.LvmSize) resource.TaskStatus {
Function execPipeline
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func execPipeline(ctx context.Context, in *graph.Graph, pipelineF MkPipelineF, renderingPlant *render.Factory, notify *graph.Notifier) (*graph.Graph, error) {
Method executor.HealthCheck
has 5 return statements (exceeds 4 allowed). Open
Open
func (e *executor) HealthCheck(in *pb.LoadRequest, stream pb.Executor_HealthCheckServer) error {
logger, ctx := setIDLogger(stream.Context())
logger = logger.WithField("function", "executor.Plan")
loaded, err := in.Load(ctx)
Method Formatter.init
has 5 return statements (exceeds 4 allowed). Open
Open
func (f *Formatter) init() {
isColorTerminal := logrus.IsTerminal(os.Stderr) && (runtime.GOOS != "windows")
f.fancy = (!f.DisableColors && isColorTerminal)
f.replacer = strings.NewReplacer(
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
Method pipelineGen.DependencyCheck
has 5 return statements (exceeds 4 allowed). Open
Open
func (g *pipelineGen) DependencyCheck(ctx context.Context, taskI interface{}) (interface{}, error) {
task, ok := taskI.(taskWrapper)
if !ok {
return nil, errors.New("input node is not a task wrapper")
}
Function ResolveTask
has 5 return statements (exceeds 4 allowed). Open
Open
func ResolveTask(w interface{}) (Task, bool) {
if w == nil {
return nil, false
}
if tasker, ok := w.(Tasker); ok {
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 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 Client.CreateContainer
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *Client) CreateContainer(opts dc.CreateContainerOptions) (*dc.Container, error) {
name := opts.Name
container, err := c.FindContainer(name)
if err != nil {
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 Container.compareLinks
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *Container) compareLinks(container *dc.Container) (actual, expected string) {
normalizeLink := func(link string) string {
// internally links are stored as "/linkedcontainername:/containername/alias"
parts := strings.Split(link, ":")
if len(parts) == 1 {
Method Preparer.Prepare
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Preparer) Prepare(ctx context.Context, r Renderer) (Task, error) {
value := reflect.ValueOf(p.Destination)
typ := value.Type()
wasPtr := false // so we can re-wrap later if we need to
Function AssertDiff
has 5 return statements (exceeds 4 allowed). Open
Open
func AssertDiff(t *testing.T, diffs map[string]resource.Diff, name, original, current string) bool {
var ok bool
if ok = assert.NotEmpty(t, diffs); !ok {
return false
Method Preparer.convertMap
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Preparer) convertMap(typ reflect.Type, r Renderer, name string, val interface{}, base int) (reflect.Value, error) {
if val == nil {
return reflect.Zero(typ), nil
}
Method Unarchive.readWrite
has 5 return statements (exceeds 4 allowed). Open
Open
func (u *Unarchive) readWrite(file string) error {
fileName := strings.TrimPrefix(file, u.fetchDir.Name())
fStat, err := os.Stat(file)
if err != nil {
Method pipelineGen.prepareNode
has 5 return statements (exceeds 4 allowed). Open
Open
func (p pipelineGen) prepareNode(ctx context.Context, idi interface{}) (interface{}, error) {
var metadataErr error
res, ok := idi.(resource.Resource)
if !ok {
Method Preparer.convertDuration
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Preparer) convertDuration(typ reflect.Type, r Renderer, name string, val interface{}, base int) (reflect.Value, error) {
if val == nil {
return reflect.Zero(typ), nil
}