jcberquist / commandbox-cfformat

A CommandBox module for formatting CFML component files.
MIT License
21 stars 10 forks source link

Question on why it doesn't respect tabs #84

Closed lmajano closed 4 years ago

lmajano commented 4 years ago

I have a section of code like this:

prepareMock( getController().getRoutingService() )
    .$( "getCGIElement" )
        .$args( "path_info", requestContext )
        .$results( arguments.route )
    .$( "getCGIElement" )
        .$args( "script_name", requestContext )
        .$results( "" )
    .$( "getCGIElement" )
        .$args( "domain", requestContext )
            .$results( CGI.SERVER_NAME );

As you can see it has semantic tabbing to delineate the mocking constructs. However, with my current rules it reformats it to this:

prepareMock( getController().getRoutingService() )
    .$( "getCGIElement" )
    .$args( "path_info", requestContext )
    .$results( arguments.route )
    .$( "getCGIElement" )
    .$args( "script_name", requestContext )
    .$results( "" )
    .$( "getCGIElement" )
    .$args( "domain", requestContext )
    .$results( CGI.SERVER_NAME );

Here are my rules. I am at a loss of which rule is causing this.

{
    "array.empty_padding": false,
    "array.padding": true,
    "array.multiline.min_length": 50,
    "array.multiline.element_count": 2,
    "array.multiline.leading_comma.padding": true,
    "array.multiline.leading_comma": false,
    "alignment.consecutive.assignments": true,
    "alignment.consecutive.properties": true,
    "alignment.consecutive.params": true,
    "brackets.padding": true,
    "comment.asterisks": "align",
    "binary_operators.padding": true,
    "for_loop_semicolons.padding": true,
    "function_call.empty_padding": false,
    "function_call.padding": true,
    "function_call.multiline.leading_comma.padding": true,
    "function_call.casing.builtin": "cfdocs",
    "function_call.casing.userdefined": "camel",
    "function_call.multiline.element_count": 3,
    "function_call.multiline.leading_comma": false,
    "function_call.multiline.min_length": 50,
    "function_declaration.padding": true,
    "function_declaration.empty_padding": false,
    "function_declaration.multiline.leading_comma": false,
    "function_declaration.multiline.leading_comma.padding": true,
    "function_declaration.multiline.element_count": 3,
    "function_declaration.multiline.min_length": 50,
    "function_declaration.group_to_block_spacing": "compact",
    "function_anonymous.empty_padding": false,
    "function_anonymous.group_to_block_spacing": "compact",
    "function_anonymous.multiline.element_count": 3,
    "function_anonymous.multiline.leading_comma": false,
    "function_anonymous.multiline.leading_comma.padding": true,
    "function_anonymous.multiline.min_length": 50,
    "function_anonymous.padding": true,
    "indent_size": 4,
    "keywords.block_to_keyword_spacing": "spaced",
    "keywords.group_to_block_spacing": "spaced",
    "keywords.padding_inside_group": true,
    "keywords.spacing_to_block": "spaced",
    "keywords.spacing_to_group": true,
    "keywords.empty_group_spacing": false,
    "max_columns": 100,
    "metadata.multiline.element_count": 3,
    "metadata.multiline.min_length": 50,
    "method_call.chain.multiline" : 3,
    "newline":"\n",
    "property.multiline.element_count": 3,
    "property.multiline.min_length": 30,
    "parentheses.padding": true,
    "strings.quote": "double",
    "strings.attributes.quote": "double",
    "struct.separator": " : ",
    "struct.padding": true,
    "struct.empty_padding": false,
    "struct.multiline.leading_comma": false,
    "struct.multiline.leading_comma.padding": true,
    "struct.multiline.element_count": 2,
    "struct.multiline.min_length": 60,
    "tab_indent": true
}
jcberquist commented 4 years ago

I don't think the formatter should do this. There is no easy way to tell if the spacing you have in your example is on purpose, or is actually code that needs to be formatted. It would have to make assumptions about tab indent levels that would get really complicated.

I ran your code through Prettier and it formats it the same way cfformat does. Are there formatters that preserve indents in this fashion? @elpete have you seen anything like that?

lmajano commented 4 years ago

I have not tried on other formatters. However, it made me sad :(

elpete commented 4 years ago

I can't see how a formatter would know to not change your indents here. If it is that important, I think you will want to either ignore this section or this file.

On Tue, Jul 21, 2020, 11:38 AM Luis Majano notifications@github.com wrote:

I have not tried on other formatters. However, it made me sad :(

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jcberquist/commandbox-cfformat/issues/84#issuecomment-662005015, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATWYXVBJRCX2SEIZVYGYK3R4XHCBANCNFSM4PDXIB3Q .

lmajano commented 4 years ago

Ohh you can ignore sections?

Luis Majano CEO Ortus Solutions, Corp www.ortussolutions.com P/F: 1-888-557-8057


From: Eric Peterson notifications@github.com Sent: Tuesday, July 21, 2020 3:05:57 PM To: jcberquist/commandbox-cfformat commandbox-cfformat@noreply.github.com Cc: Luis Majano lmajano@gmail.com; Author author@noreply.github.com Subject: Re: [jcberquist/commandbox-cfformat] Question on why it doesn't respect tabs (#84)

I can't see how a formatter would know to not change your indents here. If it is that important, I think you will want to either ignore this section or this file.

On Tue, Jul 21, 2020, 11:38 AM Luis Majano notifications@github.com wrote:

I have not tried on other formatters. However, it made me sad :(

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jcberquist/commandbox-cfformat/issues/84#issuecomment-662005015, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATWYXVBJRCX2SEIZVYGYK3R4XHCBANCNFSM4PDXIB3Q .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jcberquist/commandbox-cfformat/issues/84#issuecomment-662078720, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AABBPF5BQ2PJKN23OYYVPXTR4XYKLANCNFSM4PDXIB3Q.

jcberquist commented 4 years ago

@lmajano Yes, you can ignore sections of code if you want - but it requires you do demark those sections with special comments: ignoring-code-sections.

I don't think I can offer an option beyond having cfformat ignore the code here, sorry!