aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb
blob: d4b5f7db9052aa97a0feabd9b644ac2558463090 (plain)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<%= render :partial => 'tabs' -%>

<%= render :partial => "browse/header_#{@extension.getId()}" -%>


<% if @display_violations && @global_violations && @global_violations.size>0 -%>
  <table id="global_violations" cellpadding="0" cellspacing="0" border="0">
    <% @global_violations.each do |violation| %>
      <tr>
        <td><%= render :partial => 'violation', :locals => {:violation => violation} -%></td>
      </tr>
    <% end %>
  </table>
<% end %>

<div id="source_options">
  <form method="GET" action="<%= url_for :controller => 'browse', :id => @resource.key -%>">
    <input type="hidden" name="tab" value="<%= params[:tab] -%>"/>
    <% if @scm_available %>
      <input type="checkbox" value="true" name="scm" id="scm" <%= 'checked' if @display_scm -%> onclick="submit()"/>
      <label for="scm">Authors</label>
    <% end %>

    <% if @snapshot.project_snapshot.periods? %>
      <select id="period" name="period" class="small" onchange="submit()">
        <option value="">Time changes...</option>
        <%= period_select_options(@snapshot, 1) -%>
        <%= period_select_options(@snapshot, 2) -%>
        <%= period_select_options(@snapshot, 3) -%>
        <%= period_select_options(@snapshot, 4) -%>
        <%= period_select_options(@snapshot, 5) -%>
      </select>
    <% end %>

    <% if @expandable %>
      <input type="checkbox" value="true" name="expand" id="expand" <%= 'checked' if @expanded -%> onclick="submit()"/>
      <label for="expand">Expand</label>
    <% end %>

    <%= render :partial => 'rules_filter' if @display_violations -%>
  </form>
</div>

<% if @lines && @lines.size>0 %>
<table id="sources" class="sources2 code" cellpadding="0" cellspacing="0" border="0">
  <%
    current_revision=nil
    colspan=2
    colspan+=1 if @display_scm
    colspan+=1 if @display_violations
    colspan+=2 if @display_coverage
    previous_hidden=false
    first_section=true
    @lines.each_with_index do |line, index|
      if line.hidden
        previous_hidden=true
        next
      end

      if previous_hidden && !first_section
       current_revision=nil
%>
  <tr>
    <td colspan="<%= colspan -%>" class="new_section"> </td>
  </tr>
<%
      end
      previous_hidden=false
      first_section=false

      status=hits_status=conditions_status=''
      if @display_coverage && line.hits
        hits_status=(line.hits>0 ? 'ok' : 'ko')
        if line.conditions && line.conditions>0 && line.covered_conditions
          if line.covered_conditions==0
            status='ko'
            conditions_status='ko'
          elsif line.covered_conditions==line.conditions
            status=''
            conditions_status='ok'
          else
            conditions_status='warn'
            status='warn'
          end
        elsif line.hits
          status=(line.hits>0 ? '' : 'ko')
        end
      elsif @display_violations
        status="sev#{line.violation_severity}"
      end
  %>
  <tr>
    <% if @display_scm
         if current_revision!=line.revision
           current_revision=line.revision
           title = "Revision #{h(line.revision)} (#{l(line.datetime)})"
    %>
            <td class="scm revision"><span class="date"><a href="#" title="<%= title -%>" alt="<%= title -%>"><%= l(line.date) -%></a></span> <span class="author"><%= h(line.author) -%></span></td>
    <%   else %>
            <td class="scm"></td>
    <%   end
       end %>
    <% if @display_violations %>
      <td class="rule <%= 'violations section' if line.violations? -%>">
        <% if line.violations?
             line.violations.each_with_index do |violation, violation_index| %>
               <%= '<br/>' if violation_index>0 %>
               <%= render :partial => 'violation', :locals => {:violation => violation} -%>
        <%
             end
           end
        %>
      </td>
    <% end %>
    <td class="lid <%= ' section' if line.violations? -%>" id="L<%= index+1 -%>"><a name="L<%= index+1 -%>" href="#L<%= index+1 -%>"><%= index + 1 -%></a></td>

    <% if @display_coverage  %>
      <td class="ind <%= hits_status -%>"><%= line.hits -%></td>
      <td class="ind <%= conditions_status -%>">
        <% if line.deprecated_conditions_label -%>
          <%= line.deprecated_conditions_label -%>
        <% elsif line.conditions && line.conditions>0 -%>
          <%= line.covered_conditions -%>/<%= line.conditions -%>
        <% end %>
      </td>
    <% end %>
    <td class="line <%= status -%>"><%= line.source -%></td>
  </tr>
  <% end %>
</table>
<% end %>