question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CC0014 should place the three elements of the ternary on separate lines if the total length would exceed 72 characters.

See original GitHub issue
         if veryLongCondition(withALongArgumentList) Then
             aVariable = aLongfunctionName(withAnotherLongArgList)
         else
             aVariable = anEvenLongerfunctionName(withYetAnotherLongArgList)
         end if

Current output after fix applied:

    aVariable = if(veryLongCondition(withALongArgumentList), aLongfunctionName(withAnotherLongArgList), anEvenLongerfunctionName(withYetAnotherLongArgList))

Expected output after fix applied:

    aVariable = if(veryLongCondition(withALongArgumentList),
                          aLongfunctionName(withAnotherLongArgList), 
                          anEvenLongerfunctionName(withYetAnotherLongArgList))

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jwooleycommented, Mar 28, 2016

I wonder if a better option for the long line issue would be having a refactoring which takes a method with multiple parameters on a single line and breaks them up on multiple lines adding named parameters. It wouldn’t necessarily help the case of ternary operators, but might be useful as a separate tool.

0reactions
kwhitefootcommented, Mar 29, 2016

@giggio I too have quite a lot screen area (two side by side 60cm/24" monitors) but long lines are still a pain to read.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple Statements in the Ternary Operator - java
If you absolutely must do it with one ternary operator that's how it can be done : flag = str.length() == 1 ?...
Read more >
Can ternary operators contain multiple actions? - JavaScript
Yes, we can, but with one proviso… There is no block demarcation so that action should be simple, else it would be better...
Read more >
Ternary Operator in C Explained
Programmers use the ternary operator for decision making in place of longer if and else conditional statements. The ternary operator take three ......
Read more >
Multiple lines in a ternary operator's clauses? - JavaScript
Basically if you want a nest a ternary operator in an existing ternary operator you need to put parentheses around the whole thing...
Read more >
Ternary operators are the worst..unless you indent them right!
There is no reason that an if expression can't be multiple lines long. If you need a condition with three or more branches,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found