@@ -38,45 +38,46 @@ def build_violation_table_body(doc, key, value)
3838 end
3939 end
4040
41- def build_violation_table_row ( doc , key , pmd_violation )
42- doc . tr ( class : get_css_class ( pmd_violation ) ) do
41+ def build_violation_table_row ( doc , key , violation )
42+ doc . tr ( class : get_css_class ( violation ) ) do
4343 build_table_anchor_column ( doc , 'A' , increment_violation_index )
4444
45- violation = pmd_violation . attrs
46-
4745 # The rule that trigger the violation
4846 doc . td do
49- doc . a ( href : ( violation [ 'externalInfoUrl' ] ) . to_s ) { doc . text violation [ 'rule' ] }
47+ doc . a ( href : violation . info_url . to_s ) { doc . text violation . rule_name }
5048 end
5149
5250 # The violation message
53- if pmd_violation . changed
54- doc . td { diff_fragments ( doc , pmd_violation ) }
51+ if violation . changed && violation . message != violation . old_message
52+ doc . td { diff_fragments ( doc , violation ) }
5553 else
56- doc . td pmd_violation . text
54+ doc . td violation . text
5755 end
5856
59- # The begin line of the violation
60- line = violation [ 'beginline' ]
61-
6257 # The link to the source file
6358 doc . td do
6459 link = get_link_to_source ( violation , key )
65- doc . a ( href : link . to_s ) { doc . text line }
60+ doc . a ( href : link . to_s ) { doc . text display_line ( violation ) }
6661 end
6762 end
6863 end
6964
7065 def diff_fragments ( doc , violation )
71- old_message = violation . attrs [ 'oldMessage' ]
72- new_message = violation . text
73- diff = Differ . diff_by_word ( old_message , new_message )
66+ diff = Differ . diff_by_word ( violation . old_message , violation . message )
7467 doc << diff . format_as ( :html )
7568 end
7669
70+ def display_line ( violation )
71+ if violation . changed && violation . old_line != violation . line
72+ "#{ violation . old_line } => #{ violation . line } "
73+ else
74+ violation . line
75+ end
76+ end
77+
7778 def get_link_to_source ( violation , key )
7879 l_str = @project . type == 'git' ? 'L' : 'l'
79- line_str = "##{ l_str } #{ violation [ 'beginline' ] } "
80+ line_str = "##{ l_str } #{ violation . line } "
8081 @project . get_webview_url ( key ) + line_str
8182 end
8283
@@ -85,8 +86,6 @@ def increment_violation_index
8586 @violation_index += 1
8687 end
8788
88- private
89-
9089 def get_css_class ( pmd_violation )
9190 if pmd_violation . changed
9291 'd'
0 commit comments