javascript-analyzer icon indicating copy to clipboard operation
javascript-analyzer copied to clipboard

Detect dead code from stub

Open SleeplessByte opened this issue 8 months ago • 8 comments

The following four placeholders are present in the stubs. They should be detected and a "must-fix" message should be added to remove the line which is now dead-code.

throw new Error('Please implement the (...) function')
throw new Error('Remove this line and implement the function')
throw new Error('Implement the (...) function')
throw new Error('Remove this statement and implement this function');

SleeplessByte avatar Jun 11 '25 00:06 SleeplessByte

Is this an opportunity to switch them all to one consistent message style?

IsaacG avatar Jun 24 '25 05:06 IsaacG

We would still need to support older versions, but yes, I have no issue with all of the messages being the same in the JS and TS track!

SleeplessByte avatar Jun 24 '25 17:06 SleeplessByte

I'll be happy to switch them all to one consistent message and raise a PR on both the JS and TS tracks for the same. Just let me know which message should be used consistently throughout the track!

jagdish-15 avatar Jun 25 '25 17:06 jagdish-15

@Cool-Katt what is your preferred stub message?

SleeplessByte avatar Jul 04 '25 02:07 SleeplessByte

I aways use

throw new Error('Remove this statement and implement this function');

But maybe this one can also work, in the light of being more direct

throw new Error('Remove this line and implement the function');

Cool-Katt avatar Jul 04 '25 05:07 Cool-Katt

Yah I like throw new Error('Remove this line and implement the function');, but technically it's the statement to remove not the line, but I think it's fine in this case.

Let's go with

throw new Error('Remove this line and implement the function');

SleeplessByte avatar Jul 04 '25 15:07 SleeplessByte

https://github.com/exercism/javascript/pull/2714 (JS Concept) https://github.com/exercism/javascript/pull/2715 (JS Practice) https://github.com/exercism/typescript/pull/1591 (TS Practice)

jagdish-15 avatar Jul 04 '25 20:07 jagdish-15

All concept exercises in the TS track (there was only one, apparently) already had the correct throw new line, so no changes were needed there!

jagdish-15 avatar Jul 05 '25 06:07 jagdish-15