index int64 0 0 | repo_id stringclasses 829
values | file_path stringlengths 34 254 | content stringlengths 6 5.38M |
|---|---|---|---|
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/setup/new_machine.md | # Developer Setup for users starting on a fresh Mac without any of the needed software installed.
Created to walk users through the entire process of setting up the Vets-API locally.
---
## Cloning the Vets-API Repo
Start by cloning the repository and navigating into the project directory.
```bash
git clone https:... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/setup/hybrid.md | # Developer Setup
In hybrid mode, you'll run vets-api natively, but run Postgres and Redis in Docker. By doing so, you avoid the challenges of installing these two software packages and having to keep them upgraded to the appropriate version.
## Base Setup
Follow these steps, or alternatively use [binstubs](binstubs... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/setup/local-traefik.md | # Running Traefik Locally (native Vets API)
This guide shows how to spin up a production-like Traefik container on your local machine, routing all traffic through it to your Vets API instance. No YAML configuration files are required beyond the generated dynamic file.
> **Note:** When using Traefik with [OpenResty](l... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/deployment/information.md | # Deployment Information
## When merged pr is deployed to various environments
Merged work is automatically deployed to all environments.
Below details at what point in the process these auto-deployments will occur.
* dev + staging + sandbox = immediately after code is merged and passes ci
* production = once a day a... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/engineering-guides-analysis/engineering-principles-compliance.md | # Engineering Principles Compliance Analysis
## Overview
This document analyzes vets-api compliance with the engineering principles outlined in the Ad Hoc Engineering Guides.
## Key Findings
### 1. Sandi Metz Rules Compliance
#### Classes ≤ 100 lines
**Status**: ⚠️ **Needs Review**
- Many controllers exceed 100 lin... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/engineering-guides-analysis/rails-standards-compliance.md | # Rails Standards Compliance Analysis
## Overview
This document analyzes vets-api compliance with Rails-specific standards from the Ad Hoc Engineering Guides.
## Key Findings
### 1. Controller Standards
#### Thin Controllers (Actions ≤ 10 lines)
**Status**: ❌ **Non-Compliant**
**Examples**:
- `BenefitsClaimsContro... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/engineering-guides-analysis/guides-to-codebase-mapping.md | # Engineering Guides to vets-api Codebase Mapping
## Overview
This document maps the Ad Hoc Engineering Guides to the vets-api codebase structure, showing where each guide applies and what areas need attention.
## Guide Mapping
### 1. Engineering Principles (`essentials/engineering_principles.md`)
**Applies To**:
-... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/engineering-guides-analysis/CHECKPOINT.md | # Engineering Guides Analysis - Checkpoint Document
**Last Updated**: January 2025
**Status**: Phase 1 Complete - Core Analysis Done
**Next Session**: Continue with detailed analyses or begin implementation
---
## Session Context
### What We're Doing
Analyzing vets-api codebase against Ad Hoc Engineering Guides... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/engineering-guides-analysis/README.md | # Engineering Guides Analysis for vets-api
## Overview
This directory contains analysis documents comparing vets-api against the Ad Hoc Engineering Guides standards. The analysis was conducted to identify areas for improvement and provide actionable recommendations.
## Documents
### 1. [Engineering Principles Compl... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/engineering-guides-analysis/prioritized-recommendations.md | # Prioritized Recommendations for vets-api
Based on analysis against Ad Hoc Engineering Guides standards.
## High-Priority Refactoring Opportunities
### 1. Extract Non-RESTful Actions to New Controllers
**Impact**: High | **Effort**: Medium | **Risk**: Low
**Problem**: Many controllers have non-RESTful actions mixe... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/engineering-guides-main/LICENSE | MIT License
Copyright (c) 2023 Ad Hoc
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/engineering-guides-main/TERMINOLOGY.md | # Terminology
### Definitions
- Never = Never
- Don't = Don't unless you have a great reason
- Avoid = Avoid unless you have a good reason
- Always = Always
- Must = Must unless you have a great reason
- Should = Should unless you have a good reason
- Prefer = Others are acceptable, but one is better
|
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/engineering-guides-main/README.md | # Ad Hoc's Engineering Guides
A collection of guides, best practices, snippets, templates, and cheat sheets for knowledge sharing and pattern standardization.
## Getting Started
If you're just browsing the guides or it's your first time here, start with [Engineering Principles](essentials/engineering_principles.md).... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/engineering-guides-main/ROADMAP.md | # Roadmap
> There's no ordered priority to-do list. This is a list of potential topics
## Essentials
- [X] The Twelve-Factor App - Modern app development methodology (`twelve_factor_app.md`)
- [ ] Code Review - What to look for, giving feedback (`code_review.md`)
- [X] Refactoring - When, how, common patterns (`refa... |
0 | code_files/vets-api-private/docs | code_files/vets-api-private/docs/engineering-guides-main/CONTRIBUTING.md | # Contributing
> These guides are intended to be program independent. Nothing in the these guides supersede any program rules or standards. Please do not add any style guides.
## Writing
### AI-Assisted Writing
It's perfectly acceptable to use AI to assist in writing prose, examples, snippets, etc. However, it's ... |
0 | code_files/vets-api-private/docs/engineering-guides-main/devops | code_files/vets-api-private/docs/engineering-guides-main/devops/docker/docker-security.md | # Docker Security Best Practices
This document provides guidance when creating, modifying, or reviewing Docker configurations. Follow these best practices to ensure secure, efficient, and maintainable container deployments.
## Table of Contents
- [Choosing a Base Image](#choosing-a-base-image)
- [Multi-Stage Builds]... |
0 | code_files/vets-api-private/docs/engineering-guides-main | code_files/vets-api-private/docs/engineering-guides-main/.claude/CLAUDE.md | # CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Repository Overview
This is a documentation-only repository containing engineering guides, best practices, snippets, and templates for Ad Hoc's engineering teams. There are no build commands, tests, ... |
0 | code_files/vets-api-private/docs/engineering-guides-main/.claude | code_files/vets-api-private/docs/engineering-guides-main/.claude/commands/guide-review.md | Review the guide at $ARGUMENTS for:
1. **Spelling & Grammar** - Check for typos, grammatical errors, and awkward phrasing
2. **Style Guide Compliance** (from CLAUDE.md):
- No em dashes (use commas, parentheses, or separate sentences)
- No semicolons in prose (use separate sentences or commas)
- Active voice ... |
0 | code_files/vets-api-private/docs/engineering-guides-main/languages | code_files/vets-api-private/docs/engineering-guides-main/languages/javascript/control-flow.md | # Control Flow
### Or, When To Use If, Switch, And Object Mapping
By Andrew Steele (@Andrew565)
## Introduction
Control flow (sometimes referred to as "conditional branching") is something virtually every script needs at some point. It occurs when you have two or more different actions you need your program to take... |
0 | code_files/vets-api-private/docs/engineering-guides-main/languages | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby/gotchas.md | # Gotchas
The New Hacker's Dictionary defines a gotcha as:
> A misfeature of a system, especially a programming language or environment, that tends to breed bugs or mistakes because it both enticingly easy to invoke and completely unexpected and/or unreasonable in its outcome. For example, a classic gotcha in C is th... |
0 | code_files/vets-api-private/docs/engineering-guides-main/languages | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby/creating_custom_cops.md | # Creating Custom Cops with RuboCop
Cops can be used to enforce more than style. They can prevent old approaches, regression, promote new best practices, or even catch performance inefficiencies.
Rails example:
> Initially, a Rails API used ActiveModelSerializer (AMS), but the core team has decided to switch to JS... |
0 | code_files/vets-api-private/docs/engineering-guides-main/languages | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby/ruby_standards.md | # Ruby Standards
Ruby-specific conventions and idioms. For general design principles, see `engineering_principles.md`.
## Naming Conventions
### Predicates (`?`) and Mutators (`!`)
- Methods ending in `?` return a boolean
- Methods ending in `!` indicate danger: mutation, side effects, or raising exceptions
- The `... |
0 | code_files/vets-api-private/docs/engineering-guides-main/languages | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby/naming_things.md | # Naming Things
Good names create clarity. Bad names create obscurity. This guide covers naming conventions for variables, methods, and classes with emphasis on declarative vs imperative style.
## Core Principle: Declarative Over Imperative
- **Imperative** names describe the action or process: `calculate_total`, `f... |
0 | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby/design_patterns/builder.md | # Builder Pattern
The Builder Pattern helps to construct or configure complex objects. This pattern encapsulates the "construction code" in a step by step approach. The benefit of this pattern is to reduce initialize method size and mitigate creating invalid objects.
## Naming Best Practices
In most circumstances... |
0 | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby/design_patterns/README.md | # Design Patterns with Ruby
This section contains practical and commonly used patterns with Ruby. Most people using Ruby are using it for Rails. So many conventions particularly with naming will be in context of Rails. Additionally, many basic patterns used in Rails will be ignored. For example, ActiveRecord is a dat... |
0 | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby/design_patterns/command.md | # Command Pattern
The Command Pattern helps you extract business logic from models or controllers by encapsulating actions as objects. In the Rails context this is usually implemented a Service Object. ActiveJob classes are also implementations of the Command Pattern, but this guide will focus on Service Objects.
Fo... |
0 | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby/design_patterns/null_objects.md | # Null Objects
A Null Object is an object with no referenced value or with defined neutral (null) behavior. It's creates an interface for representing default behavior for a real object. That means we can use a Null Object in place of nil. In refactoring this can be used replace nil checks and translates to cleaner co... |
0 | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby/design_patterns/strategy.md | # Strategy Pattern
This Gang of Four pattern is described as a Behavioral Pattern that groups different algorithm or behaviors together to be used interchangeably at runtime. The patterns involves a context (the object) and some strategies. The strategies should have a common public interface and can vary in the priva... |
0 | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby/design_patterns/decorator.md | # Decorator Pattern
The Decorator Pattern allows you to wrap an object in another object to add new behavior without modifying the original class. Wrapping doesn't modify the object's class directly, which adheres to the Open-Closed Principle and Composition over Inheritance. Decorators can be useful
In the context ... |
0 | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby | code_files/vets-api-private/docs/engineering-guides-main/languages/ruby/design_patterns/adapter.md | # Adapter Pattern
The Adapter Pattern act as a bridge between two incompatible interfaces. Adapters modify objects at runtime instead of classes. The most common use-case is to interface between internal and external APIs. The two primary reasons to use the Adapter Pattern are: extensive or complex interface mismatch ... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/rails_standards.md | # Rails Standards
Rails-specific conventions and patterns. For Ruby idioms, see `ruby_standards.md`. For domain object patterns, see `backend/rails/object_organization.md`.
## Convention Over Configuration
Lean into Rails defaults. Fight the framework only when you have a compelling reason.
```ruby
# bad - fighting... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/object_organization.md | # Object Organization
This guide details how to use several patterns and types of domain objects. In this guide domain objects are considered objects that encapsulate data and/or behavior associated with a domain. A model object is a persisted domain object.
Types of Domain Objects
- Plain Old Ruby Domain Object
- F... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/performance.md | # Rails Performance Guide
## Overview
Disclaimer: This performance guide isn't intended to be exhaustive
Use this guide as a foundation for performance improvements and developing with performance in mind. Performance fine-tuning is best done with monitoring, profiling, and experimentation. Aim for 100 ms, stay unde... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/credentials.md | # Credentials
## Overview
Rails 5.2 introduced "credentials" which are encrypted YAML files for storing secrets, tokens, API keys, or anything you don't want exposed. These credential files can be safely stored in version control and access to the master key can be shared as needed. Using credentials doesn't stop y... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/base_class_pattern.md | # Base Class Pattern
Rails implements Application* classes for its built-in classes like ActiveRecord::Base, ActionController::Base, etc. Application* classes are generally called "base classes" or "application base classes" and are special superclasses for the Rails framework classes. This "pattern" provides a single... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/security.md | # Rails Security Guide
## Overview
Disclaimer: This security guide isn't intended to be exhaustive
Use this guide as a foundation for security improvements and developing with security in mind. Not all security measures are created equal, some practices are more important than others. For example, it's more importan... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/connection.md | # Connection
Extracting a Connection object can be useful when you have several clients or a client class has become too large. The Client would then be responsible for initiating the request and the Connection would be responsible for building the Faraday connection and executing the request.
```ruby
# lib/calendl... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/model.md | # Model
The enterprise approach effectively creates mini gems for an external API. Models can be either POROs (Plain Old Ruby Objects) or ActiveRecord objects. Models handles the coordination between the Client and the Adapter. It often contain most of the business logic not related to transforming the response. PORO ... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/errors.md | # Errors
Error handling and creation will greatly depend on business requirements. You may want to create a external API specific error or a generic external error. You could use a config file for error attributes or relay the body of an unsuccessful response.
_Note:_ The following examples are to demonstrate approa... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/README.md | # Enterprise Approach to External APIs
A simple API wrapper type Client is enough for many use cases. However, that's not the case for major integrations or complex external legacy mainframes. The enterprise approach involves adding additional domain objects and classes to handle extensive or complex interactions wit... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/response.md | # Response
The Response object is responsible for creating the interface between the Client, Model, and Adapter. Typically, like a Client, only one is class is required per external API. Often a Response object is so generalized, it can be re-used between external APIs.
## Structure
```ruby
# lib/calendly/response.... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/adapter.md | # Adapter
The Adapter translates a Client's response body (in this case `Faraday::Response`) to into data for a Model object.
## Structure
### Data
Data's purpose is to translate the given response body into a model parameter hash. It's similar to controller params used in `ActiveRecord.create` as in `Car.create... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/client.md | # Enterprise Client
In principle a Client is the same as a simple wrapper Client. The most notable difference is the generalization. An enterprise Client is built with intent of being used by all the requests for a given external API. Instead of matching the external API calls, Clients only make generic GET, POST, PO... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/example/model.rb | # lib/calendly/event_type.rb
# This class has also been refactored to demonstrate
# how to build off the examples provided
module Calendly
class EventType
include ExternalModel
ADAPTER_CLASS = Calendly::Adapters::EventType
attr_reader :raw_data, :errors
attr_reader :name, :active, :slug, :schedulin... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/example/response.rb | # lib/calendly/response.rb
module Calendly
class Response
attr_reader :status, :body, :errors, :original_body
def initialize(response)
@status = response.status
@original_body = response.body
@body = JSON.parse(response.body, symbolize_names: true)
end
def errors
return nil i... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/example/adapter.rb | # lib/calendly/adapters/event_type.rb
module Calendly
module Adapters
class EventType < ResponseAdapter
def body
return nil unless success?
{
name: name,
active: active,
slug: slug,
scheduling_url: scheduling_url,
phone_number: phone_number... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/example/client.rb | # lib/calendly/client.rb
module Calendly
class Client
include Calendly::Oauth # get a valid access token
include Calendly::RateLimiting # uses Rack::Attack
include Calendly::SanitizeJson # sanitize PII
include Calendly::Monitoring # metrics and error logging
include Calendly::QueryParams # formats... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/example/error.rb | # lib/calendly/error.rb
module Calendly
class Error < StandardError
attr_reader :status, :detail
def initialize(message, status, detail:)
@status = status
@detail = detail
super(message)
end
def to_json
{
title: i18t_data[:title]
code: i18t_data[:code]
... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/enterprise/example/controller.rb | # app/controllers/event_types_controller.rb
class EventTypesController < ApplicationController
def index
event_type = EventType.list(query_params)
if event_type.valid?
render json: EventTypeSerializer.new(event_type), status: :ok
else
render json: errors: event_type.errors, status: :not_foun... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/wrapper/response_parser.md | # Response Parser
One approach to DRY your client(s) is to create a module for parsing responses. This can both DRY your code and provide a consistent way to handle json parsing, log messages, and error handling for your clients.
```ruby
# lib/github/response_parser.rb
module Github
module ResponseParser
def p... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/wrapper/README.md | # Wrapper Approach to External APIs
A "wrapper" type Client can be used when there are limited interactions between your internal system and the external API. For example, a wrapper can be used to get current weather data, geocode an address, or trigger a GitHub Actions workflow run.
## Components
For the most p... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/wrapper/client.md | # Wrapper Client
A client is mainly composed of public methods that each represent one external API request. The client is responsible for sending the request and parsing the response. Additionally, the client may include authentication and error handling. Clients and their related classes are almost always put in the... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/wrapper | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/wrapper/example/response_parser.md | # Response Parser
One approach to DRY your client(s) is to create a module for parsing responses. This can both DRY your code and provide a consistent way to handle json parsing, log messages, and error handling for your clients.
```ruby
# lib/github/response_parser.rb
module Github
module ResponseParser
def p... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/wrapper | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/wrapper/example/errors.rb |
# lib/github/errors.rb
module GitHub
class ApiError < StandardError; end
class UnauthorizedError < ApiError; end
class NotFoundError < ApiError; end
end
|
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/wrapper | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/wrapper/example/client.rb | # lib/github/pull_requests/client.rb
require 'github/auth'
require 'github/errors'
module GitHub
module Workflows
class Client
BASE_URL = 'https://api.github.com/repos/OWNER/REPO/actions/workflows'.freeze
attr_reader :workflow_id, :access_token
def initialize(workflow_id)
@workflow_i... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/wrapper | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/external_apis/wrapper/example/auth.rb | # lib/github/auth.rb
require 'faraday'
require 'openssl'
require 'json'
require 'jwt'
module GitHub
class Auth
BASE_URL = 'https://api.github.com/app/installations'
INSTALLATION_ID = 1
def self.access_token
self.new.post_installation_access_token['token']
end
private
def post_instal... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/core_ext/parseable_date.rb | # When you need to know if a Date can be parse. This may come up with user submitted dates.
# Location:
# lib/core_ext or lib/core_extensions
# Common use case:
# validators
# Usage:
# errors.add(:birth_date, "must be valid date") unless Date.parseable?(birth_date)
class Date
def self.parseable?(string)
pars... |
0 | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails | code_files/vets-api-private/docs/engineering-guides-main/frameworks/rails/models/queries.md | # Queries
Big list of finder methods (and ActiveRecord::Relation)
- [`ActiveRecord::Relation`](https://api.rubyonrails.org/classes/ActiveRecord/Relation.html)
- [`annotate`](https://api.rubyonrails.org/classes/ActiveRecord/QueryMethods.html#method-i-annotate)
- [`create_with`](https://api.rubyonrails.org/classes/Acti... |
0 | code_files/vets-api-private/docs/engineering-guides-main | code_files/vets-api-private/docs/engineering-guides-main/essentials/composition_vs_inheritance.md | # Composition vs inheritance
Both composition and inheritance enable code reuse, but they have different trade-offs. Prefer composition and only use inheritance when appropriate.
## Quick comparison
| Aspect | Inheritance | Composition |
|--------|-------------|-------------|
| Relationship | "is a" | "has a" |
| Co... |
0 | code_files/vets-api-private/docs/engineering-guides-main | code_files/vets-api-private/docs/engineering-guides-main/essentials/engineering_principles.md | # Engineering principles
## Fundamental principles
- **Convention Over Configuration**: Follow conventions religiously
- **DRY**: Don't Repeat Yourself
- **YAGNI**: You Aren't Gonna Need It - don't add functionality until needed
- **KISS**: Keep It Simple, Stupid
- **Expressive**: Code should read like well-written p... |
0 | code_files/vets-api-private/docs/engineering-guides-main | code_files/vets-api-private/docs/engineering-guides-main/essentials/twelve_factor_app.md | # The twelve-factor app
The Twelve-Factor App is a methodology for building modern, scalable software-as-a-service applications. Originally published by Heroku, these principles help create apps that are portable, resilient, and suitable for cloud deployment.
## 1. Codebase
**One codebase tracked in version control,... |
0 | code_files/vets-api-private/docs/engineering-guides-main | code_files/vets-api-private/docs/engineering-guides-main/essentials/dependency_injection.md | # Dependency injection
Dependency injection means passing collaborators into an object rather than having the object create them internally. This makes dependencies explicit, visible, and replaceable.
## What is a dependency
A dependency is a class upon which another class depends.
```ruby
class Company
def month... |
0 | code_files/vets-api-private/docs/engineering-guides-main | code_files/vets-api-private/docs/engineering-guides-main/essentials/testing_philosophy.md | # Testing philosophy
Tests verify that code works and protect against regressions. Good tests are fast, focused, and test behavior rather than implementation.
## The test pyramid
Structure your test suite with more tests at the bottom, fewer at the top.
```
/\
/ \ End-to-end (few)
/----\... |
0 | code_files/vets-api-private/docs/engineering-guides-main | code_files/vets-api-private/docs/engineering-guides-main/essentials/documentation.md | # Documentation
Documentation explains what code can't. Good documentation helps others (and future you) understand context, decisions, and usage.
## Primary types of documentation
- Developer docs
- Architecture docs
- Code comments
## Developer documentation
Developer documentation helps engineers understand t... |
0 | code_files/vets-api-private/docs/engineering-guides-main | code_files/vets-api-private/docs/engineering-guides-main/essentials/technical_debt.md | # Technical debt
Technical debt is the implied cost of future rework caused by choosing a quick solution over a better approach. Over time the debt accumulates interest and the longer it exists, the higher it costs to address.
Some technical debt is expected and the cost of doing business. In some cases, like startu... |
0 | code_files/vets-api-private/docs/engineering-guides-main/essentials | code_files/vets-api-private/docs/engineering-guides-main/essentials/complexity/obscurity.md | # Obscurity
Code whose purpose or behavior requires significant effort to understand.
Obscure code forces readers to mentally execute it to figure out what it does. Clear code reveals its intent immediately.
## Symptoms
- You need to read every line to understand the method
- Variable names require detective work t... |
0 | code_files/vets-api-private/docs/engineering-guides-main/essentials | code_files/vets-api-private/docs/engineering-guides-main/essentials/complexity/dependencies.md | # Too many dependencies
A dependency, also called coupling, exists when a given piece of code cannot be understood or modified in isolation.
Each dependency is an opportunity to make the code more fragile, complex, and harder to maintain.
## Symptoms
- Constructor takes 5+ arguments
- Mocking setup in tests is lo... |
0 | code_files/vets-api-private/docs/engineering-guides-main/essentials | code_files/vets-api-private/docs/engineering-guides-main/essentials/complexity/complex_interfaces.md | # Complex interfaces
Complex Interfaces that are hard to use or require understanding implementation details to use safely.
A good interface hides complexity. A bad interface leaks it, forcing callers to understand internals just to use it correctly.
## Symptoms
- You need to read the source code to use a method co... |
0 | code_files/vets-api-private/docs/engineering-guides-main/essentials | code_files/vets-api-private/docs/engineering-guides-main/essentials/complexity/untrue_interfaces.md | # Untrue interfaces
Methods or classes that mislead about what they actually do.
An untrue interface lies to its caller. The name promises one thing, but the implementation does another. This forces developers to read implementations instead of trusting interfaces.
## Symptoms
- You can't use a method without readi... |
0 | code_files/vets-api-private/docs/engineering-guides-main/essentials | code_files/vets-api-private/docs/engineering-guides-main/essentials/complexity/unstable_dependencies.md | # Unstable dependencies
Depending on code that changes frequently causes cascading modifications.
When a dependency changes, everything that depends on it may need to change too. Unstable dependencies spread volatility through your codebase.
## Symptoms
- Unrelated features break after seemingly isolated changes
- ... |
0 | code_files/vets-api-private/docs/engineering-guides-main/essentials | code_files/vets-api-private/docs/engineering-guides-main/essentials/complexity/duplication.md | # Duplication
The same logic expressed in multiple places, forcing parallel changes.
When you change one instance but miss another, bugs appear. Duplication is a maintenance tax that compounds over time.
## Symptoms
- Changing one feature requires edits in multiple files
- Copy-paste is your primary development tec... |
0 | code_files/vets-api-private/docs/engineering-guides-main/essentials | code_files/vets-api-private/docs/engineering-guides-main/essentials/refactoring/major_refactorings.md | # Major Refactorings
## Defining major
A major refactoring sits between resolving a code smell and a full rewrite. It's large in size and impact. A minor refactoring is like a ticket and a major refactoring is like an epic.
Characteristics:
- requires discovery and planning beforehand
- requires some discussion/ag... |
0 | code_files/vets-api-private/docs/engineering-guides-main/essentials | code_files/vets-api-private/docs/engineering-guides-main/essentials/refactoring/overview.md | # Refactoring Overview
Refactoring is changing code structure without changing behavior. The goal is to make code easier to understand, modify, and extend.
Refactoring is an essential tool for maintainability and reducing technical debt. It makes code easier to understand to others and your future self. Ultimately, i... |
0 | code_files/vets-api-private/docs/engineering-guides-main/essentials | code_files/vets-api-private/docs/engineering-guides-main/essentials/refactoring/refactoring_code_smells_cheatsheet.md | # Refactoring code smells cheatsheet
A quick reference mapping code smells to refactorings. Based on the "Smells to Refactorings Quick Reference Guide" by Industrial Logic.
## Table of contents
- [Alternative classes with different interfaces](#alternative-classes-with-different-interfaces)
- [Combinatorial explosio... |
0 | code_files/vets-api-private/docs/engineering-guides-main/essentials | code_files/vets-api-private/docs/engineering-guides-main/essentials/refactoring/code_smells_reference.md | # Code smells reference
## Table of contents
- [Alternative classes with different interfaces](#alternative-classes-with-different-interfaces)
- [Combinatorial explosion](#combinatorial-explosion)
- [Comments (deodorant)](#comments-deodorant)
- [Conditional complexity](#conditional-complexity)
- [Data class](#data-cl... |
0 | code_files/vets-api-private/docs/engineering-guides-main/essentials | code_files/vets-api-private/docs/engineering-guides-main/essentials/refactoring/technique_reference.md | ## Refactoring Techniques
I recommend using [Refactoring Guru](https://refactoring.guru/refactoring/techniques) for detailed explanations of each technique
### Composing Methods
- Extract Method
- Inline Method
- Extract Variable
- Inline Temp
- Replace Temp with Query
- Split Temporary Variable
- Remove Assignments... |
0 | code_files/vets-api-private | code_files/vets-api-private/.devcontainer/post-start.sh | #!/bin/sh
echo "Ensuring ruby is up to date..."
export PATH="${HOME}/.asdf/shims:${HOME}/.asdf/bin:${PATH}"
asdf plugin update ruby
asdf install ruby $( cat .ruby-version )
asdf global ruby $( cat .ruby-version )
echo "Ensuring packages are up to date..."
bundle install
echo "Starting Redis ..."
sudo /etc/init.d/red... |
0 | code_files/vets-api-private | code_files/vets-api-private/.devcontainer/on-create.sh | #!/bin/sh
# this runs as part of pre-build
echo "on-create start"
echo "$(date +'%Y-%m-%d %H:%M:%S') on-create start" >> "$HOME/status"
# Homebrew/asdf paths to zsh
{
echo "source \"\$HOME/.asdf/asdf.sh\""
} >> ~/.zshrc
export PATH="${HOME}/.asdf/shims:${HOME}/.asdf/bin:${PATH}"
asdf install ruby $( cat .ruby-... |
0 | code_files/vets-api-private | code_files/vets-api-private/.devcontainer/post-create.sh | #!/bin/sh
# this runs at Codespace creation - not part of pre-build
echo "post-create start"
echo "$(date) post-create start" >> "$HOME/status"
# update the repos
git -C /workspaces/vets-api-mockdata pull
git -C /workspaces/vets-api pull
mkdir /workspaces/vets-api/.vscode
{
{
"rubyLsp.rubyVersionManager": "non... |
0 | code_files/vets-api-private | code_files/vets-api-private/.devcontainer/welcome.txt | ~~~~~~ Welcome to vets-api on codespaces! ~~~~~~
For more information, see the codespaces README in docs/setup.
~~~~~~ Quickstart ~~~~~
To start vets-api, run this command:
foreman start -m all=1,clamd=0,freshclam=0
|
0 | code_files/vets-api-private | code_files/vets-api-private/.devcontainer/devcontainer.json | {
"name": "native",
"image": "mcr.microsoft.com/devcontainers/base:bookworm",
"customizations": {
"codespaces": {
"openFiles": [
"docs/setup/codespaces.md",
"README.md"
],
"repositories": {
"department-of-veterans-affairs/vets-api-mockdata": {
"permissions"... |
0 | code_files/vets-api-private/helmCharts | code_files/vets-api-private/helmCharts/vets-api/Chart.yaml | apiVersion: v2
name: "vets-api"
description: the vets-api helm for for Kubernetes deployment
type: application
version: 0.0.1
|
0 | code_files/vets-api-private/helmCharts | code_files/vets-api-private/helmCharts/vets-api/values.yaml | # Default values for vets-api.
replicaCount: 1
image:
repository: 008577686731.dkr.ecr.us-gov-west-1.amazonaws.com/dsva/preview-environment/vets-api
pullPolicy: IfNotPresent
tag: "0.0.1"
|
0 | code_files/vets-api-private/helmCharts/vets-api | code_files/vets-api-private/helmCharts/vets-api/templates/deployment.yaml | apiVersion: apps/v1
kind: Deployment
metadata:
name: vets-api
labels:
app: vets-api
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: vets-api
template:
metadata:
labels:
app: vets-api
spec:
initContainers:
- name: db-create
imag... |
0 | code_files/vets-api-private/helmCharts/vets-api | code_files/vets-api-private/helmCharts/vets-api/templates/NOTES.txt | 1. Your application URL is:
https://{{ .Values.domainName }}
|
0 | code_files/vets-api-private/helmCharts/vets-api | code_files/vets-api-private/helmCharts/vets-api/templates/ingress.yaml | apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: vets-api-service-routing
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/router.middlewares: {{ .Values.namespace }}-vets-header@kubernet... |
0 | code_files/vets-api-private/helmCharts/vets-api | code_files/vets-api-private/helmCharts/vets-api/templates/service.yaml | apiVersion: v1
kind: Service
metadata:
name: vets-api-service
spec:
ports:
- protocol: TCP
name: web
port: 80
targetPort: http
selector:
app: vets-api
|
0 | code_files/vets-api-private/helmCharts/vets-api | code_files/vets-api-private/helmCharts/vets-api/templates/settings-local-configmap.yaml | apiVersion: v1
kind: ConfigMap
metadata:
name: settings-local-yml
data:
settings.local.yml: |
virtual_hosts: ["{{ .Values.domainName }}"]
redis:
host: "{{ .Values.redisHost }}"
app_data:
url: "{{ .Values.redisAppDataUrl }}"
sidekiq:
url: "{{ .Values.redisSideKiqUrl }}"
... |
0 | code_files/vets-api-private/helmCharts/vets-api | code_files/vets-api-private/helmCharts/vets-api/templates/required.yaml | {{- $_ := required "A valid domainName is required!" .Values.domainName}}
{{- $__ := required "A valid databaseUrl is required!" .Values.databaseUrl}}
{{- $___ := required "A valid BUNDLE_ENTERPRISE__CONTRIBSYS__COM is required!" .Values.BUNDLE_ENTERPRISE__CONTRIBSYS__COM}}
{{- $____ := required "A valid redisRailsU... |
0 | code_files/vets-api-private | code_files/vets-api-private/script/sync_settings.rb | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'yaml'
require 'json'
require 'fileutils'
require 'open3'
require 'optparse'
class SettingsSync
FORWARD_PROXY_PATTERN = /fwdproxy-(\w+)\.vfs\.va\.gov:(\d+)/
SETTINGS_LOCAL_PATH = File.expand_path('../config/settings.local.yml', __dir__)
TEST_SETTINGS_LOC... |
0 | code_files/vets-api-private | code_files/vets-api-private/script/sync-settings | #!/bin/bash
# Wrapper script for sync_settings.rb - uses devops utilities
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SYNC_SCRIPT="$SCRIPT_DIR/sync_settings.rb"
USAGE=$(cat <<-END
sync-settings [OPTIONS] NAMESPACE ENVIRONMENT
Sync settings from AWS Parameter Store to settings.local.yml
Uses devops re... |
0 | code_files/vets-api-private | code_files/vets-api-private/script/forward-proxy-tunnel.sh | #!/bin/bash
# Script to start a SSM port forwarding session to the 'forward-proxy' on an app environment
# based on a combination of devops scripts:
# https://github.com/department-of-veterans-affairs/devops/blob/master/utilities/issue_mfa.sh
# https://github.com/department-of-veterans-affairs/devops/blob/master/util... |
0 | code_files/vets-api-private/script | code_files/vets-api-private/script/vcr_mcp/ssl_patcher.rb | # frozen_string_literal: true
require_relative 'constants'
# rubocop:disable Rails/Delegate
module VcrMcp
# Temporarily patches Faraday configurations to disable SSL verification
# for VCR cassette re-recording through local tunnels
class SslPatcher
VETS_API_ROOT = Constants::VETS_API_ROOT
# Known conf... |
0 | code_files/vets-api-private/script | code_files/vets-api-private/script/vcr_mcp/service_config.rb | # frozen_string_literal: true
require 'concurrent'
require_relative 'constants'
module VcrMcp
# Service configuration and detection for VCR cassettes
# Dynamically parses spec/support/vcr.rb to extract placeholder-to-settings mappings
class ServiceConfig
# Port range for auto-assignment (4480-4499)
PORT... |
0 | code_files/vets-api-private/script | code_files/vets-api-private/script/vcr_mcp/preparation_guide.rb | # frozen_string_literal: true
require_relative 'constants'
require_relative 'inspector'
require_relative 'spec_finder'
require_relative 'service_config'
module VcrMcp
# Generates instructions for re-recording a VCR cassette
class PreparationGuide
VETS_API_ROOT = Constants::VETS_API_ROOT
CASSETTE_ROOT = Co... |
0 | code_files/vets-api-private/script | code_files/vets-api-private/script/vcr_mcp/inspector.rb | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'json'
require 'yaml'
require 'base64'
require_relative 'constants'
require_relative 'cassette_parser'
module VcrMcp
module Inspector
CASSETTE_ROOT = Constants::CASSETTE_ROOT
# Resolves and validates a path to prevent directory traversal attacks.
... |
0 | code_files/vets-api-private/script | code_files/vets-api-private/script/vcr_mcp/spec_finder.rb | # frozen_string_literal: true
require_relative 'constants'
module VcrMcp
# Finds spec files that use a given VCR cassette
class SpecFinder
VETS_API_ROOT = Constants::VETS_API_ROOT
SPEC_DIRS = [
'spec',
'modules/*/spec'
].freeze
# Patterns that indicate cassette usage in spec files
... |
0 | code_files/vets-api-private/script | code_files/vets-api-private/script/vcr_mcp/constants.rb | # frozen_string_literal: true
module VcrMcp
# Shared constants for VCR MCP tools
module Constants
# Root path of the vets-api repository
VETS_API_ROOT = File.expand_path('../..', __dir__)
# VCR cassette directory
CASSETTE_ROOT = File.join(VETS_API_ROOT, 'spec', 'support', 'vcr_cassettes')
# A... |
0 | code_files/vets-api-private/script | code_files/vets-api-private/script/vcr_mcp/cassette_parser.rb | # frozen_string_literal: true
require 'yaml'
require 'json'
require 'base64'
module VcrMcp
class CassetteParser
def self.parse(file_path)
yaml_content = YAML.safe_load_file(file_path, permitted_classes: [], permitted_symbols: [], aliases: true)
{
interactions: parse_interactions(yaml_conten... |
0 | code_files/vets-api-private/script | code_files/vets-api-private/script/vcr_mcp/validator.rb | # frozen_string_literal: true
require 'English'
require 'open3'
require_relative 'constants'
require_relative 'inspector'
module VcrMcp
# Validates VCR cassettes for sensitive data
class Validator
VETS_API_ROOT = Constants::VETS_API_ROOT
CASSETTE_ROOT = Constants::CASSETTE_ROOT
# Sensitive data patte... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.