summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Ziegler <austin@zieglers.ca>2018-08-17 20:37:42 -0400
committerAustin Ziegler <austin@zieglers.ca>2018-08-17 20:39:54 -0400
commit6d022610daa047278e78db55ecdfaa786cb709e2 (patch)
tree747e954e5ba841f92bd3852f24875748765e7638
parentbeed92cef1f304c967f53314f4668e787fd85128 (diff)
downloadmime-types-6d022610daa047278e78db55ecdfaa786cb709e2.tar.gz
Add a configuration file for unused
- https://github.com/joshuaclayton/unused - All of the reported items are present because they are required for implementation or they are present because they are used by tools outside of mime-types itself (e.g., the mime-types-data tools). Also remove .freeze methods on strings from all files because of the frozen string magic comment.
-rw-r--r--.unused.yml39
-rw-r--r--lib/mime/type.rb19
-rw-r--r--lib/mime/types/_columnar.rb18
3 files changed, 57 insertions, 19 deletions
diff --git a/.unused.yml b/.unused.yml
new file mode 100644
index 0000000..9cfe549
--- /dev/null
+++ b/.unused.yml
@@ -0,0 +1,39 @@
+---
+- name: Ruby
+ autoLowLikelihood:
+ - name: MIME::Types::Container implementation details
+ pathStartsWith: lib/mime/types/container.rb
+ allowedTerms:
+ - '[]='
+ - marshal_dump
+ - marshal_load
+ - to_hash
+ - name: MIME::Types::Columnar array parser
+ pathStartsWith: lib/mime/types/_columnar.rb
+ allowedTerms:
+ - arr
+ - extended
+ - name: MIME::Types::Logger close (required for implementation)
+ pathStartsWith: lib/mime/types/logger.rb
+ termEquals: close
+ - name: MIME::Type writers
+ pathStartsWith: lib/mime/type.rb
+ allowedTerms:
+ - content_type=
+ - extensions=
+ - name: MIME::Type dynamic calls
+ pathStartsWith: lib/mime/type.rb
+ termStartsWith: xref_url_for_
+ - name: MIME::Type object implementation
+ pathStartsWith: lib/mime/type.rb
+ allowedTerms:
+ - eql?
+ - to_str
+ - name: MIME::Types::Loader YAML loader (used by mime-types-data tools)
+ pathStartsWith: lib/mime/types/loader.rb
+ termEquals: load_yaml
+ - name: MIME::Types tests
+ pathStartsWith: test/
+ allowedTerms:
+ - around
+ - teardown
diff --git a/lib/mime/type.rb b/lib/mime/type.rb
index 61d20ab..11b8530 100644
--- a/lib/mime/type.rb
+++ b/lib/mime/type.rb
@@ -331,7 +331,7 @@ class MIME::Type
# call-seq:
# text_plain.friendly # => "Text File"
# text_plain.friendly('en') # => "Text File"
- def friendly(lang = 'en'.freeze)
+ def friendly(lang = 'en')
@friendly ||= {}
case lang
@@ -504,7 +504,7 @@ class MIME::Type
# use with the I18n library.
def i18n_key(content_type)
simplify_matchdata(match(content_type), joiner: '.') { |e|
- e.gsub!(I18N_RE, '-'.freeze)
+ e.gsub!(I18N_RE, '-')
}
end
@@ -521,12 +521,12 @@ class MIME::Type
private
- def simplify_matchdata(matchdata, remove_x = false, joiner: '/'.freeze)
+ def simplify_matchdata(matchdata, remove_x = false, joiner: '/')
return nil unless matchdata
matchdata.captures.map { |e|
e.downcase!
- e.sub!(%r{^x-}, ''.freeze) if remove_x
+ e.sub!(%r{^x-}, '') if remove_x
yield e if block_given?
e
}.join(joiner)
@@ -551,23 +551,22 @@ class MIME::Type
end
def xref_url_for_rfc(value)
- 'http://www.iana.org/go/%s'.freeze % value
+ 'http://www.iana.org/go/%s' % value
end
def xref_url_for_draft(value)
- 'http://www.iana.org/go/%s'.freeze % value.sub(/\ARFC/, 'draft')
+ 'http://www.iana.org/go/%s' % value.sub(/\ARFC/, 'draft')
end
def xref_url_for_rfc_errata(value)
- 'http://www.rfc-editor.org/errata_search.php?eid=%s'.freeze % value
+ 'http://www.rfc-editor.org/errata_search.php?eid=%s' % value
end
def xref_url_for_person(value)
- 'http://www.iana.org/assignments/media-types/media-types.xhtml#%s'.freeze %
- value
+ 'http://www.iana.org/assignments/media-types/media-types.xhtml#%s' % value
end
def xref_url_for_template(value)
- 'http://www.iana.org/assignments/media-types/%s'.freeze % value
+ 'http://www.iana.org/assignments/media-types/%s' % value
end
end
diff --git a/lib/mime/types/_columnar.rb b/lib/mime/types/_columnar.rb
index 8c87267..8938f19 100644
--- a/lib/mime/types/_columnar.rb
+++ b/lib/mime/types/_columnar.rb
@@ -45,7 +45,7 @@ module MIME::Types::Columnar
i = -1
column = File.join(@__root__, "mime.#{name}.column")
- IO.readlines(column, encoding: 'UTF-8'.freeze).each do |line|
+ IO.readlines(column, encoding: 'UTF-8').each do |line|
line.chomp!
if lookup
@@ -63,7 +63,7 @@ module MIME::Types::Columnar
def load_encoding
each_file_line('encoding') do |type, line|
pool ||= {}
- line.freeze
+ line
type.instance_variable_set(:@encoding, (pool[line] ||= line))
end
end
@@ -108,11 +108,11 @@ module MIME::Types::Columnar
end
def dict(line, array: false)
- if line == '-'.freeze
+ if line == '-'
{}
else
- line.split('|'.freeze).each_with_object({}) { |l, h|
- k, v = l.split('^'.freeze)
+ line.split('|').each_with_object({}) { |l, h|
+ k, v = l.split('^')
v = nil if v.empty?
h[k] = array ? Array(v) : v
}
@@ -120,18 +120,18 @@ module MIME::Types::Columnar
end
def arr(line)
- if line == '-'.freeze
+ if line == '-'
[]
else
- line.split('|'.freeze).flatten.compact.uniq
+ line.split('|').flatten.compact.uniq
end
end
def opt(line)
- line unless line == '-'.freeze
+ line unless line == '-'
end
def flag(line)
- line == '1'.freeze ? true : false
+ line == '1' ? true : false
end
end