CodeIgniter Forums
Github code formatting - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Github code formatting (/showthread.php?tid=63244)



Github code formatting - ignitedcms - 10-11-2015

Hi guys,

This isn't really a question related to anything with codeigniter per se.

I am going through the process of tidying up my code on github to standardize it but I'm a bit miffed with the formatting. I am using sublime text editor and everything is indented nicely, but on github it seems random.

First I want to get through the controllers and lastly the views as this is the most untidy, but when I integrated twig templating it should be much easier to format.

Is there something I should be doing to make it nice and neat. Maybe converting all tabs to spaces or something?


RE: Github code formatting - slax0r - 10-11-2015

Tabs vs. spaces is an age old discussion, and there are really no drawbacks on either of the two. When there is a drawback is when your code is riddled with tabs AND spaces. Decide which path you want to go, and then convert all tabs to spaces, or space indents to tabs.


RE: Github code formatting - ivantcholakov - 10-11-2015

@iamthwee

1. If you take code from other authors and you need to modify it, just follow their conventions.

2. Formatting the original code of your project is up to you. But there is no need you to be original and to invent something, choose already an existing set of rules. For example, you may have a look at this: https://github.com/lonnieezell/CodeIgniter4/blob/develop/user_guide_src/source/general/styleguide.md


RE: Github code formatting - ignitedcms - 10-11-2015

Thanks ivantcholakov.

My question wasn't to do with coding name styles but more to do with tabs and indentation mirroring on github. I think the solution is what slaxor posted. I either got to convert all to tabs or all to spaces. I'm following the codeigniter style guide.


RE: Github code formatting - ignitedcms - 10-17-2015

Related to original question, but does anyone know of a good php formatter plugin for sublime?

So all my controllers and models are nicely formatted the same way. I think this would resolve the issues I'm having with spaces and tabs as well.


RE: Github code formatting - mwhitney - 10-19-2015

I previously used one of the more general-purpose formatters, but had some trouble with it doing a little more than I wanted it to. At the moment, I use Alignment, Line Endingssublime-phpcs, and possibly SublimeLinter 3 to deal with code formatting in Sublime Text 3. It may seem like a lot, but Alignment and Line Endings are very simple, focused tools which do only a couple of things, which makes them perfect for my needs.