pennz/DataViz

View on GitHub

Showing 227 of 227 total issues

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

// Copyright (c) 2015, Emir Pasic. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main
Severity: Major
Found in examples/linkedliststack/linkedliststack.go and 1 other location - About 1 hr to fix
examples/arraystack/arraystack.go on lines 1..23

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

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 Iterator.Prev has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
Open

func (iterator *Iterator) Prev() bool {
    // If already at beginning, go to begin
    if iterator.position == begin {
        goto begin
    }
Severity: Minor
Found in trees/btree/iterator.go - About 1 hr 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 Iterator.Next has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
Open

func (iterator *Iterator) Next() bool {
    // If already at end, go to end
    if iterator.position == end {
        goto end
    }
Severity: Minor
Found in trees/btree/iterator.go - About 1 hr 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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

func (m *Map) Find(f func(key interface{}, value interface{}) bool) (interface{}, interface{}) {
    iterator := m.Iterator()
    for iterator.Next() {
        if f(iterator.Key(), iterator.Value()) {
            return iterator.Key(), iterator.Value()
Severity: Major
Found in maps/linkedhashmap/enumerable.go and 2 other locations - About 1 hr to fix
maps/treebidimap/enumerable.go on lines 72..80
maps/treemap/enumerable.go on lines 75..83

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

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

func (m *Map) Find(f func(key interface{}, value interface{}) bool) (interface{}, interface{}) {
    iterator := m.Iterator()
    for iterator.Next() {
        if f(iterator.Key(), iterator.Value()) {
            return iterator.Key(), iterator.Value()
Severity: Major
Found in maps/treebidimap/enumerable.go and 2 other locations - About 1 hr to fix
maps/linkedhashmap/enumerable.go on lines 72..80
maps/treemap/enumerable.go on lines 75..83

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

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

func (m *Map) Find(f func(key interface{}, value interface{}) bool) (interface{}, interface{}) {
    iterator := m.Iterator()
    for iterator.Next() {
        if f(iterator.Key(), iterator.Value()) {
            return iterator.Key(), iterator.Value()
Severity: Major
Found in maps/treemap/enumerable.go and 2 other locations - About 1 hr to fix
maps/linkedhashmap/enumerable.go on lines 72..80
maps/treebidimap/enumerable.go on lines 72..80

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

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 Tree.rebalance has 51 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (tree *Tree) rebalance(node *Node, deletedKey interface{}) {
    // check if rebalancing is needed
    if node == nil || len(node.Entries) >= tree.minEntries() {
        return
    }
Severity: Minor
Found in trees/btree/btree.go - About 1 hr to fix

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

func (set *Set) Find(f func(index int, value interface{}) bool) (int, interface{}) {
    iterator := set.Iterator()
    for iterator.Next() {
        if f(iterator.Index(), iterator.Value()) {
            return iterator.Index(), iterator.Value()
Severity: Major
Found in sets/linkedhashset/enumerable.go and 2 other locations - About 1 hr to fix
lists/arraylist/enumerable.go on lines 71..79
sets/treeset/enumerable.go on lines 74..82

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

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 3 locations. Consider refactoring.
Open

func (set *Set) Find(f func(index int, value interface{}) bool) (int, interface{}) {
    iterator := set.Iterator()
    for iterator.Next() {
        if f(iterator.Index(), iterator.Value()) {
            return iterator.Index(), iterator.Value()
Severity: Major
Found in sets/treeset/enumerable.go and 2 other locations - About 1 hr to fix
lists/arraylist/enumerable.go on lines 71..79
sets/linkedhashset/enumerable.go on lines 71..79

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

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 3 locations. Consider refactoring.
Open

func (list *List) Find(f func(index int, value interface{}) bool) (int, interface{}) {
    iterator := list.Iterator()
    for iterator.Next() {
        if f(iterator.Index(), iterator.Value()) {
            return iterator.Index(), iterator.Value()
Severity: Major
Found in lists/arraylist/enumerable.go and 2 other locations - About 1 hr to fix
sets/linkedhashset/enumerable.go on lines 71..79
sets/treeset/enumerable.go on lines 74..82

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

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 (iterator *Iterator) Prev() bool {
    switch iterator.position {
    case end:
        iterator.position = between
        iterator.node = iterator.tree.Right()
Severity: Minor
Found in trees/avltree/iterator.go and 1 other location - About 55 mins to fix
trees/avltree/iterator.go on lines 35..49

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

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 (iterator *Iterator) Next() bool {
    switch iterator.position {
    case begin:
        iterator.position = between
        iterator.node = iterator.tree.Left()
Severity: Minor
Found in trees/avltree/iterator.go and 1 other location - About 55 mins to fix
trees/avltree/iterator.go on lines 55..69

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

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

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

        for i, value := range avw.d.(*arraylist.List).Values() {
            switch i {
            case swapIdA:
                values = append(values, fmt.Sprintf("%v %s", value, nodeProp))
            case swapIdB:
Severity: Minor
Found in viz/wrapper.go and 1 other location - About 55 mins to fix
viz/wrapper.go on lines 447..457

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

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

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

        for i, value := range avw.d.(*arraylist.List).Values() {
            switch i {
            case swapIdA:
                values = append(values, fmt.Sprintf("%v %s", value, nodeProp))
            case swapIdB:
Severity: Minor
Found in viz/wrapper.go and 1 other location - About 55 mins to fix
viz/wrapper.go on lines 390..400

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

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

        if it.node.Right != nil { // Right Child
            dotString += (strconv.Itoa(it.node.nodeIndex) + " -> " + strconv.Itoa(it.node.Right.nodeIndex) + ";")
        } else {
            dotString += (strconv.Itoa(it.node.nodeIndex) + " -> " + strconv.Itoa(NilNodes) + ";")
            NilNodes++
Severity: Minor
Found in trees/redblacktree/redblacktree.go and 1 other location - About 50 mins to fix
trees/redblacktree/redblacktree.go on lines 324..329

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

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

        if it.node.Left != nil { // Left Child
            dotString += (strconv.Itoa(it.node.nodeIndex) + " -> " + strconv.Itoa(it.node.Left.nodeIndex) + ";")
        } else {
            dotString += (strconv.Itoa(it.node.nodeIndex) + " -> " + strconv.Itoa(NilNodes) + ";")
            NilNodes++
Severity: Minor
Found in trees/redblacktree/redblacktree.go and 1 other location - About 50 mins to fix
trees/redblacktree/redblacktree.go on lines 330..335

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

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

        if err == nil {
            astFileExtra, err := dot.ParseString(visualizeList(v.m.(*arraylist.List)))
            if err == nil {

                g := astFile.Graphs[0]
Severity: Minor
Found in viz/wrapper.go and 1 other location - About 50 mins to fix
viz/wrapper.go on lines 410..422

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

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

        if err == nil {
            astFileExtra, err := dot.ParseString(visualizeList(avw.m.(*arraylist.List)))
            if err == nil {

                g := astFile.Graphs[0]
Severity: Minor
Found in viz/wrapper.go and 1 other location - About 50 mins to fix
viz/wrapper.go on lines 323..335

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

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

Function main has 7 return statements (exceeds 4 allowed).
Open

func main() {
    m := treemap.NewWithStringComparator()
    m.Put("g", 7)
    m.Put("f", 6)
    m.Put("e", 5)
Severity: Major
Found in examples/enumerablewithkey/enumerablewithkey.go - About 45 mins to fix

Function main has 7 return statements (exceeds 4 allowed).
Open

func main() {
    set := treeset.NewWithIntComparator()
    set.Add(2, 3, 4, 2, 5, 6, 7, 8)
    printSet("Initial", set) // [ 2 3 4 5 6 7 8 ]

Severity: Major
Found in examples/enumerablewithindex/enumerablewithindex.go - About 45 mins to fix
Severity
Category
Status
Source
Language