From 37f40142ca24da7ec26ab51babef31d4d3dfeca4 Mon Sep 17 00:00:00 2001 From: Thomas Nys Date: Sun, 26 Apr 2015 23:44:21 +0200 Subject: [PATCH 1/7] Mitigates Style/TrailingComma --- spec/web/url_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/web/url_spec.rb b/spec/web/url_spec.rb index d5827ba..9ba3c6c 100644 --- a/spec/web/url_spec.rb +++ b/spec/web/url_spec.rb @@ -47,7 +47,7 @@ 'http:///a', 'http:// shouldfail.com', ':// should fail', - 'http://foo.bar/foo(bar)baz quux', + 'http://foo.bar/foo(bar)baz quux' ] let(:r) { Regexy::Web::Url.new } From 866a39433f3c00c2cfa11b42428ffd601e921f13 Mon Sep 17 00:00:00 2001 From: Thomas Nys Date: Sun, 26 Apr 2015 23:57:10 +0200 Subject: [PATCH 2/7] Mitigates Style/TrailingBlankLines --- lib/regexy/regexp.rb | 2 +- lib/regexy/text.rb | 2 +- lib/regexy/text/emoji.rb | 2 +- lib/regexy/text/smile.rb | 2 +- lib/regexy/web.rb | 2 +- lib/regexy/web/email.rb | 2 +- lib/regexy/web/hashtag.rb | 2 +- lib/regexy/web/host_name.rb | 2 +- lib/regexy/web/url.rb | 2 +- spec/regexp_spec.rb | 2 +- spec/text/emoji_spec.rb | 2 +- spec/text/smile_spec.rb | 2 +- spec/web/email_spec.rb | 2 +- spec/web/hashtag_spec.rb | 2 +- spec/web/host_name_spec.rb | 2 +- spec/web/ip_spec.rb | 2 +- spec/web/url_spec.rb | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/regexy/regexp.rb b/lib/regexy/regexp.rb index af1d59f..2fbac6b 100644 --- a/lib/regexy/regexp.rb +++ b/lib/regexy/regexp.rb @@ -94,4 +94,4 @@ def default_mode :normal end end -end \ No newline at end of file +end diff --git a/lib/regexy/text.rb b/lib/regexy/text.rb index 652ade8..80b63ff 100644 --- a/lib/regexy/text.rb +++ b/lib/regexy/text.rb @@ -3,4 +3,4 @@ module Text autoload :Smile, 'regexy/text/smile' autoload :Emoji, 'regexy/text/emoji' end -end \ No newline at end of file +end diff --git a/lib/regexy/text/emoji.rb b/lib/regexy/text/emoji.rb index 9c84531..0192ceb 100644 --- a/lib/regexy/text/emoji.rb +++ b/lib/regexy/text/emoji.rb @@ -10,4 +10,4 @@ def initialize(*args) end end end -end \ No newline at end of file +end diff --git a/lib/regexy/text/smile.rb b/lib/regexy/text/smile.rb index 16c7236..a3edb1a 100644 --- a/lib/regexy/text/smile.rb +++ b/lib/regexy/text/smile.rb @@ -8,4 +8,4 @@ def initialize(*args) end end end -end \ No newline at end of file +end diff --git a/lib/regexy/web.rb b/lib/regexy/web.rb index 0b319bc..0d51650 100644 --- a/lib/regexy/web.rb +++ b/lib/regexy/web.rb @@ -7,4 +7,4 @@ module Web autoload :Url, 'regexy/web/url' autoload :HostName, 'regexy/web/host_name' end -end \ No newline at end of file +end diff --git a/lib/regexy/web/email.rb b/lib/regexy/web/email.rb index 7535bfc..35ed549 100644 --- a/lib/regexy/web/email.rb +++ b/lib/regexy/web/email.rb @@ -19,4 +19,4 @@ def regexp_for(mode) end end end -end \ No newline at end of file +end diff --git a/lib/regexy/web/hashtag.rb b/lib/regexy/web/hashtag.rb index c3b6367..26eaa47 100644 --- a/lib/regexy/web/hashtag.rb +++ b/lib/regexy/web/hashtag.rb @@ -10,4 +10,4 @@ def initialize(*args) end end end -end \ No newline at end of file +end diff --git a/lib/regexy/web/host_name.rb b/lib/regexy/web/host_name.rb index f323473..ddcd539 100644 --- a/lib/regexy/web/host_name.rb +++ b/lib/regexy/web/host_name.rb @@ -10,4 +10,4 @@ def initialize(*args) end end end -end \ No newline at end of file +end diff --git a/lib/regexy/web/url.rb b/lib/regexy/web/url.rb index a37f489..c05d837 100644 --- a/lib/regexy/web/url.rb +++ b/lib/regexy/web/url.rb @@ -17,4 +17,4 @@ def initialize(*args) end end end -end \ No newline at end of file +end diff --git a/spec/regexp_spec.rb b/spec/regexp_spec.rb index b6be55b..ad5ee1c 100644 --- a/spec/regexp_spec.rb +++ b/spec/regexp_spec.rb @@ -202,4 +202,4 @@ def default_mode it 'fails when wrong mode is provided' do expect { ValidRegex.new(:mode_3) }.to raise_error ArgumentError end -end \ No newline at end of file +end diff --git a/spec/text/emoji_spec.rb b/spec/text/emoji_spec.rb index 7da6db7..4698512 100644 --- a/spec/text/emoji_spec.rb +++ b/spec/text/emoji_spec.rb @@ -8,4 +8,4 @@ expect([p].pack('U*') =~ r).to be_truthy end end -end \ No newline at end of file +end diff --git a/spec/text/smile_spec.rb b/spec/text/smile_spec.rb index a245d90..796ade9 100644 --- a/spec/text/smile_spec.rb +++ b/spec/text/smile_spec.rb @@ -32,4 +32,4 @@ expect(smile =~ r).to be_nil end end -end \ No newline at end of file +end diff --git a/spec/web/email_spec.rb b/spec/web/email_spec.rb index d6a80c8..6cc015a 100644 --- a/spec/web/email_spec.rb +++ b/spec/web/email_spec.rb @@ -151,4 +151,4 @@ end end end -end \ No newline at end of file +end diff --git a/spec/web/hashtag_spec.rb b/spec/web/hashtag_spec.rb index c5dda56..6a420c7 100644 --- a/spec/web/hashtag_spec.rb +++ b/spec/web/hashtag_spec.rb @@ -35,4 +35,4 @@ expect("##{hashtag}" =~ r).to be_nil end end -end \ No newline at end of file +end diff --git a/spec/web/host_name_spec.rb b/spec/web/host_name_spec.rb index db0e761..c7ed05f 100644 --- a/spec/web/host_name_spec.rb +++ b/spec/web/host_name_spec.rb @@ -35,4 +35,4 @@ expect(hostname =~ r).to be_nil end end -end \ No newline at end of file +end diff --git a/spec/web/ip_spec.rb b/spec/web/ip_spec.rb index 8e022f3..2481686 100644 --- a/spec/web/ip_spec.rb +++ b/spec/web/ip_spec.rb @@ -134,4 +134,4 @@ end end end -end \ No newline at end of file +end diff --git a/spec/web/url_spec.rb b/spec/web/url_spec.rb index 9ba3c6c..f332c7a 100644 --- a/spec/web/url_spec.rb +++ b/spec/web/url_spec.rb @@ -63,4 +63,4 @@ expect(url =~ r).to be_nil end end -end \ No newline at end of file +end From eb925bd5440e9a9aba4072d0ca1e0da618c1bc28 Mon Sep 17 00:00:00 2001 From: Thomas Nys Date: Mon, 27 Apr 2015 00:04:39 +0200 Subject: [PATCH 3/7] Mitigates Style/LeadingCommentSpace --- spec/regexp_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/regexp_spec.rb b/spec/regexp_spec.rb index ad5ee1c..1f48c33 100644 --- a/spec/regexp_spec.rb +++ b/spec/regexp_spec.rb @@ -31,7 +31,7 @@ end it 'mimics original regexp behaviour' do - #Fix for rubinius + # Fix for rubinius expected_methods = ::Regexp.public_instance_methods(false) - [:initialize, :initialize_copy] expect(Regexy::Regexp.public_instance_methods(false)).to include(*expected_methods) end From cfb501237e4731fdfe77b3b95fbebebd29b4af77 Mon Sep 17 00:00:00 2001 From: Thomas Nys Date: Mon, 27 Apr 2015 00:16:25 +0200 Subject: [PATCH 4/7] Mitigates Style/IfUnlessModifier --- lib/regexy/regexp.rb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/regexy/regexp.rb b/lib/regexy/regexp.rb index 2fbac6b..6e9fc5b 100644 --- a/lib/regexy/regexp.rb +++ b/lib/regexy/regexp.rb @@ -35,12 +35,8 @@ def + other def bound(method = :both) new_regexp = source method = method.to_sym - if method == :left || method == :both - new_regexp.prepend('\A') - end - if method == :right || method == :both - new_regexp.concat('\z') - end + new_regexp.prepend('\A') if method == :left || method == :both + new_regexp.concat('\z') if method == :right || method == :both new_regexp = additional_bound(method, new_regexp) ::Regexy::Regexp.new(new_regexp, options) end @@ -48,12 +44,8 @@ def bound(method = :both) def unbound(method = :both) new_regexp = source method = method.to_sym - if method == :left || method == :both - new_regexp.sub!(/\A\\A/, '') - end - if method == :right || method == :both - new_regexp.sub!(/\\z\s*\z/, '') - end + new_regexp.sub!(/\A\\A/, '') if method == :left || method == :both + new_regexp.sub!(/\\z\s*\z/, '') if method == :right || method == :both new_regexp = additional_unbound(method, new_regexp) ::Regexy::Regexp.new(new_regexp, options) end From bbcf7d32bba3c0910f7251d4cbf7a6d81585660f Mon Sep 17 00:00:00 2001 From: Thomas Nys Date: Mon, 27 Apr 2015 00:21:46 +0200 Subject: [PATCH 5/7] Mitigates Style/EmptyElse --- lib/regexy/web/email.rb | 1 - lib/regexy/web/ip.rb | 2 -- spec/regexp_spec.rb | 1 - 3 files changed, 4 deletions(-) diff --git a/lib/regexy/web/email.rb b/lib/regexy/web/email.rb index 35ed549..2e8a6d2 100644 --- a/lib/regexy/web/email.rb +++ b/lib/regexy/web/email.rb @@ -14,7 +14,6 @@ def regexp_for(mode) when :relaxed then EMAIL_RELAXED when :normal then EMAIL_NORMAL when :strict then EMAIL_STRICT - else nil end end end diff --git a/lib/regexy/web/ip.rb b/lib/regexy/web/ip.rb index d57f360..5efcd33 100644 --- a/lib/regexy/web/ip.rb +++ b/lib/regexy/web/ip.rb @@ -12,7 +12,6 @@ def regexp_for(mode) case mode when :normal then IPV4_NORMAL when :with_port then IPV4_WITH_PORT - else nil end end end @@ -35,7 +34,6 @@ def regexp_for(mode) case mode when :normal then IPV6_NORMAL when :with_port then IPV6_WITH_PORT - else nil end end end diff --git a/spec/regexp_spec.rb b/spec/regexp_spec.rb index 1f48c33..c5edbd7 100644 --- a/spec/regexp_spec.rb +++ b/spec/regexp_spec.rb @@ -174,7 +174,6 @@ def regexp_for(mode) case mode when :mode_1 then /mode_1/ when :mode_2 then /mode_2/ - else nil end end From 606138201fd5333ad383611966311ec7d9190d19 Mon Sep 17 00:00:00 2001 From: Thomas Nys Date: Mon, 27 Apr 2015 00:23:59 +0200 Subject: [PATCH 6/7] Mitigates Style/CaseIndentation --- lib/regexy/web/ip.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/regexy/web/ip.rb b/lib/regexy/web/ip.rb index 5efcd33..b648db9 100644 --- a/lib/regexy/web/ip.rb +++ b/lib/regexy/web/ip.rb @@ -32,8 +32,8 @@ class IPv6 < ::Regexy::RegexpWithMode def regexp_for(mode) case mode - when :normal then IPV6_NORMAL - when :with_port then IPV6_WITH_PORT + when :normal then IPV6_NORMAL + when :with_port then IPV6_WITH_PORT end end end From 2a9d8715884d97f482f2a11685214452be63f594 Mon Sep 17 00:00:00 2001 From: Thomas Nys Date: Mon, 27 Apr 2015 00:26:01 +0200 Subject: [PATCH 7/7] Mitigates Lint/StringConversionInInterpolation --- lib/regexy/regexp.rb | 2 +- spec/regexp_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/regexy/regexp.rb b/lib/regexy/regexp.rb index 6e9fc5b..6b1b5be 100644 --- a/lib/regexy/regexp.rb +++ b/lib/regexy/regexp.rb @@ -72,7 +72,7 @@ def additional_unbound(method, regex) class RegexpWithMode < ::Regexy::Regexp def initialize(mode = default_mode, *args) regexp = regexp_for(mode.to_sym) - fail ArgumentError, "Unknown mode #{mode.to_s}" unless regexp + fail ArgumentError, "Unknown mode #{mode}" unless regexp super(regexp, *args) end diff --git a/spec/regexp_spec.rb b/spec/regexp_spec.rb index c5edbd7..7e05138 100644 --- a/spec/regexp_spec.rb +++ b/spec/regexp_spec.rb @@ -107,7 +107,7 @@ class BoundCallbackCheck < Regexy::Regexp protected def additional_bound(method, regex) - "#{method.to_s}&#{regex}" + "#{method}&#{regex}" end end @@ -137,7 +137,7 @@ class UnboundCallbackCheck < Regexy::Regexp protected def additional_unbound(method, regex) - "#{method.to_s}&#{regex}" + "#{method}&#{regex}" end end