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: Logical-and is counted in complexity rule (fixes #8535) #9754

Merged
merged 2 commits into from Dec 23, 2017

Conversation

platinumazure
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

See #8535.

What changes did you make? (Give an overview)

Logical-and now counts the same as logical-or for increasing cyclomatic complexity in a function. (a && b is the same as !(!a || !b), so either operator should increase complexity)

Since this change will result in strictly non-decreasing complexity, this will result in more warnings reported, hence "Update".

Is there anything you'd like reviewers to focus on?

Not really.

@platinumazure platinumazure added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules labels Dec 22, 2017

// Avoiding &&
if (node.operator === "||") {
if (node.operator === "&&" || node.operator === "||") {
Copy link
Member

Choose a reason for hiding this comment

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

Could this if statement be removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact, I can remove the whole function!

@platinumazure
Copy link
Member Author

@not-an-aardvark Please take another look, at your convenience. Thanks!

@platinumazure
Copy link
Member Author

Closing/reopening to attempt another AppVeyor build.

@gyandeeps gyandeeps merged commit 75c7419 into master Dec 23, 2017
@gyandeeps gyandeeps deleted the complexity branch December 23, 2017 19:02
@10xLaCroixDrinker
Copy link

This was a breaking change

@j-f1
Copy link
Contributor

j-f1 commented Jan 8, 2018

@jking90 ESLint’s policy is that a minor release can break your build, and they recommend using ~ to specify the version you require, instead of the default ^.

@10xLaCroixDrinker
Copy link

@j-f1 thanks for clarifying

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants