rrd108 / vue-mess-detector

A static code analysis tool for detecting code smells and best practice violations in Vue.js and Nuxt.js projects
MIT License
216 stars 9 forks source link

False positive for nested ternary #298

Closed crystalfp closed 1 month ago

crystalfp commented 1 month ago

Describe the bug If the statement contains multiple question marks, that is, for "?." and ternary, it is marked as nested ternary (see example below).

To Reproduce Steps to reproduce the behavior:

  1. What is the exact code you are analyzing (this is line 55)?
    const countDatasets = this.structure?.volume ? this.structure.volume.length : 0;
  2. What is the output you are getting?
    -  rrd ~ nested Ternary
    src\electron\nodes\DrawOrthoslice.ts
    👉 Break the nested ternary into standalone ternaries, if statements, && operators, or a dedicated function. See: https://vue-mess-detector.webmania.cc/rules/rrd/nested-ternary.html
    line #55 has nested ternary 🚨

Expected behavior Ignore "?." constructs.

Screenshots If applicable, add screenshots to help explain your problem.

Used version number of vue-mess-detector: 0.6.0

Used version number of node & yarn: v22.5.1 and npm, not yarn 10.8.3

Additional context Add any other context about the problem here.

David-Pena commented 1 month ago

Thanks for using our tool 🙏🏻

This will probably get fixed by rrd when is on again, if not, tomorrow morning I can check it out 🙌🏻

rrd108 commented 1 month ago

@crystalfp do you want to send a PR for this?

Thanks for reporting 🌟

David-Pena commented 1 month ago

I think I solved this

David-Pena commented 1 month ago

Its fixed in latest commit https://github.com/rrd108/vue-mess-detector/commit/1e8133bed69eb543e31b6723ea794ba7b26511a4

You can try it out thanks to pkg.pr.new before its released npm i https://pkg.pr.new/rrd108/vue-mess-detector@1e8133b @crystalfp

For more context, key changes made:

David-Pena commented 1 month ago

@rrd108 I wonder if the issue should be closed after its released or when the fix is done?

rrd108 commented 1 month ago

I close them when the fix is commited. And I add a new comment when the fix is released - if I do not forget it

rrd108 commented 1 month ago

implemented in 0.54.0