CC0013 CC0014 ternary operator - not always desired
See original GitHub issueIn some cases, switching to a ternary operator is not a good suggestion. Say, I have this code:
If String.IsNullOrWhiteSpace(path) Or Not File.Exists(path) Then
skinStream = Application.GetResourceStream(New Uri(DefaultSkinUri)).Stream
Else
skinStream = File.OpenRead(path)
End If
Changing it to an If()
function would yield an immense statement, which is hard to read and to debug.
Maybe, Code Cracker should check for the resulting line length or some other parameter to avoid suggesting things that complicate the code.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Ternary operator is always false
What I am trying to do is if reportParameterArray[P_TARGET] doesn't equal to \0 then it should output the actual value otherwise it prints...
Read more >ultraThinMaterial doesn't work in ternary operator
I'm trying to make the background of a view use the .ultraThinMaterial property with the following code: .background(!isPlayerOpen ?
Read more >JavaScript Ternary Operator – Syntax and Example Use ...
The ternary operator is a conditional operator which evaluates either of two expressions – a true expression and a false expression – based...
Read more >Conditional (ternary) operator - JavaScript - MDN Web Docs
The conditional (ternary) operator is the only JavaScript operator that takes three operands: a condition followed by a question mark (?)
Read more >What is a ternary operator in programming?
No, the ternary operator only evaluates a single condition. If multiple conditions need to be checked, logical operators (e.g., && and ||) or ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mc0re Ternary operation is not trivial for many developers, but I don’t believe that is complex to understand 😃
I run into this issue all the time and I think line length is a reasonable solution. If there is no way to set options I would be happy if it new lime was limited to 80 characters or don’t offer refactoring on lines over 30 characters. If someone doesn’t like it they can make the change manually.