From 92a20aa7c71cd4e71516f0ddd54a7ef63c658e0c Mon Sep 17 00:00:00 2001 From: Rishi Date: Wed, 18 Oct 2023 19:01:09 +0700 Subject: [PATCH] fallback to overview.html when pages do not exist for compare option (#470) --- CHANGELOG.md | 1 + lib/rubycritic/generators/html/view_helpers.rb | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e434f0ce..ffe68354 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * [CHANGE] Add rexml dependency for Ruby 3.0.0+ support (by [@fbuys][]) * [BUGFIX] Raise error when the same branches are compared (by [@rishijain][]) * [BUGFIX] Churn score was always 0 when rubycritic was executed from a sub-directory (by [@rishijain][]) +* [BUGFIX] Use overview.html as the fallback path when files does not exist during compare option (by [@rishijain][]) # v4.8.1 / 2023-05-17 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.8.0...v4.8.1) diff --git a/lib/rubycritic/generators/html/view_helpers.rb b/lib/rubycritic/generators/html/view_helpers.rb index afbc48b1..fde78721 100644 --- a/lib/rubycritic/generators/html/view_helpers.rb +++ b/lib/rubycritic/generators/html/view_helpers.rb @@ -24,7 +24,10 @@ def smell_location_path(location) end def code_index_path(root_directory, file_name) - file_path("#{File.expand_path(root_directory)}/#{file_name}") + root_directory_path = File.expand_path(root_directory) + index_path = "#{root_directory_path}/#{file_name}" + index_path = "#{root_directory_path}/overview.html" unless File.exist?(index_path) + file_path(index_path) end private