Skip to content

Commit d569fb0

Browse files
committed
Use angellist rubocop + autocorrects
1 parent 6b3be80 commit d569fb0

21 files changed

+157
-189
lines changed

.rubocop.yml

Lines changed: 6 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,9 @@
1-
require:
2-
- rubocop-rspec
1+
inherit_gem:
2+
rubocop-angellist: rubocop.yml
33

4+
# Local project tweaks can go below. Keep minimal; rely on shared config.
45
AllCops:
5-
NewCops: enable
6-
TargetRubyVersion: 3.0
76
Exclude:
8-
- 'vendor/**/*'
9-
- 'sorbet/**/*'
10-
- 'tmp/**/*'
11-
12-
Style/Documentation:
13-
Enabled: false
14-
15-
Style/StringLiterals:
16-
EnforcedStyle: single_quotes
17-
18-
Style/FrozenStringLiteralComment:
19-
Enabled: true
20-
21-
Layout/LineLength:
22-
Max: 120
23-
24-
Metrics/BlockLength:
25-
Exclude:
26-
- 'spec/**/*'
27-
- 'examples/**/*'
28-
29-
Metrics/MethodLength:
30-
Max: 20
31-
Exclude:
32-
- 'spec/**/*'
33-
34-
Metrics/AbcSize:
35-
Max: 25
36-
Exclude:
37-
- 'spec/**/*'
38-
39-
Style/TrailingCommaInArrayLiteral:
40-
EnforcedStyleForMultiline: no_comma
41-
42-
Style/TrailingCommaInHashLiteral:
43-
EnforcedStyleForMultiline: no_comma
44-
45-
Naming/MethodParameterName:
46-
AllowedNames:
47-
- io
48-
- id
49-
- to
50-
- by
51-
- on
52-
- in
53-
- at
54-
55-
RSpec/ExampleLength:
56-
Max: 15
57-
58-
RSpec/MultipleExpectations:
59-
Max: 5
60-
61-
RSpec/NestedGroups:
62-
Max: 4
63-
7+
- "vendor/**/*"
8+
- "sorbet/**/*"
9+
- "tmp/**/*"

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ gemspec
77

88
gem 'pry', '~> 0.14'
99
gem 'simplecov', '~> 0.22', require: false
10+
11+
group :development do
12+
gem 'rubocop-angellist', github: 'angellist/rubocop-angellist'
13+
end

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ RSpec::Core::RakeTask.new(:spec)
88
RuboCop::RakeTask.new
99

1010
desc 'Run Sorbet type checker'
11-
task :sorbet do
11+
task sorbet: :environment do
1212
sh 'bundle exec srb tc'
1313
end
1414

1515
desc 'Run all checks (tests, linting, type checking)'
16-
task checks: %i[spec rubocop sorbet]
16+
task checks: [:spec, :rubocop, :sorbet]
1717

1818
task default: :checks

examples/basic_spreadsheet.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@
2323
bg_color: '366092',
2424
fg_color: 'FFFFFF',
2525
b: true,
26-
alignment: { horizontal: :center }
26+
alignment: { horizontal: :center },
2727
)
2828

2929
document.add_style!(
3030
:currency,
31-
format_code: '$#,##0.00'
31+
format_code: '$#,##0.00',
3232
)
3333

3434
document.add_style!(
3535
:total,
3636
b: true,
3737
format_code: '$#,##0.00',
38-
bg_color: 'E7E6E6'
38+
bg_color: 'E7E6E6',
3939
)
4040

4141
# Add header row
@@ -46,15 +46,15 @@
4646
{ month: 'January', sales: 50_000, expenses: 30_000 },
4747
{ month: 'February', sales: 55_000, expenses: 32_000 },
4848
{ month: 'March', sales: 60_000, expenses: 35_000 },
49-
{ month: 'April', sales: 58_000, expenses: 33_000 }
49+
{ month: 'April', sales: 58_000, expenses: 33_000 },
5050
]
5151

5252
rows = []
5353
data.each_with_index do |item, index|
5454
row = sheet.add_row!(:"month_#{index + 1}")
55-
.add!(:month, value: item[:month])
56-
.add!(:sales, value: item[:sales], style: :currency)
57-
.add!(:expenses, value: item[:expenses], style: :currency)
55+
.add!(:month, value: item[:month])
56+
.add!(:sales, value: item[:sales], style: :currency)
57+
.add!(:expenses, value: item[:expenses], style: :currency)
5858

5959
# Profit = Sales - Expenses (formula)
6060
row.add!(:profit, value: row.ref(:sales) - row.ref(:expenses), style: :currency)
@@ -63,27 +63,27 @@
6363

6464
# Add total row
6565
total_row = sheet.add_row!(:total)
66-
.add!(:month, value: 'TOTAL', style: :total)
66+
.add!(:month, value: 'TOTAL', style: :total)
6767

6868
# Sum all sales
6969
total_row.add!(
7070
:sales,
7171
value: Zaxcel::Functions.sum(Zaxcel::Lang.range(rows.first!.ref(:sales), rows.last!.ref(:sales))),
72-
style: :total
72+
style: :total,
7373
)
7474

7575
# Sum all expenses
7676
total_row.add!(
7777
:expenses,
7878
value: Zaxcel::Functions.sum(Zaxcel::Lang.range(rows.first!.ref(:expenses), rows.last!.ref(:expenses))),
79-
style: :total
79+
style: :total,
8080
)
8181

8282
# Sum all profit
8383
total_row.add!(
8484
:profit,
8585
value: Zaxcel::Functions.sum(Zaxcel::Lang.range(rows.first!.ref(:profit), rows.last!.ref(:profit))),
86-
style: :total
86+
style: :total,
8787
)
8888

8989
# Position rows before generating so references resolve

examples/cross_sheet_references.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
{ name: 'Widget A', price: 10.50, stock: 100 },
2525
{ name: 'Widget B', price: 15.75, stock: 75 },
2626
{ name: 'Gadget X', price: 25.00, stock: 50 },
27-
{ name: 'Gadget Y', price: 30.25, stock: 25 }
27+
{ name: 'Gadget Y', price: 30.25, stock: 25 },
2828
]
2929

3030
product_rows = []
3131
products.each do |product|
3232
row = data_sheet.add_row!(product[:name])
33-
.add!(:product, value: product[:name])
34-
.add!(:unit_price, value: product[:price], style: :currency)
35-
.add!(:stock, value: product[:stock])
33+
.add!(:product, value: product[:name])
34+
.add!(:unit_price, value: product[:price], style: :currency)
35+
.add!(:stock, value: product[:stock])
3636
product_rows << row
3737
end
3838

@@ -51,46 +51,46 @@
5151
end
5252

5353
summary_sheet.add_row!(:total_inventory)
54-
.add!(:metric, value: 'Total Inventory Value')
55-
.add!(:value, value: inventory_formula, style: :currency)
54+
.add!(:metric, value: 'Total Inventory Value')
55+
.add!(:value, value: inventory_formula, style: :currency)
5656

5757
# Average product price
5858
avg_price = Zaxcel::Functions::Average.new(
5959
Zaxcel::Lang.range(
6060
data_sheet.cell_ref(:unit_price, products.first[:name]),
61-
data_sheet.cell_ref(:unit_price, products.last[:name])
62-
)
61+
data_sheet.cell_ref(:unit_price, products.last[:name]),
62+
),
6363
)
6464

6565
summary_sheet.add_row!(:avg_price)
66-
.add!(:metric, value: 'Average Product Price')
67-
.add!(:value, value: avg_price, style: :currency)
66+
.add!(:metric, value: 'Average Product Price')
67+
.add!(:value, value: avg_price, style: :currency)
6868

6969
# Total stock units
7070
total_stock = Zaxcel::Functions.sum(
7171
Zaxcel::Lang.range(
7272
data_sheet.cell_ref(:stock, products.first[:name]),
73-
data_sheet.cell_ref(:stock, products.last[:name])
74-
)
73+
data_sheet.cell_ref(:stock, products.last[:name]),
74+
),
7575
)
7676

7777
summary_sheet.add_row!(:total_stock)
78-
.add!(:metric, value: 'Total Stock Units')
79-
.add!(:value, value: total_stock)
78+
.add!(:metric, value: 'Total Stock Units')
79+
.add!(:value, value: total_stock)
8080

8181
# Most expensive product
8282
max_price = Zaxcel::Functions::Max.new(
8383
[
8484
Zaxcel::Lang.range(
8585
data_sheet.cell_ref(:unit_price, products.first[:name]),
86-
data_sheet.cell_ref(:unit_price, products.last[:name])
87-
)
88-
]
86+
data_sheet.cell_ref(:unit_price, products.last[:name]),
87+
),
88+
],
8989
)
9090

9191
summary_sheet.add_row!(:max_price)
92-
.add!(:metric, value: 'Highest Price')
93-
.add!(:value, value: max_price, style: :currency)
92+
.add!(:metric, value: 'Highest Price')
93+
.add!(:value, value: max_price, style: :currency)
9494

9595
summary_sheet.position_rows!
9696
summary_sheet.generate_sheet!

lib/zaxcel/binary_expression.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Zaxcel::BinaryExpression < Zaxcel::CellFormula
1111
params(
1212
operator: String,
1313
lh_value: Zaxcel::Cell::ValueType,
14-
rh_value: Zaxcel::Cell::ValueType
14+
rh_value: Zaxcel::Cell::ValueType,
1515
).void
1616
end
1717
def initialize(operator, lh_value, rh_value)
@@ -33,7 +33,7 @@ def format(on_sheet:)
3333
sig do
3434
params(
3535
value: Zaxcel::Cell::ValueType,
36-
on_sheet: String
36+
on_sheet: String,
3737
).returns(T.any(Numeric, Money, String))
3838
end
3939
def format_value(value, on_sheet:)

lib/zaxcel/binary_expressions/addition.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Zaxcel::BinaryExpressions::Addition < Zaxcel::BinaryExpression
77
sig do
88
params(
99
lh_value: Zaxcel::Cell::ValueType,
10-
rh_value: Zaxcel::Cell::ValueType
10+
rh_value: Zaxcel::Cell::ValueType,
1111
).void
1212
end
1313
def initialize(lh_value, rh_value)

lib/zaxcel/binary_expressions/division.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Zaxcel::BinaryExpressions::Division < Zaxcel::BinaryExpression
77
sig do
88
params(
99
lh_value: Zaxcel::Cell::ValueType,
10-
rh_value: Zaxcel::Cell::ValueType
10+
rh_value: Zaxcel::Cell::ValueType,
1111
).void
1212
end
1313
def initialize(lh_value, rh_value)

lib/zaxcel/binary_expressions/multiplication.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Zaxcel::BinaryExpressions::Multiplication < Zaxcel::BinaryExpression
77
sig do
88
params(
99
lh_value: Zaxcel::Cell::ValueType,
10-
rh_value: Zaxcel::Cell::ValueType
10+
rh_value: Zaxcel::Cell::ValueType,
1111
).void
1212
end
1313
def initialize(lh_value, rh_value)

lib/zaxcel/binary_expressions/subtraction.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Zaxcel::BinaryExpressions::Subtraction < Zaxcel::BinaryExpression
77
sig do
88
params(
99
lh_value: Zaxcel::Cell::ValueType,
10-
rh_value: Zaxcel::Cell::ValueType
10+
rh_value: Zaxcel::Cell::ValueType,
1111
).void
1212
end
1313
def initialize(lh_value, rh_value)

0 commit comments

Comments
 (0)