Skip to content

Commit aaf8cfd

Browse files
committed
style: do not clutter the root directory
1 parent 8c09f75 commit aaf8cfd

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

.github/workflows/project_structure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ jobs:
1818
python-version: '3.13'
1919

2020
- name: Check project structure
21-
run: python3 check_structure.py
21+
run: python3 .github/workflows/scripts/check_structure.py
2222
...
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pathlib
2+
import sys
3+
4+
5+
def _is_java_file_properly_located(java_file: pathlib.Path) -> bool:
6+
main_parents = java_file.parent.parents
7+
return (
8+
pathlib.Path("src/main/java/com/thealgorithms/") in main_parents
9+
or pathlib.Path("src/test/java/com/thealgorithms/") in main_parents
10+
)
11+
12+
13+
def _find_misplaced_java_files() -> list[pathlib.Path]:
14+
return [
15+
java_file
16+
for java_file in pathlib.Path(".").rglob("*.java")
17+
if not _is_java_file_properly_located(java_file)
18+
]
19+
20+
21+
if __name__ == "__main__":
22+
misplaced_files = _find_misplaced_java_files()
23+
if misplaced_files:
24+
print("The following java files are not located in the correct directory:")
25+
for _ in misplaced_files:
26+
print(_)
27+
sys.exit(1)

0 commit comments

Comments
 (0)