<% content_for :title, "Component audit" %> <%= render 'govuk_publishing_components/components/title', title: "Components audit", margin_top: 0; %> <% if ENV["MAIN_COMPONENT_GUIDE"] %>

Contents

<%= render "govuk_publishing_components/components/heading", { text: "Applications", font_size: "l", margin_bottom: 6 } %> <% if @applications.any? %>
How to use this information

This page shows information about component use on GOV.UK. This information has been cross referenced with the components in the gem to produce warnings where e.g. a print stylesheet for a component exists but has not been included in an application.

Warnings should be investigated, although there may be a reason why the application has been configured as it is. Note that 'code' can refer to templates or ruby code.

<% @applications.each_with_index do |application, index| %>

<%= application[:name] %>

<% if application[:application_found] %> Warnings: <% if application[:warning_count] > 0 %> <%= application[:warning_count] %> <% else %> <%= application[:warning_count] %> <% end %> <% else %> Application not found <% end %>
<% if application[:application_found] %> <% application[:warnings].each do |warning| %>

Warn <%= warning[:component] %> - <%= warning[:message] %>

<% end %> <%= render "govuk_publishing_components/components/heading", { text: "Components used", font_size: "m", margin_bottom: 4, heading_level: 3, } %>
<% application[:summary].each do |item| %>
<%= item[:name] %>
<% if item[:value].length > 0 %> <%= item[:value] %> <% else %> None <% end %>
<% end %>
<% if application[:gem_style_references].any? %> <%= render "govuk_publishing_components/components/heading", { text: "Component references", font_size: "m", margin_bottom: 4, heading_level: 3, } %>

This shows instances of `gem-c-` classes found in the application. If a reference is found in a stylesheet or in code a warning is created, as this could be a style override or hard coded component markup.

    <% application[:gem_style_references].each do |ref| %>
  • <%= ref %>
  • <% end %>
<% end %> <% if application[:jquery_references].any? %> <%= render "govuk_publishing_components/components/heading", { text: "jQuery references", font_size: "m", margin_bottom: 4, heading_level: 3, } %>

This shows JavaScript files that might contain jQuery, which we are trying to remove our dependency on.

    <% application[:jquery_references].each do |ref| %>
  • <%= ref %>
  • <% end %>
<% end %> <% else %>

This application was not found. This could be because you do not have this repository checked out locally.

<% end %>
<% end %>
<% else %>

No applications found.

<% end %>
<%= render "govuk_publishing_components/components/heading", { text: "Components", font_size: "l", margin_bottom: 6, } %> <% if @components.any? %>

Component files

Lists what files each component has
<% @components[:component_listing].each do |component| %> <% end %>
Component Stylesheet Print stylesheet JS Test JS test
<%= component[:name] %> <% if component[:stylesheet] %> Yes <% end %> <% if component[:print_stylesheet] %> Yes <% end %> <% if component[:javascript] %> Yes <% end %> <% if component[:tests] %> Yes <% end %> <% if component[:js_tests] %> Yes <% end %>

Components containing components

Shows which components contain other components
<% @components[:components_containing_components].each do |component| %>
<%= component[:component] %>
<%= component[:sub_components].join(', ') %>
<% end %>

Components by application

Shows which applications use each component
<% if @components[:components_by_application].any? %>
<% @components[:components_by_application].each do |component| %>
<%= component[:component] %> (<%= component[:count] %>)
<%= component[:list] %>
<% end %>
<% else %>

Sorry, no applications found.

<% end %>
<% else %>

No components found.

<% end %>
<% else %>

Component auditing is only available when the component guide is running locally as a standalone app.

<% end %>