Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5a6383f
Add Reek configuration file to manage code smells
olbrich Dec 27, 2025
0544494
Refactor Cache and Unit classes to use attr_reader for improved encap…
olbrich Dec 27, 2025
c7c323f
Refactor nil checks to use NilClass for improved clarity and consistency
olbrich Dec 27, 2025
320e8e6
Refactor unit processing methods for improved readability and maintai…
olbrich Dec 27, 2025
7242dc9
Refactor unit conversion logic for improved clarity and performance
olbrich Dec 28, 2025
99fc749
Refactor unit_signature_vector method to use apply_signature_items fo…
olbrich Dec 28, 2025
ade539d
Refactor to_s method parameters for improved clarity and flexibility
olbrich Dec 28, 2025
fec23a4
Refactor use_definition method to improve regex cache management and …
olbrich Dec 28, 2025
0112fca
Refactor power method for improved readability and maintainability by…
olbrich Dec 28, 2025
dd338cb
Refactor parse method for improved readability and maintainability by…
olbrich Dec 28, 2025
b70585c
Refactor unit methods for improved clarity and maintainability by reo…
olbrich Dec 28, 2025
e861f45
Refactor return_scalar_or_raise method to simplify conversion logic a…
olbrich Dec 28, 2025
041a8b4
Refactor return_scalar_or_unit method to simplify parameter usage and…
olbrich Dec 28, 2025
1a9b19c
Refactor error messages for consistency in power operation validation
olbrich Dec 28, 2025
95fa138
Refactor simplify_rational method to improve clarity and encapsulate …
olbrich Dec 28, 2025
4793e58
Refactor simplify_rational method to be a class method and improve vi…
olbrich Dec 28, 2025
1e11a30
Refactor regex patterns in unit parsing for improved clarity and main…
olbrich Dec 28, 2025
c18cc6c
Refactor error messages for unit compatibility to include unit values…
olbrich Dec 28, 2025
eff38ce
Merge branch 'master' into reek-cleanup-unit
olbrich Dec 28, 2025
9c95df5
Enhance documentation for unit methods with parameter and return type…
olbrich Dec 28, 2025
c01e0c0
Remove redundant comment in hash method override for clarity
olbrich Dec 28, 2025
9a16584
Refactor division method to eliminate duplicate zero division checks …
olbrich Dec 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .reek.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Reek configuration
#
# InstanceVariableAssumption is disabled for Unit class because it uses a mix of
# eager initialization (in initialize_instance_variables) and lazy initialization
# (using defined? checks) for its instance variables. This is an intentional design
# pattern where some variables are initialized immediately and others are computed
# on first access for performance reasons.
#
# See: https://github.com/troessner/reek/blob/master/docs/Instance-Variable-Assumption.md
#
# RepeatedConditional warnings are excluded for Unit class where the same condition
# needs to be checked in different methods for different purposes:
#
# - base?: Checked in to_base (early return), update_base_scalar (base unit calculation),
# and unit_signature_vector (recursion avoidance). Each serves a distinct purpose.
#
# - other: Type checking in operator overloading methods using case statements.
# This is a standard Ruby pattern for implementing polymorphic operators.
#
# - prefix_value: Checked in to_base (numerator/denominator processing) and parse
# (string parsing). These are completely different contexts.
#
# - temperature?: Checked in multiple methods (to_base, temperature_scale, arithmetic
# operators, power/root) where each serves a different purpose (conversion, formatting,
# validation, etc.).

detectors:
InstanceVariableAssumption:
exclude:
- RubyUnits::Unit

RepeatedConditional:
exclude:
- RubyUnits::Unit
2 changes: 1 addition & 1 deletion lib/ruby_units/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module RubyUnits
# Performance optimizations to avoid creating units unnecessarily
class Cache
attr_accessor :data
attr_reader :data

def initialize
clear
Expand Down
Loading