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 nilaway warnings #1571

Merged

Conversation

sarvsav
Copy link
Contributor

@sarvsav sarvsav commented Feb 19, 2024

Why: nilaway identified issues related to nil panics, and for better user experience those needs to be fixed

How: By adding checks for nil value

Tags: nilaway, panics

Changes include

  • Bugfix (non-breaking change that solves an issue)

Closes issue(s)

Resolve #1420

Checklist

Why: nilaway identified issues related to nil panics, and for better
user experience those needs to be fixed

How: By adding checks for nil value

Tags: nilaway, panics
Copy link

netlify bot commented Feb 19, 2024

Deploy Preview for go-feature-flag-doc-preview canceled.

Name Link
🔨 Latest commit 0d61421
🔍 Latest deploy log https://app.netlify.com/sites/go-feature-flag-doc-preview/deploys/65dc9bd16cec2a0007fd0fdd

@sarvsav
Copy link
Contributor Author

sarvsav commented Feb 19, 2024

nilaway updated report:

$ nilaway.exe -include-pkgs="github.com/thomaspoignant/go-feature-flag" ./...
C:\Users\ss\Projects\Go\src\github.com\sarvsav\go-feature-flag\feature_flag.go:231:9: error: Potential nil panic detected. Observed nil flow from source to dereference point: 
        - C:\Users\ss\Projects\Go\src\github.com\sarvsav\go-feature-flag\feature_flag.go:59:5: nilable value assigned into global variable `ff`      
        - C:\Users\ss\Projects\Go\src\github.com\sarvsav\go-feature-flag\feature_flag.go:236:9: global variable `ff` used as receiver to call `GetCacheRefreshDate()`
        - C:\Users\ss\Projects\Go\src\github.com\sarvsav\go-feature-flag\feature_flag.go:231:9: read by method receiver `g` accessed field `cache`   

C:\Users\ss\Projects\Go\src\github.com\sarvsav\go-feature-flag\exporter\data_exporter_test.go:58:18: error: Potential nil panic detected. Observed nil flow from source to dereference point: 
        - C:\Users\ss\Projects\Go\src\github.com\sarvsav\go-feature-flag\exporter\data_exporter_test.go:58:18: unassigned variable `inputEvents` sliced into

C:\Users\ss\Projects\Go\src\github.com\sarvsav\go-feature-flag\exporter\data_exporter_test.go:78:18: error: Potential nil panic detected. Observed nil flow from source to dereference point:
        - C:\Users\ss\Projects\Go\src\github.com\sarvsav\go-feature-flag\exporter\data_exporter_test.go:78:18: unassigned variable `inputEvents` sliced into

C:\Users\ss\Projects\Go\src\github.com\sarvsav\go-feature-flag\exporter\data_exporter_test.go:104:18: error: Potential nil panic detected. Observed nil flow from source to dereference point:
        - C:\Users\ss\Projects\Go\src\github.com\sarvsav\go-feature-flag\exporter\data_exporter_test.go:104:18: unassigned variable `inputEvents` sliced into

C:\Users\ss\Projects\Go\src\github.com\sarvsav\go-feature-flag\exporter\data_exporter_test.go:130:18: error: Potential nil panic detected. Observed nil flow from source to dereference point:
        - C:\Users\ss\Projects\Go\src\github.com\sarvsav\go-feature-flag\exporter\data_exporter_test.go:130:18: unassigned variable `inputEvents` sliced into`

The above reporting is false positive from the tool.

Copy link

codecov bot commented Feb 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.88%. Comparing base (68bbd39) to head (0d61421).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1571      +/-   ##
==========================================
+ Coverage   87.75%   87.88%   +0.12%     
==========================================
  Files          77       77              
  Lines        3627     3640      +13     
==========================================
+ Hits         3183     3199      +16     
+ Misses        361      358       -3     
  Partials       83       83              

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

Copy link
Owner

@thomaspoignant thomaspoignant left a comment

Choose a reason for hiding this comment

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

This looks great, I've proposed some NIT changes.

cmd/relayproxy/main.go Outdated Show resolved Hide resolved
retriever/k8sretriever/retriever.go Outdated Show resolved Hide resolved
@sarvsav
Copy link
Contributor Author

sarvsav commented Feb 19, 2024

This looks great, I've proposed some NIT changes.

Thank you for the quick review, I am addressing the coverage also by writing the test cases. I will share the updated PR soon and remove WIP from the title once is ready for review again.

Copy link

sonarcloud bot commented Feb 26, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@thomaspoignant thomaspoignant merged commit 6834d8c into thomaspoignant:main Feb 26, 2024
21 checks passed
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.

(bug) Generated a report for nil panics using nilaway
2 participants