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

Fix for checkForFunctionProperty so that order does not matter #6248

Merged
merged 11 commits into from
Apr 9, 2024

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Mar 22, 2024

Description

Fixes an issue with the implementation of a utility function used in vis_type_vega plugin where order matters when determining if an object has a property that is a function. This PR adds test to assert the desired behavior in multiple scenarios.

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Copy link

codecov bot commented Mar 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.47%. Comparing base (a0eaf84) to head (11d0b2f).
Report is 2 commits behind head on main.

❗ Current head 11d0b2f differs from pull request most recent head a8f7413. Consider uploading reports for the commit a8f7413 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6248      +/-   ##
==========================================
- Coverage   67.56%   67.47%   -0.10%     
==========================================
  Files        3379     3368      -11     
  Lines       65894    65431     -463     
  Branches    10660    10560     -100     
==========================================
- Hits        44522    44147     -375     
+ Misses      18774    18713      -61     
+ Partials     2598     2571      -27     
Flag Coverage Δ
Linux_1 32.14% <100.00%> (-0.49%) ⬇️
Linux_2 55.58% <ø> (-0.04%) ⬇️
Linux_3 44.90% <ø> (-0.10%) ⬇️
Linux_4 35.07% <ø> (+0.08%) ⬆️
Windows_1 32.16% <100.00%> (-0.49%) ⬇️
Windows_2 55.55% <ø> (-0.04%) ⬇️
Windows_3 44.92% <ø> (-0.09%) ⬇️
Windows_4 35.07% <ø> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
@cwperks
Copy link
Member Author

cwperks commented Mar 26, 2024

@ashwin-pc @joshuarrrr Could I get some reviews on this PR?

cwperks and others added 3 commits March 28, 2024 19:53
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Copy link
Member

@SuZhou-Joe SuZhou-Joe left a comment

Choose a reason for hiding this comment

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

LGTM.

@SuZhou-Joe SuZhou-Joe added bug Something isn't working v2.14.0 backport 2.x labels Apr 9, 2024
Copy link
Member

@bandinib-amzn bandinib-amzn left a comment

Choose a reason for hiding this comment

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

LGTM!

@ZilongX ZilongX merged commit b70c327 into opensearch-project:main Apr 9, 2024
66 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 9, 2024
* Fix for checkForFunctionProperty so that order does not matter

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Remove import for inspect

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add to CHANGELOG

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* replace with jest.fn()

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Update CHANGELOG

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add scenarios where object does not contain fn

Signed-off-by: Craig Perkins <cwperx@amazon.com>

---------

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Co-authored-by: SuZhou-Joe <suzhou@amazon.com>
Co-authored-by: ZilongX <99905560+ZilongX@users.noreply.github.com>
(cherry picked from commit b70c327)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
Comment on lines +82 to +89
for (const value of Object.values(object)) {
if (typeof value === 'function') {
return true;
} else if (Utils.isObject(value) && Utils.checkForFunctionProperty(value)) {
return true;
}
}
return false;
Copy link
Member

Choose a reason for hiding this comment

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

@cwperks could we refactory code a little


    for (const value of Object.values(object)) {
      if (typeof value === 'function') return true;
      if (Utils.isObject(value) && Utils.checkForFunctionProperty(value)) return true;
    }
    return false;

ananzh pushed a commit that referenced this pull request Apr 12, 2024
#6384)

* Fix for checkForFunctionProperty so that order does not matter
* Remove import for inspect
* replace with jest.fn()
* Add scenarios where object does not contain fn

---------

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Co-authored-by: SuZhou-Joe <suzhou@amazon.com>
Co-authored-by: ZilongX <99905560+ZilongX@users.noreply.github.com>
(cherry picked from commit b70c327)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants