Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JSDoc comments to add missing parameters #362

Merged
merged 3 commits into from
Oct 5, 2018

Conversation

whymarrh
Copy link
Contributor

This PR updates a few of the JSDoc comments that were incorrectly listing the arguments of the functions they were documenting.

@whymarrh
Copy link
Contributor Author

As an aside: is there a way to add an extra ESLint rule to standard? From the docs:

If you really want to configure hundreds of ESLint rules individually, you can always use eslint directly with eslint-config-standardd to layer your changes on top. standard-eject can help you migrate from standard to eslint and eslint-config-standard.

Would the team be open to ejecting from standard to add, for example, valid-jsdoc?

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this first PR, some things to discuss and/or update.

I think moving from standard to eslint directly is not an option regarding the added maintenance work. If there is a simple way just to add one rule or the other to standard I would be eventually open to it, but I guess that just contradicts the original idea of the library?

lib/bloom.js Outdated
@@ -6,6 +6,7 @@ const byteSize = 256
* drops leading zeroes from a buffer
* @function dropLeadingZeroes
* @param {Buffer} buff
* @returns {Buffer} a slice of the buffer starting at the first non-zero entry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

lib/bloom.js Outdated
@@ -32,7 +33,7 @@ var Bloom = module.exports = function (bitvector) {
/**
* adds an element to a bit vector of a 64 byte bloom filter
* @method add
* @param {Buffer} element
* @param e - the element
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not really getting the change here. This calls dropLeadingZeroes() which requires a Buffer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, should've kept the type, I'll add that back. The main change is the param name which was incorrect (i.e. s/element/e/).

lib/bloom.js Outdated
* @method check
* @param {Buffer} element
* @param e - the element
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

lib/bloom.js Outdated
* checks if multiple topics are in a bloom
* @method multiCheck
* @param {Buffer} topics
* @returns {boolean} Returns {@code true}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how much consistency we have with this in the code in general, but we should see that we stay with one convention using capital letter at the explanatory comment ("Returns...") or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had noticed that a majority of the @returns clauses started with "Returns" so I'm following that—I can update the comments for consistency in a separate PR if we want?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think that's overblown for now. If you do an update with the other changes that should suffice for now.

lib/opFns.js Outdated
@@ -799,6 +799,7 @@ function trap (err) {
/**
* Subtracts the amount needed for memory usage from `runState.gasLeft`
* @method subMemUsage
* @param runState
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We normally have the convention to just use {Object} as a type if this is the most we can get 😄 (see other documentation in the library). If this is not wrong per se (I am not a super-comment-syntax expert) I would like to keep here with this as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I'll add the type in

lib/opFns.js Outdated
@@ -858,6 +860,7 @@ function memLoad (runState, offset, length) {
* Stores bytes to memory. If an error occurs a string is instead returned.
* The function also subtracts the amount of gas need for memory expansion.
* @method memStore
* @param runState
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

lib/opFns.js Outdated
@@ -829,6 +830,7 @@ function subMemUsage (runState, offset, length) {
* a string is instead returned. The function also subtracts the amount of
* gas need for memory expansion.
* @method memLoad
* @param runState
* @param {BN} offset where to start reading from
* @param {BN} length how far to read
* @return {Buffer|String}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it return or returns?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either is valid, I believe @returns is more prevalent in the codebase from what I see currently

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some @return -> @returns cases which needs to be updated. The following normally wouldn't be a blocker, but if you update please also remove the - from the @param {Buffer} e - the element to check since this introduces a minor inconsistency in the format.

Otherwise this can be merged.

@@ -4,6 +4,7 @@ const async = require('async')
* processes blocks and adds them to the blockchain
* @method onBlock
* @param blockchain
* @param {Function} cb the callback
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

lib/runCall.js Outdated
@@ -10,6 +10,7 @@ const ERROR = exceptions.ERROR
* runs a CALL operation
* @method runCall
* @param opts
* @param cb the callback
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be at the end of the opts.xxx param values (or again, if this is generally wrong, changed everywhere for consistency).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing

* @param {Set} address
* @param {cb} function
* @param {Set} addresses a set of addresses
* @param {Function} cb the callback
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@whymarrh
Copy link
Contributor Author

I think moving from standard to eslint directly is not an option regarding the added maintenance work. If there is a simple way just to add one rule or the other to standard I would be eventually open to it, but I guess that just contradicts the original idea of the library?

Yeah from what I can tell the standardjs setup is quite specific and, as a result, somewhat inflexible. Not moving to ESLint is fine, just thought I'd bring it up as an option for more static analysis.

lib/opFns.js Outdated
@@ -829,6 +830,7 @@ function subMemUsage (runState, offset, length) {
* a string is instead returned. The function also subtracts the amount of
* gas need for memory expansion.
* @method memLoad
* @param runState
* @param {BN} offset where to start reading from
* @param {BN} length how far to read
* @return {Buffer|String}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some @return -> @returns cases which needs to be updated. The following normally wouldn't be a blocker, but if you update please also remove the - from the @param {Buffer} e - the element to check since this introduces a minor inconsistency in the format.

Otherwise this can be merged.

@whymarrh
Copy link
Contributor Author

whymarrh commented Oct 2, 2018

Thanks for the review, I'll update this today

@holgerd77
Copy link
Member

Can this be updated so we can merge? That would be great, PR like this with both a broad scope and low-level changes tend to otherwise cause a disproportionate amount of additional work keeping things up-to-date...

@whymarrh
Copy link
Contributor Author

whymarrh commented Oct 5, 2018

There are some @return -> @returns cases which needs to be updated. The following normally wouldn't be a blocker, but if you update please also remove the - from the @param {Buffer} e - the element to check since this introduces a minor inconsistency in the format.

Updated

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks!

@holgerd77 holgerd77 merged commit 9a3dc04 into ethereumjs:master Oct 5, 2018
@whymarrh whymarrh deleted the update-jsdoc branch October 5, 2018 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants