Skip to content

Improve resistor-color-duo: detect string concat #55

@SleeplessByte

Description

@SleeplessByte

Describe the improvement:

When the following main method is provided, the analyzer bails early:

export const value = arr => {
  return +(COLORS.indexOf(arr[0]) + "" + COLORS.indexOf(arr[1]));
};

Instead, it should be caught by hasDigitsString, and produce the same comment.

Which exercise

resistor-color-duo

Additional context

The ResistorColorDuoSolution has a method that checks if an exercise has a constructed string. It currently only detects a string template literal that looks like ${a}${b}, but we want to also capture the following:

`${a}` + `${b}`
a + "" + b
a + '' + b
""  + a + b
''  + a + b
a.toString() + b
a.toString() + b.toString()
a.toString().concat(b)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions