Skip to content

Commit 67f75c2

Browse files
committed
Refactor #73: Make var names more consistent for better code reading
1 parent 2041645 commit 67f75c2

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

_tests/custom_checks.rb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,31 @@ def run
1616
# Check directory structure to ensure all pages are generated as index.html
1717
# This ensures proper routing for both /foobar/ and /foobar pathes.
1818
def check_directory_structure(filename)
19+
# Get the file's basename and allowed ones
20+
basename = File.basename(filename)
1921
allowed_names = ['index.html', '404.html']
20-
current_file = @runner.current_filename
21-
22-
# Get the filename
23-
filename = File.basename(current_file)
2422

2523
# Skip if allowed filenames or redirect files
26-
return if allowed_names.include?(filename)
27-
return if is_redirect_file?(current_file)
24+
return if allowed_names.include?(basename)
25+
return if is_redirect_file?(filename)
2826

2927
# Report failure for non-index HTML files
3028
add_failure(
3129
<<~ERROR_MESSAGE
3230
index.html でない HTML ファイルが生成されました:
33-
\s File: #{current_file}
31+
\s File: #{filename}
3432
\s すべてのページは index.html として生成される必要があります。
3533
\s これにより /path/ と /path の両方でルーティングが可能になります。
3634
ERROR_MESSAGE
3735
)
3836
end
3937

4038
# Check if it's a redirect or not by meta tags
41-
def is_redirect_file?(filepath)
42-
return false unless File.exist?(filepath)
39+
def is_redirect_file?(filename)
40+
return false unless File.exist?(filename)
4341

44-
content = File.read(filepath)
4542
# Check for meta refresh redirect tag
43+
content = File.read(filename)
4644
content.include?('<meta http-equiv="refresh"') ||
4745
content.include?("<meta http-equiv='refresh'") ||
4846
content.include?('<meta http-equiv=refresh')

0 commit comments

Comments
 (0)