Skip to content

docs: extend CONTRIBUTING.md with code guidelines#4202

Open
jlaportebot wants to merge 1 commit intogoogle:masterfrom
jlaportebot:docs/extend-contributing-guidelines
Open

docs: extend CONTRIBUTING.md with code guidelines#4202
jlaportebot wants to merge 1 commit intogoogle:masterfrom
jlaportebot:docs/extend-contributing-guidelines

Conversation

@jlaportebot
Copy link
Copy Markdown

Summary

This PR extends CONTRIBUTING.md with a comprehensive section on code guidelines and conventions, addressing issue #4023.

Changes

Added a new "Code Guidelines" section that documents:

  1. Naming Conventions

    • File names ({service}_{api}.go pattern)
    • Receiver names (consistently use 's')
    • Request option types
    • Request body types
    • Response types
    • Method and variable naming
    • Common variable names (owner, repo, org, user, team, project)
    • Enterprise and organization scoped methods
    • Common structs (ListOptions, ListCursorOptions, UploadOptions, Response)
  2. JSON Tags for Request Bodies

    • Required fields: non-pointer types without omitempty
    • Optional fields: pointer types with omitempty
    • Use omitzero for structs and slices
  3. URL Tags for Query Parameters

    • All fields should be non-pointer types with url tags
    • Use omitempty to omit zero values
  4. Pagination

    • Offset-based pagination (ListOptions)
    • Cursor-based pagination (ListCursorOptions)
    • Pagination best practices (embedding options, handling nil, using iterators)
  5. Common Types

    • ID fields: always int64
    • Node ID fields: always string
    • Timestamp fields: use Timestamp type
    • Boolean fields: always *bool
  6. Generation Patterns

    • Generated accessors
    • Generated iterators
    • Generated documentation
    • Linter rules (sliceofpointers, structfield)

Benefits

  • Helps new contributors understand the codebase better
  • Reduces review burden by making expectations explicit
  • Improves code consistency across the project
  • Documents patterns that are frequently discussed in reviews

Testing

This is a documentation-only change. No code changes or tests needed.

Closes #4023

Add comprehensive section documenting common code patterns and conventions:
- Naming conventions (files, receivers, types, methods, variables)
- JSON tags for request bodies (required vs optional fields, omitzero)
- URL tags for query parameters (non-pointer fields with omitempty)
- Pagination patterns (ListOptions, ListCursorOptions, best practices)
- Common types (ID, NodeID, Timestamp, boolean fields)
- Generation patterns (accessors, iterators, documentation, linter rules)

This addresses issue google#4023 and helps new contributors understand the codebase
better, reducing review burden and improving code consistency.
Copy link
Copy Markdown
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Thank you, @jlaportebot.
LGTM.

cc: @alexandear

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.71%. Comparing base (6c58592) to head (6fcb261).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4202   +/-   ##
=======================================
  Coverage   93.71%   93.71%           
=======================================
  Files         209      209           
  Lines       19772    19772           
=======================================
  Hits        18529    18529           
  Misses       1046     1046           
  Partials      197      197           

☔ 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.

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.

Extend CONTRIBUTING.md with common code guidelines

2 participants