Code Quality
Contents
- 1 General development and debugging environment config
- 1.1 Sshfs client to mount remote file system
- 1.2 Eclipse Lua (remember sdk & jdk)
- 1.3 Xdebug toolbar chrome
- 1.4 Install xdebug ubuntu case:
- 1.5 Eclipse setup:
- 1.6 General eclipse coding standards and GUI setup:
- 1.7 PDT code formatting on steroids. Built-In PSR-2 formatter profile.:
- 1.8 Eclipse for JS:
- 1.9 For vim Users:
- 2 PHP
- 3 SENCHA
General development and debugging environment config[edit]
Sshfs client to mount remote file system[edit]
Linux:
sshfs user@domain.com:/remote/path /local/path
Windows:
https://code.google.com/p/win-sshfs/downloads/detail?name=win-sshfs-0.0.1.5-setup.exe&can=2&q=
Eclipse Lua (remember sdk & jdk)[edit]
https://eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/lunasr1a
Xdebug toolbar chrome[edit]
https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en
Install xdebug ubuntu case:[edit]
Installation:
http://xdebug.org/docs/install
pecl install xdebug
zend_extension="/usr/local/php/modules/xdebug.so"
verify: php -v | grep ‘xdebug’
Configuration
config xdebug.ini or php.ini
zend_extension=/usr/local/php/modules/xdebug.so
xdebug.idekey=default
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost //Must use ssh tunnel
xdebug.remote_port=9000
Eclipse setup:[edit]
Setup debugger:
- Preferences => PHP => Debug => Installed debuggers => xdebug
- Accept remote session (JIT): any
- If remote use ssh tunnel.
Create remote server:
- Preferences => PHP => PHP Servers < Server tab
General eclipse coding standards and GUI setup:[edit]
- Preferences -> Language(java) -> Editor -> Save Actions and configure it to remove trailing whitespace.
- Window->Preferences->Java->Code Style->Formatter->Edit->Indentation = "Spaces Only" to tabs to space.
- Window > Preferences > General > Editors > Text Editors > Click on the CheckBox "whitespace characters".
- Eclipse LF to CRLF
Eclipse cool GUI:
- Install plugin http://eclipsecolorthemes.org/?view=plugin
- Download and import https://github.com/guari/eclipse-ui-theme/blob/master/com.github.eclipseuitheme.themes.plugin/bin/color-scheme/RainbowDrops.xml?raw=true
PDT code formatting on steroids. Built-In PSR-2 formatter profile.:[edit]
- Install PDT : http://download.eclipse.org/tools/pdt/updates/latest
Coding Standards:
- Window -> Preferences -> PHP -> Code Style -> Formatter -> Select (PRS2)
Security:
- Read: http://phpsec.org/projects/guide/
- Enable CodeSniffer Validator
Code documentation:
- Window > Preferences > PHP > Editor > Typing > Automatically close > Phpdoc (Check) > Add Phpdoc tags
Eclipse for JS:[edit]
Coding Standards:
- jsHint http://github.eclipsesource.com/jshint-eclipse
- Window Menu >> Preference >> JSHINT >> Enable JSHINT errors (Check)
From google:
- Download this xml file https://code.google.com/p/google-styleguide/source/browse/trunk/eclipse-java-google-style.xml
- Import as new file configuration
- Window Menu >> Preference >> Web >> JavaScript >> Formatter
Sencha:
Code documentation:
For vim Users:[edit]
- set numberset listchars=eol:$,tab:>-,trail:.,extends:>,precedes:<
- set list
- set tabstop=4 shiftwidth=4 expandtab
- highlight ExtraWhitespace ctermbg=red guibg=red
- match ExtraWhitespace /\s\+$/
- autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
- autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
- autocmd InsertLeave * match ExtraWhitespace /\s\+$/
- autocmd BufWinLeave * call clearmatches()
Useful resources: http://www.ibm.com/developerworks/library/os-debug/ https://code.google.com/p/google-styleguide
PHP[edit]
Code Validator and fixer[edit]
- Go to buildtools_backend/libs/docs
- Run ./buildtools_backend/libs/docs/codeValidor.sh
- Fix errors
Sample output:
FILE: /home/james/buildtools_backend/libs/models/Configuration.php
FOUND 4 ERRORS AFFECTING 4 LINES
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
2 | ERROR | [x] Whitespace found at end of line
5 | ERROR | [ ] Each class must be in a namespace of at least one level (a top-level vendor name)
6 | ERROR | [x] Tabs must be used to indent lines; spaces are not allowed
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
buildtools_backend[edit]
- Models files and class names always in plural
SENCHA[edit]