There's a lot of unused code in the code tree, and a good deal of the used code is not conforming to the Drupal code standards. Let's change that.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Freso’s picture

Status: Active » Needs review
FileSize
20.07 KB

Okay, here's a first go. Please comment on any and everything. :)

jonathan1055’s picture

Freso,

This is a good idea. I've looked through the patch and it all seems good, but I have not actually applied it (as I have already made some mods to my installation of pingback which I will be suggesting in another post). I may take a fresh download and test out the patches, and post here again.

One thing I noticed - you missed one call to dpm in pingback_send()

It would be good to get this done and committed into the dev release, as it is a great module but does need tidying up. I can then make further suggestions when the bulk of these code changes are in place.

Jonathan

Freso’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
FileSize
20.6 KB

Well spotted. :) This patch removes this and has some other small code adjustments.

jonathan1055’s picture

Excellent work. I have applied the patch to a fresh 2.x-dev install and it all looks good. I have also tested it and it works just the same, so I do not think any accidental errors have crept in. I have noticed the following, which you may like to include, just to make things even cleaner and more to standards:

1. In pingback.module, function pingback_send() there are three calls to dpm(), lines 376, 387, 392 which should be removed

2. in pingback_form_alter, line 69, there is the following code:

//hide pingback input format if desired for anon users
  elseif (
    $form_id == 'comment_form'
    && (!$user->uid)
    && variable_get('pingback_hide_format_for_anon', 0)
    //&& (isset($GLOBALS['pingback_bypass_format_hiding']) ? !$GLOBALS['pingback_bypass_format_hiding'] : TRUE)
  ) {

Is this the correct way to format according to coding standards? Should the tests be on the same line if they are short?. Also it includes a commented out test in the middle of the if construction, which I think should be removed (and placed in a separate comment for refernce if/when the bypass code is implemented)

3. pingback_exit() and pingback_xmlrpc() both need the standard comment block, ie

/**
 * Implementation of hook_... ().
 */

4. Line 322, comment /* --- theme_pingback_* --- */ should be improved. Also it might be good to move this definition to just after pingback_theme(), so that it is clearer that they are related.

5. Line 435 the comment “private_functions” is a bit misleading. Many of the functions are named with a leading _ but also many are not. Just remove it, as we are not going to rename any functions.

6. In pingback.admin.inc there is a very long comment starting ‘// to devs: every node update’ which appears three times, lines 36, 57 & 85. The second are third of these are not required, seems like they got copied accidentally. For the first one, is this the proper way to write such a comment on a single line where it is very hard to read? Maybe better in a comment block?

Take your pick as to which if any of the above you include, but obviously I hope you do all of them. This is a great clean-up. When it is done in dev, I can then share some fixes and improvements I have made, but it will be good to get this done first.

Jonathan

andreashaugstrup’s picture

Great work guys. I'm on vacation at the moment, but I will commit this when I get to DrupalCon next week.

Freso’s picture

@ Andreas: No sweat. I'll commit it when it's ready. ;)

@ Jonathan:

  1. I think I did this one already, in the patch from #3, didn't I?
  2. Neither Drupal's nor PEAR's coding guidelines seem to cover this, so it's every developer for themselves. If you can dig up some core examples, I'd like to see what's done there. :) Anyway, for now, I've removed the commented out code (it can still be seen through CVS, if needed to be referenced later), and collected the remaining arguments on one line.
  3. Done. And well caught. :)
  4. Removed the comment and others like it. The Doxygen should be enough to self-document functions.
  5. The three functions following that comments all start with "_". Never the less, as they are marked as "private" with the "_", the comment is superfluous.
  6. I can't figure out what is meant by the comments, nor when/where they were introduced... so I've kept them in for now.

I also did some other small clean-ups, so please give this a look over and see if you can spot any other things. :)

jonathan1055’s picture

Thanks Freso, I've just re-applied the patch. Here are my responses:

1. Yes it is fine. I don't know why I thought they were still there, I must have still been looking at the first patch. Maybe I got confused with your file numbering which started with suffix 1, then had no suffix for the second patch ;-)
2,3,4,5 All good now.
6. My main point was that this is a comment that has been accidentally duplicated when copying lines to make new form items. The comment only makes sense on the pingback_mode entry so you could delete it from the other two. But I'm not going to argue too hard over this!

Yes the other little clean-ups are fine. Good work!

Jonathan

Freso’s picture

Alright. I'll take your word for it and remove the other two instances of the comment and try and get this committed this afternoon/evening. Thank you for the reviews! =)

Freso’s picture

Status: Needs review » Fixed
FileSize
23.12 KB

Committed the attached patch to 6.x-2.x and 6.x-1.x.

Status: Fixed » Closed (fixed)

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