Suboptimal recommendation to use elvis operator
stevenh opened this issue · 3 comments
The follow code triggers a warning for the use of an elvis operator to assign a default value:
if (!platforms[platform]) {
platforms[platform] = new Platform(name: platform, id: platformID, subSystems: [])
}
Code could use elvis operator: platforms[platform] = platforms[platform] ?: new Platform([name:platform, id:platformID, subSystems:[]]) CouldBeElvis
This would introduce an unnecessary assign to the map value, so it doesn't seem like the best advise.
Should the warning trigger in this case?
Now I know more of how this is put together I'm guessing this is a CodeNarc issue?
@stevenh if this is a groovy error, it is raised by CodeNarc yes :)
And the CodeNarc used within npm-groovy-lint is not up to date :(
This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.
If you think this issue should stay open, please remove the O: stale 🤖
label or comment on the issue.