Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code formatting option for lining up assignment operators in DSC configurations #672

Closed
daviwil opened this issue Apr 10, 2017 · 7 comments
Assignees
Labels
Area-Code Formatting Issue-Enhancement A feature request (enhancement).
Milestone

Comments

@daviwil
Copy link
Contributor

daviwil commented Apr 10, 2017

When a user writes a DSC configuration, they might line up their assignment statements like this:

configuration MyConfiguration {
    xDscWebService PSDSCPullServer {
        Ensure                = Present
        EndpointName          = PSDSCPullServer
        Port                  = 8080
        PhysicalPath          = $env:SystemDrive\inetpub\wwwroot\PSDSCPullServer
        CertificateThumbPrint = AllowUnencryptedTraffic
    }
}

We should do this formatting for them so that when they add new properties they can reformat the configuration and have all the properties be lined up at the equal signs again.

/cc @jpsnover @smurawski

@daviwil daviwil added Area-Code Formatting Issue-Enhancement A feature request (enhancement). labels Apr 10, 2017
@daviwil daviwil added this to the April 2017 milestone Apr 10, 2017
@smurawski
Copy link

smurawski commented Apr 11, 2017

Folks also tend to do this with hashtables (especially when constructing one to splat into another command).

@kapilmb
Copy link

kapilmb commented Apr 11, 2017

I think this rule would be a great addition to our existing set of rules. But do we want to limit ourselves just to Configurations or Hashtables? Should it be general enough that whenever there are consecutive assignment statements, it should take effect? Or maybe we can provide options wherein the user can select if they want to line up only property value pairs or consecutive assignment statements.

@dotps1
Copy link

dotps1 commented Apr 11, 2017

I would prefer options, as I do not line the equal signs up, and would prefer not to be forced to.

@daviwil
Copy link
Contributor Author

daviwil commented Apr 11, 2017

@kapilmb let's go with just configurations and hashtables for now and then expand to others if we get feedback on that

@daviwil
Copy link
Contributor Author

daviwil commented Apr 11, 2017

@dotps1 we'll definitely have an option to turn it off!

@daviwil daviwil modified the milestones: April 2017, 1.0.0-beta1, 1.0.0 May 8, 2017
@fodonnel
Copy link

This rule is not very version control friendly.

If I remove CertificateThumbPrint from the above example then all the other lines in the resource move back and look like the have been edited if I do a compare.

If i also had actually edited another line - like changing the port it would not be clear. There are ignore whitespace settings that I use for the compare, the they are not the default behaviour.

@daviwil
Copy link
Contributor Author

daviwil commented May 11, 2017

That's a fair point, though I don't see any way around this other than just turning off the rule if it's problematic for you. Can you think of a better option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Code Formatting Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

5 participants