Skip to content

Fix logical-assignment error handling - #212

Draft
mozfreddyb wants to merge 3 commits into
mainfrom
issue-210
Draft

Fix logical-assignment error handling#212
mozfreddyb wants to merge 3 commits into
mainfrom
issue-210

Conversation

@mozfreddyb

Copy link
Copy Markdown
Collaborator

@mozfreddyb
mozfreddyb requested a review from rpl November 1, 2022 13:56
@mozfreddyb

Copy link
Copy Markdown
Collaborator Author

this is a WIP, but I'd like to you to help me start thinking through this issue (see previous issues, #206 to #210 for context)

@rpl rpl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@mozfreddyb follows some feedback about this PR.

(My apologies for the time I needed to get back to and to take a look into this PR).

Comment thread lib/ruleHelper.js
">>>=", "&=", "|=", "^="];

// operators where we don"t know the result of a logical expression, which may result in the code executing the left or the right part of the assignmentcan check the left bit:
const LOGICAL_OPERATOS = ["||=", "&&=", "??="];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo: OPERATOS => OPERATORS

Comment thread lib/ruleHelper.js
Comment on lines +279 to +281
// Issue #210: oh, no! we have two methods names we need to check, but this function
// may only return one. it's not immediately clear how to reconcile that with existing callers of normalizeMethodCall.
methodName = "";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

// Issue #210: oh, no! we have two methods names we need to check, but this function
may only return one. it's not immediately clear how to reconcile that with existing callers of normalizeMethodCall.

how about changing this method to return an array of method names and on the caller side to expect an array to be always returned and iterate on that array to check all method names returned?

Comment thread lib/ruleHelper.js
}
else {
// this is the forcing function for us to complain about and implement support if new JS operators come up.
this.reportUnsupported(node, "Unexpected callable", `unexpected assignment with operator '${node.operator}' in normalizeMethodCall`);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thought: I think that we may be able to cover this branch with a test case using that parser: require.resolve("../parsers/fantasy-operator") approach we used in some other test cases in the past for similar reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unexpected AssignmentExpression in normalizeMethodCall

2 participants