The Drupal 7 Trello module provides an API for developers to integrate their site with Trello data. See http://trello.com for information about the Trello project management system. A developer can use this module to read/write Trello cards, lists, boards and anything available in the Trello API reference here: https://trello.com/docs/api/. I haven't tested the module with all of the API as there is quite a bit there, but I can successfully read anything as a json object and create new cards with descriptions.

Project page: http://drupal.org/sandbox/daven/1795720
Repo viewer: http://drupalcode.org/sandbox/daven/1795720.git
Get the code: git clone --recursive --branch 7.x-1.x http://git.drupal.org/sandbox/daven/1795720.git trello

This module currently targeted to other developers interested in working with Trello. I plan to expand the module to do more useful things with API but currently the example module and API explorer page are working successfully. Please see the project page for install instructions.

CommentFileSizeAuthor
#7 Trello1.png25.53 KBBob Humphrey

Comments

varunmishra2006’s picture

Category: task » bug
Status: Needs review » Needs work

There are lots of coding standard error found. Please check my review here http://ventral.org/pareview/httpgitdrupalorgsandboxdaven1795720git-7x-1x

Also set the correct default branch and remove the master branch.

daven’s picture

Category: bug » task
Status: Needs work » Needs review

I've updated comments and such to match Drupal coding standards.

jvdurme’s picture

Status: Needs review » Needs work

Hi there,

I see that you set a few variables, but you should also delete them when the user uninstalls your module.
Create a trello.install file with hook_uninstall() and delete your variables with variable_del().

I didn't go much deeper into your code, since I'm no expert. But deleting these variables is something that can block module approval. Trust me. ;)

And there are still some minor coding standard errors:

Severity minor, Drupal Commenting Standards, Internationalization, Drupal Security Checks, Drupal SQL Standards, Drupal Coding Standards

sites/all/modules/pareview_temp/./test_candidate/trello.inc:
+25: [normal] The $string argument to t() should not begin or end with a space.
+30: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
+31: [minor] in most cases, replace the string function with the drupal_ equivalent string functions

Status Messages:
Coder found 2 projects, 2 files, 1 normal warnings, 2 minor warnings, 0 warnings were flagged to be ignored

FILE: ...l-7-pareview/sites/all/modules/pareview_temp/test_candidate/trello.info
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
5 | ERROR | It's only necessary to declare files[] if they declare a class or
| | interface.
--------------------------------------------------------------------------------

You can manually check your code for coding standard errors at http://ventral.org/pareview or use the Coder module.

cheers!

daven’s picture

Status: Needs work » Needs review

Since October I've had a lot of work and a new baby in the house. =) Happy to be getting back to this again though.

I now have a clean automatic code review: http://ventral.org/pareview/httpgitdrupalorgsandboxdaven1795720git
Re-submitting for review.

-Dave

maxgor’s picture

Here is in the code you define forced the handler for submut buttons on all forms, for example:

$form['#submit'][] = 'trello_api_explorer_form_submit';

however the same handler is executed by default for forms if you define function with name name_form_submit()

Best regards,
Max.

daven’s picture

maxgor thanks for the tip. I removed the redundant lines and did some other clean-up.

-dave

Bob Humphrey’s picture

Status: Needs review » Needs work
StatusFileSize
new25.53 KB

Some small stuff:

  • The automated code review at http://ventral.org/ is finding a few errors.
  • trello.module line 18 - You should change the title to something a little more descriptive than 'Administer my module'. Maybe 'Administer Trello module'.
  • trello.module line 63 - The comments for trello_get_conf() do not document the parameter or return value.
  • trello.module line 124 - The comments for trello_auth_page() do not document the return value.
  • trello.inc line 82 - The call to watchdog seems more like a debugging statement that's been left in the code rather than any kind of useful information for the user.
  • trello.inc line 107 - The variable result should have a comment block documenting it.

Also, when I bring up the Trello Example Configuration page, I get the following error messages:
errors

I went to trello.com, opened an account, created a board, and added some lists and a bunch of cards. However, I wasn't really able to find my information using the Trello API Explorer page you created. I was probably doing something wrong in entering the parameters, but I spent all the time I could studying the Trello documentation. It might have been easier if your example application worked.

Bob Humphrey

daven’s picture

Thanks Bob, I will address those items before setting the status back to needs review. I agree the API explorer could use some improvement to be more helpful. I think I can fix the example module bug easily enough.

I also have plans for views integration which would make this much more interesting than just the base API + example. Not sure if I should get that in before the review. I'll see when I have some more free time in at least a week from now.

Dave

daven’s picture

Status: Needs work » Needs review

I did some major improvements to the API explorer and some other bug fixes as suggested in this discussion. And since the module requires some messing with trello API keys and authentication tokens I set up a demo site here: http://trello.gv.ca/trello/api-explorer Now you can quickly see what the module does so far.

Improvements to API explorer:

  • API docs are scraped and built into explorer form and cached (three cheers for structured content)
  • Reference link points directly to selected API section
  • Code examples are generated on form submission
sylus’s picture

Just did a automated review using Code Sniffer and found some minor issues:

FILE: /mnt/www/html/pareviewsh/pareview_temp/trello.inc
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
 64 | ERROR | Empty CASE statements are not allowed
--------------------------------------------------------------------------------

FILE: /mnt/www/html/pareviewsh/pareview_temp/trello_api_explorer.module
--------------------------------------------------------------------------------
FOUND 3 ERROR(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
  68 | ERROR | An operator statement must be followed by a single space
  68 | ERROR | There must be a single space before an operator statement
 220 | ERROR | There must be a single space before an operator statement
--------------------------------------------------------------------------------

Did a manual review as well and code looks good just some minor spelling mistakes:

http://drupalcode.org/sandbox/daven/1795720.git/blob/refs/heads/7.x-1.x:...
http://drupalcode.org/sandbox/daven/1795720.git/blob/refs/heads/7.x-1.x:...

I did have a question about having two .info files in the same directory though perhaps move trello_api_explorer (module + info) into a subfolder? I could totally be wrong about this though.

Same Directory:

a) trello.info
b) trello_api_explorer.info

As an aside I thought it was pretty cool that you are supporting both functional and OO version of the trello api. Also bonus points for providing an example module on how to leverage the functionality. Will definitely be taking a further look at this!

daven’s picture

sylus, thanks for your review. Spelling typos and such corrected. Thanks for your aside, though I think it was exactly on topic. :)

Looks like views_ui module uses a second .info file in the module directory:
http://drupalcode.org/project/views.git/tree/refs/heads/7.x-3.x
But not in the D8 version so I'm not sure what is best practice and I didn't find mention of this in the coding standards.
http://drupalcode.org/project/views.git/tree/refs/heads/8.x-3.x

I don't have a preference here, it just ended up where it is as I was developing. Also, the example module is in a 'modules' subdirectory but maybe should just be in trello_example. Anyone have opinions or observed patterns on where to place submodules?

klausi’s picture

We are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)

codeyourdream’s picture

1. Set error_reporting in your php configuration to E_ALL | E_STRICT and test module again
Problems apper on at least the following page:
- admin/config/trello/example

Notice: Trying to get property of non-object in trello_example_config_form() (line 87 of /var/www/_REVIEWS/trello/modules/trello_example/trello_example.module).

2. You do not need own submission handler for trello_config_form() because you use core system_settings_form($form) function that saves variables for you. Also you should not clear $form argument in trello_config_form():
-14: $form = array();

3. You do not need global variables
Instead, use the common practise with a staticly cached variables:

function trello_get_api_explorer_toc($table_of_contents = NULL, $reset = FALSE) {
  static $api_explorer_toc = &drupal_static(__FUNCTION__);
  if ($reset) {
    $api_explorer_toc = NULL;
  }
  if (isset($table_of_contents)) {
    $api_explorer_toc = $table_of_contents;
  }
  return $api_explorer_toc;
}

4. Use constants instead of hard-coded strings such as $base_url = 'https://trello.com/docs/api/';

5. Use t() function properly
trello_api_explorer.module

-105: $fieldset['#description'] = t('API reference: ') . l($url, $url);
+105: $fieldset['#description'] = t('API reference: <a href="@url">@url</a>.', array('@url' => $url));

A couple of questions:

1. Why not use drupal_http_request() function?

2. You really need $include_curl_handle param in trello_api() function?

sreynen’s picture

Status: Needs review » Needs work

#13 has blocker issues, so I'm setting this back to needs work.

drupik’s picture

5. Use t() function properly
trello_api_explorer.module

-105: $fieldset['#description'] = t('API reference: ') . l($url, $url);
+105: $fieldset['#description'] = t('API reference: <a href="@url">@url</a>.', array('@url' => $url));

This is not a correct use of t() function, it will returns the error: "The submitted string contains disallowed HTML" if you try to translate. It should be something like this:
$fieldset['#description'] = t('API reference: !url', array('!url' => l(t($url), $url)));

daven’s picture

Thanks all for the continued feedback. I'm hoping to get to the changes soon.

codeyourdream the reason I'm not using the drupal_http_request() function is because I wasn't aware of it. Thanks for pointing that out, I'll give it a try.

drupik, thanks for clarifying. I was going to ask about proper t() usage but you already answered.

codeyourdream’s picture

However, for links enclosed in translatable text you should use t() and embed the HTML anchor tag directly in the translated string. For example:

t('Visit the <a href="@url">settings</a> page', array('@url' => url('admin')));

This keeps the context of the link title ('settings' in the example) for translators.

http://api.drupal.org/api/drupal/includes%21common.inc/function/l/7

drupik’s picture

So it seems that <a> tag is allowed. But in this way also have translation available.

<?php
t('Visit the !url page', array('!url' => l(t('settings'), 'admin')));
?>
sreynen’s picture

The encouragement in http://api.drupal.org/api/drupal/includes%21common.inc/function/l/7 to include link tags in translation strings surprises a lot of people. But that is, indeed, what the documentation says you should do, so the advice in #13 should be followed. The formats in #15 and #18 are a common practice, but #13 follows best practice.

daven’s picture

Status: Needs work » Needs review

I went with the t function as suggested in #13. Also removed the curl requirement as drupal_http_request is working for me, and other changes from this discussion.

Thanks again for the suggestions.

sreynen’s picture

Status: Needs review » Needs work
  • In trello.admin.inc, I don't think it makes sense to translate the domain name in t('at trello.com').
  • Why isn't trello_api_explorer in the modules directory?
  • In trello.module, the const TRELLO_API_VERSION syntax is only supported as of PHP 5.3. This raises your PHP version requirement above Drupal's 5.2.5. You should either make that requirement explicit in .info file (see http://drupal.org/node/171205#php), or change to the define() syntax, removing the 5.3 requirement.

I was hoping to mark this as reviewed and tested. Unfortunately that last one is a blocker, as it can cause fatal errors on older PHP versions. If you can fix that, I'll try to finish this up quickly.

daven’s picture

Status: Needs work » Needs review

@sreynen

  • I changed the string to "at the Trello web site" which sounds better.
  • I now moved the two modules into their own subdirectory in the main module directory instead of another modules directory. This seems to be the way many other modules do it, such as the coder module. Feels cleaner now. :)
  • Thanks for pointing that out. I changed it to the define() syntax.
  • I also changed trello.module lines 83-84 to send Trello the Drupal site name instead of my initial lazy placeholder "a Drupal site" which is used for the auth token. Probably minor, but I'm not sure if this variable should also be configurable in the admin page.

Thanks again. I've been meaning to do a reviews of another projects too but haven't had a chance yet. I'll try to get on that soon.

fgm’s picture

Some things that should probably be changed in the module:

  • trello_api_explorer.module: line 106, don't use @url for the URL itself, rather use !url and pass '!url' => check_url(...)
  • line 109, matches[1] is not set if the match failed: you should probably check its result
  • line 111, you are adding unsanitized data from an external string to a #title, so they should be sanitized
  • note that you can also probably make this more php-like by using the index as "foreach ($matches[1] as $k => $v)" and use $k instead of using an outer variable incremented numerically
  • released code should not contain any dpm() or dsm() calls if it does not check for devel module.
  • there are a bunch of coding standard violations: you should probably use coder_review and/or codesniffer.
  • since this is a web service, the config path should probably be admin/config/services/trello rather than admin/config/trello
daven’s picture

Thanks fgm,

I made the changes you suggested. I agree dpm shouldn't be in released code, however it is only in the trello_api_explorer module which is intended for developers and that module has devel as a dependency in its info file. The dpm function provides a very convenient way to pick though the data that the Trello api returns.

I just pulled the latest 7.x-2.x of the coder module and I run drush dcs on my module but I don't see any coding standard violations. Please specify.

PHP_CodeSniffer did not find any problems. [success]

Dave

fgm’s picture

You're right about the devel dependency: I had only checked it on trello.info, not trello_api_explorer.info.

However, here are the coder_review results I get on on trello_api_explorer:

Line 156: Potential problem: FAPI elements '#title' and '#description' only accept filtered text, be sure to use check_plain(), filter_xss() or similar to ensure your $variable is fully sanitized.
    '#description' => t('API reference: ') . l($url, $url),

Line 156: The $string argument to t() should not begin or end with a space. (Drupal Docs)
    '#description' => t('API reference: ') . l($url, $url),

Line 211: in most cases, replace the string function with the drupal_ equivalent string functions
    sprintf('$t->%s(\'%s\'%s);', strtolower($method), $path, $query ? ", '$query'" : ''),
daven’s picture

How did you get those coder_review results? I must be doing something wrong. When I do drush dcs . or drush dcs trello_api_explorer.module I get a clean report but it now looks like it's missing results.

daven’s picture

p.s. I also get a clean report from http://ventral.org/pareview/httpgitdrupalorgsandboxdaven1795720git-7x-1x but your results look important. Well, the sanitize ones look important although the string is explicitly defined a few lines before so it's not a huge issue but could be rearranged a bit. I'd like to be able to see these results though with my code sniffing tools. but maybe that's a discussion/issue for somewhere else.

sreynen’s picture

Status: Needs review » Reviewed & tested by the community

Though it's worth fixing, nothing in #25 seems like a blocker to me. It looks like all previous feedback is addressed now, so I'm marking this reviewed and tested.

daven’s picture

Woohoo! Thanks.

I just committed the code style fixes from #25 anyway:
http://drupalcode.org/sandbox/daven/1795720.git/commitdiff/6cb807dcd62f6...

fgm’s picture

These appear when you enable the "minor" review level and the off-by-default checks in coder_review (not in coder_sniffer).

klausi’s picture

Status: Reviewed & tested by the community » Fixed

Sorry for the delay, but you have not listed any reviews of other project applications in your issue summary as strongly recommended in the application documentation.

Review of the 7.x-1.x branch:

  • Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
    
    FILE: /home/klausi/pareview_temp/trello.inc
    --------------------------------------------------------------------------------
    FOUND 0 ERROR(S) AND 4 WARNING(S) AFFECTING 4 LINE(S)
    --------------------------------------------------------------------------------
     104 | WARNING | Code after RETURN statement cannot be executed
     105 | WARNING | Code after RETURN statement cannot be executed
     107 | WARNING | Code after RETURN statement cannot be executed
     108 | WARNING | Code after RETURN statement cannot be executed
    --------------------------------------------------------------------------------
    
    Time: 0 seconds, Memory: 12.00Mb
    

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.

manual review:

  1. The Trello class file should be listed in the info file with the files[] directive.
  2. trello_api_explorer_form_submit(): contains dpm() debug code.
  3. trello_example_block_view(): you could use theme('item_list') for your list markup.

But that are not blockers, so ...

Thanks for your contribution, daven!

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

daven’s picture

klausi thanks so much for approving my application before I got to doing some reviews. I still intend to do so. I'm quite happy with the review process and I plan to help out if I can.

Thanks for your review as well... Never done making improvements.

Note, the dpm() is a perhaps hackish way of displaying the returned results in the API explorer and is a submodule for developers so I though it appropriate at least for now. The trello_api_explorer module states devel as a dependency. I might change that eventually, although i'd like to get views integration first.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.