mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Check line length for minified for now
This commit is contained in:
@@ -75,14 +75,16 @@ module Linguist
|
|||||||
|
|
||||||
# Internal: Is the blob minified files?
|
# Internal: Is the blob minified files?
|
||||||
#
|
#
|
||||||
# Consider a file minified if it contains less than 5% spaces.
|
# Consider a file minified if the average line length is
|
||||||
|
# greater then 110c.
|
||||||
|
#
|
||||||
# Currently, only JS and CSS files are detected by this method.
|
# Currently, only JS and CSS files are detected by this method.
|
||||||
#
|
#
|
||||||
# Returns true or false.
|
# Returns true or false.
|
||||||
def minified_files?
|
def minified_files?
|
||||||
return unless ['.js', '.css'].include? extname
|
return unless ['.js', '.css'].include? extname
|
||||||
if data && data.length > 200
|
if lines.any?
|
||||||
(data.each_char.count{ |c| c <= ' ' } / data.length.to_f) < 0.05
|
(lines.inject(0) { |n, l| n += l.length } / lines.length) > 110
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user