-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
fix: compare the LogBoxData ignorePatterns with the right code #31977
Conversation
Hi @wiseqingyang! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Base commit: 91cac20 |
Base commit: 91cac20 |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
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 the fix! Can you add a test in LogBoxData-test.js
?
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 the tests!
@yungsters has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@yungsters merged this pull request in a950634. |
Summary: the `LogBoxData.addIgnorePatterns` function shows the wrong code to get a item in `Set`. because every item in `set.entries` looks like `[value, value]`, but not `value`. while the `addIgnorePatterns` function evalutes two itertaions that is not necessary. So I refacted this function. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [General] [Fixed] - for LogBox checking existingPattern in a wrong way. [General] [Changed] - addIgnorePatterns runs in one iteration. [General] [Added] - add a function `getIgnorePatterns` in `LogBoxData.js` for tests or other usecases. Pull Request resolved: #31977 Test Plan: test codes in `LogBoxData-test.js`: ````js it('adding same pattern multiple times', () => { expect(LogBoxData.getIgnorePatterns().length).toBe(0); LogBoxData.addIgnorePatterns(['abc']); expect(LogBoxData.getIgnorePatterns().length).toBe(1); LogBoxData.addIgnorePatterns([/abc/]); expect(LogBoxData.getIgnorePatterns().length).toBe(2); LogBoxData.addIgnorePatterns(['abc']); expect(LogBoxData.getIgnorePatterns().length).toBe(2); LogBoxData.addIgnorePatterns([/abc/]); expect(LogBoxData.getIgnorePatterns().length).toBe(2); }); it('adding duplicated patterns', () => { expect(LogBoxData.getIgnorePatterns().length).toBe(0); LogBoxData.addIgnorePatterns(['abc', /ab/, /abc/, /abc/, 'abc']); expect(LogBoxData.getIgnorePatterns().length).toBe(3); LogBoxData.addIgnorePatterns([/ab/, /abc/]); expect(LogBoxData.getIgnorePatterns().length).toBe(3); }); ```` and they have passed Reviewed By: rickhanlonii Differential Revision: D30675522 Pulled By: yungsters fbshipit-source-id: 4a05e0f04a41d06cac416219f1e8e540bf0eea02
Summary
the
LogBoxData.addIgnorePatterns
function shows the wrong code to get a item inSet
. because every item inset.entries
looks like[value, value]
, but notvalue
.while the
addIgnorePatterns
function evalutes two itertaions that is not necessary. So I refacted this function.Changelog
[General] [Fixed] - for LogBox checking existingPattern in a wrong way.
[General] [Changed] - addIgnorePatterns runs in one iteration.
[General] [Added] - add a function
getIgnorePatterns
inLogBoxData.js
for tests or other usecases.Test Plan
test codes in
LogBoxData-test.js
:and they have passed