-
Notifications
You must be signed in to change notification settings - Fork 53
SimpleReport Style Guide
This style guide is very much a WIP! Feel free to edit!
We use the Google Java Style Guide as our baseline.
Our gradle spotlessApply
command (run automatically when committing changes) will format some things based on this style guide, like formatting and spacing. However, the linter isn't strongly opinionated, so it won't catch everything.
Avoid throwing a generic Exception
in the method signature, preferring to throw the explicit Exception type.
No:
private String getUserStatus(UUID id) throws Exception {}
Yes:
private String getUserStatus(UUID id) throws IllegalStateException, BadRequestException {}
SimpleReport follows the Java and Google style guide recommendations for variable names. In particular, we discourage prepending an underscore to local fields, so organizationService
is used instead of _organizationService
. See this PR discussion for more details: https://github.com/CDCgov/prime-simplereport/pull/4722#discussion_r1047852222
All graphql queries used in a container component (a component that is the root of a view, e.g., Test Results View) should be placed in a operations.graphql
file that lives in the relevant subdirectory. For example, for the Test Results View the file that lives in the testResults
folder.
Whenever you change the location/contents of a query file, run the command yarn codegen
. This will generate the necessary hooks that will allow you to call the query on the front end. For example, to fetch data using the query GetResultsCountByFacility
you need to use the hook useGetResultsCountByFacilityQuery
which will get automatically generated by the codegen
command.
To see this example in action, check the file TestResultsList.tsx in the repo.
This project uses eslint, prettier, and stylelint as frontend linters, and spotless and google-java-format for the backend. GitHub Actions is configured to run these linters on every pull request, so you must resolve all mismatches/errors before merging. There are a few ways to manage this:
- Run
yarn lint:write
in thefrontend/
dir, and./gradlew spotlessApply
in thebackend/
dir, before every commit - Enable the optional pre-commit hook by running
yarn lefthook install
in the root dir (install lefthook if you haven't already done so during setup by runningyarn install
) - Add extensions to your code editor that runs the linters for you on save, e.g., prettier-vscode, vscode-eslint, vscode-spotless-gradle
You can also run the pre-commit hooks in docker using yarn lefthook run in-docker
.
- Getting Started
- [Setup] Docker and docker compose development
- [Setup] IntelliJ run configurations
- [Setup] Running DB outside of Docker (optional)
- [Setup] Running nginx locally (optional)
- [Setup] Running outside of docker
- Accessing and testing weird parts of the app on local dev
- Accessing patient experience in local dev
- API Testing with Insomnia
- Cypress
- How to run e2e locally for development
- E2E tests
- Database maintenance
- MailHog
- Running tests
- SendGrid
- Setting up okta
- Sonar
- Storybook and Chromatic
- Twilio
- User roles
- Wiremock
- CSV Uploader
- Log local DB queries
- Code review and PR conventions
- SimpleReport Style Guide
- How to Review and Test Pull Requests for Dependabot
- How to Review and Test Pull Requests with Terraform Changes
- SimpleReport Deployment Process
- Adding a Developer
- Removing a developer
- Non-deterministic test tracker
- Alert Response - When You Know What is Wrong
- What to Do When You Have No Idea What is Wrong
- Main Branch Status
- Maintenance Mode
- Swapping Slots
- Monitoring
- Container Debugging
- Debugging the ReportStream Uploader
- Renew Azure Service Principal Credentials
- Releasing Changelog Locks
- Muting Alerts
- Architectural Decision Records
- Backend Stack Overview
- Frontend Overview
- Cloud Architecture
- Cloud Environments
- Database ERD
- External IDs
- GraphQL Flow
- Hibernate Lazy fetching and nested models
- Identity Verification (Experian)
- Spring Profile Management
- SR Result bulk uploader device validation logic
- Test Metadata and how we store it
- TestOrder vs TestEvent
- ReportStream Integration
- Feature Flag Setup
- FHIR Resources
- FHIR Conversions
- Okta E2E Integration
- Deploy Application Action
- Slack notifications for support escalations
- Creating a New Environment Within a Resource Group
- How to Add and Use Environment Variables in Azure
- Web Application Firewall (WAF) Troubleshooting and Maintenance
- How to Review and Test Pull Requests with Terraform Changes