openhue/openhue-cli

View on GitHub

Showing 12 of 12 total issues

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

func (groupedLight *GroupedLight) Set(o *SetLightOptions) {
    request := &gen.UpdateGroupedLightJSONRequestBody{}

    if o.Status != LightStatusUndefined {
        request.On = &gen.On{
Severity: Major
Found in openhue/home_model.go and 1 other location - About 4 hrs to fix
openhue/home_model.go on lines 125..157

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

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 (light *Light) Set(o *SetLightOptions) {
    request := &gen.UpdateLightJSONRequestBody{}

    if o.Status != LightStatusUndefined {
        request.On = &gen.On{
Severity: Major
Found in openhue/home_model.go and 1 other location - About 4 hrs to fix
openhue/home_model.go on lines 169..201

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

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

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

func fetchLights(api *gen.ClientWithResponses) (map[string]gen.LightGet, error) {
    log.Info("Fetching lights...")

    resp, err := api.GetLightsWithResponse(context.Background())
    if err != nil {
Severity: Major
Found in openhue/home_context.go and 4 other locations - About 1 hr to fix
openhue/home_context.go on lines 82..98
openhue/home_context.go on lines 100..116
openhue/home_context.go on lines 136..152
openhue/home_context.go on lines 154..170

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

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

func fetchScenes(api *gen.ClientWithResponses) (map[string]gen.SceneGet, error) {
    log.Info("Fetching scenes...")

    resp, err := api.GetScenesWithResponse(context.Background())
    if err != nil {
Severity: Major
Found in openhue/home_context.go and 4 other locations - About 1 hr to fix
openhue/home_context.go on lines 82..98
openhue/home_context.go on lines 100..116
openhue/home_context.go on lines 118..134
openhue/home_context.go on lines 136..152

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

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

func fetchRooms(api *gen.ClientWithResponses) (map[string]gen.RoomGet, error) {
    log.Info("Fetching rooms...")

    resp, err := api.GetRoomsWithResponse(context.Background())
    if err != nil {
Severity: Major
Found in openhue/home_context.go and 4 other locations - About 1 hr to fix
openhue/home_context.go on lines 82..98
openhue/home_context.go on lines 118..134
openhue/home_context.go on lines 136..152
openhue/home_context.go on lines 154..170

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

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

func fetchGroupedLights(api *gen.ClientWithResponses) (map[string]gen.GroupedLightGet, error) {
    log.Info("Fetching grouped lights...")

    resp, err := api.GetGroupedLightsWithResponse(context.Background())
    if err != nil {
Severity: Major
Found in openhue/home_context.go and 4 other locations - About 1 hr to fix
openhue/home_context.go on lines 82..98
openhue/home_context.go on lines 100..116
openhue/home_context.go on lines 118..134
openhue/home_context.go on lines 154..170

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

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

func fetchDevices(api *gen.ClientWithResponses) (map[string]gen.DeviceGet, error) {
    log.Info("Fetching devices...")

    resp, err := api.GetDevicesWithResponse(context.Background())
    if err != nil {
Severity: Major
Found in openhue/home_context.go and 4 other locations - About 1 hr to fix
openhue/home_context.go on lines 100..116
openhue/home_context.go on lines 118..134
openhue/home_context.go on lines 136..152
openhue/home_context.go on lines 154..170

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

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

      2: cannot find package "github.com/spf13/cobra" in any of:
      Open

          "github.com/spf13/cobra"
      Severity: Minor
      Found in cmd/get/get.go by govet
      Severity
      Category
      Status
      Source
      Language