Skip to content

Commit ad17276

Browse files
committed
Allow flexible naming conventions for file validation in PR checks
1 parent 98d376c commit ad17276

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

.github/scripts/validate-pr.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ while IFS= read -r file; do
3434
filename=$(basename "$file")
3535
dir=$(dirname "$file")
3636

37-
# Check naming conventions based on file extension
37+
# Check naming conventions based on file extension (Allow flexible naming)
3838
case "$file" in
3939
*.c|*.cpp|*.py)
40-
# Should use snake_case
41-
if [[ ! "$filename" =~ ^[a-z0-9_]+\.[a-z]+$ ]]; then
42-
invalid_files+=("$file: Should use snake_case (e.g., binary_search.cpp)")
40+
# Allow snake_case, camelCase, or PascalCase for C/C++/Python
41+
if [[ ! "$filename" =~ ^[a-zA-Z0-9_]+\.[a-z]+$ ]]; then
42+
invalid_files+=("$file: Use alphanumeric characters and underscores only (e.g., binary_search.cpp, maxRectangle.cpp)")
4343
fi
4444
;;
4545
*.java)
46-
# Should use PascalCase
46+
# Should use PascalCase for Java classes
4747
if [[ ! "$filename" =~ ^[A-Z][a-zA-Z0-9]*\.java$ ]]; then
48-
invalid_files+=("$file: Should use PascalCase (e.g., BinarySearch.java)")
48+
invalid_files+=("$file: Java files should use PascalCase (e.g., BinarySearch.java, MaxRectangle.java)")
4949
fi
5050
;;
5151
*.js|*.ts|*.go|*.rs|*.kt|*.swift|*.php|*.rb|*.cs|*.dart|*.scala)
52-
# Language-specific naming
53-
if [[ ! "$filename" =~ ^[a-z][a-zA-Z0-9_]*\.[a-z]+$ ]]; then
54-
invalid_files+=("$file: Should follow language conventions")
52+
# Allow flexible naming for other languages
53+
if [[ ! "$filename" =~ ^[a-zA-Z0-9_]+\.[a-z]+$ ]]; then
54+
invalid_files+=("$file: Use alphanumeric characters and underscores only")
5555
fi
5656
;;
5757
esac

.github/workflows/pr-validation.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@ jobs:
4949
filename=$(basename "$file")
5050
dir=$(dirname "$file")
5151
52-
# Check for proper naming conventions
52+
# Check for proper naming conventions (Allow snake_case, camelCase, or PascalCase)
5353
case "$file" in
5454
*.c|*.cpp|*.py)
55-
# Should use snake_case
56-
if [[ ! "$filename" =~ ^[a-z0-9_]+\.[a-z]+$ ]]; then
57-
invalid_files+=("$file: Should use snake_case (e.g., binary_search.cpp)")
55+
# Allow snake_case, camelCase, or PascalCase for C/C++/Python
56+
if [[ ! "$filename" =~ ^[a-zA-Z0-9_]+\.[a-z]+$ ]]; then
57+
invalid_files+=("$file: Use alphanumeric characters and underscores only (e.g., binary_search.cpp, maxRectangle.cpp)")
5858
fi
5959
;;
6060
*.java)
61-
# Should use PascalCase
61+
# Should use PascalCase for Java classes
6262
if [[ ! "$filename" =~ ^[A-Z][a-zA-Z0-9]*\.java$ ]]; then
63-
invalid_files+=("$file: Should use PascalCase (e.g., BinarySearch.java)")
63+
invalid_files+=("$file: Java files should use PascalCase (e.g., BinarySearch.java, MaxRectangle.java)")
6464
fi
6565
;;
6666
*.js|*.ts|*.go|*.rs|*.kt|*.swift|*.php|*.rb|*.cs|*.dart|*.scala)
67-
# Language-specific naming (mostly snake_case or camelCase)
68-
if [[ ! "$filename" =~ ^[a-z][a-zA-Z0-9_]*\.[a-z]+$ ]]; then
69-
invalid_files+=("$file: Should follow language conventions")
67+
# Allow flexible naming for other languages
68+
if [[ ! "$filename" =~ ^[a-zA-Z0-9_]+\.[a-z]+$ ]]; then
69+
invalid_files+=("$file: Use alphanumeric characters and underscores only")
7070
fi
7171
;;
7272
esac

0 commit comments

Comments
 (0)