pgoultiaev/aoc2017

View on GitHub

Showing 6 of 31 total issues

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

        Severity
        Category
        Status
        Source
        Language