Skip to content

Commit

Permalink
Addressed Rubocop concerns from PR 29
Browse files Browse the repository at this point in the history
Rubocop checks in PR marketplacer#29 did not fire, so issues were not discovered
until release. This corrects them, making Rubocop and tests pass.

- GTIN module was 31 lines (max 30), so I inlined a guard clause
- Use of redundant `self.` was removed
- Prefer `__send__` over `send` when `public_send` is not an option
  • Loading branch information
Narnach committed Sep 28, 2022
1 parent 225aadc commit 5e2d2b2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions lib/barcodevalidation/gtin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ def new(input)

# Adds the provided class to the back of the list of prioritized GTIN classes.
def append_gtin_class(gtin_class)
return if gtin_class?(gtin_class)

prioritized_gtin_classes.push(gtin_class)
prioritized_gtin_classes.push(gtin_class) unless gtin_class?(gtin_class)
nil
end

Expand Down
2 changes: 1 addition & 1 deletion lib/barcodevalidation/gtin/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def initialize(input)
# Does this class (potentially) handle a GTIN that matches the input?
# Subclasses can choose to implement their own logic. The default is to look at +VALID_LENGTH+ and use that to match the length of the input the class handles.
def self.handles?(input)
return false unless self.const_defined?(:VALID_LENGTH)
return false unless const_defined?(:VALID_LENGTH)

input.length == self::VALID_LENGTH
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/barcodevalidation/gtin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@

class_obj = Object.const_get(class_sym)
BarcodeValidation::GTIN.remove_gtin_class(class_obj)
Object.send(:remove_const, class_sym)
Object.__send__(:remove_const, class_sym)
end
end

Expand Down

0 comments on commit 5e2d2b2

Please sign in to comment.