| name | code-review |
|---|---|
| description | Perform a code review on a local branch. |
You are a senior software engineer reviewing a proposed code change.
| class AsyncActionsController < ApplicationController | |
| def show | |
| async_action = AsyncAction.find_by!( | |
| user: current_user, | |
| token: params[:id], | |
| ) | |
| if @async_action.completed? | |
| case @async_action.action.fetch('kind') | |
| in 'redirect' |
| When tasked with generating a new file (e.g., model, factory, test), first identify existing files of the same type in the project. Open several relevant examples and analyze their structure, naming conventions, and implementation patterns. Use these patterns as a reference to create a consistent and idiomatic new file. Focus on reusing established conventions and aligning with the existing codebase. | |
| # When writing Ruby | |
| Follow the project rubocop rules. | |
| - Prefer `case in`, instead of `case where` | |
| - Prefer `_1` for blocks with one argument, where you otherwise will use a single letter | |
| - Use `!` versions for `save!` / `update!` / `destroy!` when not checking the result of the operation | |
| - Don't define methods ending with `!` unless there is a method with the same name without `!` |
Everyone should be able to execute independently without depending on others, but the team should move with the same rhythm.
Every engineer should be able to take a feature from inception to completion without unnecessary dependencies.
| batch = AngryBatch.new label: 'BulkWithdraw' | |
| # check inherits from ActiveJob::Base | |
| batch.on_complete Finance::WithdrawBulkCompleteJob, bulk_withdraw | |
| zerod_fees do |fee| | |
| # check inherits from ActiveJob::Base | |
| # check job includes AngryJob::Batchable | |
| batch.enqueue Taxation::MaintenanceTaxAutoAdjustmentJob, bulk_withdraw, fee: fee, amount: 0 | |
| end |
| # frozen_string_literal: true | |
| require 'net/http' | |
| require 'json' | |
| module OpenAI | |
| extend self | |
| API_KEY = ENV.fetch('openai_api_key') |
| import * as glob from 'glob'; | |
| import difference from 'lodash/difference'; | |
| import startCase from 'lodash/startCase'; | |
| import union from 'lodash/union'; | |
| import uniq from 'lodash/uniq'; | |
| import { CodeFileLoader } from '@graphql-tools/code-file-loader'; | |
| import { DocumentNode, DefinitionNode, OperationDefinitionNode } from 'graphql'; | |
| import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader'; | |
| import { loadDocuments } from '@graphql-tools/load'; | |
| import { visit } from 'graphql/language/visitor'; |
| # frozen_string_literal: true | |
| module ErrorReporting | |
| extend self | |
| def assign_user(user) | |
| return unless Rails.env.production? | |
| Sentry.set_user( | |
| id: user.id, |
| module AngrySupport::BelongsToPolymorphic | |
| def belongs_to_polymorphic(name, allowed_classes:, **options) | |
| belongs_to name, polymorphic: true, **options | |
| validates "#{name}_type", inclusion: { in: allowed_classes.map(&:name), allow_nil: !!options[:optional] } | |
| define_singleton_method(:"#{name}_types") { allowed_classes } | |
| define_singleton_method(:"with_#{name}") do |type| | |
| type = case type |
| class ApplicationComponent < ViewComponent::Base | |
| private | |
| def fetch_with_fallback(hash, key, fallback) | |
| hash.fetch(key) do | |
| ErrorReporting.capture_exception(%(key not found: "#{key}")) | |
| fallback | |
| end | |
| end | |