Skip to main content

Coding Standards

Purpose: For contributors, provides language-specific style guides and linting rules.

Go (openCenter-cli)

RuleEnforcement
Formattinggofmt -w . — must produce no diff
NamingExported identifiers use PascalCase; unexported use camelCase. Avoid single-letter names outside trivial loops.
Error handlingAlways return or handle errors. Wrap with context: fmt.Errorf("loading config: %w", err)
DependenciesInjected via constructors (internal/di/). No global mutable state.
CommentsExported functions require doc comments explaining why, not what.
Struct tagsyaml for serialization, validate for go-playground/validator rules, json for JSON schema generation.
TestingEvery behavior change requires tests. Use testify/assert for assertions, gopter for property tests, godog for BDD.

Run all checks:

mise run fmt
mise run test
mise run godog

Python (openCenter-AirGap)

RuleEnforcement
Formattingblack (line length 100, target Python 3.10+)
Type annotationsRequired on all functions. mypy strict mode (disallow_untyped_defs = true).
Lintingpylint with project-specific config in pyproject.toml
Namingsnake_case for functions and variables, PascalCase for classes
Error handlingUse custom exceptions from exceptions.py. No bare except: clauses.
ImportsStandard library → third-party → local, separated by blank lines
Testingpytest with strict markers. Property tests use Hypothesis. Coverage minimum 80%.

Run all checks:

black --check src/ tests/
mypy src/
pylint src/opencenter_build/
pytest

TypeScript (headlamp-branding-plugin)

RuleEnforcement
FormattingPrettier
LintingESLint with project config
TypesStrict TypeScript — avoid any without justification
NamingcamelCase for variables/functions, PascalCase for components/classes
TestingJest for unit tests
Package naming@opencenter/headlamp-plugin-<name>

Run all checks:

pnpm run format:check
pnpm run lint
pnpm test

Cross-cutting rules

These apply to all repositories:

  • No secrets in code. Use environment variables or SOPS encryption.
  • Pin all dependencies (lockfiles committed: go.sum, bun.lock, pnpm-lock.yaml, Gemfile.lock).
  • Commits follow Conventional Commits: feat:, fix:, docs:, chore:, test:.
  • PRs must pass all CI checks before merge.
  • Dead code and debugging artifacts must be removed before merge.
  • Comments explain why (constraints, tradeoffs), not what the code does.