Showing 247 of 615 total issues
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) {
Function simpleCheckSuccess
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func simpleCheckSuccess(t *testing.T, lvm lowlevel.LVM, group string, name string, size *lowlevel.LvmSize) (resource.TaskStatus, resource.Task) {
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 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) {
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 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 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 newExportedField
has 5 return statements (exceeds 4 allowed). Open
Open
func newExportedField(input interface{}, index int) (*ExportedField, bool) {
if nil == input {
return nil, false
}
Method Preparer.convertTime
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Preparer) convertTime(typ reflect.Type, r Renderer, name string, val interface{}, base int) (reflect.Value, error) {
if val == nil {
return reflect.Zero(typ), nil
}
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 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 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 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 pipelineGen.GetTask
has 5 return statements (exceeds 4 allowed). Open
Open
func (g *pipelineGen) GetTask(ctx context.Context, idi interface{}) (interface{}, error) {
if thunk, ok := idi.(*render.PrepareThunk); ok {
thunked, err := thunk.Thunk(g.RenderingPlant)
if err != nil {
return nil, err
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
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
}
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 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 {
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 {
Method GrapherClient.Graph
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (gc *GrapherClient) Graph(ctx context.Context, loc *pb.LoadRequest, opts ...grpc.CallOption) (*graph.Graph, error) {
stream, err := gc.client.Graph(ctx, loc, opts...)
if err != nil {
return nil, errors.Wrap(err, "could not open stream")
}
- 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"