ARM-software/golang-utils

View on GitHub

Showing 96 of 97 total issues

Method SharedMutableCacheRepository.Fetch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

func (s *SharedMutableCacheRepository) Fetch(ctx context.Context, key, dest string) (err error) {
    err = parallelisation.DetermineContextError(ctx)
    if err != nil {
        return
    }
Severity: Minor
Found in utils/sharedcache/sharedcache_mutable.go - About 35 mins to fix

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 processErrorStrLine has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

func processErrorStrLine(err string) (mErr *marshallingError) {
    err = strings.TrimSpace(err)
    if err == "" {
        return nil
    }
Severity: Minor
Found in utils/commonerrors/serialisation.go - About 35 mins to fix

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 flattenDefaultsMap has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

func flattenDefaultsMap(m map[string]interface{}) map[string]interface{} {
    output := make(map[string]interface{})
    for key, value := range m {
        switch child := value.(type) {
        case map[string]interface{}:
Severity: Minor
Found in utils/config/service_configuration.go - About 35 mins to fix

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func newAbstractStreamPaginator(ctx context.Context, runOutTimeOut, backoff time.Duration, fetchFirstPageFunc func(context.Context) (IStaticPage, error), fetchNextFunc func(context.Context, IStaticPage) (IStaticPage, error), fetchFutureFunc func(context.Context, IStaticPageStream) (IStaticPageStream, error)) (paginator *AbstractStreamPaginator, err error) {
Severity: Minor
Found in utils/collection/pagination/stream.go and 1 other location - About 30 mins to fix
utils/collection/pagination/stream.go on lines 190..190

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 100.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func NewStaticPageStreamPaginator(ctx context.Context, runOutTimeOut, backoff time.Duration, fetchFirstPageFunc func(context.Context) (IStaticPageStream, error), fetchNextPageFunc func(context.Context, IStaticPage) (IStaticPage, error), fetchFutureFunc func(context.Context, IStaticPageStream) (IStaticPageStream, error)) (paginator IStreamPaginatorAndPageFetcher, err error) {
Severity: Minor
Found in utils/collection/pagination/stream.go and 1 other location - About 30 mins to fix
utils/collection/pagination/stream.go on lines 103..103

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 100.

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

Further Reading

Method cmdWrapper.Stop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

func (c *cmdWrapper) Stop() error {
    c.mu.RLock()
    defer c.mu.RUnlock()
    if c.cmd == nil {
        return fmt.Errorf("%w:undefined command", commonerrors.ErrUndefined)
Severity: Minor
Found in utils/subprocess/command_wrapper.go - About 25 mins to fix

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 AbstractPaginator.HasNext has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

func (a *AbstractPaginator) HasNext() bool {
    if parallelisation.DetermineContextError(a.ctx) != nil {
        return false
    }
    currentIt, err := a.FetchCurrentPageIterator()
Severity: Minor
Found in utils/collection/pagination/pagination.go - About 25 mins to fix

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 GenericRemove has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

func GenericRemove(equal func(string, string) bool, slice []string, val ...string) []string {
    if len(val) == 0 {
        return slice
    }
    list := make([]string, 0, len(slice))
Severity: Minor
Found in utils/collection/modify.go - About 25 mins to fix

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 NewExclusionRegexList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

func NewExclusionRegexList(pathSeparator rune, exclusionPatterns ...string) ([]*regexp.Regexp, error) {
    var regexes []*regexp.Regexp
    var patternsExtendedList []string
    for i := range exclusionPatterns {
        pattern := exclusionPatterns[i]
Severity: Minor
Found in utils/filesystem/exclusion.go - About 25 mins to fix

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 LoadFromEnvironment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

func LoadFromEnvironment(viperSession *viper.Viper, envVarPrefix string, configurationToSet IServiceConfiguration, defaultConfiguration IServiceConfiguration, configFile string) (err error) {
    // Load Defaults
    var defaults map[string]interface{}
    err = mapstructure.Decode(defaultConfiguration, &defaults)
    if err != nil {
Severity: Minor
Found in utils/config/service_configuration.go - About 25 mins to fix

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 SharedMutableCacheRepository.Store has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

func (s *SharedMutableCacheRepository) Store(ctx context.Context, key, src string) (err error) {
    err = parallelisation.DetermineContextError(ctx)
    if err != nil {
        return
    }
Severity: Minor
Found in utils/sharedcache/sharedcache_mutable.go - About 25 mins to fix

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 RunActionWithTimeoutAndCancelStore has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

func RunActionWithTimeoutAndCancelStore(ctx context.Context, timeout time.Duration, store *CancelFunctionStore, blockingAction func(context.Context) error) error {
    err := DetermineContextError(ctx)
    if err != nil {
        return err
    }
Severity: Minor
Found in utils/parallelisation/parallelisation.go - About 25 mins to fix

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 VFS.WalkWithContextAndExclusionPatterns has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

func (fs *VFS) WalkWithContextAndExclusionPatterns(ctx context.Context, root string, fn filepath.WalkFunc, exclusionPatterns ...string) (err error) {
    err = fs.checkWhetherUnderlyingResourceIsClosed()
    if err != nil {
        return
    }
Severity: Minor
Found in utils/filesystem/files.go - About 25 mins to fix

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 VFS.RemoveWithPrivileges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

func (fs *VFS) RemoveWithPrivileges(ctx context.Context, dir string) (err error) {
    err = fs.RemoveWithContext(ctx, dir)
    if commonerrors.Any(err, nil, commonerrors.ErrTimeout, commonerrors.ErrCancelled) {
        return
    }
Severity: Minor
Found in utils/filesystem/files.go - About 25 mins to fix

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 parseListWithCleanup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

func parseListWithCleanup(input string, sep string, keepBlankLines bool) (newS []string) {
    if len(input) == 0 {
        newS = []string{} // initialisation of empty arrays in function returns []string(nil) instead of []string{}
        return
    }
Severity: Minor
Found in utils/collection/parseLists.go - About 25 mins to fix

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 VFS.isDirEmpty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

func (fs *VFS) isDirEmpty(name string) (empty bool, err error) {
    err = fs.checkWhetherUnderlyingResourceIsClosed()
    if err != nil {
        return
    }
Severity: Minor
Found in utils/filesystem/files.go - About 25 mins to fix

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

Severity
Category
Status
Source
Language