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: { rubocop-rails-omakase: rubocop.yml }
inherit_gem:
rubocop-rails-omakase: rubocop.yml
# Overwrite or add rules to create your own house style
#
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
# Layout/SpaceInsideArrayLiteralBrackets:
# Enabled: false
Layout/ElseAlignment:
Enabled: false
Layout/EndAlignment:
Enabled: false
Layout/IndentationWidth:
Enabled: true
Layout/IndentationStyle:
EnforcedStyle: spaces
IndentationWidth: 2
Layout/IndentationConsistency:
Enabled: true
Layout/SpaceInsidePercentLiteralDelimiters:
Enabled: true

View file

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

View file

@ -2,7 +2,7 @@ class Account::EntriesController < ApplicationController
layout :with_sidebar
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
render entryable_view_path(:edit)

View file

@ -8,7 +8,7 @@ class Account::TradesController < ApplicationController
end
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
def create

View file

@ -2,7 +2,7 @@ class AccountsController < ApplicationController
layout :with_sidebar
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
@institutions = Current.family.institutions

View file

@ -1,7 +1,7 @@
class CategoriesController < ApplicationController
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
def index

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
class Account::EntryBuilder
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

View file

@ -1,7 +1,7 @@
module Account::Entryable
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)
entryable_type.presence_in(TYPES).constantize

View file

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

View file

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

View file

@ -1,7 +1,7 @@
class Account::TransactionBuilder
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

View file

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

View file

@ -1,5 +1,5 @@
class TimeSeries
DIRECTIONS = %w[ up down ].freeze
DIRECTIONS = %w[up down].freeze
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
config.action_controller.raise_on_missing_callback_actions = true
config.autoload_paths += %w[ test/support ]
config.autoload_paths += %w[test/support]
end

View file

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

View file

@ -39,7 +39,7 @@ class Import::CsvTest < ActiveSupport::TestCase
test "CSV with semicolon column separator" do
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 "Paycheck", csv.table[3][1]
end
@ -84,7 +84,7 @@ class Import::CsvTest < ActiveSupport::TestCase
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 "Amazon stuff", csv.table[1][1]
end
@ -113,7 +113,7 @@ class Import::CsvTest < ActiveSupport::TestCase
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 "Amazon stuff", csv.table[1][1]
end