Skip to content

Clean up encoder.go #703

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Clean up encoder.go #703

wants to merge 1 commit into from

Conversation

shuheiktgw
Copy link
Collaborator

@shuheiktgw shuheiktgw commented Apr 22, 2025

While working on another issue, I noticed a few minor problems in encoder.go. I could include the fixes in the same PR, but I thought it would be better to create a separate PR for easier review.

  • defer statements can be placed inside the if statement
  • Some variables are shadowing external functions or variables

  • Describe the purpose for which you created this PR.
  • Create test code that corresponds to the modification

@shuheiktgw shuheiktgw requested a review from Copilot April 22, 2025 06:15
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses minor cleanup improvements in encoder.go and struct.go, focusing on reducing variable shadowing and simplifying defer statements.

  • Renames local variables (e.g., "structField" to "sf" and "structFieldMap" to "fieldMap") to avoid shadowing external declarations.
  • Refactors defer statement placement in encode.go for improved clarity in indentation management.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
struct.go Renamed variables to prevent shadowing and clarify struct field usage.
encode.go Adjusted defer logic for indentation and renamed local variables for clarity.
Comments suppressed due to low confidence (2)

struct.go:47

  • [nitpick] The abbreviation 'sf' may be unclear to some readers; consider using a more descriptive name (e.g., 'structField') while ensuring external shadowing is still avoided.
sf := &StructField{

encode.go:819

  • [nitpick] Using 'sf' here might reduce clarity in the encoding logic; a more descriptive name (such as 'fieldData' or 'structField') could improve readability.
sf := fieldMap[field.Name]

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 91.66667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 77.86%. Comparing base (d1e3460) to head (6c4b4af).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #703      +/-   ##
==========================================
- Coverage   77.89%   77.86%   -0.03%     
==========================================
  Files          22       22              
  Lines        7965     7957       -8     
==========================================
- Hits         6204     6196       -8     
  Misses       1348     1348              
  Partials      413      413              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants