Showing 615 of 615 total issues
Function newMountTypePropertiesFromMap
has 389 lines of code (exceeds 50 allowed). Consider refactoring. Open
func newMountTypePropertiesFromMap(m map[string]interface{}) *MountTypeProperties {
s := &MountTypeProperties{}
if val, ok := m["AmbientCapabilities"]; ok {
s.AmbientCapabilities = val.(uint64)
Function TestListUnits
has 383 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestListUnits(t *testing.T) {
t.Parallel()
t.Run("when-dbus-errors", func(t *testing.T) {
t.Run("list-units-returns-error", func(t *testing.T) {
Function TestCheck
has 381 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestCheck(t *testing.T) {
t.Parallel()
users := []*user.User{
fakeUser("1", "1", "user-1"),
Function newSwapTypePropertiesFromMap
has 377 lines of code (exceeds 50 allowed). Consider refactoring. Open
func newSwapTypePropertiesFromMap(m map[string]interface{}) *SwapTypeProperties {
s := &SwapTypeProperties{}
if val, ok := m["AmbientCapabilities"]; ok {
s.AmbientCapabilities = val.(uint64)
Function TestCheck
has 322 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestCheck(t *testing.T) {
t.Parallel()
t.Run("state=present", func(t *testing.T) {
g := group.NewGroup(new(group.System))
Function TestPreparerPrepare
has 306 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestPreparerPrepare(t *testing.T) {
defer logging.HideLogs(t)()
// newWithField is a little utility. We have this pattern over and over
// where we need to set a target field and then check that we render without
Function TestDiffAdd
has 302 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestDiffAdd(t *testing.T) {
t.Parallel()
zone := time.FixedZone(time.Now().In(time.Local).Zone())
expiryString := "1996-12-12"
File group_test.go
has 874 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 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) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
t.Run("Current", func(t *testing.T) {
t.Run("uid", func(t *testing.T) {
o := (&owner.OwnershipDiff{UIDs: &[2]int{1, 2}}).SetProxy(m)
assert.Equal(t, "user: user-2 (2)", o.Current())
})
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 560.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
t.Run("Original", func(t *testing.T) {
t.Run("uid", func(t *testing.T) {
o := (&owner.OwnershipDiff{UIDs: &[2]int{1, 2}}).SetProxy(m)
assert.Equal(t, "user: user-1 (1)", o.Original())
})
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 560.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76