The documentation for the Archive_Tar::__construct() function does not meet Drupal coding standards. Specifically:

  • The function summary does not begin with a third-person singular present indicative transitive verb.
  • The function summary does not fit within a single 80-character line.
  • The lines do not wrap at 80 characters.
  • The parameter documentation is not formatted correctly.
  • The boolean constant TRUE is incorrectly referenced as 'true'.
  • The comment delimiters don't line up correctly.
  • The return value is not documented.

The attached patch patch in #12 corrects these deficiencies.

Comments

pillarsdotnet’s picture

StatusFileSize
new1.55 KB

That @param type should be mixed, not string.

jhodgdon’s picture

Status: Needs review » Needs work

Several problems here:

+    * Returns a new Archive_Tar Class object.

I don't think we use "Class object" anywhere else in the code. Should probably just say "Returns a new Archive_Tar object." Class seems redundant to me, and it definitely shouldn't be capitalized if it is used.

+    * identifying it by the name of the tar file. If the compress argument is

Please use the name of the parameter, which I think is $p_compress. It is more precise than "the compress argument". Also, this information should be in the @param section, not in the general function header, as it is specific to that parameter.

+    *   The name of the tar archive to create

Does not end with a period.

+    * @param mixed $p_compress
+    *   Can can be NULL, TRUE, 'gz' or 'bz2'. This parameter indicates whether
+    *   gzip or bz2 compression is required.  For compatibility reasons the
+    *   boolean value TRUE means 'gz'.

One space between sentences, not two. Start with the parameter description, then put the allowed values. Don't say "this parameter indicates", just say "Indicates". Probably you can combine the "Can be ... TRUE" with the explanation of what TRUE means, something like:
Possible values: NULL, 'gz', 'bz2', or TRUE (equivalent to 'gz').
Actually, these would be even better as a list that explains what they mean.

lars toomre’s picture

The '@param mixed' style also needs to be changed to the preferred format '@param NULL|bool|string'.

pillarsdotnet’s picture

Status: Needs work » Needs review
StatusFileSize
new0 bytes

Re-rolled as requested.

Actually, just about every docblock in the entire file is non-compliant, because it was imported from PEAR with only minor edits. But as webchick says, "When in doubt, do what PEAR does."

lars toomre’s picture

However, a zero byte patch will not change anything!

pillarsdotnet’s picture

StatusFileSize
new1.63 KB

Bah! Sorry.

lars toomre’s picture

Reading the revised docblock documentation, I wonder what will happen if one were to specify $p_compress as FALSE. This is no fault of the revised documentation. However, it points out the problem with partial/incomplete code paths. Could this be revised to be more clear?

pillarsdotnet’s picture

StatusFileSize
new1.72 KB

(sigh)

        if (($p_compress === null) || ($p_compress == '')) {

Since FALSE == '', I would say that FALSE is treated the same way as NULL; i.e. "No compression is required."

Re-rolled; the more I look at the code in this file the less I like it, but jhodgdon said:

Cleaning up a whole file like this , AS YOU WELL KNOW pillarsdotnet, is not OK at this time.

So I won't try.

jhodgdon’s picture

Status: Needs review » Needs work

One more thing I just noticed -- the /** and the * lines do not line up according to our standards on this function.

And this line still needs a period at the end:

+    *   The name of the tar archive to create

Also, the standards at http://drupal.org/node/1354#functions do not include "true|false" but instead "bool" for return value docs. I am not sure what we should do about NULL though -- using a lower-case "null" doesn't seem right, but we don't have a standard...

pillarsdotnet’s picture

Status: Needs work » Needs review
StatusFileSize
new1.84 KB

One more thing I just noticed -- the /** and the * lines do not line up according to our standards on this function.

Re-rolled. You do realize, of course, that every single docblock in that file has the same problem. But we're only going to fix the one. I should open separate issues for each of the other ones, with a day or two delay between each one. Maybe webchick won't notice. ;->

Also, the standards at http://drupal.org/node/1354#functions do not include "true|false" but instead "bool" for return value docs. I am not sure what we should do about NULL though -- using a lower-case "null" doesn't seem right, but we don't have a standard...

Thanks for answering question #3 in #711918-56. (recording for future reference...)

Okay; I dunno what to do about NULL either. Seems to me that would be a case for using mixed but I'm just a confused neophyte, not a rule-maker.

lars toomre’s picture

Status: Needs review » Needs work

There are several functions in core that have a @return profile of whatever (string, int, object) | FALSE | NULL. How should these be documented when TRUE is never returned and hence should never be considered a valid return value? In such cases, FALSE seems more appropriate than bool.

In this case though, it seems like '@return bool' is appropriate since both are valid return values.

pillarsdotnet’s picture

Status: Needs work » Needs review
StatusFileSize
new1.91 KB

What? it returns an Archive_Tar object, not TRUE or FALSE

pillarsdotnet’s picture

Issue summary: View changes

Linked to relevant section of coding standards.

pillarsdotnet’s picture

Issue summary: View changes

Added the remaining gripes.

pillarsdotnet’s picture

StatusFileSize
new1.91 KB

Oh; I see. you were talking about @param not @return.

Re-rolled again. Shame, shame, shame on me for ever thinking I could get this right in one try.

jhodgdon’s picture

See http://drupal.org/node/1295500#comment-5068622 for a discussion of the reformatting (in this case, I would only reformat the docblocks for the file at a time when disruptions are OK, or on an individual basis when there is a doc problem)....

Come to think of it, this whole issue is just about formatting of that one docblock anyway. Maybe we should postpone this whole reformat, and do the whole file at once, during the first week in November?

Sigh. If the people who added this to Drupal Core had followed the standards in the first place....

pillarsdotnet’s picture

Sigh. If the people who added this to Drupal Core had followed the standards in the first place....

This file was basically copied from PEAR sources, and as webchick says, "When in doubt, do as PEAR does."

I get the impression that it was originally supposed to be as close to the original PEAR source as possible, so that if/when the upstream PEAR sources get updated, it would be easy to merge the updates here, as well.

jhodgdon’s picture

Angie/webchick may say "when in doubt, do what PEAR does", but our expressed doc/coding standards are not the same as that project's doc standards.

Anyway, if we're trying to maintain this to be the same as PEAR as possible, then we should just leave it as-is and maybe put a note at the top of the file noting that? I'm sure we don't alter JQuery files and other things that we import from other projects... we probably shouldn't alter this either, but just be aware that it isn't "our" code?

pillarsdotnet’s picture

Dunno. PEAR is pretty stagnant; I imagine that the original expectation that we would be updating from it is probably unfounded. But yes, this should be discussed.

jhodgdon’s picture

Status: Needs review » Postponed

Can you ping someone with authority on this in IRC to get some opinions on whether we should be trying to update any coding/docs standards in this section of the code then? Postponing until I hear back...

pillarsdotnet’s picture

pillarsdotnet’s picture

Status: Postponed » Closed (won't fix)

Pinged sun -- setting to "won't fix" until I get a response, since it appears a decision has already been made.

Opened #1298304: [Meta] Move all externally-developed files to core/vendor/{vendorname}/ directories

pillarsdotnet’s picture

Issue summary: View changes

Link to the current patch.