Code Quality

From Buildtools
Jump to: navigation, search

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:

PDT code formatting on steroids. Built-In PSR-2 formatter profile.:[edit]

Coding Standards:

  • Window -> Preferences -> PHP -> Code Style -> Formatter -> Select (PRS2)

Security:

Code documentation:

  • Window > Preferences > PHP > Editor > Typing > Automatically close > Phpdoc (Check) > Add Phpdoc tags

Eclipse for JS:[edit]

Coding Standards:

From google:

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]

  1. Go to buildtools_backend/libs/docs
  2. Run ./buildtools_backend/libs/docs/codeValidor.sh
  3. 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]