Add annotate_rb gem and annotate all models
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / scan_js (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run

This commit is contained in:
sto 2025-03-22 08:39:40 +01:00
parent 884dbf40d9
commit ce5b729fef
20 changed files with 383 additions and 0 deletions

58
.annotaterb.yml Normal file
View File

@ -0,0 +1,58 @@
---
:position: before
:position_in_additional_file_patterns: before
:position_in_class: before
:position_in_factory: before
:position_in_fixture: before
:position_in_routes: before
:position_in_serializer: before
:position_in_test: before
:classified_sort: true
:exclude_controllers: true
:exclude_factories: false
:exclude_fixtures: false
:exclude_helpers: true
:exclude_scaffolds: true
:exclude_serializers: false
:exclude_sti_subclasses: false
:exclude_tests: false
:force: false
:format_markdown: false
:format_rdoc: false
:format_yard: false
:frozen: false
:ignore_model_sub_dir: false
:ignore_unknown_models: false
:include_version: false
:show_check_constraints: false
:show_complete_foreign_keys: false
:show_foreign_keys: true
:show_indexes: true
:simple_indexes: false
:sort: false
:timestamp: false
:trace: false
:with_comment: true
:with_column_comments: true
:with_table_comments: true
:active_admin: false
:command:
:debug: false
:hide_default_column_types: ''
:hide_limit_column_types: ''
:ignore_columns:
:ignore_routes:
:models: true
:routes: false
:skip_on_db_migrate: false
:target_action: :do_annotations
:wrapper:
:wrapper_close:
:wrapper_open:
:classes_default_to_s: []
:additional_file_patterns: []
:model_dir:
- app/models
:require: []
:root_dir:
- ''

View File

@ -58,6 +58,8 @@ end
group :development do group :development do
# Use console on exceptions pages [https://github.com/rails/web-console] # Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console" gem "web-console"
gem "annotaterb"
end end
group :test do group :test do

View File

@ -74,6 +74,7 @@ GEM
uri (>= 0.13.1) uri (>= 0.13.1)
addressable (2.8.7) addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0) public_suffix (>= 2.0.2, < 7.0)
annotaterb (4.14.0)
ast (2.4.2) ast (2.4.2)
autoprefixer-rails (10.4.19.0) autoprefixer-rails (10.4.19.0)
execjs (~> 2) execjs (~> 2)
@ -392,6 +393,7 @@ PLATFORMS
x86_64-linux-musl x86_64-linux-musl
DEPENDENCIES DEPENDENCIES
annotaterb
bcrypt (~> 3.1.7) bcrypt (~> 3.1.7)
bootsnap bootsnap
bootstrap (~> 5.3.3) bootstrap (~> 5.3.3)

View File

@ -1,3 +1,27 @@
# == Schema Information
#
# Table name: completions
#
# id :integer not null, primary key
# time_seconds :integer
# created_at :datetime not null
# updated_at :datetime not null
# contest_id :integer not null
# contestant_id :integer not null
# puzzle_id :integer not null
#
# Indexes
#
# index_completions_on_contest_id (contest_id)
# index_completions_on_contestant_id (contestant_id)
# index_completions_on_puzzle_id (puzzle_id)
#
# Foreign Keys
#
# contest_id (contest_id => contests.id)
# contestant_id (contestant_id => contestants.id)
# puzzle_id (puzzle_id => puzzles.id)
#
class Completion < ApplicationRecord class Completion < ApplicationRecord
belongs_to :contest belongs_to :contest
belongs_to :contestant belongs_to :contestant

View File

@ -1,3 +1,23 @@
# == Schema Information
#
# Table name: contests
#
# id :integer not null, primary key
# allow_registration :boolean default(FALSE)
# name :string
# team :boolean default(FALSE)
# created_at :datetime not null
# updated_at :datetime not null
# user_id :integer not null
#
# Indexes
#
# index_contests_on_user_id (user_id)
#
# Foreign Keys
#
# user_id (user_id => users.id)
#
class Contest < ApplicationRecord class Contest < ApplicationRecord
belongs_to :user belongs_to :user

View File

@ -1,3 +1,22 @@
# == Schema Information
#
# Table name: contestants
#
# id :integer not null, primary key
# email :string
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# contest_id :integer not null
#
# Indexes
#
# index_contestants_on_contest_id (contest_id)
#
# Foreign Keys
#
# contest_id (contest_id => contests.id)
#
class Contestant < ApplicationRecord class Contestant < ApplicationRecord
belongs_to :contest belongs_to :contest

View File

@ -1,3 +1,22 @@
# == Schema Information
#
# Table name: puzzles
#
# id :integer not null, primary key
# brand :string
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# contest_id :integer not null
#
# Indexes
#
# index_puzzles_on_contest_id (contest_id)
#
# Foreign Keys
#
# contest_id (contest_id => contests.id)
#
class Puzzle < ApplicationRecord class Puzzle < ApplicationRecord
belongs_to :contest belongs_to :contest

View File

@ -1,3 +1,22 @@
# == Schema Information
#
# Table name: sessions
#
# id :integer not null, primary key
# ip_address :string
# user_agent :string
# created_at :datetime not null
# updated_at :datetime not null
# user_id :integer not null
#
# Indexes
#
# index_sessions_on_user_id (user_id)
#
# Foreign Keys
#
# user_id (user_id => users.id)
#
class Session < ApplicationRecord class Session < ApplicationRecord
belongs_to :user belongs_to :user
end end

View File

@ -1,3 +1,19 @@
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# admin :boolean default(FALSE), not null
# email_address :string not null
# password_digest :string not null
# username :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_users_on_email_address (email_address) UNIQUE
#
class User < ApplicationRecord class User < ApplicationRecord
has_many :contests, dependent: :destroy has_many :contests, dependent: :destroy
has_many :sessions, dependent: :destroy has_many :sessions, dependent: :destroy

View File

@ -0,0 +1,8 @@
# This rake task was added by annotate_rb gem.
# Can set `ANNOTATERB_SKIP_ON_DB_TASKS` to be anything to skip this
if Rails.env.development? && ENV["ANNOTATERB_SKIP_ON_DB_TASKS"].nil?
require "annotate_rb"
AnnotateRb::Core.load_rake_tasks
end

View File

@ -1,5 +1,29 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: completions
#
# id :integer not null, primary key
# time_seconds :integer
# created_at :datetime not null
# updated_at :datetime not null
# contest_id :integer not null
# contestant_id :integer not null
# puzzle_id :integer not null
#
# Indexes
#
# index_completions_on_contest_id (contest_id)
# index_completions_on_contestant_id (contestant_id)
# index_completions_on_puzzle_id (puzzle_id)
#
# Foreign Keys
#
# contest_id (contest_id => contests.id)
# contestant_id (contestant_id => contestants.id)
# puzzle_id (puzzle_id => puzzles.id)
#
one: one:
time_seconds: 1 time_seconds: 1
contestant: one contestant: one

View File

@ -1,5 +1,24 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: contestants
#
# id :integer not null, primary key
# email :string
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# contest_id :integer not null
#
# Indexes
#
# index_contestants_on_contest_id (contest_id)
#
# Foreign Keys
#
# contest_id (contest_id => contests.id)
#
one: one:
name: MyString name: MyString
email: MyString email: MyString

View File

@ -1,5 +1,25 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: contests
#
# id :integer not null, primary key
# allow_registration :boolean default(FALSE)
# name :string
# team :boolean default(FALSE)
# created_at :datetime not null
# updated_at :datetime not null
# user_id :integer not null
#
# Indexes
#
# index_contests_on_user_id (user_id)
#
# Foreign Keys
#
# user_id (user_id => users.id)
#
one: one:
name: MyString name: MyString
user: one user: one

View File

@ -1,5 +1,24 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: puzzles
#
# id :integer not null, primary key
# brand :string
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# contest_id :integer not null
#
# Indexes
#
# index_puzzles_on_contest_id (contest_id)
#
# Foreign Keys
#
# contest_id (contest_id => contests.id)
#
one: one:
name: MyString name: MyString

View File

@ -1,5 +1,21 @@
<% password_digest = BCrypt::Password.create("password") %> <% password_digest = BCrypt::Password.create("password") %>
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# admin :boolean default(FALSE), not null
# email_address :string not null
# password_digest :string not null
# username :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_users_on_email_address (email_address) UNIQUE
#
one: one:
email_address: one@example.com email_address: one@example.com
password_digest: <%= password_digest %> password_digest: <%= password_digest %>

View File

@ -1,3 +1,27 @@
# == Schema Information
#
# Table name: completions
#
# id :integer not null, primary key
# time_seconds :integer
# created_at :datetime not null
# updated_at :datetime not null
# contest_id :integer not null
# contestant_id :integer not null
# puzzle_id :integer not null
#
# Indexes
#
# index_completions_on_contest_id (contest_id)
# index_completions_on_contestant_id (contestant_id)
# index_completions_on_puzzle_id (puzzle_id)
#
# Foreign Keys
#
# contest_id (contest_id => contests.id)
# contestant_id (contestant_id => contestants.id)
# puzzle_id (puzzle_id => puzzles.id)
#
require "test_helper" require "test_helper"
class CompletionTest < ActiveSupport::TestCase class CompletionTest < ActiveSupport::TestCase

View File

@ -1,3 +1,23 @@
# == Schema Information
#
# Table name: contests
#
# id :integer not null, primary key
# allow_registration :boolean default(FALSE)
# name :string
# team :boolean default(FALSE)
# created_at :datetime not null
# updated_at :datetime not null
# user_id :integer not null
#
# Indexes
#
# index_contests_on_user_id (user_id)
#
# Foreign Keys
#
# user_id (user_id => users.id)
#
require "test_helper" require "test_helper"
class ContestTest < ActiveSupport::TestCase class ContestTest < ActiveSupport::TestCase

View File

@ -1,3 +1,22 @@
# == Schema Information
#
# Table name: contestants
#
# id :integer not null, primary key
# email :string
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# contest_id :integer not null
#
# Indexes
#
# index_contestants_on_contest_id (contest_id)
#
# Foreign Keys
#
# contest_id (contest_id => contests.id)
#
require "test_helper" require "test_helper"
class ContestantTest < ActiveSupport::TestCase class ContestantTest < ActiveSupport::TestCase

View File

@ -1,3 +1,22 @@
# == Schema Information
#
# Table name: puzzles
#
# id :integer not null, primary key
# brand :string
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# contest_id :integer not null
#
# Indexes
#
# index_puzzles_on_contest_id (contest_id)
#
# Foreign Keys
#
# contest_id (contest_id => contests.id)
#
require "test_helper" require "test_helper"
class PuzzleTest < ActiveSupport::TestCase class PuzzleTest < ActiveSupport::TestCase

View File

@ -1,3 +1,19 @@
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# admin :boolean default(FALSE), not null
# email_address :string not null
# password_digest :string not null
# username :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_users_on_email_address (email_address) UNIQUE
#
require "test_helper" require "test_helper"
class UserTest < ActiveSupport::TestCase class UserTest < ActiveSupport::TestCase