-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathfalse_positives.rb
90 lines (89 loc) · 3.37 KB
/
false_positives.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
module NamesManager
module FalsePositives
CONNECTORS_REGEXP = %r{(?:[,/&+]|\band\b)}
# Returns +nil+ if +name+ is known *not* to correspond to an author, the
# author name(s) if special handling applies, like multiple authors separated
# by a connector. If nothing applies, returns +name+ back.
#
# Note that this method is responsible for extracting names as they appear
# in the original string. Canonicalization is done elsewhere.
def handle_false_positives(name)
case name
when /\A\d+\b/
when /#\d+/
when /GH-\d+/
when /\A\s*\z/
when /RAILS_ENV/
when /^See rails ML/
when /RubyConf/
when 'update from Trac'
when /\A['":]/
when 'RC1'
when %r{https://}
when '\\x00-\\x1f'
when /\ACVE-[\d-]+\z/i
when 'and'
when 'options'
when 'API DOCS'
when 'hat-tip to anathematic'
when 'props to Zarathu in #rubyonrails'
when 'thanks Pratik!'
when 'multiple=true'
when /ci[\s_-]s?kip/i
when 'ci skp'
when 'ci ski'
when /skip[ -]ci/i
when 'key'
when '.lock'
when "{ :ca => :'es-ES' }"
when 'fixes 5f5e6d924973003c105feb711cefdb726f312768'
when '79990505e5080804b53d81fec059136afa2237d7'
when 'direct_upload_xls_in_chrome'
when "schoenm\100earthlink.net sandra.metz\100duke.edu"
name.split
when '=?utf-8?q?Adam=20Cig=C3=A1nek?='
'Adam Cigánek'.nfc
when '=?utf-8?q?Mislav=20Marohni=C4=87?='
'Mislav Marohnić'.nfc
when 'nik.wakelin Koz'
['nik.wakelin', 'Koz']
when "me\100jonnii.com rails\100jeffcole.net Marcel Molina Jr."
["me\100jonnii.com", "rails\100jeffcole.net", 'Marcel Molina Jr.']
when "jeremy\100planetargon.com Marcel Molina Jr."
["jeremy\100planetargon.com", 'Marcel Molina Jr.']
when "matt\100mattmargolis.net Marcel Molina Jr."
["matt\100mattmargolis.net", 'Marcel Molina Jr.']
when "doppler\100gmail.com phil.ross\100gmail.com"
["doppler\100gmail.com", "phil.ross\100gmail.com"]
when 'After much pestering from Dave Thomas'
'Dave Thomas'
when "jon\100blankpad.net)"
["jon\100blankpad.net"]
when 'Jose and Yehuda'
['José Valim'.nfc, 'Yehuda Katz']
when /\A(?:Suggested|Aggregated)\s+by\s+(.*)/i
$1
when /\A(?:DHH\s*)?via\s+(.*)/i
$1
# These are present in some of Ben Sheldon commits. This pattern needs
# ad-hoc handling because "/" is considered to be a name connector.
when %r{\[he/him\]}
$`.strip
when /\b\w+\+\w+@/
# The plus sign is taken to be a connector below, this catches some known
# addresses that use a plus sign in the username, see unit tests for examples.
# We know there's no case where the plus sign acts as well as a connector in
# the same string.
name.split(/\s*,\s*/).map(&:strip)
when CONNECTORS_REGEXP # There are lots of these, even with a combination of connectors.
name.split(CONNECTORS_REGEXP).map(&:strip).reject do |part|
part == 'others' ||
part == '?'
end
else
# just return the candidate back
name
end
end
end
end