Skip to content

Commit 5c01ba3

Browse files
anna-devKagemaru
authored andcommitted
Fix some rubocop issues
1 parent d7666ac commit 5c01ba3

17 files changed

+78
-147
lines changed

.rubocop_todo.yml

Lines changed: 21 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,20 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2025-04-24 12:14:19 UTC using RuboCop version 1.72.2.
3+
# on 2025-12-03 15:37:34 UTC using RuboCop version 1.75.3.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
---
10-
# FIXME: Fix these, piece by piece
11-
129
# Offense count: 1
13-
# This cop supports safe autocorrection (--autocorrect).
14-
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
15-
# SupportedStyles: space, no_space, compact
16-
# SupportedStylesForEmptyBrackets: space, no_space
17-
Layout/SpaceInsideArrayLiteralBrackets:
18-
Exclude:
19-
- 'app/models/employment.rb'
20-
21-
# Offense count: 2
22-
# This cop supports safe autocorrection (--autocorrect).
23-
Lint/AmbiguousOperator:
24-
Exclude:
25-
- 'test/models/employee_test.rb'
26-
27-
# Offense count: 3
2810
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
2911
Lint/DuplicateBranch:
3012
Exclude:
31-
- 'app/controllers/concerns/worktimes_report.rb'
3213
- 'app/domain/plannings/employee_board.rb'
3314

34-
# Offense count: 4
15+
# Offense count: 1
3516
Lint/DuplicateMethods:
3617
Exclude:
37-
- 'app/domain/forms/multi_absence.rb'
38-
- 'app/domain/order/copier.rb'
3918
- 'app/helpers/dry_crud/form/control.rb'
4019

4120
# Offense count: 1
@@ -45,6 +24,8 @@ Lint/EmptyBlock:
4524
- 'test/helpers/table_helper_test.rb'
4625

4726
# Offense count: 2
27+
# This cop supports safe autocorrection (--autocorrect).
28+
# Configuration parameters: AutoCorrect.
4829
Lint/LiteralAsCondition:
4930
Exclude:
5031
- 'test/helpers/dry_crud/form/builder_test.rb'
@@ -80,44 +61,44 @@ Lint/UnreachableLoop:
8061
Exclude:
8162
- 'app/models/working_condition.rb'
8263

83-
# Offense count: 98
64+
# Offense count: 110
8465
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
8566
Metrics/AbcSize:
8667
Max: 282
8768

88-
# Offense count: 51
69+
# Offense count: 55
8970
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
9071
# AllowedMethods: refine
9172
Metrics/BlockLength:
9273
Max: 97
9374

94-
# Offense count: 36
75+
# Offense count: 38
9576
# Configuration parameters: CountComments, CountAsOne.
9677
Metrics/ClassLength:
9778
Max: 314
9879

99-
# Offense count: 17
80+
# Offense count: 18
10081
# Configuration parameters: AllowedMethods, AllowedPatterns.
10182
Metrics/CyclomaticComplexity:
10283
Max: 13
10384

104-
# Offense count: 110
85+
# Offense count: 129
10586
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
10687
Metrics/MethodLength:
10788
Max: 312
10889

10990
# Offense count: 5
11091
# Configuration parameters: CountComments, CountAsOne.
11192
Metrics/ModuleLength:
112-
Max: 205
93+
Max: 157
11394

11495
# Offense count: 2
11596
# Configuration parameters: CountKeywordArgs.
11697
Metrics/ParameterLists:
11798
Max: 6
11899
MaxOptionalParameters: 4
119100

120-
# Offense count: 7
101+
# Offense count: 8
121102
# Configuration parameters: AllowedMethods, AllowedPatterns.
122103
Metrics/PerceivedComplexity:
123104
Max: 13
@@ -145,7 +126,7 @@ Naming/HeredocDelimiterNaming:
145126
Exclude:
146127
- 'lib/tasks/license.rake'
147128

148-
# Offense count: 14
129+
# Offense count: 13
149130
# This cop supports unsafe autocorrection (--autocorrect-all).
150131
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
151132
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
@@ -160,7 +141,6 @@ Naming/MemoizedInstanceVariableName:
160141
- 'app/controllers/ordertimes_controller.rb'
161142
- 'app/controllers/plannings/employees_controller.rb'
162143
- 'app/controllers/plannings/orders_controller.rb'
163-
- 'app/domain/order/cockpit/accounting_post_row.rb'
164144
- 'app/domain/order/report/entry.rb'
165145
- 'app/models/util/period.rb'
166146

@@ -187,30 +167,23 @@ Naming/MethodParameterName:
187167

188168
# Offense count: 3
189169
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
190-
# NamePrefix: is_, has_, have_
191-
# ForbiddenPrefixes: is_, has_, have_
170+
# NamePrefix: is_, has_, have_, does_
171+
# ForbiddenPrefixes: is_, has_, have_, does_
192172
# AllowedMethods: is_a?
193173
# MethodDefinitionMacros: define_method, define_singleton_method
194174
Naming/PredicateName:
195175
Exclude:
196176
- 'app/helpers/dry_crud/form/builder.rb'
197177
- 'app/models/concerns/belonging_to_work_item.rb'
198178

199-
# Offense count: 5
200-
# Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns.
201-
# SupportedStyles: snake_case, camelCase
202-
Naming/VariableName:
203-
Exclude:
204-
- 'test/models/worktime_test.rb'
205-
206179
# Offense count: 15
207180
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
208181
# SupportedStyles: snake_case, normalcase, non_integer
209-
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
182+
# AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
210183
Naming/VariableNumber:
211184
Exclude:
185+
- 'test/controllers/clients_controller_test.rb'
212186
- 'test/controllers/contacts_controller_test.rb'
213-
- 'test/controllers/employments_controller_test.rb'
214187
- 'test/controllers/invoices_controller_test.rb'
215188
- 'test/controllers/orders_controller_test.rb'
216189
- 'test/controllers/overtime_vacations_controller_test.rb'
@@ -219,12 +192,6 @@ Naming/VariableNumber:
219192
- 'test/models/invoice_test.rb'
220193
- 'test/models/order_test.rb'
221194

222-
# Offense count: 1
223-
# Configuration parameters: MinSize.
224-
Performance/CollectionLiteralInLoop:
225-
Exclude:
226-
- 'test/controllers/evaluator_controller_test.rb'
227-
228195
# Offense count: 1
229196
Performance/FixedSize:
230197
Exclude:
@@ -236,14 +203,6 @@ Performance/MethodObjectAsBlock:
236203
- 'app/domain/apidocs/setup.rb'
237204
- 'app/helpers/order_helper.rb'
238205

239-
# Offense count: 2
240-
# This cop supports unsafe autocorrection (--autocorrect-all).
241-
# Configuration parameters: EnforcedStyle, AllowToTime.
242-
# SupportedStyles: strict, flexible
243-
Rails/Date:
244-
Exclude:
245-
- 'test/models/employee_test.rb'
246-
247206
# Offense count: 3
248207
# Configuration parameters: Include.
249208
# Include: app/models/**/*.rb
@@ -269,7 +228,7 @@ Rails/HasManyOrHasOneDependent:
269228
- 'app/models/service.rb'
270229
- 'app/models/work_item.rb'
271230

272-
# Offense count: 55
231+
# Offense count: 61
273232
# Configuration parameters: Include.
274233
# Include: app/helpers/**/*.rb
275234
Rails/HelperInstanceVariable:
@@ -426,7 +385,7 @@ Style/ConditionalAssignment:
426385
Exclude:
427386
- 'app/controllers/concerns/worktimes_report.rb'
428387

429-
# Offense count: 315
388+
# Offense count: 324
430389
# Configuration parameters: AllowedConstants.
431390
Style/Documentation:
432391
Enabled: false
@@ -440,21 +399,11 @@ Style/FrozenStringLiteralComment:
440399
- 'app/models/application_record.rb'
441400
- 'test/models/employee_test.rb'
442401

443-
# Offense count: 2
444-
# Configuration parameters: MinBranchesCount.
445-
Style/HashLikeCase:
446-
Exclude:
447-
- 'app/domain/order/report.rb'
448-
- 'app/helpers/order_helper.rb'
449-
450-
# Offense count: 4
402+
# Offense count: 1
451403
# This cop supports safe autocorrection (--autocorrect).
452404
Style/IfUnlessModifier:
453405
Exclude:
454-
- 'app/controllers/order_targets_controller.rb'
455-
- 'app/domain/forms/worktime_edit.rb'
456406
- 'app/domain/plannings/employee_board.rb'
457-
- 'app/models/accounting_post.rb'
458407

459408
# Offense count: 2
460409
Style/MissingRespondToMissing:
@@ -473,25 +422,15 @@ Style/OpenStructUse:
473422
- 'app/controllers/order_services_controller.rb'
474423
- 'test/controllers/employees_controller_test.rb'
475424

476-
# Offense count: 25
425+
# Offense count: 27
477426
# Configuration parameters: AllowedMethods.
478427
# AllowedMethods: respond_to_missing?
479428
Style/OptionalBooleanParameter:
480429
Enabled: false
481430

482-
# Offense count: 3
483-
# This cop supports unsafe autocorrection (--autocorrect-all).
484-
# Configuration parameters: Mode.
485-
Style/StringConcatenation:
486-
Exclude:
487-
- 'app/controllers/evaluator_controller.rb'
488-
- 'app/domain/order/services/csv_filename_generator.rb'
489-
- 'lib/tasks/license.rake'
490-
491-
# Offense count: 38
431+
# Offense count: 66
492432
# This cop supports safe autocorrection (--autocorrect).
493433
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
494434
# URISchemes: http, https
495435
Layout/LineLength:
496436
Max: 234
497-
...

app/controllers/concerns/worktimes_report.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,10 @@ def combine_ticket_employees(combined_tickets, employees, worktime)
8686
end
8787

8888
def combine_ticket_date_range(date_range, worktime)
89-
if date_range[0].nil?
90-
date_range[0] = worktime.work_date
91-
elsif worktime.work_date < date_range[0]
92-
date_range[0] = worktime.work_date
93-
end
89+
date_range[0] = worktime.work_date if date_range[0].nil? || (worktime.work_date < date_range[0])
9490

95-
if date_range[1].nil?
96-
date_range[1] = worktime.work_date
97-
elsif worktime.work_date > date_range[1]
98-
date_range[1] = worktime.work_date
99-
end
91+
return unless date_range[1].nil? || (worktime.work_date > date_range[1])
92+
93+
date_range[1] = worktime.work_date
10094
end
10195
end

app/controllers/evaluator_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def report
6363
@period.to_s.parameterize
6464
].compact
6565

66-
filename = file_parts.compact.join('-') + '.pdf'
66+
filename = "#{file_parts.compact.join('-')}.pdf"
6767

6868
send_data pdf_generator.generate_pdf.render,
6969
filename: filename,
@@ -73,8 +73,8 @@ def report
7373

7474
def export_csv
7575
set_evaluation_details
76-
filename = ['puzzletime', csv_label(@evaluation.category),
77-
csv_label(@evaluation.division)].compact.join('-') + '.csv'
76+
filename = "#{['puzzletime', csv_label(@evaluation.category),
77+
csv_label(@evaluation.division)].compact.join('-')}.csv"
7878
times = @evaluation.times(@period)
7979
send_worktimes_csv(times, filename)
8080
end

app/controllers/order_targets_controller.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ def update
2323
def update_targets
2424
@errors = OrderTarget.new.errors
2525
@order_targets.each do |target|
26-
unless target.update(target_params(target))
27-
target.errors.each { |error| @errors.add(error.attribute, error.message) }
28-
end
26+
target.errors.each { |error| @errors.add(error.attribute, error.message) } unless target.update(target_params(target))
2927
end
3028
end
3129

app/domain/forms/multi_absence.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
module Forms
99
class MultiAbsence
1010
attr_accessor :employee
11-
attr_reader :absence_id, :work_date, :duration, :description, :worktime
11+
attr_reader :absence_id, :description, :worktime
1212

1313
def initialize
1414
@duration = 1

app/domain/forms/worktime_edit.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ class WorktimeEdit < Forms::Splitable
1010
self.incomplete_finish = false
1111

1212
def add_worktime(worktime)
13-
if worktime.hours - remaining_hours > 0.00001 # we are working with floats: use delta
14-
worktime.errors.add(:hours, 'Die gesamte Anzahl Stunden kann nicht vergrössert werden')
15-
end
13+
worktime.errors.add(:hours, 'Die gesamte Anzahl Stunden kann nicht vergrössert werden') if worktime.hours - remaining_hours > 0.00001 # we are working with floats: use delta
1614
worktime.employee = original.employee
1715
super if worktime.errors.empty?
1816
worktime.errors.empty?

app/domain/order/copier.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77

88
class Order
99
class Copier
10-
attr_reader :source, :copy
10+
attr_reader :source
1111

1212
def initialize(source)
1313
@source = source
1414
end
1515

1616
# Copies an order together with everything that is edited in the order form.
1717
def copy
18+
return @copy if defined?(@copy)
19+
1820
@copy = source.dup
1921
@copy.work_item = source.work_item.dup
2022
@copy.work_item.parent_id = source.work_item.parent_id

app/domain/order/report.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,18 @@ def filter_by_closed(orders)
176176

177177
def filter_by_uncertainty(orders, attr)
178178
if params[attr].present?
179-
orders.where(attr => map_uncertainties_filter(params[attr]))
179+
orders.where(attr => uncertainties_filter[params[attr]])
180180
else
181181
orders
182182
end
183183
end
184184

185-
def map_uncertainties_filter(value)
186-
case value
187-
when 'low'
188-
0..2
189-
when 'medium'
190-
3..7
191-
when 'high'
192-
8..16
193-
end
185+
def uncertainties_filter
186+
@uncertainties_filter ||= {
187+
'low' => 0..2,
188+
'medium' => 3..7,
189+
'high' => 8..16
190+
}
194191
end
195192

196193
def sort_entries(entries)

app/domain/order/services/csv_filename_generator.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,21 @@ def initialize(order, params = {})
1616
end
1717

1818
def filename
19+
"#{filename_prefix}.csv"
20+
end
21+
22+
private
23+
24+
def filename_prefix
1925
['puzzletime',
2026
accounting_post_shortnames || order_shortnames,
2127
employee_shortname,
2228
ticket,
2329
billable]
2430
.compact
25-
.join('-') +
26-
'.csv'
31+
.join('-')
2732
end
2833

29-
private
30-
3134
def order_shortnames
3235
order.work_item.path_shortnames
3336
end

0 commit comments

Comments
 (0)