Git Product home page Git Product logo

Comments (15)

jcberquist avatar jcberquist commented on August 23, 2024

I think aligning struct values would be possible within the current framework. Of course then you would get that alignment in every struct (that was formatted onto multiple lines).

Aligning consecutive variable assignments wouldn't really be possible within the current code printing. The best I think I could do is add a post initial format pass that uses regex to find those lines and aligns them. I am not sure how well that would work in general, but I think with your examples above it would work.

from commandbox-cfformat.

lmajano avatar lmajano commented on August 23, 2024

I think aligning struct values would be possible within the current framework. Of course then you would get that alignment in every struct (that was formatted onto multiple lines).

Yes, I think this is something that would be very useful for our standards and readability of code for code reviews. We also apply this approach to method calls:

throw(
	message 		= "This message",
	type 			= "ThisException",
	extendedInfo 	       = "Hello",
	detail			= "This details"
);

Aligning consecutive variable assignments wouldn't really be possible within the current code printing. The best I think I could do is add a post initial format pass that uses regex to find those lines and aligns them. I am not sure how well that would work in general, but I think with your examples above it would work.

This to us would be a nice thing to have. We go into great extends to do it in our code bases for readability for consecutive assignments.

from commandbox-cfformat.

jcberquist avatar jcberquist commented on August 23, 2024

I have an attempt at this in v0.12.1. It relies on a simpler regex approach, so it remains to be seen how robust it is. I tested it on ModuleConfig.cfc from your cbstorages and it seemed to do alright there.

I added a setting to control this: "assignments.consecutive.alignment": (true|false). It is an all or nothing setting for now (and I am not sure how much more precise I can get). Any consecutive variables assignments, named function call arguments, or struct key values should ideally get aligned when it is set to true. I would appreciate testing and feedback on it.

from commandbox-cfformat.

lmajano avatar lmajano commented on August 23, 2024

@elpete WOW!!!

from commandbox-cfformat.

lmajano avatar lmajano commented on August 23, 2024

I have tested it but can't make it work :(
Screen Shot 2019-09-10 at 10 10 13 AM

I am attaching the code
ContentStoreCarousel.cfc.zip
cfformat.json.zip

from commandbox-cfformat.

jcberquist avatar jcberquist commented on August 23, 2024

Thanks for the test. I need to update the regex that searches for assignments to allow for bracket notation: slide[ "imageURL" ].

from commandbox-cfformat.

jcberquist avatar jcberquist commented on August 23, 2024

I have published v0.12.3 which should work with the bracket notation.

from commandbox-cfformat.

lmajano avatar lmajano commented on August 23, 2024

This is working, however we have another case where it's not, property definitions. Can you check this out.
Screen Shot 2019-09-24 at 7 43 14 AM

Is this possible?

from commandbox-cfformat.

jcberquist avatar jcberquist commented on August 23, 2024

This should be possible, however, I think I will have to use a slightly different approach for this since it is the attributes that are being aligned here.

from commandbox-cfformat.

jcberquist avatar jcberquist commented on August 23, 2024

@lmajano, I have published v0.12.7 - now there are three settings:

"alignment.consecutive.assignments"
"alignment.consecutive.properties"
"alignment.consecutive.params"

Note that this is a breaking change, sorry! The previous setting assignments.consecutive.alignment is gone in favor of alignment.consecutive.assignments - I was trying to keep these related settings together.

This is one of the reasons I haven't gone to a 1.0.0 release; I want to be able to adjust setting names. I know it is inconvenient though, so again, sorry. But in that vein, if you think any of the settings could be better named, now would be a good time!

from commandbox-cfformat.

lmajano avatar lmajano commented on August 23, 2024

No worries at all! Thanks for all that you do!

from commandbox-cfformat.

lmajano avatar lmajano commented on August 23, 2024

Ok, seems it doesn't want to align this:

/**
	 * Constructor
	 */
	function init(){
		variables.siteKeywords    = "";
		variables.siteDescription = "";
		variables.cb_site_mail_server = "";
		variables.cb_site_mail_username = "";
		variables.cb_site_mail_password = "";
		variables.cb_site_mail_smtp = "25";
		variables.cb_site_mail_tls = "false";
		variables.cb_site_mail_ssl = "false";
		variables.populateData = true;
		variables.fullRewrite  = true;
		variables.rewrite_engine = "mod_rewrite";

		return this;
	}

from commandbox-cfformat.

jcberquist avatar jcberquist commented on August 23, 2024

@lmajano: Thanks! It wasn't supporting underscores in variables names, but it is now :)

from commandbox-cfformat.

elpete avatar elpete commented on August 23, 2024

Just a note that I think you can close this issue. The alignment seems (to me) to be working great in our repos.

from commandbox-cfformat.

jcberquist avatar jcberquist commented on August 23, 2024

Sounds good, thanks!

from commandbox-cfformat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.