Skip to content

Commit 3946d0d

Browse files
committed
Update reporter tool
1 parent 7340b46 commit 3946d0d

2 files changed

Lines changed: 33 additions & 8 deletions

File tree

tool/reporter_processor.rb

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require 'errors' # Generated from revapi
33
require_relative 'acceptable_errors' # Our list of removals and unimportant errors
44

5-
old_name_search = filter = version = nil
5+
new_name_search = old_name_search = filter = version = nil
66

77
opts = OptionParser.new do |o|
88
o.banner = 'Usage: #$0 [options]'
@@ -25,18 +25,23 @@
2525
o.on('-o', '--old-name {str}', 'regexp match against old_name') do |arg|
2626
old_name_search = Regexp.new(arg)
2727
end
28+
o.on('-n', '--new-name {str}', 'regexp match against new_name') do |arg|
29+
new_name_search = Regexp.new(arg)
30+
end
2831
end
2932

3033
opts.parse!(ARGV)
3134

32-
35+
# Generic Rules
3336
NOT = ->(f1) { ->(a) {!f1.call(a) } }
3437
AND = ->(*fns) { ->(a) { fns.all? { |f| f.call(a) } } }
3538
OR = ->(*fns) { ->(a) { fns.any? { |f| f.call(a) } } }
36-
3739
FALSE = ->(a) { false }
3840
TRUE = ->(a) { true }
3941
NOOP = TRUE
42+
43+
# FIXME: to make this a generic tool move specific rules and skip list
44+
# to its own require so this script can be used by other Java projects.
4045
INVOKER = ->(a) { !!a.old_name.match(/\$INVOKER/) }
4146
POPULATOR = ->(a) { !!a.old_name.match(/\$POPULATOR/) }
4247
INTERP_ANNO = ->(a) { !!a.desc.match(/org\.jruby\.ir\.Interp/) }
@@ -62,6 +67,16 @@
6267
'java.annotation.attributeAdded' => NOOP
6368
}
6469

70+
SUBSTITUTIONS = {
71+
'org.jruby.runtime.builtin.IRubyObject' => 'IRubyObject',
72+
'org.jruby.runtime.ThreadContext' => 'ThreadContext',
73+
'org.jruby.Ruby' => 'Ruby', # This is doing a lot of heavy lifting
74+
'org.jruby.RubySymbol' => 'RubySymbol',
75+
'java.lang.String' => 'String',
76+
'org.jruby.runtime.Block' => 'Block',
77+
'org.jruby.parser.StaticScope' => 'StaticScope',
78+
}
79+
6580
class Action
6681
attr_reader :old_name, :new_name, :type, :desc, :categories
6782

@@ -79,6 +94,13 @@ def breaking?
7994
end
8095
end
8196

97+
def sanitize(str)
98+
SUBSTITUTIONS.each do |pattern, replace|
99+
str.gsub!(pattern, replace)
100+
end
101+
str
102+
end
103+
82104
def acceptable_key
83105
if removed?
84106
"#{old_name}|#{type}"
@@ -92,14 +114,16 @@ def removed?
92114
end
93115

94116
def added?
95-
!!type.match(/java\.(method|class|field)\.[^.]+[Aa]dded/)
117+
!!type.match(/java\.(method|class|field)\.[^.]*[Aa]dded/)
96118
end
97119

98120
def to_s
99121
str = "type: #{type} - #{desc}\n"
100-
str += "\n #{old_name}" if added?
101-
str += " ->\n #{new_name}" if !removed? && !annotation_change?
102-
str += "\n #{categories_to_s}"
122+
if !added?
123+
str += "\n #{sanitize(old_name)}"
124+
end
125+
str += " #{!added? ? "->" : " "}\n #{sanitize(new_name)}" if !removed? && !annotation_change?
126+
str += "\n #{categories_to_s}"
103127
str
104128
end
105129

@@ -118,6 +142,7 @@ def to_s
118142
next if filter && type != filter
119143
action = Action.new(item[:old], item[:new], type, desc, categories)
120144
next if old_name_search && !action.old_name.match?(old_name_search)
145+
next if new_name_search && !action.new_name.match?(new_name_search)
121146
fn = SKIPS[type] || FALSE
122147
next if fn.call(action) || ACCEPTABLE[action.acceptable_key]
123148
unless action.breaking?

tool/revapi.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"minSeverity": "POTENTIALLY_BREAKING",
55
"minCriticality": "documented",
66
"output" : "errors.rb",
7-
"template": "template.ftl",
7+
"template": "tool/template.ftl",
88
"append": false,
99
"keepEmptyFile": true
1010
}

0 commit comments

Comments
 (0)