JeffDeCola/control-fpga-via-raspi-and-webserver

View on GitHub
section-3-backend-server/main.go

Summary

Maintainability
F
3 days
Test Coverage

Function main has 184 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func main() {

    fmt.Println("Working on browser")

    // INIT HOST MACHINE (i.e. Raspberry Pi)
Severity: Major
Found in section-3-backend-server/main.go - About 6 hrs to fix

    Method data_pins.write_data_in has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
    Open

    func (d data_pins) write_data_in(d7 int, d6 int, d5 int, d4 int, d3 int, d2 int, d1 int, d0 int) {
    
        if d7 == 1 {
            err := d.data_7.Out(gpio.High)
            if err != nil {
    Severity: Minor
    Found in section-3-backend-server/main.go - About 4 hrs 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 main has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
    Open

    func main() {
    
        fmt.Println("Working on browser")
    
        // INIT HOST MACHINE (i.e. Raspberry Pi)
    Severity: Minor
    Found in section-3-backend-server/main.go - About 3 hrs 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

    File main.go has 525 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    // my-go-examples toggle-led-with-button-raspberry-pi-gpio-periph
    
    package main
    
    import (
    Severity: Minor
    Found in section-3-backend-server/main.go - About 2 hrs to fix

      Method data_pins.write_data_in has 88 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (d data_pins) write_data_in(d7 int, d6 int, d5 int, d4 int, d3 int, d2 int, d1 int, d0 int) {
      
          if d7 == 1 {
              err := d.data_7.Out(gpio.High)
              if err != nil {
      Severity: Major
      Found in section-3-backend-server/main.go - About 2 hrs to fix

        Method data_a_pins.write_data_in_a has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
        Open

        func (d data_a_pins) write_data_in_a(d7 int, d3 int, d2 int, d1 int, d0 int) {
        
            if d7 == 1 {
                err := d.data_7.Out(gpio.High)
                if err != nil {
        Severity: Minor
        Found in section-3-backend-server/main.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 data_a_pins.write_data_in_a has 55 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (d data_a_pins) write_data_in_a(d7 int, d3 int, d2 int, d1 int, d0 int) {
        
            if d7 == 1 {
                err := d.data_7.Out(gpio.High)
                if err != nil {
        Severity: Minor
        Found in section-3-backend-server/main.go - About 1 hr to fix

          Method data_pins.write_data_in has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func (d data_pins) write_data_in(d7 int, d6 int, d5 int, d4 int, d3 int, d2 int, d1 int, d0 int) {
          Severity: Major
          Found in section-3-backend-server/main.go - About 1 hr to fix

            Method opcode_pins.write_opcode has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
            Open

            func (o opcode_pins) write_opcode(o3 int, o2 int, o1 int, o0 int) {
            
                if o3 == 1 {
                    err := o.opcode_3.Out(gpio.High)
                    if err != nil {
            Severity: Minor
            Found in section-3-backend-server/main.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 UserControl has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func UserControl(opcode opcode_pins, data_in_a data_a_pins, data_in_b data_pins, GO_BAR_PIN gpio.PinIO, RESET_PIN gpio.PinIO, JAM_PIN gpio.PinIO, data_out data_pins) {
            Severity: Major
            Found in section-3-backend-server/main.go - About 50 mins to fix

              Method data_a_pins.write_data_in_a has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func (d data_a_pins) write_data_in_a(d7 int, d3 int, d2 int, d1 int, d0 int) {
              Severity: Minor
              Found in section-3-backend-server/main.go - About 35 mins to fix

                2: cannot find package "periph.io/x/conn/v3/gpio" in any of:
                Open

                    "periph.io/x/conn/v3/gpio"
                Severity: Minor
                Found in section-3-backend-server/main.go by govet

                don't use underscores in Go names; struct field data_3 should be data3
                Open

                    data_3 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field data_7 should be data7
                Open

                    data_7 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field data_1 should be data1
                Open

                    data_1 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; type data_a_pins should be dataAPins
                Open

                type data_a_pins struct {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field data_2 should be data2
                Open

                    data_2 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; type data_pins should be dataPins
                Open

                type data_pins struct {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field data_1 should be data1
                Open

                    data_1 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                exported function UserControl should have comment or be unexported
                Open

                func UserControl(opcode opcode_pins, data_in_a data_a_pins, data_in_b data_pins, GO_BAR_PIN gpio.PinIO, RESET_PIN gpio.PinIO, JAM_PIN gpio.PinIO, data_out data_pins) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; method write_data_in_a should be writeDataInA
                Open

                func (d data_a_pins) write_data_in_a(d7 int, d3 int, d2 int, d1 int, d0 int) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_OUT_4_PIN := gpioreg.ByName("11")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field data_3 should be data3
                Open

                    data_3 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field data_6 should be data6
                Open

                    data_6 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field data_2 should be data2
                Open

                    data_2 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; var DATA_OUT_4_PIN_Level should be DATAOUT4PINLevel
                Open

                    DATA_OUT_4_PIN_Level := d.data_4.Read()
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_A1_PIN := gpioreg.ByName("15")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_B5_PIN := gpioreg.ByName("20")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_A2_PIN := gpioreg.ByName("18")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_B0_PIN := gpioreg.ByName("25")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    GO_BAR_PIN := gpioreg.ByName("27")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; method read_data_out should be readDataOut
                Open

                func (d data_pins) read_data_out() {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_B7_PIN := gpioreg.ByName("26")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_B6_PIN := gpioreg.ByName("21")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; var DATA_OUT_1_PIN_Level should be DATAOUT1PINLevel
                Open

                    DATA_OUT_1_PIN_Level := d.data_1.Read()
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_OUT_1_PIN := gpioreg.ByName("13")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_OUT_5_PIN := gpioreg.ByName("9")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; var data_out should be dataOut
                Open

                    data_out := data_pins{DATA_OUT_7_PIN, DATA_OUT_6_PIN, DATA_OUT_5_PIN, DATA_OUT_4_PIN, DATA_OUT_3_PIN, DATA_OUT_2_PIN, DATA_OUT_1_PIN, DATA_OUT_0_PIN}
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    OPCODE_1_PIN := gpioreg.ByName("4")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    RESET_PIN := gpioreg.ByName("0")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field opcode_2 should be opcode2
                Open

                    opcode_2 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                func UserControl(opcode opcode_pins, data_in_a data_a_pins, data_in_b data_pins, GO_BAR_PIN gpio.PinIO, RESET_PIN gpio.PinIO, JAM_PIN gpio.PinIO, data_out data_pins) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; func parameter go_bar_pin should be goBarPin
                Open

                func execute_opcode(go_bar_pin gpio.PinIO, data_out data_pins) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field data_0 should be data0
                Open

                    data_0 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field data_0 should be data0
                Open

                    data_0 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field opcode_1 should be opcode1
                Open

                    opcode_1 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                func UserControl(opcode opcode_pins, data_in_a data_a_pins, data_in_b data_pins, GO_BAR_PIN gpio.PinIO, RESET_PIN gpio.PinIO, JAM_PIN gpio.PinIO, data_out data_pins) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; var DATA_OUT_3_PIN_Level should be DATAOUT3PINLevel
                Open

                    DATA_OUT_3_PIN_Level := d.data_3.Read()
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; var DATA_OUT_0_PIN_Level should be DATAOUT0PINLevel
                Open

                    DATA_OUT_0_PIN_Level := d.data_0.Read()
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field opcode_0 should be opcode0
                Open

                    opcode_0 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; func parameter data_out should be dataOut
                Open

                func UserControl(opcode opcode_pins, data_in_a data_a_pins, data_in_b data_pins, GO_BAR_PIN gpio.PinIO, RESET_PIN gpio.PinIO, JAM_PIN gpio.PinIO, data_out data_pins) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; var DATA_OUT_6_PIN_Level should be DATAOUT6PINLevel
                Open

                    DATA_OUT_6_PIN_Level := d.data_6.Read()
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_B3_PIN := gpioreg.ByName("12")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; func execute_opcode should be executeOpcode
                Open

                func execute_opcode(go_bar_pin gpio.PinIO, data_out data_pins) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; var data_in_a should be dataInA
                Open

                    data_in_a := data_a_pins{DATA_IN_A7_PIN, DATA_IN_A3_PIN, DATA_IN_A2_PIN, DATA_IN_A1_PIN, DATA_IN_A0_PIN}
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; var data_in_b should be dataInB
                Open

                    data_in_b := data_pins{DATA_IN_B7_PIN, DATA_IN_B6_PIN, DATA_IN_B5_PIN, DATA_IN_B4_PIN, DATA_IN_B3_PIN, DATA_IN_B2_PIN, DATA_IN_B1_PIN, DATA_IN_B0_PIN}
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_OUT_2_PIN := gpioreg.ByName("6")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    JAM_PIN := gpioreg.ByName("1")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_OUT_3_PIN := gpioreg.ByName("5")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    OPCODE_2_PIN := gpioreg.ByName("3")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    OPCODE_0_PIN := gpioreg.ByName("17")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field data_7 should be data7
                Open

                    data_7 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; var DATA_OUT_5_PIN_Level should be DATAOUT5PINLevel
                Open

                    DATA_OUT_5_PIN_Level := d.data_5.Read()
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_OUT_7_PIN := gpioreg.ByName("22")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field data_4 should be data4
                Open

                    data_4 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; method write_opcode should be writeOpcode
                Open

                func (o opcode_pins) write_opcode(o3 int, o2 int, o1 int, o0 int) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; func parameter data_in_a should be dataInA
                Open

                func UserControl(opcode opcode_pins, data_in_a data_a_pins, data_in_b data_pins, GO_BAR_PIN gpio.PinIO, RESET_PIN gpio.PinIO, JAM_PIN gpio.PinIO, data_out data_pins) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                func UserControl(opcode opcode_pins, data_in_a data_a_pins, data_in_b data_pins, GO_BAR_PIN gpio.PinIO, RESET_PIN gpio.PinIO, JAM_PIN gpio.PinIO, data_out data_pins) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; func parameter data_in_b should be dataInB
                Open

                func UserControl(opcode opcode_pins, data_in_a data_a_pins, data_in_b data_pins, GO_BAR_PIN gpio.PinIO, RESET_PIN gpio.PinIO, JAM_PIN gpio.PinIO, data_out data_pins) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; var DATA_OUT_2_PIN_Level should be DATAOUT2PINLevel
                Open

                    DATA_OUT_2_PIN_Level := d.data_2.Read()
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_A7_PIN := gpioreg.ByName("24")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_B4_PIN := gpioreg.ByName("16")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_OUT_6_PIN := gpioreg.ByName("10")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_A0_PIN := gpioreg.ByName("14")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_B2_PIN := gpioreg.ByName("7")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    OPCODE_3_PIN := gpioreg.ByName("2")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_OUT_0_PIN := gpioreg.ByName("19")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_B1_PIN := gpioreg.ByName("8")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; type opcode_pins should be opcodePins
                Open

                type opcode_pins struct {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field opcode_3 should be opcode3
                Open

                    opcode_3 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; func parameter data_out should be dataOut
                Open

                func execute_opcode(go_bar_pin gpio.PinIO, data_out data_pins) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use ALL_CAPS in Go names; use CamelCase
                Open

                    DATA_IN_A3_PIN := gpioreg.ByName("23")
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; struct field data_5 should be data5
                Open

                    data_5 gpio.PinIO
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; method write_data_in should be writeDataIn
                Open

                func (d data_pins) write_data_in(d7 int, d6 int, d5 int, d4 int, d3 int, d2 int, d1 int, d0 int) {
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                don't use underscores in Go names; var DATA_OUT_7_PIN_Level should be DATAOUT7PINLevel
                Open

                    DATA_OUT_7_PIN_Level := d.data_7.Read()
                Severity: Minor
                Found in section-3-backend-server/main.go by golint

                There are no issues that match your filters.

                Category
                Status