Coder Presentation Boston - Presentation Transcript
Boston DrupalCon A Developer's Assistant: Using Coder for Module Developers & Maintainers By Doug Green [email_address] [email_address]
http://drupal.org/project/coder A Developer's Assistant
Coder Module Overview
History
Developer Module, built for you (and me)
What does it do?
Credit code-style.pl
Credit contributors: snpower, webchick, nancyw
Style Review
Comment Review
SQL Review
Upgrade Reviews (4.7.x, 5.x, 6.x)
Security & Performance Reviews
What is a Review?
A Developer's Assistant
spaces, tabs, indentation
string concatenation
global variable names, camelCase
positioning of curly { }
... and more ...
What does the style review check?
See http://drupal.org/node/114774
A Developer's Assistant
spacings and indentation within comments
$Id$
several uses of @see
What does the comment review check?
See http://drupal.org/node/318
A Developer's Assistant
capitalization of SQL keywords
brackets around {table}
SQL LIMIT instead of db_query_range()
What does the SQL review check?
A Developer's Assistant
FAPI
Menu
Schema API
Info File changes
... much much more ...
What does the upgrade review check?
See http://drupal.org/node/114774
A Developer's Assistant
not enough, difficult problem
SQL injection through variables
REQUEST_URI instead of request_url()
What does the security review check?
See http://drupal.org/node/28984
A Developer's Assistant
Download from project page, install, and enable
Setup defaults on admin/settings/coder
http://localhost/coder - selection form
http://localhost/coder/defaults
http://localhostcoder/core - all of core
$ drush coder ...
How do I Use Coder?
A Developer's Assistant
Selection Form / Settings Form
A Developer's Assistant
What To Review
A Developer's Assistant
Run from Drupal 5
Run from Drupal 6 (recommended)
Catches Quite a Bit...
But it's just a tool that makes suggestions
You are Smarter than Coder
Drupal 5.x -> 6.x Upgrade Review
A Developer's Assistant
drush coder
drush coder style
drush coder panels
drush coder core
drush coder all
drush coder no-coder
Drush – Drupal Shell
A Developer's Assistant
cvs co DRUPAL-5—2 + DRUPAL-5 branches
1,843 modules
5,191 files
265 critical errors
35,950 warnings
109,000 minor warnings
Coder Style Review of all of Drupal
A Developer's Assistant
1. Use an indent of 2 spaces, with no tabs
2. missing spaces
3. extra trailing spaces
4. string concatenation
5. curly braces { should end a line, not start one
6. camelCase
7. indent secondary line of comment one space
Most Common Errors
A Developer's Assistant
ββ if (!$table) { βββββ $as .= '_orderby'; βββββ $alias = $field; ββ } should be ββ if (!$table) { ββββ $as .= '_orderby'; ββββ $alias = $field; ββ }
111,153 warnings... views.module, line 66, 67
1. Use an indent of 2 spaces with no tabs
A Developer's Assistant
if(!isset ($node)){ $node=array('status' => 1); } should be if (!isset($node)) { $node = array('status' => 1); }
35,262 warnings
2. missing spaces
A Developer's Assistant
/** β * Output a confirmation form β * β * β This function returns a complete form for confirming an action. A link is β * β offered to go back to the item that is being changed in case the user β β * β changes his/her mind. β *
29,205, system.module +2126
3. extra trailing spaces
A Developer's Assistant
'#title' => $module . ' module', should be '#title' => $module .' module',
23,679, update.php +359
4. string concatenation
A Developer's Assistant
'#title' => $module . ' module', should be '#title' => $module .' module',
13,712
5. curly braces { should end a line, not start one
A Developer's Assistant
$testBucket = variable_get('mm_s3_bucket', ... should be $test_bucket = variable_get('mm_s3_bucket', ...
11,126, stdClass is an exception
6. camelCase
A Developer's Assistant
/** * Format a password field. */ should be /** * Format a password field. */
6,281, form.inc +1604
7. indent 2 nd line of comment one space
A Developer's Assistant
show review of views from the browser
show from drush
demo 1.x upgraded to Drupal 6.x
6.x upgrade review
A Developer's Assistant
7.x upgrade review
Continue to improve security review
Create patch files – somewhat possible
Parse & code flow analysis – probably not
The Future of Coder
A Developer's Assistant
[email_address] http://drupal.org/project/coder A Developer's Assistant
0 comments
Post a comment