1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-18 20:59:39 +02:00

Rubocop updates (#1118)

* Minimal code style enforcement

* Formatting and lint code updates (no change in functionality)
This commit is contained in:
Zach Gollwitzer 2024-08-23 10:06:24 -04:00 committed by GitHub
parent 359bceb58e
commit eef4c2643b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 529 additions and 519 deletions

7
.editorconfig Normal file
View file

@ -0,0 +1,7 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2

View file

@ -1,12 +1,15 @@
# Omakase Ruby styling for Rails inherit_gem:
inherit_gem: { rubocop-rails-omakase: rubocop.yml } rubocop-rails-omakase: rubocop.yml
# Overwrite or add rules to create your own house style Layout/IndentationWidth:
# Enabled: true
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
# Layout/SpaceInsideArrayLiteralBrackets: Layout/IndentationStyle:
# Enabled: false EnforcedStyle: spaces
Layout/ElseAlignment: IndentationWidth: 2
Enabled: false
Layout/EndAlignment: Layout/IndentationConsistency:
Enabled: false Enabled: true
Layout/SpaceInsidePercentLiteralDelimiters:
Enabled: true

View file

@ -42,12 +42,12 @@ gem "inline_svg"
gem "octokit" gem "octokit"
gem "pagy" gem "pagy"
gem "rails-settings-cached" gem "rails-settings-cached"
gem "tzinfo-data", platforms: %i[ windows jruby ] gem "tzinfo-data", platforms: %i[windows jruby]
gem "csv" gem "csv"
gem "redcarpet" gem "redcarpet"
group :development, :test do group :development, :test do
gem "debug", platforms: %i[ mri windows ] gem "debug", platforms: %i[mri windows]
gem "brakeman", require: false gem "brakeman", require: false
gem "rubocop-rails-omakase", require: false gem "rubocop-rails-omakase", require: false
gem "i18n-tasks" gem "i18n-tasks"

View file

@ -2,7 +2,7 @@ class Account::EntriesController < ApplicationController
layout :with_sidebar layout :with_sidebar
before_action :set_account before_action :set_account
before_action :set_entry, only: %i[ edit update show destroy ] before_action :set_entry, only: %i[edit update show destroy]
def edit def edit
render entryable_view_path(:edit) render entryable_view_path(:edit)

View file

@ -8,7 +8,7 @@ class Account::TradesController < ApplicationController
end end
def index def index
@entries = @account.entries.reverse_chronological.where(entryable_type: %w[ Account::Trade Account::Transaction ]) @entries = @account.entries.reverse_chronological.where(entryable_type: %w[Account::Trade Account::Transaction])
end end
def create def create

View file

@ -2,7 +2,7 @@ class AccountsController < ApplicationController
layout :with_sidebar layout :with_sidebar
include Filterable include Filterable
before_action :set_account, only: %i[ edit show destroy sync update ] before_action :set_account, only: %i[edit show destroy sync update]
def index def index
@institutions = Current.family.institutions @institutions = Current.family.institutions

View file

@ -1,7 +1,7 @@
class CategoriesController < ApplicationController class CategoriesController < ApplicationController
layout :with_sidebar layout :with_sidebar
before_action :set_category, only: %i[ edit update ] before_action :set_category, only: %i[edit update]
before_action :set_transaction, only: :create before_action :set_transaction, only: :create
def index def index

View file

@ -1,7 +1,7 @@
require "ostruct" require "ostruct"
class ImportsController < ApplicationController class ImportsController < ApplicationController
before_action :set_import, except: %i[ index new create ] before_action :set_import, except: %i[index new create]
def index def index
@imports = Current.family.imports @imports = Current.family.imports

View file

@ -1,5 +1,5 @@
class InstitutionsController < ApplicationController class InstitutionsController < ApplicationController
before_action :set_institution, except: %i[ new create ] before_action :set_institution, except: %i[new create]
def new def new
@institution = Institution.new @institution = Institution.new

View file

@ -1,7 +1,7 @@
class MerchantsController < ApplicationController class MerchantsController < ApplicationController
layout :with_sidebar layout :with_sidebar
before_action :set_merchant, only: %i[ edit update destroy ] before_action :set_merchant, only: %i[edit update destroy]
def index def index
@merchants = Current.family.merchants.alphabetically @merchants = Current.family.merchants.alphabetically

View file

@ -3,7 +3,7 @@ class PasswordResetsController < ApplicationController
layout "auth" layout "auth"
before_action :set_user_by_token, only: %i[ edit update ] before_action :set_user_by_token, only: %i[edit update]
def new def new
end end

View file

@ -1,7 +1,7 @@
class TagsController < ApplicationController class TagsController < ApplicationController
layout :with_sidebar layout :with_sidebar
before_action :set_tag, only: %i[ edit update ] before_action :set_tag, only: %i[edit update]
def index def index
@tags = Current.family.tags.alphabetically @tags = Current.family.tags.alphabetically

View file

@ -1,7 +1,7 @@
class Account::EntryBuilder class Account::EntryBuilder
include ActiveModel::Model include ActiveModel::Model
TYPES = %w[ income expense buy sell interest transfer_in transfer_out ].freeze TYPES = %w[income expense buy sell interest transfer_in transfer_out].freeze
attr_accessor :type, :date, :qty, :ticker, :price, :amount, :currency, :account, :transfer_account_id attr_accessor :type, :date, :qty, :ticker, :price, :amount, :currency, :account, :transfer_account_id

View file

@ -1,7 +1,7 @@
module Account::Entryable module Account::Entryable
extend ActiveSupport::Concern extend ActiveSupport::Concern
TYPES = %w[ Account::Valuation Account::Transaction Account::Trade ] TYPES = %w[Account::Valuation Account::Transaction Account::Trade]
def self.from_type(entryable_type) def self.from_type(entryable_type)
entryable_type.presence_in(TYPES).constantize entryable_type.presence_in(TYPES).constantize

View file

@ -1,7 +1,7 @@
class Account::TradeBuilder < Account::EntryBuilder class Account::TradeBuilder < Account::EntryBuilder
include ActiveModel::Model include ActiveModel::Model
TYPES = %w[ buy sell ].freeze TYPES = %w[buy sell].freeze
attr_accessor :type, :qty, :price, :ticker, :date, :account attr_accessor :type, :qty, :price, :ticker, :date, :account

View file

@ -25,7 +25,7 @@ class Account::Transaction < ApplicationRecord
private private
def searchable_keys def searchable_keys
%i[ categories merchants ] %i[categories merchants]
end end
end end

View file

@ -1,7 +1,7 @@
class Account::TransactionBuilder class Account::TransactionBuilder
include ActiveModel::Model include ActiveModel::Model
TYPES = %w[ income expense interest transfer_in transfer_out ].freeze TYPES = %w[income expense interest transfer_in transfer_out].freeze
attr_accessor :type, :amount, :date, :account, :transfer_account_id attr_accessor :type, :amount, :date, :account, :transfer_account_id

View file

@ -1,8 +1,8 @@
module Accountable module Accountable
extend ActiveSupport::Concern extend ActiveSupport::Concern
ASSET_TYPES = %w[ Depository Investment Crypto Property Vehicle OtherAsset ] ASSET_TYPES = %w[Depository Investment Crypto Property Vehicle OtherAsset]
LIABILITY_TYPES = %w[ CreditCard Loan OtherLiability ] LIABILITY_TYPES = %w[CreditCard Loan OtherLiability]
TYPES = ASSET_TYPES + LIABILITY_TYPES TYPES = ASSET_TYPES + LIABILITY_TYPES
def self.from_type(type) def self.from_type(type)

View file

@ -1,5 +1,5 @@
class TimeSeries class TimeSeries
DIRECTIONS = %w[ up down ].freeze DIRECTIONS = %w[up down].freeze
attr_reader :values, :favorable_direction attr_reader :values, :favorable_direction

View file

@ -63,5 +63,5 @@ Rails.application.configure do
# Raise error when a before_action's only/except options reference missing actions # Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true config.action_controller.raise_on_missing_callback_actions = true
config.autoload_paths += %w[ test/support ] config.autoload_paths += %w[test/support]
end end

View file

@ -42,8 +42,8 @@ Rails.application.routes.draw do
end end
end end
resources :tags, except: %i[ show destroy ] do resources :tags, except: %i[show destroy] do
resources :deletions, only: %i[ new create ], module: :tag resources :deletions, only: %i[new create], module: :tag
end end
namespace :category do namespace :category do
@ -51,16 +51,16 @@ Rails.application.routes.draw do
end end
resources :categories do resources :categories do
resources :deletions, only: %i[ new create ], module: :category resources :deletions, only: %i[new create], module: :category
end end
resources :merchants, only: %i[ index new create edit update destroy ] resources :merchants, only: %i[index new create edit update destroy]
namespace :account do namespace :account do
resources :transfers, only: %i[ new create destroy ] resources :transfers, only: %i[new create destroy]
namespace :transaction do namespace :transaction do
resources :rules, only: %i[ index ] resources :rules, only: %i[index]
end end
end end
@ -78,21 +78,21 @@ Rails.application.routes.draw do
scope module: :account do scope module: :account do
resource :logo, only: :show resource :logo, only: :show
resources :holdings, only: %i[ index new show ] resources :holdings, only: %i[index new show]
resources :cashes, only: :index resources :cashes, only: :index
resources :transactions, only: %i[ index update ] resources :transactions, only: %i[index update]
resources :valuations, only: %i[ index new create ] resources :valuations, only: %i[index new create]
resources :trades, only: %i[ index new create ] resources :trades, only: %i[index new create]
resources :entries, only: %i[ edit update show destroy ] resources :entries, only: %i[edit update show destroy]
end end
end end
resources :properties, only: %i[ create update ] resources :properties, only: %i[create update]
resources :vehicles, only: %i[ create update ] resources :vehicles, only: %i[create update]
resources :transactions, only: %i[ index new create ] do resources :transactions, only: %i[index new create] do
collection do collection do
post "bulk_delete" post "bulk_delete"
get "bulk_edit" get "bulk_edit"
@ -103,7 +103,7 @@ Rails.application.routes.draw do
end end
end end
resources :institutions, except: %i[ index show ] resources :institutions, except: %i[index show]
resources :issues, only: :show resources :issues, only: :show

View file

@ -39,7 +39,7 @@ class Import::CsvTest < ActiveSupport::TestCase
test "CSV with semicolon column separator" do test "CSV with semicolon column separator" do
csv = Import::Csv.new(valid_csv_str_with_semicolon_separator, col_sep: ";") csv = Import::Csv.new(valid_csv_str_with_semicolon_separator, col_sep: ";")
assert_equal %w[ date name category tags amount ], csv.table.headers assert_equal %w[date name category tags amount], csv.table.headers
assert_equal 4, csv.table.size assert_equal 4, csv.table.size
assert_equal "Paycheck", csv.table[3][1] assert_equal "Paycheck", csv.table[3][1]
end end
@ -84,7 +84,7 @@ class Import::CsvTest < ActiveSupport::TestCase
csv = Import::Csv.create_with_field_mappings(raw_file_str, fields, mappings) csv = Import::Csv.create_with_field_mappings(raw_file_str, fields, mappings)
assert_equal %w[ date name ], csv.table.headers assert_equal %w[date name], csv.table.headers
assert_equal 2, csv.table.size assert_equal 2, csv.table.size
assert_equal "Amazon stuff", csv.table[1][1] assert_equal "Amazon stuff", csv.table[1][1]
end end
@ -113,7 +113,7 @@ class Import::CsvTest < ActiveSupport::TestCase
csv = Import::Csv.create_with_field_mappings(raw_file_str, fields, mappings, ";") csv = Import::Csv.create_with_field_mappings(raw_file_str, fields, mappings, ";")
assert_equal %w[ date name ], csv.table.headers assert_equal %w[date name], csv.table.headers
assert_equal 2, csv.table.size assert_equal 2, csv.table.size
assert_equal "Amazon stuff", csv.table[1][1] assert_equal "Amazon stuff", csv.table[1][1]
end end