-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect Analysis: JavaScript analyzer makes little sense when a object literal is used #127
Comments
I do think that: function colorValue(color) {
return resistorBands[color]
} is more idiomatic and readable than resistorBands[firstColor] ...but I do agree it's less problematic. |
But really that's a just naming concern, IMHO. (I personally think So I don't see a significant difference in expressiveness between: // object literal
COLOR_to_RESISTANCE[tensColor] * 10 + COLOR_to_RESISTANCE[onesColor]
// function dispatch
colorToResistance(tensColor) * 10 + colorToResistance(onesColor) Wrapping the object literal in a function dispatch just starts to feel like needless abstraction to me - and I've certainly steered students aways from such needless wrapping in other cases for sure. I don't feel the auto-intelligence should flag either of the above solutions. |
That's a good case. Ok. I agree with your assessment :) |
Hi there @SleeplessByte! I'm keen to make my first PR to Exercism and this seemed like a good option.
So, I propose that we not change the analysis itself, since it should still continue to catch case (1) above, but rather expand the message to explicitly include commentary on case (2). My working draft changes this:
to this:
Let me know if you think this would add value, or if we should opt for a different solution. |
I like it. |
Whilst the comment change is a good one @Steffe-Dev, we are no longer generating comments for mentors, and everything is done directly on solutions. So instead, detecting the code @joshgoebel opened the post with with a message that the |
I see. I can definitely try to implement that. Is there an existing template for the hoisting of variables, or would we have to add one? Otherwise, I'm still uncertain about what we want to do about the warning relating to the helper method. Because, even if you have the constant as a global, the analyzer would still suggest that you use a helper method instead of indexing the object directly (at least when I run it locally), which I think is what @joshgoebel really wanted to address with this issue. Do we want to keep that warning for now, or should I try to suppress it? |
It should be suppressed. So your options are:
I think there is already logic to see if we are in "array" or "object" mode, so the helper check probably just needs to be _moved. I think there is already a template to define a top-level constant. That's probably the term you want to look for. Please note that the template content inside this repo is purely for development. The real messages live in |
@Steffe-Dev if you need any more help or pointers, ping me here or on the Exercism Discord |
Great, thank you so much for all the patience in explaining everything! I will let you know if I need anything else. 👌 |
@SleeplessByte So, after hacking away at this for a while, I realised that we have two distinct problems to solve:
When you inspect the code inside My proposal is that we start by solving (1) in its own PR, which is a self-contained check that can be inserted into the various optimal check methods, which does an early return before the helper method checks, and would thus address @joshgoebel specific request (with the source file at the top of this issue) that the error message be replaced by something more useful (the Then we can re-evaluate the path forward of this issue. Let me know what you think, if there is a better option then I am open. 😄 |
Yah sounds fine with me! You could also check if the TS analyzer has a better base here with less intertwining |
@SleeplessByte Unfortunately the TS analyzer only has Two Fer at the moment 😅 I created a PR for what I described above, but the bot automatically closed it. I'm still learning your processes, so I don't know how to avoid that, and I would appreciate help with getting it open again. Once open, there is also a pending commit that will come through that removes an unused variable that I initially forgot about. Thanks in advance 😄 |
All good. We manually reopen it if there's merit. Which there is!!! |
Describe the incorrectness
I don't think the analyzers advice makes any sense here:
The advice assumes a student is using an array - in which case there is complexity to hide and I agree a function as a named abstraction is useful, but in this case a well-named lookup table is serving the same purpose as a function, so the advice makes little sense.
Which exercise
Resistor Duo
Source file(s)
Expected analysis
None. (well at least not on this point)
Additional context
None.
The text was updated successfully, but these errors were encountered: