-
Notifications
You must be signed in to change notification settings - Fork 756
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
Conversation
As an aside: is there a way to add an extra ESLint rule to
Would the team be open to ejecting from standard to add, for example, |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
lib/runBlockchain.js
Outdated
@@ -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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing
lib/stateManager.js
Outdated
* @param {Set} address | ||
* @param {cb} function | ||
* @param {Set} addresses a set of addresses | ||
* @param {Function} cb the callback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
38077a1
to
4c793dc
Compare
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} |
There was a problem hiding this comment.
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.
Thanks for the review, I'll update this today |
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... |
Updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks!
This PR updates a few of the JSDoc comments that were incorrectly listing the arguments of the functions they were documenting.