chore: Simplify JSON marshaling for RepositoryRulesetRules by alexandear · Pull Request #3875 · google/go-github

@alexandear

The optimization in the RepositoryRulesetRules.MarshalJSON hurts readability and maintainability. I propose removing it because the append function is smart enough to allocate memory efficiently.

@alexandear

@alexandear

@codecov

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.44%. Comparing base (1830689) to head (6286ea6).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
github/rules.go 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3875   +/-   ##
=======================================
  Coverage   92.44%   92.44%           
=======================================
  Files         200      200           
  Lines       14494    14502    +8     
=======================================
+ Hits        13399    13407    +8     
  Misses        895      895           
  Partials      200      200           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

gmlewis

Choose a reason for hiding this comment

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

@gmlewis gmlewis changed the title refactor: Simplify JSON marshaling for RepositoryRulesetRules chore: Simplify JSON marshaling for RepositoryRulesetRules

Dec 11, 2025