lib/licensee/project_files/license_file.rb in licensee-8.7.0 vs lib/licensee/project_files/license_file.rb in licensee-8.8.0
- old
+ new
@@ -27,16 +27,27 @@
/#{LICENSE_REGEX}/ => 0.4, # LICENSE-MIT
/#{COPYING_REGEX}/ => 0.3, # COPYING-MIT
// => 0.0 # Catch all
}.freeze
+ # CC-NC and CC-ND are not open source licenses and should not be
+ # detected as CC-BY or CC-BY-SA which are 98%+ similar
+ CC_FALSE_POSITIVE_REGEX = /
+ \A(creative\ commons\ )?Attribution-(NonCommercial|NoDerivatives)
+ /xi
+
def possible_matchers
[Matchers::Copyright, Matchers::Exact, Matchers::Dice]
end
def attribution
matches = /^#{Matchers::Copyright::REGEX}$/i.match(content)
matches[0].strip if matches
+ end
+
+ # Is this file likely to result in a creative commons false positive?
+ def potential_false_positive?
+ content.strip =~ CC_FALSE_POSITIVE_REGEX
end
def self.name_score(filename)
FILENAME_REGEXES.find { |regex, _| filename =~ regex }[1]
end