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

Refactor the contract analyzer #239

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

yuxincs
Copy link
Contributor

@yuxincs yuxincs commented May 4, 2024

This PR simply refactors the contract analyzer to prepare for further updates. Specifically, it

(1) Defines a separate type for []Contract such that it can be made to be exported (i.e., satisfies the analysis.Fact interface) in the future.
(2) Replaces a few places where we were returning initialized empty slices with simple nil. In principle we should not distinguish nil slice vs empty nonnil slice.
(3) Shortens a few variable names to help improve readability without introducing ambiguity (since the variables are all under the functioncontracts package already).
(4) Moved test cases from src/go.uber.org/functioncontracts/xxx to src/go.uber.org/xxx inside functioncontracts package. Those tests are only meant to be used for functioncontracts package, such that an extra folder only increases nesting but does not help test organization.

Note that this PR does not bring any functionality changes.

Copy link

codecov bot commented May 4, 2024

Codecov Report

Attention: Patch coverage is 93.33333% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 87.50%. Comparing base (fe712a8) to head (4c694b0).

Files Patch % Lines
assertion/function/functioncontracts/analyzer.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #239      +/-   ##
==========================================
- Coverage   87.50%   87.50%   -0.01%     
==========================================
  Files          61       61              
  Lines        7798     7795       -3     
==========================================
- Hits         6824     6821       -3     
  Misses        796      796              
  Partials      178      178              

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

Copy link

github-actions bot commented May 4, 2024

Golden Test

Note

✅ NilAway errors reported on standard libraries are identical.

3296 errors on base branch (main, fe712a8)
3296 errors on test branch (8421c56)

@yuxincs yuxincs force-pushed the yuxincs/refactor-function-contract-analyzer branch from ebec5a0 to 045d6f0 Compare May 13, 2024 23:46
@yuxincs yuxincs force-pushed the yuxincs/refactor-function-contract-analyzer branch from 045d6f0 to 4c694b0 Compare May 14, 2024 19:15
Copy link
Contributor

@sonalmahajan15 sonalmahajan15 left a comment

Choose a reason for hiding this comment

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

Looks good. The refactors in this PR make sense to me.

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.

None yet

2 participants