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

Some JSHint fixes #458

Merged
merged 6 commits into from
Dec 2, 2014
Merged

Some JSHint fixes #458

merged 6 commits into from
Dec 2, 2014

Conversation

jerone
Copy link
Contributor

@jerone jerone commented Nov 28, 2014

Handled code issues:

Not handled:

  • Unused parameter variables.
  • Lots of unused variables isPro, isDev & isDbg. +/-90% of the files have one these unused variables…
  • User.edit still contains a lot of bugs, but this function is never used.
  • Empty code blocks.
  • Indentation
  • Whitespace

No functionality should have been changed!

Node modules are ignored.

Ref #406

A change to get the code to a higher level of quality and consistency.

@jerone jerone added PR READY This is used to indicate that a pull request (PR) is ready for evaluation. CODE Some other Code related issue and it should clearly describe what it is affecting in a comment. labels Nov 28, 2014
@@ -126,7 +126,7 @@ exports.findDeadorAlive = function (aModel, aQuery, aUser, aCallback) {
return aCallback(false, null, aRemoved);
}

aCallback(false, new model(aRemoved.content), aRemoved); // TODO: Ambiguous
aCallback(false, new aModel(aRemoved.content), aRemoved); // TODO: Ambiguous
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably fixes a bug. Good find.

Copy link
Member

Choose a reason for hiding this comment

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

@jerone since you have appeared to resolve the ambiguity please remove the line note too associated with this fix. Won't be available until tomorrow eve for a little bit but looks good so far. Thanks.

@Martii
Copy link
Member

Martii commented Dec 1, 2014

hmmm direct pr checkout out of this doesn't let me edit my profile at http://localhost:8080/users/Marti e.g. it doesn't think that it's me.

@Martii
Copy link
Member

Martii commented Dec 1, 2014

Remaining sequential local merge of current master (50589f1), 451, 455 then 458 causes merge conflict.

@jerone
Copy link
Contributor Author

jerone commented Dec 1, 2014

@Martii commented on 1 dec. 2014 08:56 CET:

hmmm direct pr checkout out of this doesn't let me edit my profile at http://localhost:8080/users/Marti e.g. it doesn't think that it's me.

Will check tonight. Thnx for testing.

@jerone
Copy link
Contributor Author

jerone commented Dec 1, 2014

Ok, found the problem: https://github.com/OpenUserJs/OpenUserJS.org/pull/458/files#diff-664f851728e6fc6ec664075df484505cR246
authedUser._id is a string, while user._id is actually an object with among others a method toString(). Also user has the property user.id available, while authedUser doesn't. Both are from the model User.
The problem I think is that user is serialized, because it comes from the session.

This problem is a little bit bigger then I hoped it was and requires some discussion (not here) about a real solution. Because of that I'll revert all authedUser._id === user._id back changes to authedUser._id == user._id.

Some reading:

@Martii
Copy link
Member

Martii commented Dec 1, 2014

Needs master merge as I said above at #458 (comment) and complete retesting here.

…into jshint

Conflicts:
	controllers/admin.js
	controllers/user.js
@Martii
Copy link
Member

Martii commented Dec 1, 2014

I appear not to "own" my script at http://localhost:8080/scripts/Marti/uso_-_Count_Issues/source e.g. it says "Submit Code as Fork" instead of "Submit Code".

@sizzlemctwizzle
Copy link
Member

Leave all equality checks alone. When == or != are used, it was done intentionally. Defer to the programmer's judgement for this instead of blindly following convention and risk breaking things.

@Martii
Copy link
Member

Martii commented Dec 1, 2014

I kind of figured that... but I thought I'd give JSHint one last try... I'd still rather see these things split up into smaller chunks... e.g. we do need the semicolon fixes and probably a few other misc TODO fixes... but in separate PRs... I'd do cherry picking distinct commits but that is on hold since it allows chaining changes which sometimes those might need to be discussed first.

Anywho my fakes3 crashed in another console tab which is why I was having issues a few moments ago... reverted that system level patch and it's okay now.

@Martii Martii removed the PR READY This is used to indicate that a pull request (PR) is ready for evaluation. label Dec 1, 2014
@@ -122,7 +121,7 @@ exports.callback = function (aReq, aRes, aNext) {
if (openIdStrategies[strategy]) {
strategyInstance._verify = function (aId, aDone) {
verifyPassport(aId, strategy, username, aReq.session.user, aDone);
}
};
Copy link
Member

Choose a reason for hiding this comment

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

+1 here

@@ -50,7 +50,7 @@ function removeable(aModel, aContent, aUser, aCallback) {
exports.removeable = removeable;

function remove(aModel, aContent, aUser, aReason, aCallback) {
var remove = new Remove({
var removeModel = new Remove({
Copy link
Member

Choose a reason for hiding this comment

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

-0+ here... JSHint specific I think.

@Martii Martii mentioned this pull request Dec 2, 2014
@Martii
Copy link
Member

Martii commented Dec 2, 2014

I'm -1 on using == in favor of ===. It's always possible to convert to the same datatype.

@jerone
So after you update this again you'll need to convert and retest all of them then. You still need to test all the logic paths but so will I (even though you are just about stopping my potential prs due to retesting). e.g. because this encompasses more than one thing ... it's still quite possible this will be closed and possibly cherry picked for items that need to be done versus what JSHint thinks should be done. Because of our STYLEGUIDE I'm not exactly thrilled with the derivation in some of the == vs === myself... I prefer not using === in my own code because it is lengthy and detracts from JavaScript's uniqueness as a whole... but that's my opinion. Some of these fixes are from older code when things weren't made clear to everyone contributing... so the ball is in your court with this PR... What do you want to do?

@jerone
Copy link
Contributor Author

jerone commented Dec 2, 2014

I reverted all === comparison that touch objects coming from the database because of #458 (comment)

@@ -234,7 +233,6 @@ exports.getMeta = function (aChunks, aCallback) {
// get the user script header.
var str = '';
var i = 0;
var len = aChunks.length;
var header = null;

for (; i < aChunks.length; ++i) {
Copy link
Member

Choose a reason for hiding this comment

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

Just as a FYI I see an incomplete optimization from someone here which is why JSHint plucked line 237 out.

@Martii
Copy link
Member

Martii commented Dec 2, 2014

Fully retested on dev usage at this point... just need only a PR READY when you are and I'll give it a +1

@jerone jerone added the PR READY This is used to indicate that a pull request (PR) is ready for evaluation. label Dec 2, 2014
Martii added a commit that referenced this pull request Dec 2, 2014
Some JSHint fixes

+1 merge
@Martii Martii merged commit 8fdba9a into OpenUserJS:master Dec 2, 2014
@Martii Martii added bug You've guessed it... this means a bug is reported. and removed PR READY This is used to indicate that a pull request (PR) is ready for evaluation. labels Dec 2, 2014
@jerone jerone deleted the jshint branch December 2, 2014 21:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug You've guessed it... this means a bug is reported. CODE Some other Code related issue and it should clearly describe what it is affecting in a comment.
Development

Successfully merging this pull request may close these issues.

4 participants