flake8
JSHint
-
Warning: Showing 30 of 107 failures.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Review Request #9540 — Created Jan. 26, 2018 and discarded
This extension will allow users to capture short (3-5 second) videos of themselves, which are then encoded as animated GIFs client-side, and then uploaded and embedded into a comment on a code review.
The extension is now fully implemented for pop-over comments.
The gif.js library and worker (which are excluded from review) can be found here: https://github.com/jnordberg/gif.js/tree/master/dist
They should be placed in\static\js\lib\gif.js
and\static\js\lib\gif.worker.js
Test comments were posted on dummy reviews
Tried canceling out of recording in both preview and recording states by clicking cancel, unchecking and rechecking Enable Markdown
Tested extension functions in Chrome, Edge, and Firefox
Description | From | Last Updated |
---|---|---|
Can you edit the description to explain where to get js/lib/gif.js ? |
david | |
E302 expected 2 blank lines, found 1 |
reviewbot | |
E302 expected 2 blank lines, found 1 |
reviewbot | |
E261 at least two spaces before inline comment |
reviewbot | |
W292 no newline at end of file |
reviewbot | |
Col: 60 Missing semicolon. |
reviewbot | |
Col: 31 Expected '{' and instead saw 'return'. |
reviewbot | |
Col: 32 Expected '{' and instead saw 'return'. |
reviewbot | |
Col: 32 Expected '{' and instead saw 'console'. |
reviewbot | |
Col: 88 Missing semicolon. |
reviewbot | |
Col: 91 Missing semicolon. |
reviewbot | |
Col: 152 Missing semicolon. |
reviewbot | |
Col: 204 Missing semicolon. |
reviewbot | |
Col: 250 Missing semicolon. |
reviewbot | |
Col: 292 Missing semicolon. |
reviewbot | |
Col: 304 Missing semicolon. |
reviewbot | |
Col: 438 Expected '===' and instead saw '=='. |
reviewbot | |
Col: 560 Missing semicolon. |
reviewbot | |
Col: 314 Missing semicolon. |
reviewbot | |
Col: 467 Expected '{' and instead saw 'return'. |
reviewbot | |
Col: 487 Expected '{' and instead saw 'return'. |
reviewbot | |
Col: 560 Expected an identifier and instead saw '='. |
reviewbot | |
Col: 560 Expected an assignment or function call and instead saw an expression. |
reviewbot | |
Col: 561 Missing semicolon. |
reviewbot | |
Col: 580 Expected an assignment or function call and instead saw an expression. |
reviewbot | |
Col: 581 Missing semicolon. |
reviewbot | |
Col: 673 Missing semicolon. |
reviewbot | |
Col: 695 Missing semicolon. |
reviewbot | |
Col: 715 Missing semicolon. |
reviewbot | |
Col: 738 Expected '===' and instead saw '=='. |
reviewbot | |
Col: 720 'i' was used before it was defined. |
reviewbot | |
Col: 785 Expected '{' and instead saw 's'. |
reviewbot | |
Col: 801 Missing semicolon. |
reviewbot | |
Col: 942 Missing semicolon. |
reviewbot | |
Col: 1216 Expected '{' and instead saw 'throw'. |
reviewbot | |
E265 block comment should start with '# ' |
reviewbot | |
E501 line too long (90 > 79 characters) |
reviewbot | |
E501 line too long (80 > 79 characters) |
reviewbot | |
Col: 65 Missing semicolon. |
reviewbot | |
Col: 13 '$previewImage' is defined but never used. |
reviewbot | |
Col: 13 '$previewVideo' is defined but never used. |
reviewbot | |
Col: 13 '$startButton' is defined but never used. |
reviewbot | |
Col: 13 '$stopButton' is defined but never used. |
reviewbot | |
Col: 13 '$saveButton' is defined but never used. |
reviewbot | |
Col: 9 Do not use 'new' for side effects. |
reviewbot | |
Col: 5 'GifRecorder' is defined but never used. |
reviewbot | |
Col: 60 Missing semicolon. |
reviewbot | |
Col: 31 Expected '{' and instead saw 'return'. |
reviewbot | |
Col: 32 Expected '{' and instead saw 'return'. |
reviewbot | |
Col: 5 'GifEncoderAbstraction' was used before it was defined. |
reviewbot | |
Col: 32 Expected '{' and instead saw 'console'. |
reviewbot | |
Col: 88 Missing semicolon. |
reviewbot | |
Col: 91 Missing semicolon. |
reviewbot | |
Col: 152 Missing semicolon. |
reviewbot | |
Col: 204 Missing semicolon. |
reviewbot | |
Col: 250 Missing semicolon. |
reviewbot | |
Col: 292 Missing semicolon. |
reviewbot | |
Col: 304 Missing semicolon. |
reviewbot | |
Col: 314 Missing semicolon. |
reviewbot | |
Col: 438 Expected '===' and instead saw '=='. |
reviewbot | |
Col: 467 Expected '{' and instead saw 'return'. |
reviewbot | |
Col: 560 Missing semicolon. |
reviewbot | |
Col: 560 Expected an identifier and instead saw '='. |
reviewbot | |
Col: 561 Missing semicolon. |
reviewbot | |
Col: 581 Missing semicolon. |
reviewbot | |
Col: 487 Expected '{' and instead saw 'return'. |
reviewbot | |
Col: 560 Expected an assignment or function call and instead saw an expression. |
reviewbot | |
Col: 580 Expected an assignment or function call and instead saw an expression. |
reviewbot | |
E501 line too long (90 > 79 characters) |
reviewbot | |
E501 line too long (80 > 79 characters) |
reviewbot | |
Col: 9 Do not use 'new' for side effects. |
reviewbot | |
Col: 7 'GifRecorder' is defined but never used. |
reviewbot | |
Col: 60 Missing semicolon. |
reviewbot | |
Col: 60 Missing semicolon. |
reviewbot | |
Col: 31 Expected '{' and instead saw 'return'. |
reviewbot | |
Col: 32 Expected '{' and instead saw 'return'. |
reviewbot | |
Col: 46 Missing semicolon. |
reviewbot | |
Col: 5 'GifEncoderAbstraction' was used before it was defined. |
reviewbot | |
Col: 32 Expected '{' and instead saw 'console'. |
reviewbot | |
Col: 88 Missing semicolon. |
reviewbot | |
Col: 91 Missing semicolon. |
reviewbot | |
Col: 152 Missing semicolon. |
reviewbot | |
Col: 204 Missing semicolon. |
reviewbot | |
Col: 250 Missing semicolon. |
reviewbot | |
Col: 292 Missing semicolon. |
reviewbot | |
Col: 304 Missing semicolon. |
reviewbot | |
Col: 314 Missing semicolon. |
reviewbot | |
Col: 438 Expected '===' and instead saw '=='. |
reviewbot | |
Col: 467 Expected '{' and instead saw 'return'. |
reviewbot | |
Col: 487 Expected '{' and instead saw 'return'. |
reviewbot | |
Col: 560 Missing semicolon. |
reviewbot | |
Col: 561 Missing semicolon. |
reviewbot | |
Col: 580 Expected an assignment or function call and instead saw an expression. |
reviewbot | |
Col: 581 Missing semicolon. |
reviewbot | |
Col: 673 Missing semicolon. |
reviewbot | |
Col: 715 Missing semicolon. |
reviewbot | |
Col: 720 'i' was used before it was defined. |
reviewbot | |
Col: 560 Expected an identifier and instead saw '='. |
reviewbot | |
Col: 560 Expected an assignment or function call and instead saw an expression. |
reviewbot | |
Col: 695 Missing semicolon. |
reviewbot | |
Col: 9 Do not use 'new' for side effects. |
reviewbot | |
Col: 7 'GifRecorder' is defined but never used. |
reviewbot | |
Col: 60 Missing semicolon. |
reviewbot | |
Col: 46 Missing semicolon. |
reviewbot | |
Col: 5 'GifEncoderAbstraction' was used before it was defined. |
reviewbot | |
Why is this change necessary, out of curiosity? It looks unrelated to your project. |
mike_conley | |
What kind of configurability are you envisioning here? The "For now" comment doesn't give us much to work with - … |
mike_conley | |
Where is this file? I don't see it in the patch. |
mike_conley | |
What is the strange bug in Chrome? |
mike_conley | |
Please remove this newline. |
mike_conley | |
Please remove this newline. |
mike_conley | |
Can you please document each of these functions? |
mike_conley | |
Please remove this newline. |
mike_conley | |
This is how we generally do this sort of thing: https://github.com/reviewboard/reviewboard/blob/b637ecfcfff04fbe493fb6186e7be4af5745503e/reviewboard/static/rb/js/newReviewRequest/views/preCommitView.js#L10-L54 Note that it's important to keep the indentation for … |
mike_conley | |
I noticed that you're putting the strings for other things inside GIF_COMMENT_UI_STRINGS. Why not these as well? |
mike_conley | |
You don't need to set a value to the disabled attribute. |
mike_conley | |
Can you invert this condition, so that we return if $mainContainer.length > 0, and then otherwise continue on below? |
mike_conley | |
Space after // |
mike_conley | |
Please remove this newline. |
mike_conley | |
Please remove this newline, and the one at the end of the function. |
mike_conley | |
Col: 9 Do not use 'new' for side effects. |
reviewbot | |
Please remove this newline. |
mike_conley | |
Space after // |
mike_conley | |
Col: 7 'GifRecorder' is defined but never used. |
reviewbot | |
Trailing whitespace |
mike_conley | |
Space after // |
mike_conley | |
Let's format this: navigator.mediaDevices.getUserMedia({ video: VIDEO_CONFIG, audio: false }).then(this.displayMediaStream.bind(this)) .catch(this.displayMediaStreamError.bind(this)); |
mike_conley | |
Please remove this extra newline. |
mike_conley | |
Please remove this dead code. |
mike_conley | |
These extra newlines can go. |
mike_conley | |
Col: 5 'GifEncoderAbstraction' was used before it was defined. |
reviewbot | |
Extra newline can be removed. |
mike_conley | |
Extra newline can be removed. |
mike_conley | |
Maybe mention that they can be attached to Review Board comments, so: Record GIFs from your webcam and attach them … |
mike_conley | |
Col: 7 'GifRecorder' is defined but never used. |
reviewbot | |
Col: 27 Expected '!==' and instead saw '!='. |
reviewbot | |
E501 line too long (89 > 79 characters) |
reviewbot | |
Please add a docstring. |
david | |
Please add a docstring. |
david | |
Please add a docstring. |
david | |
Add another blank line here. |
david | |
This only works with the default static media path. This should instead be: (at the top) from django.contrib.staticfiles.templatetags.staticfiles import static … |
david | |
Add a trailing comma here. |
david | |
This should probably also be const instead of var |
david | |
Doc comments like this should be in a very similar format to python docstrings. Only major difference is in the … |
david | |
Since this is ES6 we can use member function sugar: injectUiIfNotInDom() { } This should probably also have "UI" and … |
david | |
This can make use of the dedent JS template string processor: ``javascript const mainContainerHtml = dedent <div class="gif-container"> <div style="max-height: … |
david | |
Instead of doing function() {}.bind(this), you can use a fat arrow function, which have lexical scoping for this: $saveButton.click(ev => … |
david | |
This can be const. |
david | |
This blank line can go away. |
david | |
This blank line can go away. |
david | |
Please fix up formatting of this docstring to match our doc standards. |
david | |
Use ES6 member function sugar. |
david | |
Please fix up formatting of this docstring to match our doc standards. |
david | |
Use ES6 member function sugar. |
david | |
Please fix docstring syntax. |
david | |
Use ES6 member function sugar. |
david | |
Instead of using inline style here, please just put it in the LESS file for the .gifcomment-control-open class. Also, please … |
david | |
This is a good place to use a fat arrow function. |
david | |
Join these two lines together. |
david | |
This is a good place to use a fat arrow function. |
david | |
This should use jquery accessors: this.$toggleMainContainerButton .prop('disabled', !$enableMarkdownCheckbox.prop('checked')); |
david | |
Since it's only used once, you can skip assigning this to a name. This is also a good place to … |
david | |
Add another blank line. |
david | |
Can use ES6 function sugar. |
david | |
We're moving away from _super because it has some issues. This should just be explicit: RB.Extension.prototype.initialize.call(this) |
david | |
Add a trailing comma. |
david | |
Add a trailing comma. |
david | |
This isn't an ES6 file so it needs to use var. Or you could change it to be .es6.js. |
david | |
Col: 7 'GifRecorder' is defined but never used. |
reviewbot | |
E501 line too long (97 > 79 characters) |
reviewbot | |
E501 line too long (92 > 79 characters) |
reviewbot | |
Col: 7 'GifRecorder' is defined but never used. |
reviewbot | |
This was probably copied from other code, but it uses an old format for docstrings. See https://www.notion.so/reviewboard/Writing-Codebase-Documentation-e16312b5f061437cb73cbfa369ac3cb5 |
david | |
Just confirming , if there's a micro or patch, we still bump up the micro version? |
FL floriecai | |
Single quotes |
david | |
Same here. |
david | |
Same here. |
david | |
The summary line of doc comments should be in the imperative mood (Create) rather than passive (Creates) |
david | |
Wrap to 80 columns |
david | |
Should be in the format of: Returns: jQuery: The newly created or previously existing DOM element... See https://www.notion.so/reviewboard/Writing-Codebase-Documentation-e16312b5f061437cb73cbfa369ac3cb5 |
david | |
Blank line after this. |
david | |
Blank line after this. |
david | |
This should be: ``javascript dedent <div class="gif-container"> </div> `; |
david | |
Should be imperative mood ("Display") |
david | |
Should be imperative mood ("Close") |
david | |
Blank line after this. |
david | |
Do we have string localization in our js code? |
FL floriecai | |
Blank line after this. |
david | |
Should be imperative mood ("Inject") |
david | |
Wrap to 80 columns. |
david | |
There's an extra space character at the end of this line. |
david | |
ditto about localization |
FL floriecai | |
Blank line after this. |
david | |
Blank line after this. |
david | |
Blank line after this. |
david | |
Blank line after this. |
david | |
Add a doc comment? |
david | |
Should be imperative mood ("Create") |
david | |
Should use "Args:" and "Returns:" format as described in our codebase docs guide. |
david | |
Blank line after this. |
david | |
Trailing comma. |
david | |
Adds -> Add |
david | |
Should use Args/Returns |
david | |
Renders -> Render |
david | |
Should use Args/Returns |
david | |
Col: 7 'GifRecorder' is defined but never used. |
reviewbot | |
Checks -> Check Returns: boolean: Whether the current browser has the getUserMedia function. |
david | |
Displays -> Display |
david | |
Args: |
david | |
Initializes -> Initialize |
david | |
Shutdowns -> Shut down the |
david | |
Triages and displays -> Triage and display |
david | |
Wrap to 80 columns. We should also probably use dedent... here. |
david | |
Should be } else { |
david | |
Pops up -> Pop up |
david | |
Let's wrap as: navigator.mediaDevices.getUserMedia({ ... }) .then(...) .catch(...); |
david | |
Trailing comma. |
david | |
Renders -> Render |
david | |
Args: |
david | |
Can be: this.$previewVideo.onloadedmetadata = () => { this.startRecButton.disabled = false; } |
david | |
Enables -> Enable |
david | |
Enables -> Enable These two lines also need to be indented 1 more space. |
david | |
Disables -> Disable |
david | |
Updates -> Update |
david | |
Args: |
david | |
Starts -> Start |
david | |
Blank line after this. |
david | |
Wrap to 80 columns. |
david | |
Stops -> Stop |
david | |
Blank line after this. |
david | |
Use a fat arrow function instead of function(blob) {}.bind(this) |
david | |
Args: |
david | |
Wrap to 80 columns |
david | |
These should be indented 4 spaces (currently they're indented 1). |
david | |
This can be const-- or even better, just do return new GIF({ ... }); |
david | |
Col: 7 'GifRecorder' is defined but never used. |
reviewbot | |
Same here as my previous comment regarding indentation with dedent |
david |
Revision 2 (+462)
Warning: Showing 30 of 116 failures.
This extension will allow users to capture short (3-5 second) videos of themselves, which are then encoded as animated GIFs client-side, and then uploaded and embedded into a comment on a code review. | ||
~ | Currently, I have implemented a workflow in javascript which allows a user to record, stop, and re-record a video. The gif is held as a blob in memory for now. | |
~ | The extension is now fully implemented for pop-over comments. |
~ | Proof of concept was manually tested in a standalone HTML page before it was ported and refactored into the reviewboard extension structure. | |
~ | Test comments were posted on dummy reviews | |
+ | Tried canceling out of recording in both preview and recording states by clicking cancel, unchecking and rechecking Enable Markdown |
Revision 3 (+530)
Warning: Showing 30 of 112 failures.
Test comments were posted on dummy reviews | ||
~ | Tried canceling out of recording in both preview and recording states by clicking cancel, unchecking and rechecking Enable Markdown | |
~ | Tried canceling out of recording in both preview and recording states by clicking cancel, unchecking and rechecking Enable Markdown | |
+ | Tested extension functions in Chrome, Edge, and Firefox |
Revision 4 (+570 -1)
Replaced third-party spinner
Revision 5 (+576 -1)
Hey Roman,
Thanks! I think this looks pretty great. I have some cosmetic issues, but I think the overall architecture makes sense.
See below for questions and suggestions.
-Mike
What kind of configurability are you envisioning here? The "For now" comment doesn't give us much to work with - maybe should remove it for now.
This is how we generally do this sort of thing:
https://github.com/reviewboard/reviewboard/blob/b637ecfcfff04fbe493fb6186e7be4af5745503e/reviewboard/static/rb/js/newReviewRequest/views/preCommitView.js#L10-L54
Note that it's important to keep the indentation for each of the nodes to make it easier to reason about what is parenting what.
I noticed that you're putting the strings for other things inside GIF_COMMENT_UI_STRINGS. Why not these as well?
Can you invert this condition, so that we return if $mainContainer.length > 0, and then otherwise continue on below?
Let's format this:
navigator.mediaDevices.getUserMedia({ video: VIDEO_CONFIG, audio: false }).then(this.displayMediaStream.bind(this)) .catch(this.displayMediaStreamError.bind(this));
Maybe mention that they can be attached to Review Board comments, so:
Record GIFs from your webcam and attach them to Review Board comments!
Addressed review concerns and fixed an edge case bug involving cancelling out of the gif recorder before accepting camera permissions.
Revision 6 (+596)
Revision 7 (+597)
This only works with the default static media path. This should instead be:
(at the top) from django.contrib.staticfiles.templatetags.staticfiles import static (here) @property def js_worker_path(self): return static('ext/%s/js/lib/gif.worker.js' % self.id)
Doc comments like this should be in a very similar format to python docstrings. Only major difference is in the comment syntax:
/** * Create the GIF recording UI. * * ... more explanation ... */
(note the double
**
on the first line and alignment of the*
s)."Returns" should also be a "Returns:" section, and the type it returns is
jQuery
.
Since this is ES6 we can use member function sugar:
injectUiIfNotInDom() { }
This should probably also have "UI" and "DOM" instead of "Ui" and "Dom".
This can make use of the
dedent
JS template string processor:
``javascript const mainContainerHtml = dedent
<div class="gif-container">
<div style="max-height: 85%;">
...
</div>
</div>
`;This way you can avoid all the string concatenation.
Instead of doing
function() {}.bind(this)
, you can use a fat arrow function, which have lexical scoping forthis
:$saveButton.click(ev => { ... });
Instead of using inline style here, please just put it in the LESS file for the
.gifcomment-control-open
class.Also, please try to wrap to 80 columns.
This should use jquery accessors:
this.$toggleMainContainerButton .prop('disabled', !$enableMarkdownCheckbox.prop('checked'));
Since it's only used once, you can skip assigning this to a name. This is also a good place to use a fat arrow function.
We're moving away from
_super
because it has some issues. This should just be explicit:RB.Extension.prototype.initialize.call(this)
Implemented code style and documentation feedback
This extension will allow users to capture short (3-5 second) videos of themselves, which are then encoded as animated GIFs client-side, and then uploaded and embedded into a comment on a code review. | ||
The extension is now fully implemented for pop-over comments. | ||
+ | ||
+ | The gif.js library and worker (which are excluded from review) can be found here: https://github.com/jnordberg/gif.js/tree/master/dist | |
+ | They should be placed in \static\js\lib\gif.js and \static\js\lib\gif.worker.js |
Revision 8 (+734)
Fixed flake8 issues
Revision 9 (+735)
This was probably copied from other code, but it uses an old format for docstrings. See https://www.notion.so/reviewboard/Writing-Codebase-Documentation-e16312b5f061437cb73cbfa369ac3cb5
The summary line of doc comments should be in the imperative mood (Create) rather than passive (Creates)
Should be in the format of:
Returns: jQuery: The newly created or previously existing DOM element...
See https://www.notion.so/reviewboard/Writing-Codebase-Documentation-e16312b5f061437cb73cbfa369ac3cb5
Fixed documentation and improved use of ES6
Revision 10 (+808)
Addressed remaining issues
Revision 11 (+810)