openhue/openhue-cli

View on GitHub

Showing 4 of 12 total issues

Function SearchLights has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
Open

func SearchLights(home *Home, roomNameOrId string, nameOrIds []string) []Light {
    var lights []Light

    for _, room := range home.Rooms {
        if room.matchesNameOrId(roomNameOrId) {
Severity: Minor
Found in openhue/home_service.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 SearchScenes has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func SearchScenes(home *Home, roomNameOrId string, nameOrIds []string) []Scene {
    var scenes []Scene

    for _, room := range home.Rooms {
        if len(roomNameOrId) == 0 || (len(roomNameOrId) > 0 && room.matchesNameOrId(roomNameOrId)) {
Severity: Minor
Found in openhue/home_service.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 loadHueHomeCtx has 7 return statements (exceeds 4 allowed).
Open

func loadHueHomeCtx(api *gen.ClientWithResponses) (*hueHomeCtx, error) {

    hueHome, err := fetchBridgeHome(api)
    if err != nil {
        return nil, err
Severity: Major
Found in openhue/home_context.go - About 45 mins to fix

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

    func assertRGBFromHexString(t *testing.T, hexStr string, r int, g int, b int) {
    Severity: Minor
    Found in util/color/conversion_test.go - About 35 mins to fix
      Severity
      Category
      Status
      Source
      Language