makandra / active_type

Make any Ruby object quack like ActiveRecord
MIT License
1.09k stars 74 forks source link

Fix a ruby warning due to redundant regex pattern #155

Closed sudoremo closed 2 years ago

sudoremo commented 2 years ago

This fixes the following ruby warning:

lib/active_type/virtual_attributes.rb:115:warning: character class has duplicated range: /\A[A-z0-9_]*\z/

This fix adapts the regex in a way that does not alter its matching pattern. However, while the pattern [A-z] includes all the characters from the alphabet, lower and upper case, it also includes the characters [, \, ], and ^ (among _, which is the point of this issue). If this is not desired, the pattern should be changed to /\A[A-Za-z0-9_]*\z/ instead, as it would be more specific and does not allow any additional characters.

Thanks for considering this PR 👍

kratob commented 2 years ago

Hi @remofritzsche. Your proposed regexp is definitely the better choice, do you want to adapt the PR for that?

sudoremo commented 2 years ago

Sure, the PR should be updated now. Thanks 👌

kratob commented 2 years ago

Released as 2.1.1. Thanks!

sudoremo commented 2 years ago

Many thanks @kratob und Grüsse aus der Schweiz!