diff options
author | Austin Ziegler <austin@zieglers.ca> | 2014-10-08 16:38:56 -0400 |
---|---|---|
committer | Austin Ziegler <austin@zieglers.ca> | 2014-10-08 16:38:56 -0400 |
commit | 6c75ee5446833fa96fc484205465b01edab4c1f0 (patch) | |
tree | 7630080dff793d385edb03d001031a9a632e96cc | |
parent | aa0902a0b01eab2f926473d173fc4e33544b8177 (diff) | |
download | git-6c75ee5446833fa96fc484205465b01edab4c1f0.tar.gz |
Clearing up some code smells.
-rw-r--r-- | .pullreview.yml | 17 | ||||
-rw-r--r-- | lib/mime/type.rb | 13 | ||||
-rw-r--r-- | test/test_mime_type.rb | 21 | ||||
-rw-r--r-- | test/test_mime_types.rb | 3 | ||||
-rw-r--r-- | test/test_mime_types_class.rb | 2 | ||||
-rw-r--r-- | test/test_mime_types_loader.rb | 2 |
6 files changed, 30 insertions, 28 deletions
diff --git a/.pullreview.yml b/.pullreview.yml index d40b4d63d3..354a0f999c 100644 --- a/.pullreview.yml +++ b/.pullreview.yml @@ -6,6 +6,7 @@ excludes: - docs - type-lists - .minitest.rb + - lib/mime-types.rb rules: documentation: except: @@ -14,21 +15,14 @@ rules: style: except: - db/** - - config/deploy/** - - config/environments/** - - config/application.rb - - config/routes.rb duplication: except: - - db/** - - config/deploy/** - - config/environments/** - - config/application.rb - - config/routes.rb + - test/** complexity: except: - - config/routes.rb -# ignore: + - test/** + ignore: + - space_inside_square_brackets_detected # - add_underscores_to_large_numeric # - avoid_using_curly_braces_for_multi-line_blocks # - don_t_use_parentheses_around_the_condition @@ -47,7 +41,6 @@ rules: # - space_inside_parentheses_detected # - space_inside_opening_curly_brace_missing # - space_inside_closing_curly_brace_missing -# - space_inside_square_brackets_detected # - space_missing_inside_opening_curly_brace # - space_missing_inside_closing_curly_brace # - space_missing_after_hash_sign diff --git a/lib/mime/type.rb b/lib/mime/type.rb index e1bd972e14..07b692e290 100644 --- a/lib/mime/type.rb +++ b/lib/mime/type.rb @@ -157,13 +157,13 @@ class MIME::Type def priority_compare(other) pc = simplified <=> other.simplified if pc.zero? - pc = if ((reg = registered?) != other.registered?) + pc = if (reg = registered?) != other.registered? reg ? -1 : 1 # registered < unregistered - elsif ((plat = platform?(true)) != other.platform?(true)) + elsif (plat = platform?(true)) != other.platform?(true) plat ? 1 : -1 # generic < platform - elsif ((comp = complete?) != other.complete?) + elsif (comp = complete?) != other.complete? comp ? -1 : 1 # complete < incomplete - elsif ((obs = obsolete?) != other.obsolete?) + elsif (obs = obsolete?) != other.obsolete? obs ? 1 : -1 # current < obsolete elsif obs and ((ui = use_instead) != (oui = other.use_instead)) if ui.nil? @@ -275,6 +275,7 @@ class MIME::Type MIME.deprecated(self, __method__) @system end + def system=(os) # :nodoc: if os.nil? or os.kind_of?(Regexp) @system = os @@ -302,6 +303,7 @@ class MIME::Type def obsolete? !!@obsolete end + def obsolete=(v) # :nodoc: @obsolete = !!v end @@ -354,6 +356,7 @@ class MIME::Type MIME.deprecated(self, __method__, "and has been renamed to #references") references end + def url=(r) # :nodoc: MIME.deprecated(self, __method__) self.references = r @@ -451,6 +454,7 @@ class MIME::Type !!@registered end end + def registered=(v) # :nodoc: @registered = v.nil? ? v : !!v end @@ -474,6 +478,7 @@ class MIME::Type def signature? !!@signature end + def signature=(v) # :nodoc: @signature = !!v end diff --git a/test/test_mime_type.rb b/test/test_mime_type.rb index 5608d73cb9..889d6033f1 100644 --- a/test/test_mime_type.rb +++ b/test/test_mime_type.rb @@ -415,15 +415,18 @@ class TestMIMEType < Minitest::Test def test_to_hash yaml = make_yaml_mime_type assert_deprecated("MIME::Type#to_hash") do - assert_equal({'Content-Type' => 'text/x-yaml', - 'Content-Transfer-Encoding' => '8bit', - 'Extensions' => %w(yaml yml), - 'System' => /d9d172f608/, - 'Registered' => false, - 'URL' => [], - 'Obsolete' => false, - 'Docs' => nil }, - yaml.to_hash) + assert_equal( + { + 'Content-Type' => 'text/x-yaml', + 'Content-Transfer-Encoding' => '8bit', + 'Extensions' => %w(yaml yml), + 'System' => /d9d172f608/, + 'Registered' => false, + 'URL' => [], + 'Obsolete' => false, + 'Docs' => nil + }, + yaml.to_hash) end end diff --git a/test/test_mime_types.rb b/test/test_mime_types.rb index c6aaa169f7..1189c01230 100644 --- a/test/test_mime_types.rb +++ b/test/test_mime_types.rb @@ -15,7 +15,7 @@ class TestMIMETypes < Minitest::Test end def test_enumerable - assert(@mime_types.any? {|type| type.content_type == 'text/plain'}) + assert(@mime_types.any? { |type| type.content_type == 'text/plain' }) assert_kind_of(Enumerator, @mime_types.each) assert_equal(6, @mime_types.each.count) end @@ -56,6 +56,7 @@ class TestMIMETypes < Minitest::Test assert_empty(MIME::Types['text/plain', platform: true]) end end + def test_add eruby = MIME::Type.new("application/x-eruby") do |t| t.extensions = "rhtml" diff --git a/test/test_mime_types_class.rb b/test/test_mime_types_class.rb index 0185dd3ccd..e9c2b8fe7c 100644 --- a/test/test_mime_types_class.rb +++ b/test/test_mime_types_class.rb @@ -9,7 +9,7 @@ class TestMIMETypesQueryClassMethods < Minitest::Test end def test_enumerable - assert(MIME::Types.any? {|type| type.content_type == 'text/plain'}) + assert(MIME::Types.any? { |type| type.content_type == 'text/plain' }) assert_kind_of(Enumerator, MIME::Types.each) assert(MIME::Types.each.count > 999) end diff --git a/test/test_mime_types_loader.rb b/test/test_mime_types_loader.rb index 61848ba39c..61cb22077d 100644 --- a/test/test_mime_types_loader.rb +++ b/test/test_mime_types_loader.rb @@ -18,7 +18,7 @@ class TestMIMETypesLoader < Minitest::Test assert_equal(%w(webm), types['audio/webm'].first.extensions) refute(types['audio/webm'].first.registered?) - assert_equal("Fixes a bug with IE6 and progressive JPEGs", + assert_equal('Fixes a bug with IE6 and progressive JPEGs', types['image/pjpeg'].first.docs) assert(types['application/x-apple-diskimage'].first.system?) |