pgoultiaev/aoc2017

View on GitHub

Showing 31 of 31 total issues

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

func partOne(a []int, ia []int, cp, ss int) (partOne []int, currPos, skipSize int) {
    //fmt.Printf("range: %+v, len %d\n", a, len(a))
    currPos = cp
    skipSize = ss
    for i, num := range ia {
Severity: Major
Found in 10/10.go and 1 other location - About 2 hrs to fix
14/10.go on lines 52..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 245.

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

func partOne(a []int, ia []int, cp, ss int) (partOne []int, currPos, skipSize int) {
    //fmt.Printf("range: %+v, len %d\n", a, len(a))
    currPos = cp
    skipSize = ss
    for i, num := range ia {
Severity: Major
Found in 14/10.go and 1 other location - About 2 hrs to fix
10/10.go on lines 68..99

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

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

func partTwo(a []int, ba []byte) (hash string) {
    suffix := []byte{17, 31, 73, 47, 23}
    ba = append(ba, suffix...)
    ia := util.ConvByteArrayToIntArray(ba)

Severity: Major
Found in 14/10.go and 1 other location - About 2 hrs to fix
10/10.go on lines 29..58

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

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

func partTwo(a []int, ba []byte) (hash string) {
    suffix := []byte{17, 31, 73, 47, 23}
    ba = append(ba, suffix...)
    ia := util.ConvByteArrayToIntArray(ba)

Severity: Major
Found in 10/10.go and 1 other location - About 2 hrs to fix
14/10.go on lines 13..42

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

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

func findUnbalancedNodes(n Node, diff int) {
    if len(n.children) > 2 {
        childWeights := make(map[int]int)

        for i := range n.children {
Severity: Minor
Found in 7/7.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

Function solve has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func solve(filename string, iterations int) (ones int) {
    grid := [][]int{
        []int{0, 1, 0},
        []int{0, 0, 1},
        []int{1, 1, 1},
Severity: Minor
Found in 21/21.go - About 55 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 evalRule has 7 return statements (exceeds 4 allowed).
Open

func evalRule(s []string) bool {
    regVal := register[s[0]]
    val, _ := strconv.Atoi(s[2])

    switch s[1] {
Severity: Major
Found in 8/8.go - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if reflect.DeepEqual(ruleToPattern(k), pattern) || reflect.DeepEqual(ruleToPattern(k), flip(pattern)) {
                                matchedRule = true
                                newGrid = append(newGrid, ruleToPattern(ruleSet[k]))
                                break
                            }
    Severity: Major
    Found in 21/21.go - About 45 mins to fix

      Function traverse has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func traverse(grid map[Point]string, p Point, dir string, t string, steps int) (string, int) {
      Severity: Minor
      Found in 19/19.go - About 35 mins to fix

        Function findSumGroups has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
        Open

        func findSumGroups(s string) (int, garbageCounter int) {
            st := make(stack, 0)
        
            sumGroups := 0
            garbage := false
        Severity: Minor
        Found in 9/9.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

        exported type Particle should have comment or be unexported
        Open

        type Particle struct {
        Severity: Minor
        Found in 20/20.go by golint

        exported type Direction should have comment or be unexported
        Open

        type Direction struct {
        Severity: Minor
        Found in 11/11.go by golint

        exported type Player should have comment or be unexported
        Open

        type Player struct {
        Severity: Minor
        Found in 3/3.go by golint

        exported type Pos should have comment or be unexported
        Open

        type Pos struct {
        Severity: Minor
        Found in 0.go by golint

        exported type Player should have comment or be unexported
        Open

        type Player struct {
        Severity: Minor
        Found in 11/11.go by golint

        exported function KnotHashDay10 should have comment or be unexported
        Open

        func KnotHashDay10(s string) string {
        Severity: Minor
        Found in 14/10.go by golint

        exported var Right should have comment or be unexported
        Open

            Right  = Direction{1, 0}
        Severity: Minor
        Found in 3/3.go by golint

        exported type Component should have comment or be unexported
        Open

        type Component struct {
        Severity: Minor
        Found in 24/24.go by golint

        exported var A should have comment or be unexported
        Open

            A = stateInstruction{1, 0, 1, -1, "B", "D"}
        Severity: Minor
        Found in 25/25.go by golint

        exported type Node should have comment or be unexported
        Open

        type Node struct {
        Severity: Minor
        Found in 7/7.go by golint
        Severity
        Category
        Status
        Source
        Language