diff --git a/lib/rubycritic/generators/html/assets/javascripts/application.js b/lib/rubycritic/generators/html/assets/javascripts/application.js index 38f1d169..95a9522b 100644 --- a/lib/rubycritic/generators/html/assets/javascripts/application.js +++ b/lib/rubycritic/generators/html/assets/javascripts/application.js @@ -12,6 +12,9 @@ $(function() { else if(/smells_index/.test(loc)) { $('.smells-index-nav').addClass('active'); } + else if(/simple_cov_index/.test(loc)) { + $('.coverage-index-nav').addClass('active'); + } }); var turbulenceData = turbulenceData || []; diff --git a/lib/rubycritic/generators/html/simple_cov_index.rb b/lib/rubycritic/generators/html/simple_cov_index.rb index 9dc80a5e..c96fc278 100644 --- a/lib/rubycritic/generators/html/simple_cov_index.rb +++ b/lib/rubycritic/generators/html/simple_cov_index.rb @@ -9,9 +9,7 @@ class SimpleCovIndex < Base TEMPLATE = erb_template('simple_cov_index.html.erb') def initialize(analysed_modules) - @smells = analysed_modules.flat_map(&:smells).uniq - @analysed_module_names = analysed_module_names(analysed_modules) - @show_status = (Config.mode == :default) + @analysed_modules = sorted(filtered(analysed_modules)) set_header_links if Config.compare_branches_mode? end @@ -30,14 +28,15 @@ def render LAYOUT_TEMPLATE.result(base_binding { index_body }) end - private + def sorted(mods) + mods.sort_by(&:coverage) + end - def analysed_module_names(analysed_modules) - names = {} - analysed_modules.each do |analysed_module| - names[analysed_module.pathname] = analysed_module.name + def filtered(mods) + mods.reject do |a_module| + path = a_module.pathname.to_s + path.start_with?('spec', 'test') end - names end end end diff --git a/lib/rubycritic/generators/html/templates/layouts/application.html.erb b/lib/rubycritic/generators/html/templates/layouts/application.html.erb index 81b3178f..e9b451e7 100644 --- a/lib/rubycritic/generators/html/templates/layouts/application.html.erb +++ b/lib/rubycritic/generators/html/templates/layouts/application.html.erb @@ -40,7 +40,7 @@ Smells diff --git a/lib/rubycritic/generators/html/templates/simple_cov_index.html.erb b/lib/rubycritic/generators/html/templates/simple_cov_index.html.erb index fb81b281..b9bd7921 100644 --- a/lib/rubycritic/generators/html/templates/simple_cov_index.html.erb +++ b/lib/rubycritic/generators/html/templates/simple_cov_index.html.erb @@ -11,32 +11,29 @@ - - - + <% unless Config.suppress_ratings %> + + <% end %> + + - <% @smells.each do |smell| %> + <% @analysed_modules.each do |analysed_module| %> - - - + <% unless Config.suppress_ratings %> + + <% end %> + +
  • + <%= analysed_module.name %>
  • - <% end %> - + + <% end %>
    SmellLocationsStatusRatingNameCoverage
    <%= smell.type %> - - - <% if @show_status %> +
    +
    <%= analysed_module.coverage_rating %>
    +
    <%= smell.status %> <%= '%g' % analysed_module.coverage %>%
    diff --git a/test/test_helper.rb b/test/test_helper.rb index b370f464..2149b500 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,5 +1,12 @@ # frozen_string_literal: true +if ENV['COVERAGE'] == 'true' + require 'simplecov' + SimpleCov.start do + track_files '/lib/' + end +end + require 'minitest/autorun' require 'minitest/around/spec' require 'minitest/pride'