Rubberduck: Inspection for redundant leading, inline and trailing line continuations (also Indenter setting)

Created on 25 Jul 2018  路  3Comments  路  Source: rubberduck-vba/Rubberduck

For those digging for the continuator badge, line continuations are a secret weapon, but a line that contains nothing other than a line continuation is redundant, and should be removed to improve readability.

 _
 _
Option _
_
Explicit _
 _
 _

' ^ End of Option Explicit Statement

Note that the trailing line continuation, by definition, includes the blank line after the last line continuator.

Could, at a minimum, be rewritten as:

 Option _
Explicit
' ^ End of Option Explicit Statement

This could be an inspection, but also be an indenter setting, so that it's taken care of on indent.

edge-case enhancement feature-inspections feature-smart-indenter

Most helpful comment

Did we ever discuss an indenter option to reformat line continuations? It seems like in the case of the indenter, a more general approach might be of more use.

I was thinking of something more along the lines of a "target" or "preferred" column width. For example, if your target column width was a GitHub friendly 95 then this...

Sub Foo()
    Dim example As String
    example = "This line has " & _
        "a bunch of " & _
        "short continuations."
End Sub

...would recombine in the indenter to:

Sub Foo()
    Dim example As String
    example = "This line has a bunch of short continuations."                                                          
End Sub

Similarly, this...

Sub Bar()
    Dim example As String
    example = "This line is likely much to long to be on one line without line continuations. Really, do you want to have to side scroll to see the end of it?"
End Sub

...would "auto-wrap" to the more readable...

Sub Bar()
    Dim example As String
    example = "This line is likely much to long to be on one line without line continuations. " & _
        "Really, do you want to have to side scroll to see the end of it?"
End Sub

The same code would re-write your example as Option Explicit.

All 3 comments

Is there a badge for breaking syntax highlighting on GitHub? :imp:

Did we ever discuss an indenter option to reformat line continuations? It seems like in the case of the indenter, a more general approach might be of more use.

I was thinking of something more along the lines of a "target" or "preferred" column width. For example, if your target column width was a GitHub friendly 95 then this...

Sub Foo()
    Dim example As String
    example = "This line has " & _
        "a bunch of " & _
        "short continuations."
End Sub

...would recombine in the indenter to:

Sub Foo()
    Dim example As String
    example = "This line has a bunch of short continuations."                                                          
End Sub

Similarly, this...

Sub Bar()
    Dim example As String
    example = "This line is likely much to long to be on one line without line continuations. Really, do you want to have to side scroll to see the end of it?"
End Sub

...would "auto-wrap" to the more readable...

Sub Bar()
    Dim example As String
    example = "This line is likely much to long to be on one line without line continuations. " & _
        "Really, do you want to have to side scroll to see the end of it?"
End Sub

The same code would re-write your example as Option Explicit.

Ref #2406

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bclothier picture bclothier  路  3Comments

MDoerner picture MDoerner  路  4Comments

eteichm picture eteichm  路  4Comments

philippetev picture philippetev  路  3Comments

Gener4tor picture Gener4tor  路  3Comments