Showing 247 of 615 total issues
Function TestNetworkCheck
has 295 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestNetworkCheck(t *testing.T) {
t.Parallel()
defer logging.HideLogs(t)()
nwName := "test-network"
Function TestDiffMod
has 290 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestDiffMod(t *testing.T) {
t.Parallel()
t.Run("set all options", func(t *testing.T) {
u := user.NewUser(new(user.System))
Function TestApply
has 283 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestApply(t *testing.T) {
t.Parallel()
t.Run("hash error", func(t *testing.T) {
task := fetch.Fetch{
Function TestApply
has 277 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestApply(t *testing.T) {
t.Parallel()
t.Run("query-unit-returns-error", func(t *testing.T) {
t.Parallel()
expected := errors.New("error1")
File systemd_linux_test.go
has 834 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Copyright © 2016 Asteris, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Function newPropertiesFromMap
has a Cognitive Complexity of 74 (exceeds 20 allowed). Consider refactoring. Open
func newPropertiesFromMap(m map[string]interface{}) *Properties {
s := &Properties{}
if val, ok := m["ActiveEnterTimestamp"]; ok {
s.ActiveEnterTimestamp = val.(uint64)
- 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 Group.Apply
has a Cognitive Complexity of 74 (exceeds 20 allowed). Consider refactoring. Open
func (g *Group) Apply(context.Context) (resource.TaskStatus, error) {
var (
groupByGid *user.Group
gidErr error
newNameErr error
- 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
Function TestEvaluateDuplicates
has 248 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestEvaluateDuplicates(t *testing.T) {
t.Parallel()
t.Run("no duplicates", func(t *testing.T) {
destDir, err := ioutil.TempDir("", "destDir_unarchive")
Function TestApply
has 247 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestApply(t *testing.T) {
t.Parallel()
srcDir, err := ioutil.TempDir("", "unarchive_srcDir")
require.NoError(t, err)
Function TestApply
has 246 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestApply(t *testing.T) {
t.Parallel()
t.Run("state=present", func(t *testing.T) {
t.Run("add tests", func(t *testing.T) {
Function newPropertiesFromMap
has 224 lines of code (exceeds 50 allowed). Consider refactoring. Open
func newPropertiesFromMap(m map[string]interface{}) *Properties {
s := &Properties{}
if val, ok := m["ActiveEnterTimestamp"]; ok {
s.ActiveEnterTimestamp = val.(uint64)
Function TestCopyToFinalDest
has 213 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestCopyToFinalDest(t *testing.T) {
t.Parallel()
t.Run("no duplicates", func(t *testing.T) {
destDir, err := ioutil.TempDir("", "destDir_unarchive")
Function TestPreparer
has 212 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestPreparer(t *testing.T) {
t.Parallel()
var (
fr = fakerenderer.FakeRenderer{}
Function TestCheck
has 202 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestCheck(t *testing.T) {
t.Parallel()
t.Run("send-signal", func(t *testing.T) {
r := &Resource{
State: "running",
Function TestPreparer
has 195 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestPreparer(t *testing.T) {
t.Parallel()
var (
fr = fakerenderer.FakeRenderer{}
Function TestDiffFile
has 188 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestDiffFile(t *testing.T) {
t.Parallel()
t.Run("fetch new file", func(t *testing.T) {
t.Run("with checksum", func(t *testing.T) {
File resource_test.go
has 688 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Copyright © 2016 Asteris, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Function dependencyWalk
has a Cognitive Complexity of 53 (exceeds 20 allowed). Consider refactoring. Open
func dependencyWalk(rctx context.Context, g *Graph, cb WalkFunc) error {
// the basic idea of this implementation is that we want to defer schedule
// children of any given node until after that node's non-child dependencies
// are satisfied. We're going to have a couple major components of this.
// First, a scheduler/latch to make sure we don't schedule work more than
- 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
Function TestOwnershipDiff
has 159 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestOwnershipDiff(t *testing.T) {
users := []*user.User{
fakeUser("1", "1", "user-1"),
fakeUser("2", "2", "user-2"),
fakeUser("3", "3", "user-3"),
Function peerBranchSampleGraph
has 146 lines of code (exceeds 50 allowed). Consider refactoring. Open
func peerBranchSampleGraph(t *testing.T) *graph.Graph {
g := graph.New()
g.Add(node.New(graph.ID("root"), struct{}{}))
g.Add(node.New(graph.ID("root", "switch1"), struct{}{}))