Comments (15)
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.
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.
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.
@elpete WOW!!!
from commandbox-cfformat.
I have tested it but can't make it work :(
I am attaching the code
ContentStoreCarousel.cfc.zip
cfformat.json.zip
from commandbox-cfformat.
Thanks for the test. I need to update the regex that searches for assignments to allow for bracket notation: slide[ "imageURL" ]
.
from commandbox-cfformat.
I have published v0.12.3
which should work with the bracket notation.
from commandbox-cfformat.
This is working, however we have another case where it's not, property definitions. Can you check this out.
Is this possible?
from commandbox-cfformat.
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.
@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.
No worries at all! Thanks for all that you do!
from commandbox-cfformat.
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.
@lmajano: Thanks! It wasn't supporting underscores in variables names, but it is now :)
from commandbox-cfformat.
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.
Sounds good, thanks!
from commandbox-cfformat.
Related Issues (20)
- Subsequent lines of a multiline statement should be indented. HOT 2
- cfformat check doesn't handle Unicode with BOM files HOT 1
- Forgebox installation is broken HOT 1
- DocBox commenting formatting HOT 6
- struct element alignment HOT 5
- Tag type comments converted to script comments erroneously HOT 2
- annotation with a `:` is adding a space HOT 2
- Latest version removing indendations on Comments HOT 1
- Latest version removing comments HOT 1
- CommandBox no longer reloads on module installation HOT 8
- preserve case in doc-block? HOT 2
- Indent content between cfscript tags HOT 3
- Ignoring blocks/tags via settings vs comment HOT 2
- Property alignment incorrect when the number of attributes differs
- annotation with a - is adding a space
- tag-check and single tags that are not self-closing HOT 3
- abstract component modifier injects spaces
- Lines are improperly outdented
- Method Multiline formatting/highlighting when inital element is not a method HOT 1
- CSS styles
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commandbox-cfformat.